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 |
Bram Moolenaar | 86b6835 | 2004-12-27 21:59:20 +0000 | [diff] [blame] | 85 | , PV_FLP |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 86 | , PV_FO |
| 87 | , PV_FT |
| 88 | , PV_GP |
| 89 | , PV_IMI |
| 90 | , PV_IMS |
| 91 | , PV_INC |
| 92 | , PV_INDE |
| 93 | , PV_INDK |
| 94 | , PV_INEX |
| 95 | , PV_INF |
| 96 | , PV_ISK |
| 97 | , PV_KEY |
| 98 | , PV_KMAP |
| 99 | , PV_KP |
| 100 | , PV_LBR |
| 101 | , PV_LISP |
| 102 | , PV_LIST |
| 103 | , PV_MA |
| 104 | , PV_ML |
| 105 | , PV_MOD |
| 106 | , PV_MP |
| 107 | , PV_MPS |
| 108 | , PV_NF |
| 109 | , PV_NU |
Bram Moolenaar | 592e0a2 | 2004-07-03 16:05:59 +0000 | [diff] [blame] | 110 | , PV_NUW |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 111 | , PV_OFT |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 112 | , PV_OFU |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 113 | , PV_PATH |
| 114 | , PV_PI |
| 115 | , PV_PVW |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 116 | , PV_QE |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 117 | , PV_RL |
| 118 | , PV_RLC |
| 119 | , PV_RO |
| 120 | , PV_SCBIND |
| 121 | , PV_SCROLL |
| 122 | , PV_SI |
| 123 | , PV_SN |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 124 | , PV_SPELL |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 125 | , PV_SPC |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 126 | , PV_SPF |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 127 | , PV_SPL |
| 128 | , PV_STL |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 129 | , PV_STS |
| 130 | , PV_SUA |
| 131 | , PV_SW |
| 132 | , PV_SWF |
Bram Moolenaar | 3b56eb3 | 2005-07-11 22:40:32 +0000 | [diff] [blame] | 133 | , PV_SMC |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 134 | , PV_SYN |
| 135 | , PV_TAGS |
| 136 | , PV_TS |
| 137 | , PV_TSR |
| 138 | , PV_TW |
| 139 | , PV_TX |
| 140 | , PV_WFH |
| 141 | , PV_WM |
| 142 | , PV_WRAP |
| 143 | } idopt_T; |
| 144 | |
| 145 | /* |
| 146 | * Options local to a window have a value local to a buffer and global to all |
| 147 | * buffers. Indicate this by setting "var" to VAR_WIN. |
| 148 | */ |
| 149 | #define VAR_WIN ((char_u *)-1) |
| 150 | |
| 151 | /* |
| 152 | * These the global values for options which are also local to a buffer. |
| 153 | * Only to be used in option.c! |
| 154 | */ |
| 155 | static int p_ai; |
| 156 | static int p_bin; |
| 157 | #ifdef FEAT_MBYTE |
| 158 | static int p_bomb; |
| 159 | #endif |
| 160 | #if defined(FEAT_QUICKFIX) |
| 161 | static char_u *p_bh; |
| 162 | static char_u *p_bt; |
| 163 | #endif |
| 164 | static int p_bl; |
| 165 | static int p_ci; |
| 166 | #ifdef FEAT_CINDENT |
| 167 | static int p_cin; |
| 168 | static char_u *p_cink; |
| 169 | static char_u *p_cino; |
| 170 | #endif |
| 171 | #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) |
| 172 | static char_u *p_cinw; |
| 173 | #endif |
| 174 | #ifdef FEAT_COMMENTS |
| 175 | static char_u *p_com; |
| 176 | #endif |
| 177 | #ifdef FEAT_FOLDING |
| 178 | static char_u *p_cms; |
| 179 | #endif |
| 180 | #ifdef FEAT_INS_EXPAND |
| 181 | static char_u *p_cpt; |
| 182 | #endif |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 183 | #ifdef FEAT_COMPL_FUNC |
| 184 | static char_u *p_cfu; |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 185 | static char_u *p_ofu; |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 186 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 187 | static int p_eol; |
| 188 | static int p_et; |
| 189 | #ifdef FEAT_MBYTE |
| 190 | static char_u *p_fenc; |
| 191 | #endif |
| 192 | static char_u *p_ff; |
| 193 | static char_u *p_fo; |
Bram Moolenaar | 86b6835 | 2004-12-27 21:59:20 +0000 | [diff] [blame] | 194 | static char_u *p_flp; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 195 | #ifdef FEAT_AUTOCMD |
| 196 | static char_u *p_ft; |
| 197 | #endif |
| 198 | static long p_iminsert; |
| 199 | static long p_imsearch; |
| 200 | #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) |
| 201 | static char_u *p_inex; |
| 202 | #endif |
| 203 | #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) |
| 204 | static char_u *p_inde; |
| 205 | static char_u *p_indk; |
| 206 | #endif |
| 207 | static int p_inf; |
| 208 | static char_u *p_isk; |
| 209 | #ifdef FEAT_CRYPT |
| 210 | static char_u *p_key; |
| 211 | #endif |
| 212 | #ifdef FEAT_LISP |
| 213 | static int p_lisp; |
| 214 | #endif |
| 215 | static int p_ml; |
| 216 | static int p_ma; |
| 217 | static int p_mod; |
| 218 | static char_u *p_mps; |
| 219 | static char_u *p_nf; |
| 220 | #ifdef FEAT_OSFILETYPE |
| 221 | static char_u *p_oft; |
| 222 | #endif |
| 223 | static int p_pi; |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 224 | #ifdef FEAT_TEXTOBJ |
| 225 | static char_u *p_qe; |
| 226 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 227 | static int p_ro; |
| 228 | #ifdef FEAT_SMARTINDENT |
| 229 | static int p_si; |
| 230 | #endif |
| 231 | #ifndef SHORT_FNAME |
| 232 | static int p_sn; |
| 233 | #endif |
| 234 | static long p_sts; |
| 235 | #if defined(FEAT_SEARCHPATH) |
| 236 | static char_u *p_sua; |
| 237 | #endif |
| 238 | static long p_sw; |
| 239 | static int p_swf; |
| 240 | #ifdef FEAT_SYN_HL |
Bram Moolenaar | 3b56eb3 | 2005-07-11 22:40:32 +0000 | [diff] [blame] | 241 | static long p_smc; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 242 | static char_u *p_syn; |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 243 | static char_u *p_spc; |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 244 | static char_u *p_spf; |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 245 | static char_u *p_spl; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 246 | #endif |
| 247 | static long p_ts; |
| 248 | static long p_tw; |
| 249 | static int p_tx; |
| 250 | static long p_wm; |
| 251 | #ifdef FEAT_KEYMAP |
| 252 | static char_u *p_keymap; |
| 253 | #endif |
| 254 | |
| 255 | /* Saved values for when 'bin' is set. */ |
| 256 | static int p_et_nobin; |
| 257 | static int p_ml_nobin; |
| 258 | static long p_tw_nobin; |
| 259 | static long p_wm_nobin; |
| 260 | |
| 261 | /* Saved values for when 'paste' is set */ |
| 262 | static long p_tw_nopaste; |
| 263 | static long p_wm_nopaste; |
| 264 | static long p_sts_nopaste; |
| 265 | static int p_ai_nopaste; |
| 266 | |
| 267 | struct vimoption |
| 268 | { |
| 269 | char *fullname; /* full option name */ |
| 270 | char *shortname; /* permissible abbreviation */ |
| 271 | long_u flags; /* see below */ |
| 272 | char_u *var; /* global option: pointer to variable; |
| 273 | * window-local option: VAR_WIN; |
| 274 | * buffer-local option: global value */ |
| 275 | idopt_T indir; /* global option: PV_NONE; |
| 276 | * local option: indirect option index */ |
| 277 | char_u *def_val[2]; /* default values for variable (vi and vim) */ |
| 278 | #ifdef FEAT_EVAL |
| 279 | scid_T scriptID; /* script in which the option was last set */ |
| 280 | #endif |
| 281 | }; |
| 282 | |
| 283 | #define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */ |
| 284 | #define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */ |
| 285 | |
| 286 | /* |
| 287 | * Flags |
| 288 | */ |
| 289 | #define P_BOOL 0x01 /* the option is boolean */ |
| 290 | #define P_NUM 0x02 /* the option is numeric */ |
| 291 | #define P_STRING 0x04 /* the option is a string */ |
| 292 | #define P_ALLOCED 0x08 /* the string option is in allocated memory, |
| 293 | must use vim_free() when assigning new |
| 294 | value. Not set if default is the same. */ |
| 295 | #define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can |
| 296 | never be used for local or hidden options! */ |
| 297 | #define P_NODEFAULT 0x40 /* don't set to default value */ |
| 298 | #define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must |
| 299 | use vim_free() when assigning new value */ |
| 300 | #define P_WAS_SET 0x100 /* option has been set/reset */ |
| 301 | #define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */ |
| 302 | #define P_VI_DEF 0x400 /* Use Vi default for Vim */ |
| 303 | #define P_VIM 0x800 /* Vim option, reset when 'cp' set */ |
| 304 | |
| 305 | /* when option changed, what to display: */ |
| 306 | #define P_RSTAT 0x1000 /* redraw status lines */ |
| 307 | #define P_RWIN 0x2000 /* redraw current window */ |
| 308 | #define P_RBUF 0x4000 /* redraw current buffer */ |
| 309 | #define P_RALL 0x6000 /* redraw all windows */ |
| 310 | #define P_RCLR 0x7000 /* clear and redraw all */ |
| 311 | |
| 312 | #define P_COMMA 0x8000 /* comma separated list */ |
| 313 | #define P_NODUP 0x10000L/* don't allow duplicate strings */ |
| 314 | #define P_FLAGLIST 0x20000L/* list of single-char flags */ |
| 315 | |
| 316 | #define P_SECURE 0x40000L/* cannot change in modeline or secure mode */ |
| 317 | #define P_GETTEXT 0x80000L/* expand default value with _() */ |
| 318 | #define P_NOGLOB 0x100000L/* do not use local value for global vimrc */ |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 319 | #define P_NFNAME 0x200000L/* only normal file name chars allowed */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 320 | |
| 321 | /* |
| 322 | * options[] is initialized here. |
| 323 | * The order of the options MUST be alphabetic for ":set all" and findoption(). |
| 324 | * All option names MUST start with a lowercase letter (for findoption()). |
| 325 | * Exception: "t_" options are at the end. |
| 326 | * The options with a NULL variable are 'hidden': a set command for them is |
| 327 | * ignored and they are not printed. |
| 328 | */ |
| 329 | static struct vimoption |
| 330 | #ifdef FEAT_GUI_W16 |
| 331 | _far |
| 332 | #endif |
| 333 | options[] = |
| 334 | { |
| 335 | {"aleph", "al", P_NUM|P_VI_DEF, |
| 336 | #ifdef FEAT_RIGHTLEFT |
| 337 | (char_u *)&p_aleph, PV_NONE, |
| 338 | #else |
| 339 | (char_u *)NULL, PV_NONE, |
| 340 | #endif |
| 341 | { |
| 342 | #if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32) |
| 343 | (char_u *)128L, |
| 344 | #else |
| 345 | (char_u *)224L, |
| 346 | #endif |
| 347 | (char_u *)0L}}, |
| 348 | {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR, |
| 349 | #if defined(FEAT_GUI) && defined(MACOS_X) |
| 350 | (char_u *)&p_antialias, PV_NONE, |
| 351 | {(char_u *)FALSE, (char_u *)FALSE} |
| 352 | #else |
| 353 | (char_u *)NULL, PV_NONE, |
| 354 | {(char_u *)FALSE, (char_u *)FALSE} |
| 355 | #endif |
| 356 | }, |
| 357 | {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM, |
| 358 | #ifdef FEAT_ARABIC |
| 359 | (char_u *)VAR_WIN, PV_ARAB, |
| 360 | #else |
| 361 | (char_u *)NULL, PV_NONE, |
| 362 | #endif |
| 363 | {(char_u *)FALSE, (char_u *)0L}}, |
| 364 | {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR, |
| 365 | #ifdef FEAT_ARABIC |
| 366 | (char_u *)&p_arshape, PV_NONE, |
| 367 | #else |
| 368 | (char_u *)NULL, PV_NONE, |
| 369 | #endif |
| 370 | {(char_u *)TRUE, (char_u *)0L}}, |
| 371 | {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM, |
| 372 | #ifdef FEAT_RIGHTLEFT |
| 373 | (char_u *)&p_ari, PV_NONE, |
| 374 | #else |
| 375 | (char_u *)NULL, PV_NONE, |
| 376 | #endif |
| 377 | {(char_u *)FALSE, (char_u *)0L}}, |
| 378 | {"altkeymap", "akm", P_BOOL|P_VI_DEF, |
| 379 | #ifdef FEAT_FKMAP |
| 380 | (char_u *)&p_altkeymap, PV_NONE, |
| 381 | #else |
| 382 | (char_u *)NULL, PV_NONE, |
| 383 | #endif |
| 384 | {(char_u *)FALSE, (char_u *)0L}}, |
| 385 | {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR, |
| 386 | #if defined(FEAT_MBYTE) |
| 387 | (char_u *)&p_ambw, PV_NONE, |
| 388 | {(char_u *)"single", (char_u *)0L} |
| 389 | #else |
| 390 | (char_u *)NULL, PV_NONE, |
| 391 | {(char_u *)0L, (char_u *)0L} |
| 392 | #endif |
| 393 | }, |
| 394 | #if defined(FEAT_NETBEANS_INTG) || defined(FEAT_SUN_WORKSHOP) |
| 395 | {"autochdir", "acd", P_BOOL|P_VI_DEF, |
| 396 | (char_u *)&p_acd, PV_NONE, |
| 397 | {(char_u *)FALSE, (char_u *)0L}}, |
| 398 | #endif |
| 399 | {"autoindent", "ai", P_BOOL|P_VI_DEF, |
| 400 | (char_u *)&p_ai, PV_AI, |
| 401 | {(char_u *)FALSE, (char_u *)0L}}, |
| 402 | {"autoprint", "ap", P_BOOL|P_VI_DEF, |
| 403 | (char_u *)NULL, PV_NONE, |
| 404 | {(char_u *)FALSE, (char_u *)0L}}, |
| 405 | {"autoread", "ar", P_BOOL|P_VI_DEF, |
| 406 | (char_u *)&p_ar, OPT_BOTH(PV_AR), |
| 407 | {(char_u *)FALSE, (char_u *)0L}}, |
| 408 | {"autowrite", "aw", P_BOOL|P_VI_DEF, |
| 409 | (char_u *)&p_aw, PV_NONE, |
| 410 | {(char_u *)FALSE, (char_u *)0L}}, |
| 411 | {"autowriteall","awa", P_BOOL|P_VI_DEF, |
| 412 | (char_u *)&p_awa, PV_NONE, |
| 413 | {(char_u *)FALSE, (char_u *)0L}}, |
| 414 | {"background", "bg", P_STRING|P_VI_DEF|P_RCLR, |
| 415 | (char_u *)&p_bg, PV_NONE, |
| 416 | { |
| 417 | #if (defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI) |
| 418 | (char_u *)"dark", |
| 419 | #else |
| 420 | (char_u *)"light", |
| 421 | #endif |
| 422 | (char_u *)0L}}, |
| 423 | {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_COMMA|P_NODUP, |
| 424 | (char_u *)&p_bs, PV_NONE, |
| 425 | {(char_u *)"", (char_u *)0L}}, |
| 426 | {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM, |
| 427 | (char_u *)&p_bk, PV_NONE, |
| 428 | {(char_u *)FALSE, (char_u *)0L}}, |
| 429 | {"backupcopy", "bkc", P_STRING|P_VIM|P_COMMA|P_NODUP, |
| 430 | (char_u *)&p_bkc, PV_NONE, |
| 431 | #ifdef UNIX |
| 432 | {(char_u *)"yes", (char_u *)"auto"} |
| 433 | #else |
| 434 | {(char_u *)"auto", (char_u *)"auto"} |
| 435 | #endif |
| 436 | }, |
| 437 | {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE, |
| 438 | (char_u *)&p_bdir, PV_NONE, |
| 439 | {(char_u *)DFLT_BDIR, (char_u *)0L}}, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 440 | {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 441 | (char_u *)&p_bex, PV_NONE, |
| 442 | { |
| 443 | #ifdef VMS |
| 444 | (char_u *)"_", |
| 445 | #else |
| 446 | (char_u *)"~", |
| 447 | #endif |
| 448 | (char_u *)0L}}, |
| 449 | {"backupskip", "bsk", P_STRING|P_VI_DEF|P_COMMA, |
| 450 | #ifdef FEAT_WILDIGN |
| 451 | (char_u *)&p_bsk, PV_NONE, |
| 452 | {(char_u *)"", (char_u *)0L} |
| 453 | #else |
| 454 | (char_u *)NULL, PV_NONE, |
| 455 | {(char_u *)0L, (char_u *)0L} |
| 456 | #endif |
| 457 | }, |
| 458 | #ifdef FEAT_BEVAL |
| 459 | {"balloondelay","bdlay",P_NUM|P_VI_DEF, |
| 460 | (char_u *)&p_bdlay, PV_NONE, |
| 461 | {(char_u *)600L, (char_u *)0L}}, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 462 | {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC, |
| 463 | (char_u *)&p_beval, PV_NONE, |
Bram Moolenaar | f1f8bc5 | 2005-03-07 23:20:08 +0000 | [diff] [blame] | 464 | {(char_u *)FALSE, (char_u *)0L}}, |
| 465 | # ifdef FEAT_EVAL |
| 466 | {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM, |
| 467 | (char_u *)&p_bexpr, PV_NONE, |
| 468 | {(char_u *)"", (char_u *)0L}}, |
| 469 | # endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 470 | #endif |
| 471 | {"beautify", "bf", P_BOOL|P_VI_DEF, |
| 472 | (char_u *)NULL, PV_NONE, |
| 473 | {(char_u *)FALSE, (char_u *)0L}}, |
| 474 | {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT, |
| 475 | (char_u *)&p_bin, PV_BIN, |
| 476 | {(char_u *)FALSE, (char_u *)0L}}, |
| 477 | {"bioskey", "biosk",P_BOOL|P_VI_DEF, |
| 478 | #ifdef MSDOS |
| 479 | (char_u *)&p_biosk, PV_NONE, |
| 480 | #else |
| 481 | (char_u *)NULL, PV_NONE, |
| 482 | #endif |
| 483 | {(char_u *)TRUE, (char_u *)0L}}, |
| 484 | {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, |
| 485 | #ifdef FEAT_MBYTE |
| 486 | (char_u *)&p_bomb, PV_BOMB, |
| 487 | #else |
| 488 | (char_u *)NULL, PV_NONE, |
| 489 | #endif |
| 490 | {(char_u *)FALSE, (char_u *)0L}}, |
| 491 | {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST, |
| 492 | #ifdef FEAT_LINEBREAK |
| 493 | (char_u *)&p_breakat, PV_NONE, |
| 494 | {(char_u *)" \t!@*-+;:,./?", (char_u *)0L} |
| 495 | #else |
| 496 | (char_u *)NULL, PV_NONE, |
| 497 | {(char_u *)0L, (char_u *)0L} |
| 498 | #endif |
| 499 | }, |
| 500 | {"browsedir", "bsdir",P_STRING|P_VI_DEF, |
| 501 | #ifdef FEAT_BROWSE |
| 502 | (char_u *)&p_bsdir, PV_NONE, |
| 503 | {(char_u *)"last", (char_u *)0L} |
| 504 | #else |
| 505 | (char_u *)NULL, PV_NONE, |
| 506 | {(char_u *)0L, (char_u *)0L} |
| 507 | #endif |
| 508 | }, |
| 509 | {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB, |
| 510 | #if defined(FEAT_QUICKFIX) |
| 511 | (char_u *)&p_bh, PV_BH, |
| 512 | {(char_u *)"", (char_u *)0L} |
| 513 | #else |
| 514 | (char_u *)NULL, PV_NONE, |
| 515 | {(char_u *)0L, (char_u *)0L} |
| 516 | #endif |
| 517 | }, |
| 518 | {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB, |
| 519 | (char_u *)&p_bl, PV_BL, |
| 520 | {(char_u *)1L, (char_u *)0L} |
| 521 | }, |
| 522 | {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB, |
| 523 | #if defined(FEAT_QUICKFIX) |
| 524 | (char_u *)&p_bt, PV_BT, |
| 525 | {(char_u *)"", (char_u *)0L} |
| 526 | #else |
| 527 | (char_u *)NULL, PV_NONE, |
| 528 | {(char_u *)0L, (char_u *)0L} |
| 529 | #endif |
| 530 | }, |
| 531 | {"casemap", "cmp", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 532 | (char_u *)&p_cmp, PV_NONE, |
| 533 | {(char_u *)"internal,keepascii", (char_u *)0L} |
| 534 | }, |
| 535 | {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
| 536 | #ifdef FEAT_SEARCHPATH |
| 537 | (char_u *)&p_cdpath, PV_NONE, |
| 538 | {(char_u *)",,", (char_u *)0L} |
| 539 | #else |
| 540 | (char_u *)NULL, PV_NONE, |
| 541 | {(char_u *)0L, (char_u *)0L} |
| 542 | #endif |
| 543 | }, |
| 544 | {"cedit", NULL, P_STRING, |
| 545 | #ifdef FEAT_CMDWIN |
| 546 | (char_u *)&p_cedit, PV_NONE, |
| 547 | {(char_u *)"", (char_u *)CTRL_F_STR} |
| 548 | #else |
| 549 | (char_u *)NULL, PV_NONE, |
| 550 | {(char_u *)0L, (char_u *)0L} |
| 551 | #endif |
| 552 | }, |
| 553 | {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE, |
| 554 | #if defined(FEAT_MBYTE) && defined(FEAT_EVAL) |
| 555 | (char_u *)&p_ccv, PV_NONE, |
| 556 | {(char_u *)"", (char_u *)0L} |
| 557 | #else |
| 558 | (char_u *)NULL, PV_NONE, |
| 559 | {(char_u *)0L, (char_u *)0L} |
| 560 | #endif |
| 561 | }, |
| 562 | {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM, |
| 563 | #ifdef FEAT_CINDENT |
| 564 | (char_u *)&p_cin, PV_CIN, |
| 565 | #else |
| 566 | (char_u *)NULL, PV_NONE, |
| 567 | #endif |
| 568 | {(char_u *)FALSE, (char_u *)0L}}, |
| 569 | {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 570 | #ifdef FEAT_CINDENT |
| 571 | (char_u *)&p_cink, PV_CINK, |
| 572 | {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L} |
| 573 | #else |
| 574 | (char_u *)NULL, PV_NONE, |
| 575 | {(char_u *)0L, (char_u *)0L} |
| 576 | #endif |
| 577 | }, |
| 578 | {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 579 | #ifdef FEAT_CINDENT |
| 580 | (char_u *)&p_cino, PV_CINO, |
| 581 | #else |
| 582 | (char_u *)NULL, PV_NONE, |
| 583 | #endif |
| 584 | {(char_u *)"", (char_u *)0L}}, |
| 585 | {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 586 | #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) |
| 587 | (char_u *)&p_cinw, PV_CINW, |
| 588 | {(char_u *)"if,else,while,do,for,switch", |
| 589 | (char_u *)0L} |
| 590 | #else |
| 591 | (char_u *)NULL, PV_NONE, |
| 592 | {(char_u *)0L, (char_u *)0L} |
| 593 | #endif |
| 594 | }, |
| 595 | {"clipboard", "cb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 596 | #ifdef FEAT_CLIPBOARD |
| 597 | (char_u *)&p_cb, PV_NONE, |
| 598 | # ifdef FEAT_XCLIPBOARD |
| 599 | {(char_u *)"autoselect,exclude:cons\\|linux", |
| 600 | (char_u *)0L} |
| 601 | # else |
| 602 | {(char_u *)"", (char_u *)0L} |
| 603 | # endif |
| 604 | #else |
| 605 | (char_u *)NULL, PV_NONE, |
| 606 | {(char_u *)"", (char_u *)0L} |
| 607 | #endif |
| 608 | }, |
| 609 | {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL, |
| 610 | (char_u *)&p_ch, PV_NONE, |
| 611 | {(char_u *)1L, (char_u *)0L}}, |
| 612 | {"cmdwinheight", "cwh", P_NUM|P_VI_DEF, |
| 613 | #ifdef FEAT_CMDWIN |
| 614 | (char_u *)&p_cwh, PV_NONE, |
| 615 | #else |
| 616 | (char_u *)NULL, PV_NONE, |
| 617 | #endif |
| 618 | {(char_u *)7L, (char_u *)0L}}, |
| 619 | {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR, |
| 620 | (char_u *)&Columns, PV_NONE, |
| 621 | {(char_u *)80L, (char_u *)0L}}, |
| 622 | {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 623 | #ifdef FEAT_COMMENTS |
| 624 | (char_u *)&p_com, PV_COM, |
| 625 | {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-", |
| 626 | (char_u *)0L} |
| 627 | #else |
| 628 | (char_u *)NULL, PV_NONE, |
| 629 | {(char_u *)0L, (char_u *)0L} |
| 630 | #endif |
| 631 | }, |
| 632 | {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF, |
| 633 | #ifdef FEAT_FOLDING |
| 634 | (char_u *)&p_cms, PV_CMS, |
| 635 | {(char_u *)"/*%s*/", (char_u *)0L} |
| 636 | #else |
| 637 | (char_u *)NULL, PV_NONE, |
| 638 | {(char_u *)0L, (char_u *)0L} |
| 639 | #endif |
| 640 | }, |
| 641 | {"compatible", "cp", P_BOOL|P_RALL, |
| 642 | (char_u *)&p_cp, PV_NONE, |
| 643 | {(char_u *)TRUE, (char_u *)FALSE}}, |
| 644 | {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 645 | #ifdef FEAT_INS_EXPAND |
| 646 | (char_u *)&p_cpt, PV_CPT, |
| 647 | {(char_u *)".,w,b,u,t,i", (char_u *)0L} |
| 648 | #else |
| 649 | (char_u *)NULL, PV_NONE, |
| 650 | {(char_u *)0L, (char_u *)0L} |
| 651 | #endif |
| 652 | }, |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 653 | {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE, |
| 654 | #ifdef FEAT_COMPL_FUNC |
| 655 | (char_u *)&p_cfu, PV_CFU, |
| 656 | {(char_u *)"", (char_u *)0L} |
| 657 | #else |
| 658 | (char_u *)NULL, PV_NONE, |
| 659 | {(char_u *)0L, (char_u *)0L} |
| 660 | #endif |
| 661 | }, |
Bram Moolenaar | 1c7715d | 2005-10-03 22:02:18 +0000 | [diff] [blame] | 662 | {"completeopt", "cot", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 663 | #ifdef FEAT_INS_EXPAND |
| 664 | (char_u *)&p_cot, PV_NONE, |
| 665 | {(char_u *)"menu", (char_u *)0L} |
| 666 | #else |
| 667 | (char_u *)NULL, PV_NONE, |
| 668 | {(char_u *)0L, (char_u *)0L} |
| 669 | #endif |
| 670 | }, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 671 | {"confirm", "cf", P_BOOL|P_VI_DEF, |
| 672 | #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
| 673 | (char_u *)&p_confirm, PV_NONE, |
| 674 | #else |
| 675 | (char_u *)NULL, PV_NONE, |
| 676 | #endif |
| 677 | {(char_u *)FALSE, (char_u *)0L}}, |
| 678 | {"conskey", "consk",P_BOOL|P_VI_DEF, |
| 679 | #ifdef MSDOS |
| 680 | (char_u *)&p_consk, PV_NONE, |
| 681 | #else |
| 682 | (char_u *)NULL, PV_NONE, |
| 683 | #endif |
| 684 | {(char_u *)FALSE, (char_u *)0L}}, |
| 685 | {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM, |
| 686 | (char_u *)&p_ci, PV_CI, |
| 687 | {(char_u *)FALSE, (char_u *)0L}}, |
| 688 | {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST, |
| 689 | (char_u *)&p_cpo, PV_NONE, |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 690 | {(char_u *)CPO_VI, (char_u *)CPO_VIM}}, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 691 | {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM, |
| 692 | #ifdef FEAT_CSCOPE |
| 693 | (char_u *)&p_cspc, PV_NONE, |
| 694 | #else |
| 695 | (char_u *)NULL, PV_NONE, |
| 696 | #endif |
| 697 | {(char_u *)0L, (char_u *)0L}}, |
| 698 | {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 699 | #ifdef FEAT_CSCOPE |
| 700 | (char_u *)&p_csprg, PV_NONE, |
| 701 | {(char_u *)"cscope", (char_u *)0L} |
| 702 | #else |
| 703 | (char_u *)NULL, PV_NONE, |
| 704 | {(char_u *)0L, (char_u *)0L} |
| 705 | #endif |
| 706 | }, |
| 707 | {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 708 | #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX) |
| 709 | (char_u *)&p_csqf, PV_NONE, |
| 710 | {(char_u *)"", (char_u *)0L} |
| 711 | #else |
| 712 | (char_u *)NULL, PV_NONE, |
| 713 | {(char_u *)0L, (char_u *)0L} |
| 714 | #endif |
| 715 | }, |
| 716 | {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM, |
| 717 | #ifdef FEAT_CSCOPE |
| 718 | (char_u *)&p_cst, PV_NONE, |
| 719 | #else |
| 720 | (char_u *)NULL, PV_NONE, |
| 721 | #endif |
| 722 | {(char_u *)0L, (char_u *)0L}}, |
| 723 | {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM, |
| 724 | #ifdef FEAT_CSCOPE |
| 725 | (char_u *)&p_csto, PV_NONE, |
| 726 | #else |
| 727 | (char_u *)NULL, PV_NONE, |
| 728 | #endif |
| 729 | {(char_u *)0L, (char_u *)0L}}, |
| 730 | {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM, |
| 731 | #ifdef FEAT_CSCOPE |
| 732 | (char_u *)&p_csverbose, PV_NONE, |
| 733 | #else |
| 734 | (char_u *)NULL, PV_NONE, |
| 735 | #endif |
| 736 | {(char_u *)0L, (char_u *)0L}}, |
| 737 | {"debug", NULL, P_STRING|P_VI_DEF, |
| 738 | (char_u *)&p_debug, PV_NONE, |
| 739 | {(char_u *)"", (char_u *)0L}}, |
| 740 | {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF, |
| 741 | #ifdef FEAT_FIND_ID |
| 742 | (char_u *)&p_def, OPT_BOTH(PV_DEF), |
Bram Moolenaar | d4755bb | 2004-09-02 19:12:26 +0000 | [diff] [blame] | 743 | {(char_u *)"^\\s*#\\s*define", (char_u *)0L} |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 744 | #else |
| 745 | (char_u *)NULL, PV_NONE, |
| 746 | {(char_u *)NULL, (char_u *)0L} |
| 747 | #endif |
| 748 | }, |
| 749 | {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM, |
| 750 | #ifdef FEAT_MBYTE |
| 751 | (char_u *)&p_deco, PV_NONE, |
| 752 | #else |
| 753 | (char_u *)NULL, PV_NONE, |
| 754 | #endif |
| 755 | {(char_u *)FALSE, (char_u *)0L} |
| 756 | }, |
| 757 | {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
| 758 | #ifdef FEAT_INS_EXPAND |
| 759 | (char_u *)&p_dict, OPT_BOTH(PV_DICT), |
| 760 | #else |
| 761 | (char_u *)NULL, PV_NONE, |
| 762 | #endif |
| 763 | {(char_u *)"", (char_u *)0L}}, |
| 764 | {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB, |
| 765 | #ifdef FEAT_DIFF |
| 766 | (char_u *)VAR_WIN, PV_DIFF, |
| 767 | #else |
| 768 | (char_u *)NULL, PV_NONE, |
| 769 | #endif |
| 770 | {(char_u *)FALSE, (char_u *)0L}}, |
| 771 | {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE, |
| 772 | #if defined(FEAT_DIFF) && defined(FEAT_EVAL) |
| 773 | (char_u *)&p_dex, PV_NONE, |
| 774 | {(char_u *)"", (char_u *)0L} |
| 775 | #else |
| 776 | (char_u *)NULL, PV_NONE, |
| 777 | {(char_u *)0L, (char_u *)0L} |
| 778 | #endif |
| 779 | }, |
| 780 | {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_COMMA|P_NODUP, |
| 781 | #ifdef FEAT_DIFF |
| 782 | (char_u *)&p_dip, PV_NONE, |
| 783 | {(char_u *)"filler", (char_u *)NULL} |
| 784 | #else |
| 785 | (char_u *)NULL, PV_NONE, |
| 786 | {(char_u *)"", (char_u *)NULL} |
| 787 | #endif |
| 788 | }, |
| 789 | {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM, |
| 790 | #ifdef FEAT_DIGRAPHS |
| 791 | (char_u *)&p_dg, PV_NONE, |
| 792 | #else |
| 793 | (char_u *)NULL, PV_NONE, |
| 794 | #endif |
| 795 | {(char_u *)FALSE, (char_u *)0L}}, |
| 796 | {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE, |
| 797 | (char_u *)&p_dir, PV_NONE, |
| 798 | {(char_u *)DFLT_DIR, (char_u *)0L}}, |
| 799 | {"display", "dy", P_STRING|P_VI_DEF|P_COMMA|P_RALL|P_NODUP, |
| 800 | (char_u *)&p_dy, PV_NONE, |
| 801 | {(char_u *)"", (char_u *)0L}}, |
| 802 | {"eadirection", "ead", P_STRING|P_VI_DEF, |
| 803 | #ifdef FEAT_VERTSPLIT |
| 804 | (char_u *)&p_ead, PV_NONE, |
| 805 | {(char_u *)"both", (char_u *)0L} |
| 806 | #else |
| 807 | (char_u *)NULL, PV_NONE, |
| 808 | {(char_u *)NULL, (char_u *)0L} |
| 809 | #endif |
| 810 | }, |
| 811 | {"edcompatible","ed", P_BOOL|P_VI_DEF, |
| 812 | (char_u *)&p_ed, PV_NONE, |
| 813 | {(char_u *)FALSE, (char_u *)0L}}, |
| 814 | {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR, |
| 815 | #ifdef FEAT_MBYTE |
| 816 | (char_u *)&p_enc, PV_NONE, |
| 817 | {(char_u *)ENC_DFLT, (char_u *)0L} |
| 818 | #else |
| 819 | (char_u *)NULL, PV_NONE, |
| 820 | {(char_u *)0L, (char_u *)0L} |
| 821 | #endif |
| 822 | }, |
| 823 | {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, |
| 824 | (char_u *)&p_eol, PV_EOL, |
| 825 | {(char_u *)TRUE, (char_u *)0L}}, |
| 826 | {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL, |
| 827 | (char_u *)&p_ea, PV_NONE, |
| 828 | {(char_u *)TRUE, (char_u *)0L}}, |
| 829 | {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 830 | (char_u *)&p_ep, OPT_BOTH(PV_EP), |
| 831 | {(char_u *)"", (char_u *)0L}}, |
| 832 | {"errorbells", "eb", P_BOOL|P_VI_DEF, |
| 833 | (char_u *)&p_eb, PV_NONE, |
| 834 | {(char_u *)FALSE, (char_u *)0L}}, |
| 835 | {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 836 | #ifdef FEAT_QUICKFIX |
| 837 | (char_u *)&p_ef, PV_NONE, |
| 838 | {(char_u *)DFLT_ERRORFILE, (char_u *)0L} |
| 839 | #else |
| 840 | (char_u *)NULL, PV_NONE, |
| 841 | {(char_u *)NULL, (char_u *)0L} |
| 842 | #endif |
| 843 | }, |
| 844 | {"errorformat", "efm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 845 | #ifdef FEAT_QUICKFIX |
| 846 | (char_u *)&p_efm, OPT_BOTH(PV_EFM), |
| 847 | {(char_u *)DFLT_EFM, (char_u *)0L}, |
| 848 | #else |
| 849 | (char_u *)NULL, PV_NONE, |
| 850 | {(char_u *)NULL, (char_u *)0L} |
| 851 | #endif |
| 852 | }, |
| 853 | {"esckeys", "ek", P_BOOL|P_VIM, |
| 854 | (char_u *)&p_ek, PV_NONE, |
| 855 | {(char_u *)FALSE, (char_u *)TRUE}}, |
| 856 | {"eventignore", "ei", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 857 | #ifdef FEAT_AUTOCMD |
| 858 | (char_u *)&p_ei, PV_NONE, |
| 859 | #else |
| 860 | (char_u *)NULL, PV_NONE, |
| 861 | #endif |
| 862 | {(char_u *)"", (char_u *)0L}}, |
| 863 | {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM, |
| 864 | (char_u *)&p_et, PV_ET, |
| 865 | {(char_u *)FALSE, (char_u *)0L}}, |
| 866 | {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE, |
| 867 | (char_u *)&p_exrc, PV_NONE, |
| 868 | {(char_u *)FALSE, (char_u *)0L}}, |
| 869 | {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF|P_NO_MKRC, |
| 870 | #ifdef FEAT_MBYTE |
| 871 | (char_u *)&p_fenc, PV_FENC, |
| 872 | {(char_u *)"", (char_u *)0L} |
| 873 | #else |
| 874 | (char_u *)NULL, PV_NONE, |
| 875 | {(char_u *)0L, (char_u *)0L} |
| 876 | #endif |
| 877 | }, |
| 878 | {"fileencodings","fencs", P_STRING|P_VI_DEF|P_COMMA, |
| 879 | #ifdef FEAT_MBYTE |
| 880 | (char_u *)&p_fencs, PV_NONE, |
| 881 | {(char_u *)"ucs-bom", (char_u *)0L} |
| 882 | #else |
| 883 | (char_u *)NULL, PV_NONE, |
| 884 | {(char_u *)0L, (char_u *)0L} |
| 885 | #endif |
| 886 | }, |
| 887 | {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC, |
| 888 | (char_u *)&p_ff, PV_FF, |
| 889 | {(char_u *)DFLT_FF, (char_u *)0L}}, |
| 890 | {"fileformats", "ffs", P_STRING|P_VIM|P_COMMA|P_NODUP, |
| 891 | (char_u *)&p_ffs, PV_NONE, |
| 892 | {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}}, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 893 | {"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] | 894 | #ifdef FEAT_AUTOCMD |
| 895 | (char_u *)&p_ft, PV_FT, |
| 896 | {(char_u *)"", (char_u *)0L} |
| 897 | #else |
| 898 | (char_u *)NULL, PV_NONE, |
| 899 | {(char_u *)0L, (char_u *)0L} |
| 900 | #endif |
| 901 | }, |
| 902 | {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP, |
| 903 | #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
| 904 | (char_u *)&p_fcs, PV_NONE, |
| 905 | {(char_u *)"vert:|,fold:-", (char_u *)0L} |
| 906 | #else |
| 907 | (char_u *)NULL, PV_NONE, |
| 908 | {(char_u *)"", (char_u *)0L} |
| 909 | #endif |
| 910 | }, |
| 911 | {"fkmap", "fk", P_BOOL|P_VI_DEF, |
| 912 | #ifdef FEAT_FKMAP |
| 913 | (char_u *)&p_fkmap, PV_NONE, |
| 914 | #else |
| 915 | (char_u *)NULL, PV_NONE, |
| 916 | #endif |
| 917 | {(char_u *)FALSE, (char_u *)0L}}, |
| 918 | {"flash", "fl", P_BOOL|P_VI_DEF, |
| 919 | (char_u *)NULL, PV_NONE, |
| 920 | {(char_u *)FALSE, (char_u *)0L}}, |
| 921 | #ifdef FEAT_FOLDING |
| 922 | {"foldclose", "fcl", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN, |
| 923 | (char_u *)&p_fcl, PV_NONE, |
| 924 | {(char_u *)"", (char_u *)0L}}, |
| 925 | {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN, |
| 926 | (char_u *)VAR_WIN, PV_FDC, |
| 927 | {(char_u *)FALSE, (char_u *)0L}}, |
| 928 | {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN, |
| 929 | (char_u *)VAR_WIN, PV_FEN, |
| 930 | {(char_u *)TRUE, (char_u *)0L}}, |
| 931 | {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, |
| 932 | # ifdef FEAT_EVAL |
| 933 | (char_u *)VAR_WIN, PV_FDE, |
| 934 | {(char_u *)"0", (char_u *)NULL} |
| 935 | # else |
| 936 | (char_u *)NULL, PV_NONE, |
| 937 | {(char_u *)NULL, (char_u *)0L} |
| 938 | # endif |
| 939 | }, |
| 940 | {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, |
| 941 | (char_u *)VAR_WIN, PV_FDI, |
| 942 | {(char_u *)"#", (char_u *)NULL}}, |
| 943 | {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN, |
| 944 | (char_u *)VAR_WIN, PV_FDL, |
| 945 | {(char_u *)0L, (char_u *)0L}}, |
| 946 | {"foldlevelstart","fdls", P_NUM|P_VI_DEF, |
| 947 | (char_u *)&p_fdls, PV_NONE, |
| 948 | {(char_u *)-1L, (char_u *)0L}}, |
| 949 | {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF| |
| 950 | P_RWIN|P_COMMA|P_NODUP, |
| 951 | (char_u *)VAR_WIN, PV_FMR, |
| 952 | {(char_u *)"{{{,}}}", (char_u *)NULL}}, |
| 953 | {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, |
| 954 | (char_u *)VAR_WIN, PV_FDM, |
| 955 | {(char_u *)"manual", (char_u *)NULL}}, |
| 956 | {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN, |
| 957 | (char_u *)VAR_WIN, PV_FML, |
| 958 | {(char_u *)1L, (char_u *)0L}}, |
| 959 | {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN, |
| 960 | (char_u *)VAR_WIN, PV_FDN, |
| 961 | {(char_u *)20L, (char_u *)0L}}, |
| 962 | {"foldopen", "fdo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 963 | (char_u *)&p_fdo, PV_NONE, |
| 964 | {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo", |
| 965 | (char_u *)0L}}, |
| 966 | {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, |
| 967 | # ifdef FEAT_EVAL |
| 968 | (char_u *)VAR_WIN, PV_FDT, |
| 969 | {(char_u *)"foldtext()", (char_u *)NULL} |
Bram Moolenaar | 7b0294c | 2004-10-11 10:16:09 +0000 | [diff] [blame] | 970 | # else |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 971 | (char_u *)NULL, PV_NONE, |
| 972 | {(char_u *)NULL, (char_u *)0L} |
Bram Moolenaar | 7b0294c | 2004-10-11 10:16:09 +0000 | [diff] [blame] | 973 | # endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 974 | }, |
| 975 | #endif |
| 976 | {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST, |
| 977 | (char_u *)&p_fo, PV_FO, |
| 978 | {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}}, |
Bram Moolenaar | 86b6835 | 2004-12-27 21:59:20 +0000 | [diff] [blame] | 979 | {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF, |
| 980 | (char_u *)&p_flp, PV_FLP, |
| 981 | {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*", (char_u *)0L}}, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 982 | {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 983 | (char_u *)&p_fp, PV_NONE, |
| 984 | {(char_u *)"", (char_u *)0L}}, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 985 | {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF, |
| 986 | #ifdef HAVE_FSYNC |
| 987 | (char_u *)&p_fs, PV_NONE, |
| 988 | {(char_u *)TRUE, (char_u *)0L} |
| 989 | #else |
| 990 | (char_u *)NULL, PV_NONE, |
| 991 | {(char_u *)FALSE, (char_u *)0L} |
| 992 | #endif |
| 993 | }, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 994 | {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM, |
| 995 | (char_u *)&p_gd, PV_NONE, |
| 996 | {(char_u *)FALSE, (char_u *)0L}}, |
| 997 | {"graphic", "gr", P_BOOL|P_VI_DEF, |
| 998 | (char_u *)NULL, PV_NONE, |
| 999 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1000 | {"grepformat", "gfm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1001 | #ifdef FEAT_QUICKFIX |
| 1002 | (char_u *)&p_gefm, PV_NONE, |
| 1003 | {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}, |
| 1004 | #else |
| 1005 | (char_u *)NULL, PV_NONE, |
| 1006 | {(char_u *)NULL, (char_u *)0L} |
| 1007 | #endif |
| 1008 | }, |
| 1009 | {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 1010 | #ifdef FEAT_QUICKFIX |
| 1011 | (char_u *)&p_gp, OPT_BOTH(PV_GP), |
| 1012 | { |
| 1013 | # ifdef WIN3264 |
| 1014 | /* may be changed to "grep -n" in os_win32.c */ |
| 1015 | (char_u *)"findstr /n", |
| 1016 | # else |
| 1017 | # ifdef UNIX |
| 1018 | /* Add an extra file name so that grep will always |
| 1019 | * insert a file name in the match line. */ |
| 1020 | (char_u *)"grep -n $* /dev/null", |
| 1021 | # else |
| 1022 | # ifdef VMS |
| 1023 | (char_u *)"SEARCH/NUMBERS ", |
| 1024 | # else |
| 1025 | (char_u *)"grep -n ", |
| 1026 | #endif |
| 1027 | #endif |
| 1028 | # endif |
| 1029 | (char_u *)0L}, |
| 1030 | #else |
| 1031 | (char_u *)NULL, PV_NONE, |
| 1032 | {(char_u *)NULL, (char_u *)0L} |
| 1033 | #endif |
| 1034 | }, |
| 1035 | {"guicursor", "gcr", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1036 | #ifdef CURSOR_SHAPE |
| 1037 | (char_u *)&p_guicursor, PV_NONE, |
| 1038 | { |
| 1039 | # ifdef FEAT_GUI |
| 1040 | (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", |
| 1041 | # else /* MSDOS or Win32 console */ |
| 1042 | (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block", |
| 1043 | # endif |
| 1044 | (char_u *)0L} |
| 1045 | #else |
| 1046 | (char_u *)NULL, PV_NONE, |
| 1047 | {(char_u *)NULL, (char_u *)0L} |
| 1048 | #endif |
| 1049 | }, |
| 1050 | {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP, |
| 1051 | #ifdef FEAT_GUI |
| 1052 | (char_u *)&p_guifont, PV_NONE, |
| 1053 | {(char_u *)"", (char_u *)0L} |
| 1054 | #else |
| 1055 | (char_u *)NULL, PV_NONE, |
| 1056 | {(char_u *)NULL, (char_u *)0L} |
| 1057 | #endif |
| 1058 | }, |
| 1059 | {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_COMMA, |
| 1060 | #if defined(FEAT_GUI) && defined(FEAT_XFONTSET) |
| 1061 | (char_u *)&p_guifontset, PV_NONE, |
| 1062 | {(char_u *)"", (char_u *)0L} |
| 1063 | #else |
| 1064 | (char_u *)NULL, PV_NONE, |
| 1065 | {(char_u *)NULL, (char_u *)0L} |
| 1066 | #endif |
| 1067 | }, |
| 1068 | {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP, |
| 1069 | #if defined(FEAT_GUI) && defined(FEAT_MBYTE) |
| 1070 | (char_u *)&p_guifontwide, PV_NONE, |
| 1071 | {(char_u *)"", (char_u *)0L} |
| 1072 | #else |
| 1073 | (char_u *)NULL, PV_NONE, |
| 1074 | {(char_u *)NULL, (char_u *)0L} |
| 1075 | #endif |
| 1076 | }, |
| 1077 | {"guiheadroom", "ghr", P_NUM|P_VI_DEF, |
Bram Moolenaar | 9372a11 | 2005-12-06 19:59:18 +0000 | [diff] [blame] | 1078 | #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1079 | (char_u *)&p_ghr, PV_NONE, |
| 1080 | #else |
| 1081 | (char_u *)NULL, PV_NONE, |
| 1082 | #endif |
| 1083 | {(char_u *)50L, (char_u *)0L}}, |
| 1084 | {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST, |
Bram Moolenaar | 9372a11 | 2005-12-06 19:59:18 +0000 | [diff] [blame] | 1085 | #if defined(FEAT_GUI) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1086 | (char_u *)&p_go, PV_NONE, |
| 1087 | # if defined(UNIX) && !defined(MACOS) |
| 1088 | {(char_u *)"agimrLtT", (char_u *)0L} |
| 1089 | # else |
| 1090 | {(char_u *)"gmrLtT", (char_u *)0L} |
| 1091 | # endif |
| 1092 | #else |
| 1093 | (char_u *)NULL, PV_NONE, |
| 1094 | {(char_u *)NULL, (char_u *)0L} |
| 1095 | #endif |
| 1096 | }, |
| 1097 | {"guipty", NULL, P_BOOL|P_VI_DEF, |
| 1098 | #if defined(FEAT_GUI) |
| 1099 | (char_u *)&p_guipty, PV_NONE, |
| 1100 | #else |
| 1101 | (char_u *)NULL, PV_NONE, |
| 1102 | #endif |
| 1103 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1104 | {"hardtabs", "ht", P_NUM|P_VI_DEF, |
| 1105 | (char_u *)NULL, PV_NONE, |
| 1106 | {(char_u *)0L, (char_u *)0L}}, |
| 1107 | {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 1108 | (char_u *)&p_hf, PV_NONE, |
| 1109 | {(char_u *)DFLT_HELPFILE, (char_u *)0L}}, |
| 1110 | {"helpheight", "hh", P_NUM|P_VI_DEF, |
| 1111 | #ifdef FEAT_WINDOWS |
| 1112 | (char_u *)&p_hh, PV_NONE, |
| 1113 | #else |
| 1114 | (char_u *)NULL, PV_NONE, |
| 1115 | #endif |
| 1116 | {(char_u *)20L, (char_u *)0L}}, |
| 1117 | {"helplang", "hlg", P_STRING|P_VI_DEF|P_COMMA, |
| 1118 | #ifdef FEAT_MULTI_LANG |
| 1119 | (char_u *)&p_hlg, PV_NONE, |
| 1120 | {(char_u *)"", (char_u *)0L} |
| 1121 | #else |
| 1122 | (char_u *)NULL, PV_NONE, |
| 1123 | {(char_u *)0L, (char_u *)0L} |
| 1124 | #endif |
| 1125 | }, |
| 1126 | {"hidden", "hid", P_BOOL|P_VI_DEF, |
| 1127 | (char_u *)&p_hid, PV_NONE, |
| 1128 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1129 | {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP, |
| 1130 | (char_u *)&p_hl, PV_NONE, |
Bram Moolenaar | 1c7715d | 2005-10-03 22:02:18 +0000 | [diff] [blame] | 1131 | {(char_u *)"8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb", |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1132 | (char_u *)0L}}, |
| 1133 | {"history", "hi", P_NUM|P_VIM, |
| 1134 | (char_u *)&p_hi, PV_NONE, |
| 1135 | {(char_u *)0L, (char_u *)20L}}, |
| 1136 | {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM, |
| 1137 | #ifdef FEAT_RIGHTLEFT |
| 1138 | (char_u *)&p_hkmap, PV_NONE, |
| 1139 | #else |
| 1140 | (char_u *)NULL, PV_NONE, |
| 1141 | #endif |
| 1142 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1143 | {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM, |
| 1144 | #ifdef FEAT_RIGHTLEFT |
| 1145 | (char_u *)&p_hkmapp, PV_NONE, |
| 1146 | #else |
| 1147 | (char_u *)NULL, PV_NONE, |
| 1148 | #endif |
| 1149 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1150 | {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL, |
| 1151 | (char_u *)&p_hls, PV_NONE, |
| 1152 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1153 | {"icon", NULL, P_BOOL|P_VI_DEF, |
| 1154 | #ifdef FEAT_TITLE |
| 1155 | (char_u *)&p_icon, PV_NONE, |
| 1156 | #else |
| 1157 | (char_u *)NULL, PV_NONE, |
| 1158 | #endif |
| 1159 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1160 | {"iconstring", NULL, P_STRING|P_VI_DEF, |
| 1161 | #ifdef FEAT_TITLE |
| 1162 | (char_u *)&p_iconstring, PV_NONE, |
| 1163 | #else |
| 1164 | (char_u *)NULL, PV_NONE, |
| 1165 | #endif |
| 1166 | {(char_u *)"", (char_u *)0L}}, |
| 1167 | {"ignorecase", "ic", P_BOOL|P_VI_DEF, |
| 1168 | (char_u *)&p_ic, PV_NONE, |
| 1169 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1170 | {"imactivatekey","imak",P_STRING|P_VI_DEF, |
Bram Moolenaar | 9372a11 | 2005-12-06 19:59:18 +0000 | [diff] [blame] | 1171 | #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1172 | (char_u *)&p_imak, PV_NONE, |
| 1173 | #else |
| 1174 | (char_u *)NULL, PV_NONE, |
| 1175 | #endif |
| 1176 | {(char_u *)"", (char_u *)0L}}, |
| 1177 | {"imcmdline", "imc", P_BOOL|P_VI_DEF, |
| 1178 | #ifdef USE_IM_CONTROL |
| 1179 | (char_u *)&p_imcmdline, PV_NONE, |
| 1180 | #else |
| 1181 | (char_u *)NULL, PV_NONE, |
| 1182 | #endif |
| 1183 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1184 | {"imdisable", "imd", P_BOOL|P_VI_DEF, |
| 1185 | #ifdef USE_IM_CONTROL |
| 1186 | (char_u *)&p_imdisable, PV_NONE, |
| 1187 | #else |
| 1188 | (char_u *)NULL, PV_NONE, |
| 1189 | #endif |
| 1190 | #ifdef __sgi |
| 1191 | {(char_u *)TRUE, (char_u *)0L} |
| 1192 | #else |
| 1193 | {(char_u *)FALSE, (char_u *)0L} |
| 1194 | #endif |
| 1195 | }, |
| 1196 | {"iminsert", "imi", P_NUM|P_VI_DEF, |
| 1197 | (char_u *)&p_iminsert, PV_IMI, |
| 1198 | #ifdef B_IMODE_IM |
| 1199 | {(char_u *)B_IMODE_IM, (char_u *)0L} |
| 1200 | #else |
| 1201 | {(char_u *)B_IMODE_NONE, (char_u *)0L} |
| 1202 | #endif |
| 1203 | }, |
| 1204 | {"imsearch", "ims", P_NUM|P_VI_DEF, |
| 1205 | (char_u *)&p_imsearch, PV_IMS, |
| 1206 | #ifdef B_IMODE_IM |
| 1207 | {(char_u *)B_IMODE_IM, (char_u *)0L} |
| 1208 | #else |
| 1209 | {(char_u *)B_IMODE_NONE, (char_u *)0L} |
| 1210 | #endif |
| 1211 | }, |
| 1212 | {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF, |
| 1213 | #ifdef FEAT_FIND_ID |
| 1214 | (char_u *)&p_inc, OPT_BOTH(PV_INC), |
| 1215 | {(char_u *)"^\\s*#\\s*include", (char_u *)0L} |
| 1216 | #else |
| 1217 | (char_u *)NULL, PV_NONE, |
| 1218 | {(char_u *)0L, (char_u *)0L} |
| 1219 | #endif |
| 1220 | }, |
| 1221 | {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF, |
| 1222 | #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) |
| 1223 | (char_u *)&p_inex, PV_INEX, |
| 1224 | {(char_u *)"", (char_u *)0L} |
| 1225 | #else |
| 1226 | (char_u *)NULL, PV_NONE, |
| 1227 | {(char_u *)0L, (char_u *)0L} |
| 1228 | #endif |
| 1229 | }, |
| 1230 | {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM, |
| 1231 | (char_u *)&p_is, PV_NONE, |
| 1232 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1233 | {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM, |
| 1234 | #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) |
| 1235 | (char_u *)&p_inde, PV_INDE, |
| 1236 | {(char_u *)"", (char_u *)0L} |
| 1237 | #else |
| 1238 | (char_u *)NULL, PV_NONE, |
| 1239 | {(char_u *)0L, (char_u *)0L} |
| 1240 | #endif |
| 1241 | }, |
| 1242 | {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 1243 | #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) |
| 1244 | (char_u *)&p_indk, PV_INDK, |
| 1245 | {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L} |
| 1246 | #else |
| 1247 | (char_u *)NULL, PV_NONE, |
| 1248 | {(char_u *)0L, (char_u *)0L} |
| 1249 | #endif |
| 1250 | }, |
| 1251 | {"infercase", "inf", P_BOOL|P_VI_DEF, |
| 1252 | (char_u *)&p_inf, PV_INF, |
| 1253 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1254 | {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM, |
| 1255 | (char_u *)&p_im, PV_NONE, |
| 1256 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1257 | {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1258 | (char_u *)&p_isf, PV_NONE, |
| 1259 | { |
| 1260 | #ifdef BACKSLASH_IN_FILENAME |
| 1261 | /* Excluded are: & and ^ are special in cmd.exe |
| 1262 | * ( and ) are used in text separating fnames */ |
| 1263 | (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=", |
| 1264 | #else |
| 1265 | # ifdef AMIGA |
| 1266 | (char_u *)"@,48-57,/,.,-,_,+,,,$,:", |
| 1267 | # else |
| 1268 | # ifdef VMS |
| 1269 | (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~", |
| 1270 | # else /* UNIX et al. */ |
| 1271 | # ifdef EBCDIC |
| 1272 | (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=", |
| 1273 | # else |
| 1274 | (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=", |
| 1275 | # endif |
| 1276 | # endif |
| 1277 | # endif |
| 1278 | #endif |
| 1279 | (char_u *)0L}}, |
| 1280 | {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1281 | (char_u *)&p_isi, PV_NONE, |
| 1282 | { |
| 1283 | #if defined(MSDOS) || defined(MSWIN) || defined(OS2) |
| 1284 | (char_u *)"@,48-57,_,128-167,224-235", |
| 1285 | #else |
| 1286 | # ifdef EBCDIC |
| 1287 | /* TODO: EBCDIC Check this! @ == isalpha()*/ |
| 1288 | (char_u *)"@,240-249,_,66-73,81-89,98-105," |
| 1289 | "112-120,128,140-142,156,158,172," |
| 1290 | "174,186,191,203-207,219-225,235-239," |
| 1291 | "251-254", |
| 1292 | # else |
| 1293 | (char_u *)"@,48-57,_,192-255", |
| 1294 | # endif |
| 1295 | #endif |
| 1296 | (char_u *)0L}}, |
| 1297 | {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP, |
| 1298 | (char_u *)&p_isk, PV_ISK, |
| 1299 | { |
| 1300 | #ifdef EBCDIC |
| 1301 | (char_u *)"@,240-249,_", |
| 1302 | /* TODO: EBCDIC Check this! @ == isalpha()*/ |
| 1303 | (char_u *)"@,240-249,_,66-73,81-89,98-105," |
| 1304 | "112-120,128,140-142,156,158,172," |
| 1305 | "174,186,191,203-207,219-225,235-239," |
| 1306 | "251-254", |
| 1307 | #else |
| 1308 | (char_u *)"@,48-57,_", |
| 1309 | # if defined(MSDOS) || defined(MSWIN) || defined(OS2) |
| 1310 | (char_u *)"@,48-57,_,128-167,224-235" |
| 1311 | # else |
| 1312 | (char_u *)"@,48-57,_,192-255" |
| 1313 | # endif |
| 1314 | #endif |
| 1315 | }}, |
| 1316 | {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP, |
| 1317 | (char_u *)&p_isp, PV_NONE, |
| 1318 | { |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 1319 | #if defined(MSDOS) || defined(MSWIN) || defined(OS2) \ |
| 1320 | || (defined(MACOS) && !defined(MACOS_X)) \ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1321 | || defined(VMS) |
| 1322 | (char_u *)"@,~-255", |
| 1323 | #else |
| 1324 | # ifdef EBCDIC |
| 1325 | /* all chars above 63 are printable */ |
| 1326 | (char_u *)"63-255", |
| 1327 | # else |
| 1328 | (char_u *)"@,161-255", |
| 1329 | # endif |
| 1330 | #endif |
| 1331 | (char_u *)0L}}, |
| 1332 | {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM, |
| 1333 | (char_u *)&p_js, PV_NONE, |
| 1334 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1335 | {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC, |
| 1336 | #ifdef FEAT_CRYPT |
| 1337 | (char_u *)&p_key, PV_KEY, |
| 1338 | {(char_u *)"", (char_u *)0L} |
| 1339 | #else |
| 1340 | (char_u *)NULL, PV_NONE, |
| 1341 | {(char_u *)0L, (char_u *)0L} |
| 1342 | #endif |
| 1343 | }, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 1344 | {"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] | 1345 | #ifdef FEAT_KEYMAP |
| 1346 | (char_u *)&p_keymap, PV_KMAP, |
| 1347 | {(char_u *)"", (char_u *)0L} |
| 1348 | #else |
| 1349 | (char_u *)NULL, PV_NONE, |
| 1350 | {(char_u *)"", (char_u *)0L} |
| 1351 | #endif |
| 1352 | }, |
| 1353 | {"keymodel", "km", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1354 | #ifdef FEAT_VISUAL |
| 1355 | (char_u *)&p_km, PV_NONE, |
| 1356 | #else |
| 1357 | (char_u *)NULL, PV_NONE, |
| 1358 | #endif |
| 1359 | {(char_u *)"", (char_u *)0L}}, |
| 1360 | {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 1361 | (char_u *)&p_kp, OPT_BOTH(PV_KP), |
| 1362 | { |
| 1363 | #if defined(MSDOS) || defined(MSWIN) |
| 1364 | (char_u *)":help", |
| 1365 | #else |
| 1366 | #ifdef VMS |
| 1367 | (char_u *)"help", |
| 1368 | #else |
| 1369 | # if defined(OS2) |
| 1370 | (char_u *)"view /", |
| 1371 | # else |
| 1372 | # ifdef USEMAN_S |
| 1373 | (char_u *)"man -s", |
| 1374 | # else |
| 1375 | (char_u *)"man", |
| 1376 | # endif |
| 1377 | # endif |
| 1378 | #endif |
| 1379 | #endif |
| 1380 | (char_u *)0L}}, |
| 1381 | {"langmap", "lmap", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1382 | #ifdef FEAT_LANGMAP |
| 1383 | (char_u *)&p_langmap, PV_NONE, |
| 1384 | {(char_u *)"", /* unmatched } */ |
| 1385 | #else |
| 1386 | (char_u *)NULL, PV_NONE, |
| 1387 | {(char_u *)NULL, |
| 1388 | #endif |
| 1389 | (char_u *)0L}}, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 1390 | {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1391 | #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG) |
| 1392 | (char_u *)&p_lm, PV_NONE, |
| 1393 | #else |
| 1394 | (char_u *)NULL, PV_NONE, |
| 1395 | #endif |
| 1396 | {(char_u *)"", (char_u *)0L}}, |
| 1397 | {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL, |
| 1398 | #ifdef FEAT_WINDOWS |
| 1399 | (char_u *)&p_ls, PV_NONE, |
| 1400 | #else |
| 1401 | (char_u *)NULL, PV_NONE, |
| 1402 | #endif |
| 1403 | {(char_u *)1L, (char_u *)0L}}, |
| 1404 | {"lazyredraw", "lz", P_BOOL|P_VI_DEF, |
| 1405 | (char_u *)&p_lz, PV_NONE, |
| 1406 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1407 | {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN, |
| 1408 | #ifdef FEAT_LINEBREAK |
| 1409 | (char_u *)VAR_WIN, PV_LBR, |
| 1410 | #else |
| 1411 | (char_u *)NULL, PV_NONE, |
| 1412 | #endif |
| 1413 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1414 | {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR, |
| 1415 | (char_u *)&Rows, PV_NONE, |
| 1416 | { |
| 1417 | #if defined(MSDOS) || defined(WIN3264) || defined(OS2) |
| 1418 | (char_u *)25L, |
| 1419 | #else |
| 1420 | (char_u *)24L, |
| 1421 | #endif |
| 1422 | (char_u *)0L}}, |
| 1423 | {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR, |
| 1424 | #ifdef FEAT_GUI |
| 1425 | (char_u *)&p_linespace, PV_NONE, |
| 1426 | #else |
| 1427 | (char_u *)NULL, PV_NONE, |
| 1428 | #endif |
| 1429 | #ifdef FEAT_GUI_W32 |
| 1430 | {(char_u *)1L, (char_u *)0L} |
| 1431 | #else |
| 1432 | {(char_u *)0L, (char_u *)0L} |
| 1433 | #endif |
| 1434 | }, |
| 1435 | {"lisp", NULL, P_BOOL|P_VI_DEF, |
| 1436 | #ifdef FEAT_LISP |
| 1437 | (char_u *)&p_lisp, PV_LISP, |
| 1438 | #else |
| 1439 | (char_u *)NULL, PV_NONE, |
| 1440 | #endif |
| 1441 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1442 | {"lispwords", "lw", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1443 | #ifdef FEAT_LISP |
| 1444 | (char_u *)&p_lispwords, PV_NONE, |
| 1445 | {(char_u *)LISPWORD_VALUE, (char_u *)0L} |
| 1446 | #else |
| 1447 | (char_u *)NULL, PV_NONE, |
| 1448 | {(char_u *)"", (char_u *)0L} |
| 1449 | #endif |
| 1450 | }, |
| 1451 | {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN, |
| 1452 | (char_u *)VAR_WIN, PV_LIST, |
| 1453 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1454 | {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP, |
| 1455 | (char_u *)&p_lcs, PV_NONE, |
| 1456 | {(char_u *)"eol:$", (char_u *)0L}}, |
| 1457 | {"loadplugins", "lpl", P_BOOL|P_VI_DEF, |
| 1458 | (char_u *)&p_lpl, PV_NONE, |
| 1459 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1460 | {"magic", NULL, P_BOOL|P_VI_DEF, |
| 1461 | (char_u *)&p_magic, PV_NONE, |
| 1462 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1463 | {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 1464 | #ifdef FEAT_QUICKFIX |
| 1465 | (char_u *)&p_mef, PV_NONE, |
| 1466 | {(char_u *)"", (char_u *)0L} |
| 1467 | #else |
| 1468 | (char_u *)NULL, PV_NONE, |
| 1469 | {(char_u *)NULL, (char_u *)0L} |
| 1470 | #endif |
| 1471 | }, |
| 1472 | {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 1473 | #ifdef FEAT_QUICKFIX |
| 1474 | (char_u *)&p_mp, OPT_BOTH(PV_MP), |
| 1475 | # ifdef VMS |
| 1476 | {(char_u *)"MMS", (char_u *)0L} |
| 1477 | # else |
| 1478 | {(char_u *)"make", (char_u *)0L} |
| 1479 | # endif |
| 1480 | #else |
| 1481 | (char_u *)NULL, PV_NONE, |
| 1482 | {(char_u *)NULL, (char_u *)0L} |
| 1483 | #endif |
| 1484 | }, |
| 1485 | {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 1486 | (char_u *)&p_mps, PV_MPS, |
| 1487 | {(char_u *)"(:),{:},[:]", (char_u *)0L}}, |
| 1488 | {"matchtime", "mat", P_NUM|P_VI_DEF, |
| 1489 | (char_u *)&p_mat, PV_NONE, |
| 1490 | {(char_u *)5L, (char_u *)0L}}, |
| 1491 | {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF, |
| 1492 | #ifdef FEAT_EVAL |
| 1493 | (char_u *)&p_mfd, PV_NONE, |
| 1494 | #else |
| 1495 | (char_u *)NULL, PV_NONE, |
| 1496 | #endif |
| 1497 | {(char_u *)100L, (char_u *)0L}}, |
| 1498 | {"maxmapdepth", "mmd", P_NUM|P_VI_DEF, |
| 1499 | (char_u *)&p_mmd, PV_NONE, |
| 1500 | {(char_u *)1000L, (char_u *)0L}}, |
| 1501 | {"maxmem", "mm", P_NUM|P_VI_DEF, |
| 1502 | (char_u *)&p_mm, PV_NONE, |
| 1503 | {(char_u *)DFLT_MAXMEM, (char_u *)0L}}, |
Bram Moolenaar | f1f8bc5 | 2005-03-07 23:20:08 +0000 | [diff] [blame] | 1504 | {"maxmempattern","mmp", P_NUM|P_VI_DEF, |
| 1505 | (char_u *)&p_mmp, PV_NONE, |
| 1506 | {(char_u *)1000L, (char_u *)0L}}, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1507 | {"maxmemtot", "mmt", P_NUM|P_VI_DEF, |
| 1508 | (char_u *)&p_mmt, PV_NONE, |
| 1509 | {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}}, |
| 1510 | {"menuitems", "mis", P_NUM|P_VI_DEF, |
| 1511 | #ifdef FEAT_MENU |
| 1512 | (char_u *)&p_mis, PV_NONE, |
| 1513 | #else |
| 1514 | (char_u *)NULL, PV_NONE, |
| 1515 | #endif |
| 1516 | {(char_u *)25L, (char_u *)0L}}, |
| 1517 | {"mesg", NULL, P_BOOL|P_VI_DEF, |
| 1518 | (char_u *)NULL, PV_NONE, |
| 1519 | {(char_u *)FALSE, (char_u *)0L}}, |
Bram Moolenaar | 8aff23a | 2005-08-19 20:40:30 +0000 | [diff] [blame] | 1520 | {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE, |
| 1521 | #ifdef FEAT_SYN_HL |
| 1522 | (char_u *)&p_msm, PV_NONE, |
| 1523 | {(char_u *)"460000,2000,500", (char_u *)0L} |
| 1524 | #else |
| 1525 | (char_u *)NULL, PV_NONE, |
| 1526 | {(char_u *)0L, (char_u *)0L} |
| 1527 | #endif |
| 1528 | }, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1529 | {"modeline", "ml", P_BOOL|P_VIM, |
| 1530 | (char_u *)&p_ml, PV_ML, |
| 1531 | {(char_u *)FALSE, (char_u *)TRUE}}, |
| 1532 | {"modelines", "mls", P_NUM|P_VI_DEF, |
| 1533 | (char_u *)&p_mls, PV_NONE, |
| 1534 | {(char_u *)5L, (char_u *)0L}}, |
| 1535 | {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB, |
| 1536 | (char_u *)&p_ma, PV_MA, |
| 1537 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1538 | {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, |
| 1539 | (char_u *)&p_mod, PV_MOD, |
| 1540 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1541 | {"more", NULL, P_BOOL|P_VIM, |
| 1542 | (char_u *)&p_more, PV_NONE, |
| 1543 | {(char_u *)FALSE, (char_u *)TRUE}}, |
| 1544 | {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST, |
| 1545 | (char_u *)&p_mouse, PV_NONE, |
| 1546 | { |
| 1547 | #if defined(MSDOS) || defined(WIN3264) |
| 1548 | (char_u *)"a", |
| 1549 | #else |
| 1550 | (char_u *)"", |
| 1551 | #endif |
| 1552 | (char_u *)0L}}, |
| 1553 | {"mousefocus", "mousef", P_BOOL|P_VI_DEF, |
| 1554 | #ifdef FEAT_GUI |
| 1555 | (char_u *)&p_mousef, PV_NONE, |
| 1556 | #else |
| 1557 | (char_u *)NULL, PV_NONE, |
| 1558 | #endif |
| 1559 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1560 | {"mousehide", "mh", P_BOOL|P_VI_DEF, |
| 1561 | #ifdef FEAT_GUI |
| 1562 | (char_u *)&p_mh, PV_NONE, |
| 1563 | #else |
| 1564 | (char_u *)NULL, PV_NONE, |
| 1565 | #endif |
| 1566 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1567 | {"mousemodel", "mousem", P_STRING|P_VI_DEF, |
| 1568 | (char_u *)&p_mousem, PV_NONE, |
| 1569 | { |
| 1570 | #if defined(MSDOS) || defined(MSWIN) |
| 1571 | (char_u *)"popup", |
| 1572 | #else |
| 1573 | # if defined(MACOS) |
| 1574 | (char_u *)"popup_setpos", |
| 1575 | # else |
| 1576 | (char_u *)"extend", |
| 1577 | # endif |
| 1578 | #endif |
| 1579 | (char_u *)0L}}, |
| 1580 | {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1581 | #ifdef FEAT_MOUSESHAPE |
| 1582 | (char_u *)&p_mouseshape, PV_NONE, |
| 1583 | {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L} |
| 1584 | #else |
| 1585 | (char_u *)NULL, PV_NONE, |
| 1586 | {(char_u *)NULL, (char_u *)0L} |
| 1587 | #endif |
| 1588 | }, |
| 1589 | {"mousetime", "mouset", P_NUM|P_VI_DEF, |
| 1590 | (char_u *)&p_mouset, PV_NONE, |
| 1591 | {(char_u *)500L, (char_u *)0L}}, |
Bram Moolenaar | 325b7a2 | 2004-07-05 15:58:32 +0000 | [diff] [blame] | 1592 | {"mzquantum", "mzq", P_NUM, |
| 1593 | #ifdef FEAT_MZSCHEME |
| 1594 | (char_u *)&p_mzq, PV_NONE, |
| 1595 | #else |
| 1596 | (char_u *)NULL, PV_NONE, |
| 1597 | #endif |
| 1598 | {(char_u *)100L, (char_u *)100L}}, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1599 | {"novice", NULL, P_BOOL|P_VI_DEF, |
| 1600 | (char_u *)NULL, PV_NONE, |
| 1601 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1602 | {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP, |
| 1603 | (char_u *)&p_nf, PV_NF, |
| 1604 | {(char_u *)"octal,hex", (char_u *)0L}}, |
| 1605 | {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN, |
| 1606 | (char_u *)VAR_WIN, PV_NU, |
| 1607 | {(char_u *)FALSE, (char_u *)0L}}, |
Bram Moolenaar | 592e0a2 | 2004-07-03 16:05:59 +0000 | [diff] [blame] | 1608 | {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM, |
| 1609 | #ifdef FEAT_LINEBREAK |
| 1610 | (char_u *)VAR_WIN, PV_NUW, |
| 1611 | #else |
| 1612 | (char_u *)NULL, PV_NONE, |
| 1613 | #endif |
| 1614 | {(char_u *)8L, (char_u *)4L}}, |
Bram Moolenaar | f75a963 | 2005-09-13 21:20:47 +0000 | [diff] [blame] | 1615 | {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE, |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 1616 | #ifdef FEAT_COMPL_FUNC |
| 1617 | (char_u *)&p_ofu, PV_OFU, |
| 1618 | {(char_u *)"", (char_u *)0L} |
| 1619 | #else |
| 1620 | (char_u *)NULL, PV_NONE, |
| 1621 | {(char_u *)0L, (char_u *)0L} |
| 1622 | #endif |
| 1623 | }, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1624 | {"open", NULL, P_BOOL|P_VI_DEF, |
| 1625 | (char_u *)NULL, PV_NONE, |
| 1626 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1627 | {"optimize", "opt", P_BOOL|P_VI_DEF, |
| 1628 | (char_u *)NULL, PV_NONE, |
| 1629 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1630 | {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF, |
| 1631 | #ifdef FEAT_OSFILETYPE |
| 1632 | (char_u *)&p_oft, PV_OFT, |
| 1633 | {(char_u *)DFLT_OFT, (char_u *)0L} |
| 1634 | #else |
| 1635 | (char_u *)NULL, PV_NONE, |
| 1636 | {(char_u *)0L, (char_u *)0L} |
| 1637 | #endif |
| 1638 | }, |
| 1639 | {"paragraphs", "para", P_STRING|P_VI_DEF, |
| 1640 | (char_u *)&p_para, PV_NONE, |
| 1641 | {(char_u *)"IPLPPPQPP LIpplpipbp", (char_u *)0L}}, |
| 1642 | {"paste", NULL, P_BOOL|P_VI_DEF, |
| 1643 | (char_u *)&p_paste, PV_NONE, |
| 1644 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1645 | {"pastetoggle", "pt", P_STRING|P_VI_DEF, |
| 1646 | (char_u *)&p_pt, PV_NONE, |
| 1647 | {(char_u *)"", (char_u *)0L}}, |
| 1648 | {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE, |
| 1649 | #if defined(FEAT_DIFF) && defined(FEAT_EVAL) |
| 1650 | (char_u *)&p_pex, PV_NONE, |
| 1651 | {(char_u *)"", (char_u *)0L} |
| 1652 | #else |
| 1653 | (char_u *)NULL, PV_NONE, |
| 1654 | {(char_u *)0L, (char_u *)0L} |
| 1655 | #endif |
| 1656 | }, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 1657 | {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1658 | (char_u *)&p_pm, PV_NONE, |
| 1659 | {(char_u *)"", (char_u *)0L}}, |
| 1660 | {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
| 1661 | (char_u *)&p_path, OPT_BOTH(PV_PATH), |
| 1662 | { |
| 1663 | #if defined AMIGA || defined MSDOS || defined MSWIN |
| 1664 | (char_u *)".,,", |
| 1665 | #else |
| 1666 | # if defined(__EMX__) |
| 1667 | (char_u *)".,/emx/include,,", |
| 1668 | # else /* Unix, probably */ |
| 1669 | (char_u *)".,/usr/include,,", |
| 1670 | # endif |
| 1671 | #endif |
| 1672 | (char_u *)0L}}, |
| 1673 | {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM, |
| 1674 | (char_u *)&p_pi, PV_PI, |
| 1675 | {(char_u *)FALSE, (char_u *)0L}}, |
Bram Moolenaar | 592e0a2 | 2004-07-03 16:05:59 +0000 | [diff] [blame] | 1676 | {"previewheight", "pvh", P_NUM|P_VI_DEF, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1677 | #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) |
| 1678 | (char_u *)&p_pvh, PV_NONE, |
| 1679 | #else |
| 1680 | (char_u *)NULL, PV_NONE, |
| 1681 | #endif |
| 1682 | {(char_u *)12L, (char_u *)0L}}, |
| 1683 | {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB, |
| 1684 | #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) |
| 1685 | (char_u *)VAR_WIN, PV_PVW, |
| 1686 | #else |
| 1687 | (char_u *)NULL, PV_NONE, |
| 1688 | #endif |
| 1689 | {(char_u *)FALSE, (char_u *)0L}}, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 1690 | {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1691 | #ifdef FEAT_PRINTER |
| 1692 | (char_u *)&p_pdev, PV_NONE, |
| 1693 | {(char_u *)"", (char_u *)0L} |
| 1694 | #else |
| 1695 | (char_u *)NULL, PV_NONE, |
| 1696 | {(char_u *)NULL, (char_u *)0L} |
| 1697 | #endif |
| 1698 | }, |
| 1699 | {"printencoding", "penc", P_STRING|P_VI_DEF, |
| 1700 | #ifdef FEAT_POSTSCRIPT |
| 1701 | (char_u *)&p_penc, PV_NONE, |
| 1702 | {(char_u *)"", (char_u *)0L} |
| 1703 | #else |
| 1704 | (char_u *)NULL, PV_NONE, |
| 1705 | {(char_u *)NULL, (char_u *)0L} |
| 1706 | #endif |
| 1707 | }, |
| 1708 | {"printexpr", "pexpr", P_STRING|P_VI_DEF, |
| 1709 | #ifdef FEAT_POSTSCRIPT |
| 1710 | (char_u *)&p_pexpr, PV_NONE, |
| 1711 | {(char_u *)"", (char_u *)0L} |
| 1712 | #else |
| 1713 | (char_u *)NULL, PV_NONE, |
| 1714 | {(char_u *)NULL, (char_u *)0L} |
| 1715 | #endif |
| 1716 | }, |
| 1717 | {"printfont", "pfn", P_STRING|P_VI_DEF, |
| 1718 | #ifdef FEAT_PRINTER |
| 1719 | (char_u *)&p_pfn, PV_NONE, |
| 1720 | { |
| 1721 | # ifdef MSWIN |
| 1722 | (char_u *)"Courier_New:h10", |
| 1723 | # else |
| 1724 | (char_u *)"courier", |
| 1725 | # endif |
| 1726 | (char_u *)0L} |
| 1727 | #else |
| 1728 | (char_u *)NULL, PV_NONE, |
| 1729 | {(char_u *)NULL, (char_u *)0L} |
| 1730 | #endif |
| 1731 | }, |
| 1732 | {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT, |
| 1733 | #ifdef FEAT_PRINTER |
| 1734 | (char_u *)&p_header, PV_NONE, |
| 1735 | {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L} |
| 1736 | #else |
| 1737 | (char_u *)NULL, PV_NONE, |
| 1738 | {(char_u *)NULL, (char_u *)0L} |
| 1739 | #endif |
| 1740 | }, |
Bram Moolenaar | 8299df9 | 2004-07-10 09:47:34 +0000 | [diff] [blame] | 1741 | {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF, |
| 1742 | #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE) |
| 1743 | (char_u *)&p_pmcs, PV_NONE, |
| 1744 | {(char_u *)"", (char_u *)0L} |
| 1745 | #else |
| 1746 | (char_u *)NULL, PV_NONE, |
| 1747 | {(char_u *)NULL, (char_u *)0L} |
| 1748 | #endif |
| 1749 | }, |
| 1750 | {"printmbfont", "pmbfn", P_STRING|P_VI_DEF, |
| 1751 | #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE) |
| 1752 | (char_u *)&p_pmfn, PV_NONE, |
| 1753 | {(char_u *)"", (char_u *)0L} |
| 1754 | #else |
| 1755 | (char_u *)NULL, PV_NONE, |
| 1756 | {(char_u *)NULL, (char_u *)0L} |
| 1757 | #endif |
| 1758 | }, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1759 | {"printoptions", "popt", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1760 | #ifdef FEAT_PRINTER |
| 1761 | (char_u *)&p_popt, PV_NONE, |
| 1762 | {(char_u *)"", (char_u *)0L} |
| 1763 | #else |
| 1764 | (char_u *)NULL, PV_NONE, |
| 1765 | {(char_u *)NULL, (char_u *)0L} |
| 1766 | #endif |
| 1767 | }, |
| 1768 | {"prompt", NULL, P_BOOL|P_VI_DEF, |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 1769 | (char_u *)&p_prompt, PV_NONE, |
| 1770 | {(char_u *)TRUE, (char_u *)0L}}, |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 1771 | {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF, |
| 1772 | #ifdef FEAT_TEXTOBJ |
| 1773 | (char_u *)&p_qe, PV_QE, |
| 1774 | {(char_u *)"\\", (char_u *)0L} |
| 1775 | #else |
| 1776 | (char_u *)NULL, PV_NONE, |
| 1777 | {(char_u *)NULL, (char_u *)0L} |
| 1778 | #endif |
| 1779 | }, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1780 | {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB, |
| 1781 | (char_u *)&p_ro, PV_RO, |
| 1782 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1783 | {"redraw", NULL, P_BOOL|P_VI_DEF, |
| 1784 | (char_u *)NULL, PV_NONE, |
| 1785 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1786 | {"remap", NULL, P_BOOL|P_VI_DEF, |
| 1787 | (char_u *)&p_remap, PV_NONE, |
| 1788 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1789 | {"report", NULL, P_NUM|P_VI_DEF, |
| 1790 | (char_u *)&p_report, PV_NONE, |
| 1791 | {(char_u *)2L, (char_u *)0L}}, |
| 1792 | {"restorescreen", "rs", P_BOOL|P_VI_DEF, |
| 1793 | #ifdef WIN3264 |
| 1794 | (char_u *)&p_rs, PV_NONE, |
| 1795 | #else |
| 1796 | (char_u *)NULL, PV_NONE, |
| 1797 | #endif |
| 1798 | {(char_u *)TRUE, (char_u *)0L}}, |
| 1799 | {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM, |
| 1800 | #ifdef FEAT_RIGHTLEFT |
| 1801 | (char_u *)&p_ri, PV_NONE, |
| 1802 | #else |
| 1803 | (char_u *)NULL, PV_NONE, |
| 1804 | #endif |
| 1805 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1806 | {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN, |
| 1807 | #ifdef FEAT_RIGHTLEFT |
| 1808 | (char_u *)VAR_WIN, PV_RL, |
| 1809 | #else |
| 1810 | (char_u *)NULL, PV_NONE, |
| 1811 | #endif |
| 1812 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1813 | {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN, |
| 1814 | #ifdef FEAT_RIGHTLEFT |
| 1815 | (char_u *)VAR_WIN, PV_RLC, |
| 1816 | {(char_u *)"search", (char_u *)NULL} |
| 1817 | #else |
| 1818 | (char_u *)NULL, PV_NONE, |
| 1819 | {(char_u *)NULL, (char_u *)0L} |
| 1820 | #endif |
| 1821 | }, |
| 1822 | {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT, |
| 1823 | #ifdef FEAT_CMDL_INFO |
| 1824 | (char_u *)&p_ru, PV_NONE, |
| 1825 | #else |
| 1826 | (char_u *)NULL, PV_NONE, |
| 1827 | #endif |
| 1828 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1829 | {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT, |
| 1830 | #ifdef FEAT_STL_OPT |
| 1831 | (char_u *)&p_ruf, PV_NONE, |
| 1832 | #else |
| 1833 | (char_u *)NULL, PV_NONE, |
| 1834 | #endif |
| 1835 | {(char_u *)"", (char_u *)0L}}, |
| 1836 | {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_COMMA|P_NODUP|P_SECURE, |
| 1837 | (char_u *)&p_rtp, PV_NONE, |
| 1838 | {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}}, |
| 1839 | {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF, |
| 1840 | (char_u *)VAR_WIN, PV_SCROLL, |
| 1841 | {(char_u *)12L, (char_u *)0L}}, |
| 1842 | {"scrollbind", "scb", P_BOOL|P_VI_DEF, |
| 1843 | #ifdef FEAT_SCROLLBIND |
| 1844 | (char_u *)VAR_WIN, PV_SCBIND, |
| 1845 | #else |
| 1846 | (char_u *)NULL, PV_NONE, |
| 1847 | #endif |
| 1848 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1849 | {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM, |
| 1850 | (char_u *)&p_sj, PV_NONE, |
| 1851 | {(char_u *)1L, (char_u *)0L}}, |
| 1852 | {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL, |
| 1853 | (char_u *)&p_so, PV_NONE, |
| 1854 | {(char_u *)0L, (char_u *)0L}}, |
| 1855 | {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1856 | #ifdef FEAT_SCROLLBIND |
| 1857 | (char_u *)&p_sbo, PV_NONE, |
| 1858 | {(char_u *)"ver,jump", (char_u *)0L} |
| 1859 | #else |
| 1860 | (char_u *)NULL, PV_NONE, |
| 1861 | {(char_u *)0L, (char_u *)0L} |
| 1862 | #endif |
| 1863 | }, |
| 1864 | {"sections", "sect", P_STRING|P_VI_DEF, |
| 1865 | (char_u *)&p_sections, PV_NONE, |
| 1866 | {(char_u *)"SHNHH HUnhsh", (char_u *)0L}}, |
| 1867 | {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE, |
| 1868 | (char_u *)&p_secure, PV_NONE, |
| 1869 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1870 | {"selection", "sel", P_STRING|P_VI_DEF, |
| 1871 | #ifdef FEAT_VISUAL |
| 1872 | (char_u *)&p_sel, PV_NONE, |
| 1873 | #else |
| 1874 | (char_u *)NULL, PV_NONE, |
| 1875 | #endif |
| 1876 | {(char_u *)"inclusive", (char_u *)0L}}, |
| 1877 | {"selectmode", "slm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1878 | #ifdef FEAT_VISUAL |
| 1879 | (char_u *)&p_slm, PV_NONE, |
| 1880 | #else |
| 1881 | (char_u *)NULL, PV_NONE, |
| 1882 | #endif |
| 1883 | {(char_u *)"", (char_u *)0L}}, |
| 1884 | {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 1885 | #ifdef FEAT_SESSION |
| 1886 | (char_u *)&p_ssop, PV_NONE, |
| 1887 | {(char_u *)"blank,buffers,curdir,folds,help,options,winsize", |
| 1888 | (char_u *)0L} |
| 1889 | #else |
| 1890 | (char_u *)NULL, PV_NONE, |
| 1891 | {(char_u *)0L, (char_u *)0L} |
| 1892 | #endif |
| 1893 | }, |
| 1894 | {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 1895 | (char_u *)&p_sh, PV_NONE, |
| 1896 | { |
| 1897 | #ifdef VMS |
| 1898 | (char_u *)"-", |
| 1899 | #else |
| 1900 | # if defined(MSDOS) |
| 1901 | (char_u *)"command", |
| 1902 | # else |
| 1903 | # if defined(WIN16) |
| 1904 | (char_u *)"command.com", |
| 1905 | # else |
| 1906 | # if defined(WIN3264) |
| 1907 | (char_u *)"", /* set in set_init_1() */ |
| 1908 | # else |
| 1909 | # if defined(OS2) |
| 1910 | (char_u *)"cmd.exe", |
| 1911 | # else |
| 1912 | # if defined(ARCHIE) |
| 1913 | (char_u *)"gos", |
| 1914 | # else |
| 1915 | (char_u *)"sh", |
| 1916 | # endif |
| 1917 | # endif |
| 1918 | # endif |
| 1919 | # endif |
| 1920 | # endif |
| 1921 | #endif /* VMS */ |
| 1922 | (char_u *)0L}}, |
| 1923 | {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE, |
| 1924 | (char_u *)&p_shcf, PV_NONE, |
| 1925 | { |
| 1926 | #if defined(MSDOS) || defined(MSWIN) |
| 1927 | (char_u *)"/c", |
| 1928 | #else |
| 1929 | # if defined(OS2) |
| 1930 | (char_u *)"/c", |
| 1931 | # else |
| 1932 | (char_u *)"-c", |
| 1933 | # endif |
| 1934 | #endif |
| 1935 | (char_u *)0L}}, |
| 1936 | {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE, |
| 1937 | #ifdef FEAT_QUICKFIX |
| 1938 | (char_u *)&p_sp, PV_NONE, |
| 1939 | { |
| 1940 | #if defined(UNIX) || defined(OS2) |
| 1941 | # ifdef ARCHIE |
| 1942 | (char_u *)"2>", |
| 1943 | # else |
| 1944 | (char_u *)"| tee", |
| 1945 | # endif |
| 1946 | #else |
| 1947 | (char_u *)">", |
| 1948 | #endif |
| 1949 | (char_u *)0L} |
| 1950 | #else |
| 1951 | (char_u *)NULL, PV_NONE, |
| 1952 | {(char_u *)0L, (char_u *)0L} |
| 1953 | #endif |
| 1954 | }, |
| 1955 | {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE, |
| 1956 | (char_u *)&p_shq, PV_NONE, |
| 1957 | {(char_u *)"", (char_u *)0L}}, |
| 1958 | {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE, |
| 1959 | (char_u *)&p_srr, PV_NONE, |
| 1960 | {(char_u *)">", (char_u *)0L}}, |
| 1961 | {"shellslash", "ssl", P_BOOL|P_VI_DEF, |
| 1962 | #ifdef BACKSLASH_IN_FILENAME |
| 1963 | (char_u *)&p_ssl, PV_NONE, |
| 1964 | #else |
| 1965 | (char_u *)NULL, PV_NONE, |
| 1966 | #endif |
| 1967 | {(char_u *)FALSE, (char_u *)0L}}, |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 1968 | {"shelltemp", "stmp", P_BOOL, |
| 1969 | (char_u *)&p_stmp, PV_NONE, |
| 1970 | {(char_u *)FALSE, (char_u *)TRUE}}, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1971 | {"shelltype", "st", P_NUM|P_VI_DEF, |
| 1972 | #ifdef AMIGA |
| 1973 | (char_u *)&p_st, PV_NONE, |
| 1974 | #else |
| 1975 | (char_u *)NULL, PV_NONE, |
| 1976 | #endif |
| 1977 | {(char_u *)0L, (char_u *)0L}}, |
| 1978 | {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE, |
| 1979 | (char_u *)&p_sxq, PV_NONE, |
| 1980 | { |
| 1981 | #if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__) |
| 1982 | (char_u *)"\"", |
| 1983 | #else |
| 1984 | (char_u *)"", |
| 1985 | #endif |
| 1986 | (char_u *)0L}}, |
| 1987 | {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM, |
| 1988 | (char_u *)&p_sr, PV_NONE, |
| 1989 | {(char_u *)FALSE, (char_u *)0L}}, |
| 1990 | {"shiftwidth", "sw", P_NUM|P_VI_DEF, |
| 1991 | (char_u *)&p_sw, PV_SW, |
| 1992 | {(char_u *)8L, (char_u *)0L}}, |
| 1993 | {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST, |
| 1994 | (char_u *)&p_shm, PV_NONE, |
| 1995 | {(char_u *)"", (char_u *)"filnxtToO"}}, |
| 1996 | {"shortname", "sn", P_BOOL|P_VI_DEF, |
| 1997 | #ifdef SHORT_FNAME |
| 1998 | (char_u *)NULL, PV_NONE, |
| 1999 | #else |
| 2000 | (char_u *)&p_sn, PV_SN, |
| 2001 | #endif |
| 2002 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2003 | {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL, |
| 2004 | #ifdef FEAT_LINEBREAK |
| 2005 | (char_u *)&p_sbr, PV_NONE, |
| 2006 | #else |
| 2007 | (char_u *)NULL, PV_NONE, |
| 2008 | #endif |
| 2009 | {(char_u *)"", (char_u *)0L}}, |
| 2010 | {"showcmd", "sc", P_BOOL|P_VIM, |
| 2011 | #ifdef FEAT_CMDL_INFO |
| 2012 | (char_u *)&p_sc, PV_NONE, |
| 2013 | #else |
| 2014 | (char_u *)NULL, PV_NONE, |
| 2015 | #endif |
| 2016 | {(char_u *)FALSE, |
| 2017 | #ifdef UNIX |
| 2018 | (char_u *)FALSE |
| 2019 | #else |
| 2020 | (char_u *)TRUE |
| 2021 | #endif |
| 2022 | }}, |
| 2023 | {"showfulltag", "sft", P_BOOL|P_VI_DEF, |
| 2024 | (char_u *)&p_sft, PV_NONE, |
| 2025 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2026 | {"showmatch", "sm", P_BOOL|P_VI_DEF, |
| 2027 | (char_u *)&p_sm, PV_NONE, |
| 2028 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2029 | {"showmode", "smd", P_BOOL|P_VIM, |
| 2030 | (char_u *)&p_smd, PV_NONE, |
| 2031 | {(char_u *)FALSE, (char_u *)TRUE}}, |
| 2032 | {"sidescroll", "ss", P_NUM|P_VI_DEF, |
| 2033 | (char_u *)&p_ss, PV_NONE, |
| 2034 | {(char_u *)0L, (char_u *)0L}}, |
| 2035 | {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF, |
| 2036 | (char_u *)&p_siso, PV_NONE, |
| 2037 | {(char_u *)0L, (char_u *)0L}}, |
| 2038 | {"slowopen", "slow", P_BOOL|P_VI_DEF, |
| 2039 | (char_u *)NULL, PV_NONE, |
| 2040 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2041 | {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM, |
| 2042 | (char_u *)&p_scs, PV_NONE, |
| 2043 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2044 | {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM, |
| 2045 | #ifdef FEAT_SMARTINDENT |
| 2046 | (char_u *)&p_si, PV_SI, |
| 2047 | #else |
| 2048 | (char_u *)NULL, PV_NONE, |
| 2049 | #endif |
| 2050 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2051 | {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM, |
| 2052 | (char_u *)&p_sta, PV_NONE, |
| 2053 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2054 | {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM, |
| 2055 | (char_u *)&p_sts, PV_STS, |
| 2056 | {(char_u *)0L, (char_u *)0L}}, |
| 2057 | {"sourceany", NULL, P_BOOL|P_VI_DEF, |
| 2058 | (char_u *)NULL, PV_NONE, |
| 2059 | {(char_u *)FALSE, (char_u *)0L}}, |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 2060 | {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN, |
| 2061 | #ifdef FEAT_SYN_HL |
| 2062 | (char_u *)VAR_WIN, PV_SPELL, |
| 2063 | #else |
| 2064 | (char_u *)NULL, PV_NONE, |
| 2065 | #endif |
| 2066 | {(char_u *)FALSE, (char_u *)0L}}, |
Bram Moolenaar | 488c651 | 2005-08-11 20:09:58 +0000 | [diff] [blame] | 2067 | {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF, |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 2068 | #ifdef FEAT_SYN_HL |
| 2069 | (char_u *)&p_spc, PV_SPC, |
Bram Moolenaar | 0dc065e | 2005-07-04 22:49:24 +0000 | [diff] [blame] | 2070 | {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L} |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 2071 | #else |
| 2072 | (char_u *)NULL, PV_NONE, |
| 2073 | {(char_u *)0L, (char_u *)0L} |
| 2074 | #endif |
| 2075 | }, |
| 2076 | {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE|P_COMMA, |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 2077 | #ifdef FEAT_SYN_HL |
| 2078 | (char_u *)&p_spf, PV_SPF, |
| 2079 | {(char_u *)"", (char_u *)0L} |
| 2080 | #else |
| 2081 | (char_u *)NULL, PV_NONE, |
| 2082 | {(char_u *)0L, (char_u *)0L} |
| 2083 | #endif |
| 2084 | }, |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 2085 | {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_RBUF|P_EXPAND, |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 2086 | #ifdef FEAT_SYN_HL |
| 2087 | (char_u *)&p_spl, PV_SPL, |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 2088 | {(char_u *)"en", (char_u *)0L} |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 2089 | #else |
| 2090 | (char_u *)NULL, PV_NONE, |
| 2091 | {(char_u *)0L, (char_u *)0L} |
| 2092 | #endif |
| 2093 | }, |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 2094 | {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE, |
Bram Moolenaar | d857f0e | 2005-06-21 22:37:39 +0000 | [diff] [blame] | 2095 | #ifdef FEAT_SYN_HL |
| 2096 | (char_u *)&p_sps, PV_NONE, |
| 2097 | {(char_u *)"best", (char_u *)0L} |
| 2098 | #else |
| 2099 | (char_u *)NULL, PV_NONE, |
| 2100 | {(char_u *)0L, (char_u *)0L} |
| 2101 | #endif |
| 2102 | }, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2103 | {"splitbelow", "sb", P_BOOL|P_VI_DEF, |
| 2104 | #ifdef FEAT_WINDOWS |
| 2105 | (char_u *)&p_sb, PV_NONE, |
| 2106 | #else |
| 2107 | (char_u *)NULL, PV_NONE, |
| 2108 | #endif |
| 2109 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2110 | {"splitright", "spr", P_BOOL|P_VI_DEF, |
| 2111 | #ifdef FEAT_VERTSPLIT |
| 2112 | (char_u *)&p_spr, PV_NONE, |
| 2113 | #else |
| 2114 | (char_u *)NULL, PV_NONE, |
| 2115 | #endif |
| 2116 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2117 | {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM, |
| 2118 | (char_u *)&p_sol, PV_NONE, |
| 2119 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2120 | {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT, |
| 2121 | #ifdef FEAT_STL_OPT |
Bram Moolenaar | b5bf5b8 | 2004-12-24 14:35:23 +0000 | [diff] [blame] | 2122 | (char_u *)&p_stl, OPT_BOTH(PV_STL), |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2123 | #else |
| 2124 | (char_u *)NULL, PV_NONE, |
| 2125 | #endif |
| 2126 | {(char_u *)"", (char_u *)0L}}, |
| 2127 | {"suffixes", "su", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 2128 | (char_u *)&p_su, PV_NONE, |
| 2129 | {(char_u *)".bak,~,.o,.h,.info,.swp,.obj", |
| 2130 | (char_u *)0L}}, |
| 2131 | {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_COMMA|P_NODUP, |
| 2132 | #if defined(FEAT_SEARCHPATH) |
| 2133 | (char_u *)&p_sua, PV_SUA, |
| 2134 | {(char_u *)"", (char_u *)0L} |
| 2135 | #else |
| 2136 | (char_u *)NULL, PV_NONE, |
| 2137 | {(char_u *)0L, (char_u *)0L} |
| 2138 | #endif |
| 2139 | }, |
| 2140 | {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT, |
| 2141 | (char_u *)&p_swf, PV_SWF, |
| 2142 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2143 | {"swapsync", "sws", P_STRING|P_VI_DEF, |
| 2144 | (char_u *)&p_sws, PV_NONE, |
| 2145 | {(char_u *)"fsync", (char_u *)0L}}, |
| 2146 | {"switchbuf", "swb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 2147 | (char_u *)&p_swb, PV_NONE, |
| 2148 | {(char_u *)"", (char_u *)0L}}, |
Bram Moolenaar | 3b56eb3 | 2005-07-11 22:40:32 +0000 | [diff] [blame] | 2149 | {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF, |
| 2150 | #ifdef FEAT_SYN_HL |
| 2151 | (char_u *)&p_smc, PV_SMC, |
| 2152 | {(char_u *)3000L, (char_u *)0L} |
| 2153 | #else |
| 2154 | (char_u *)NULL, PV_NONE, |
| 2155 | {(char_u *)0L, (char_u *)0L} |
| 2156 | #endif |
| 2157 | }, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 2158 | {"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] | 2159 | #ifdef FEAT_SYN_HL |
| 2160 | (char_u *)&p_syn, PV_SYN, |
| 2161 | {(char_u *)"", (char_u *)0L} |
| 2162 | #else |
| 2163 | (char_u *)NULL, PV_NONE, |
| 2164 | {(char_u *)0L, (char_u *)0L} |
| 2165 | #endif |
| 2166 | }, |
| 2167 | {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF, |
| 2168 | (char_u *)&p_ts, PV_TS, |
| 2169 | {(char_u *)8L, (char_u *)0L}}, |
| 2170 | {"tagbsearch", "tbs", P_BOOL|P_VI_DEF, |
| 2171 | (char_u *)&p_tbs, PV_NONE, |
| 2172 | #ifdef VMS /* binary searching doesn't appear to work on VMS */ |
| 2173 | {(char_u *)0L, (char_u *)0L} |
| 2174 | #else |
| 2175 | {(char_u *)TRUE, (char_u *)0L} |
| 2176 | #endif |
| 2177 | }, |
| 2178 | {"taglength", "tl", P_NUM|P_VI_DEF, |
| 2179 | (char_u *)&p_tl, PV_NONE, |
| 2180 | {(char_u *)0L, (char_u *)0L}}, |
| 2181 | {"tagrelative", "tr", P_BOOL|P_VIM, |
| 2182 | (char_u *)&p_tr, PV_NONE, |
| 2183 | {(char_u *)FALSE, (char_u *)TRUE}}, |
| 2184 | {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
| 2185 | (char_u *)&p_tags, OPT_BOTH(PV_TAGS), |
| 2186 | { |
| 2187 | #if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME) |
| 2188 | (char_u *)"./tags,./TAGS,tags,TAGS", |
| 2189 | #else |
| 2190 | (char_u *)"./tags,tags", |
| 2191 | #endif |
| 2192 | (char_u *)0L}}, |
| 2193 | {"tagstack", "tgst", P_BOOL|P_VI_DEF, |
| 2194 | (char_u *)&p_tgst, PV_NONE, |
| 2195 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2196 | {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL, |
| 2197 | (char_u *)&T_NAME, PV_NONE, |
| 2198 | {(char_u *)"", (char_u *)0L}}, |
| 2199 | {"termbidi", "tbidi", P_BOOL|P_VI_DEF, |
| 2200 | #ifdef FEAT_ARABIC |
| 2201 | (char_u *)&p_tbidi, PV_NONE, |
| 2202 | #else |
| 2203 | (char_u *)NULL, PV_NONE, |
| 2204 | #endif |
| 2205 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2206 | {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR, |
| 2207 | #ifdef FEAT_MBYTE |
| 2208 | (char_u *)&p_tenc, PV_NONE, |
| 2209 | {(char_u *)"", (char_u *)0L} |
| 2210 | #else |
| 2211 | (char_u *)NULL, PV_NONE, |
| 2212 | {(char_u *)0L, (char_u *)0L} |
| 2213 | #endif |
| 2214 | }, |
| 2215 | {"terse", NULL, P_BOOL|P_VI_DEF, |
| 2216 | (char_u *)&p_terse, PV_NONE, |
| 2217 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2218 | {"textauto", "ta", P_BOOL|P_VIM, |
| 2219 | (char_u *)&p_ta, PV_NONE, |
| 2220 | {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}}, |
| 2221 | {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC, |
| 2222 | (char_u *)&p_tx, PV_TX, |
| 2223 | { |
| 2224 | #ifdef USE_CRNL |
| 2225 | (char_u *)TRUE, |
| 2226 | #else |
| 2227 | (char_u *)FALSE, |
| 2228 | #endif |
| 2229 | (char_u *)0L}}, |
| 2230 | {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM, |
| 2231 | (char_u *)&p_tw, PV_TW, |
| 2232 | {(char_u *)0L, (char_u *)0L}}, |
| 2233 | {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, |
| 2234 | #ifdef FEAT_INS_EXPAND |
| 2235 | (char_u *)&p_tsr, OPT_BOTH(PV_TSR), |
| 2236 | #else |
| 2237 | (char_u *)NULL, PV_NONE, |
| 2238 | #endif |
| 2239 | {(char_u *)"", (char_u *)0L}}, |
| 2240 | {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM, |
| 2241 | (char_u *)&p_to, PV_NONE, |
| 2242 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2243 | {"timeout", "to", P_BOOL|P_VI_DEF, |
| 2244 | (char_u *)&p_timeout, PV_NONE, |
| 2245 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2246 | {"timeoutlen", "tm", P_NUM|P_VI_DEF, |
| 2247 | (char_u *)&p_tm, PV_NONE, |
| 2248 | {(char_u *)1000L, (char_u *)0L}}, |
| 2249 | {"title", NULL, P_BOOL|P_VI_DEF, |
| 2250 | #ifdef FEAT_TITLE |
| 2251 | (char_u *)&p_title, PV_NONE, |
| 2252 | #else |
| 2253 | (char_u *)NULL, PV_NONE, |
| 2254 | #endif |
| 2255 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2256 | {"titlelen", NULL, P_NUM|P_VI_DEF, |
| 2257 | #ifdef FEAT_TITLE |
| 2258 | (char_u *)&p_titlelen, PV_NONE, |
| 2259 | #else |
| 2260 | (char_u *)NULL, PV_NONE, |
| 2261 | #endif |
| 2262 | {(char_u *)85L, (char_u *)0L}}, |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 2263 | {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2264 | #ifdef FEAT_TITLE |
| 2265 | (char_u *)&p_titleold, PV_NONE, |
| 2266 | {(char_u *)N_("Thanks for flying Vim"), |
| 2267 | (char_u *)0L} |
| 2268 | #else |
| 2269 | (char_u *)NULL, PV_NONE, |
| 2270 | {(char_u *)0L, (char_u *)0L} |
| 2271 | #endif |
| 2272 | }, |
| 2273 | {"titlestring", NULL, P_STRING|P_VI_DEF, |
| 2274 | #ifdef FEAT_TITLE |
| 2275 | (char_u *)&p_titlestring, PV_NONE, |
| 2276 | #else |
| 2277 | (char_u *)NULL, PV_NONE, |
| 2278 | #endif |
| 2279 | {(char_u *)"", (char_u *)0L}}, |
| 2280 | #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) |
| 2281 | {"toolbar", "tb", P_STRING|P_COMMA|P_VI_DEF|P_NODUP, |
| 2282 | (char_u *)&p_toolbar, PV_NONE, |
| 2283 | {(char_u *)"icons,tooltips", (char_u *)0L}}, |
| 2284 | #endif |
| 2285 | #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2) |
| 2286 | {"toolbariconsize", "tbis", P_STRING|P_VI_DEF, |
| 2287 | (char_u *)&p_tbis, PV_NONE, |
| 2288 | {(char_u *)"small", (char_u *)0L}}, |
| 2289 | #endif |
| 2290 | {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM, |
| 2291 | (char_u *)&p_ttimeout, PV_NONE, |
| 2292 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2293 | {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF, |
| 2294 | (char_u *)&p_ttm, PV_NONE, |
| 2295 | {(char_u *)-1L, (char_u *)0L}}, |
| 2296 | {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF, |
| 2297 | (char_u *)&p_tbi, PV_NONE, |
| 2298 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2299 | {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF, |
| 2300 | (char_u *)&p_tf, PV_NONE, |
| 2301 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2302 | {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF, |
| 2303 | #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) |
| 2304 | (char_u *)&p_ttym, PV_NONE, |
| 2305 | #else |
| 2306 | (char_u *)NULL, PV_NONE, |
| 2307 | #endif |
| 2308 | {(char_u *)"", (char_u *)0L}}, |
| 2309 | {"ttyscroll", "tsl", P_NUM|P_VI_DEF, |
| 2310 | (char_u *)&p_ttyscroll, PV_NONE, |
| 2311 | {(char_u *)999L, (char_u *)0L}}, |
| 2312 | {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL, |
| 2313 | (char_u *)&T_NAME, PV_NONE, |
| 2314 | {(char_u *)"", (char_u *)0L}}, |
| 2315 | {"undolevels", "ul", P_NUM|P_VI_DEF, |
| 2316 | (char_u *)&p_ul, PV_NONE, |
| 2317 | { |
| 2318 | #if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS) |
| 2319 | (char_u *)1000L, |
| 2320 | #else |
| 2321 | (char_u *)100L, |
| 2322 | #endif |
| 2323 | (char_u *)0L}}, |
| 2324 | {"updatecount", "uc", P_NUM|P_VI_DEF, |
| 2325 | (char_u *)&p_uc, PV_NONE, |
| 2326 | {(char_u *)200L, (char_u *)0L}}, |
| 2327 | {"updatetime", "ut", P_NUM|P_VI_DEF, |
| 2328 | (char_u *)&p_ut, PV_NONE, |
| 2329 | {(char_u *)4000L, (char_u *)0L}}, |
| 2330 | {"verbose", "vbs", P_NUM|P_VI_DEF, |
| 2331 | (char_u *)&p_verbose, PV_NONE, |
| 2332 | {(char_u *)0L, (char_u *)0L}}, |
Bram Moolenaar | 54ee775 | 2005-05-31 22:22:17 +0000 | [diff] [blame] | 2333 | {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 2334 | (char_u *)&p_vfile, PV_NONE, |
| 2335 | {(char_u *)"", (char_u *)0L}}, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2336 | {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, |
| 2337 | #ifdef FEAT_SESSION |
| 2338 | (char_u *)&p_vdir, PV_NONE, |
| 2339 | {(char_u *)DFLT_VDIR, (char_u *)0L} |
| 2340 | #else |
| 2341 | (char_u *)NULL, PV_NONE, |
| 2342 | {(char_u *)0L, (char_u *)0L} |
| 2343 | #endif |
| 2344 | }, |
| 2345 | {"viewoptions", "vop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 2346 | #ifdef FEAT_SESSION |
| 2347 | (char_u *)&p_vop, PV_NONE, |
| 2348 | {(char_u *)"folds,options,cursor", (char_u *)0L} |
| 2349 | #else |
| 2350 | (char_u *)NULL, PV_NONE, |
| 2351 | {(char_u *)0L, (char_u *)0L} |
| 2352 | #endif |
| 2353 | }, |
| 2354 | {"viminfo", "vi", P_STRING|P_COMMA|P_NODUP|P_SECURE, |
| 2355 | #ifdef FEAT_VIMINFO |
| 2356 | (char_u *)&p_viminfo, PV_NONE, |
| 2357 | #if defined(MSDOS) || defined(MSWIN) || defined(OS2) |
| 2358 | {(char_u *)"", (char_u *)"'20,<50,s10,h,rA:,rB:"} |
| 2359 | #else |
| 2360 | # ifdef AMIGA |
| 2361 | {(char_u *)"", |
| 2362 | (char_u *)"'20,<50,s10,h,rdf0:,rdf1:,rdf2:"} |
| 2363 | # else |
| 2364 | {(char_u *)"", (char_u *)"'20,<50,s10,h"} |
| 2365 | # endif |
| 2366 | #endif |
| 2367 | #else |
| 2368 | (char_u *)NULL, PV_NONE, |
| 2369 | {(char_u *)0L, (char_u *)0L} |
| 2370 | #endif |
| 2371 | }, |
| 2372 | {"virtualedit", "ve", P_STRING|P_COMMA|P_NODUP|P_VI_DEF|P_VIM, |
| 2373 | #ifdef FEAT_VIRTUALEDIT |
| 2374 | (char_u *)&p_ve, PV_NONE, |
| 2375 | {(char_u *)"", (char_u *)""} |
| 2376 | #else |
| 2377 | (char_u *)NULL, PV_NONE, |
| 2378 | {(char_u *)0L, (char_u *)0L} |
| 2379 | #endif |
| 2380 | }, |
| 2381 | {"visualbell", "vb", P_BOOL|P_VI_DEF, |
| 2382 | (char_u *)&p_vb, PV_NONE, |
| 2383 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2384 | {"w300", NULL, P_NUM|P_VI_DEF, |
| 2385 | (char_u *)NULL, PV_NONE, |
| 2386 | {(char_u *)0L, (char_u *)0L}}, |
| 2387 | {"w1200", NULL, P_NUM|P_VI_DEF, |
| 2388 | (char_u *)NULL, PV_NONE, |
| 2389 | {(char_u *)0L, (char_u *)0L}}, |
| 2390 | {"w9600", NULL, P_NUM|P_VI_DEF, |
| 2391 | (char_u *)NULL, PV_NONE, |
| 2392 | {(char_u *)0L, (char_u *)0L}}, |
| 2393 | {"warn", NULL, P_BOOL|P_VI_DEF, |
| 2394 | (char_u *)&p_warn, PV_NONE, |
| 2395 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2396 | {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR, |
| 2397 | (char_u *)&p_wiv, PV_NONE, |
| 2398 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2399 | {"whichwrap", "ww", P_STRING|P_VIM|P_COMMA|P_FLAGLIST, |
| 2400 | (char_u *)&p_ww, PV_NONE, |
| 2401 | {(char_u *)"", (char_u *)"b,s"}}, |
| 2402 | {"wildchar", "wc", P_NUM|P_VIM, |
| 2403 | (char_u *)&p_wc, PV_NONE, |
| 2404 | {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}}, |
| 2405 | {"wildcharm", "wcm", P_NUM|P_VI_DEF, |
| 2406 | (char_u *)&p_wcm, PV_NONE, |
| 2407 | {(char_u *)0L, (char_u *)0L}}, |
| 2408 | {"wildignore", "wig", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 2409 | #ifdef FEAT_WILDIGN |
| 2410 | (char_u *)&p_wig, PV_NONE, |
| 2411 | #else |
| 2412 | (char_u *)NULL, PV_NONE, |
| 2413 | #endif |
| 2414 | {(char_u *)"", (char_u *)0L}}, |
| 2415 | {"wildmenu", "wmnu", P_BOOL|P_VI_DEF, |
| 2416 | #ifdef FEAT_WILDMENU |
| 2417 | (char_u *)&p_wmnu, PV_NONE, |
| 2418 | #else |
| 2419 | (char_u *)NULL, PV_NONE, |
| 2420 | #endif |
| 2421 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2422 | {"wildmode", "wim", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, |
| 2423 | (char_u *)&p_wim, PV_NONE, |
| 2424 | {(char_u *)"full", (char_u *)0L}}, |
Bram Moolenaar | b5bf5b8 | 2004-12-24 14:35:23 +0000 | [diff] [blame] | 2425 | {"wildoptions", "wop", P_STRING|P_VI_DEF, |
| 2426 | #ifdef FEAT_CMDL_COMPL |
| 2427 | (char_u *)&p_wop, PV_NONE, |
| 2428 | {(char_u *)"", (char_u *)0L} |
| 2429 | #else |
| 2430 | (char_u *)NULL, PV_NONE, |
| 2431 | {(char_u *)NULL, (char_u *)0L} |
| 2432 | #endif |
| 2433 | }, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2434 | {"winaltkeys", "wak", P_STRING|P_VI_DEF, |
| 2435 | #ifdef FEAT_WAK |
| 2436 | (char_u *)&p_wak, PV_NONE, |
| 2437 | {(char_u *)"menu", (char_u *)0L} |
| 2438 | #else |
| 2439 | (char_u *)NULL, PV_NONE, |
| 2440 | {(char_u *)NULL, (char_u *)0L} |
| 2441 | #endif |
| 2442 | }, |
| 2443 | {"window", "wi", P_NUM|P_VI_DEF, |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 2444 | (char_u *)&p_window, PV_NONE, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2445 | {(char_u *)0L, (char_u *)0L}}, |
| 2446 | {"winheight", "wh", P_NUM|P_VI_DEF, |
| 2447 | #ifdef FEAT_WINDOWS |
| 2448 | (char_u *)&p_wh, PV_NONE, |
| 2449 | #else |
| 2450 | (char_u *)NULL, PV_NONE, |
| 2451 | #endif |
| 2452 | {(char_u *)1L, (char_u *)0L}}, |
| 2453 | {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT, |
| 2454 | #if defined(FEAT_WINDOWS) |
| 2455 | (char_u *)VAR_WIN, PV_WFH, |
| 2456 | #else |
| 2457 | (char_u *)NULL, PV_NONE, |
| 2458 | #endif |
| 2459 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2460 | {"winminheight", "wmh", P_NUM|P_VI_DEF, |
| 2461 | #ifdef FEAT_WINDOWS |
| 2462 | (char_u *)&p_wmh, PV_NONE, |
| 2463 | #else |
| 2464 | (char_u *)NULL, PV_NONE, |
| 2465 | #endif |
| 2466 | {(char_u *)1L, (char_u *)0L}}, |
| 2467 | {"winminwidth", "wmw", P_NUM|P_VI_DEF, |
| 2468 | #ifdef FEAT_VERTSPLIT |
| 2469 | (char_u *)&p_wmw, PV_NONE, |
| 2470 | #else |
| 2471 | (char_u *)NULL, PV_NONE, |
| 2472 | #endif |
| 2473 | {(char_u *)1L, (char_u *)0L}}, |
| 2474 | {"winwidth", "wiw", P_NUM|P_VI_DEF, |
| 2475 | #ifdef FEAT_VERTSPLIT |
| 2476 | (char_u *)&p_wiw, PV_NONE, |
| 2477 | #else |
| 2478 | (char_u *)NULL, PV_NONE, |
| 2479 | #endif |
| 2480 | {(char_u *)20L, (char_u *)0L}}, |
| 2481 | {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN, |
| 2482 | (char_u *)VAR_WIN, PV_WRAP, |
| 2483 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2484 | {"wrapmargin", "wm", P_NUM|P_VI_DEF, |
| 2485 | (char_u *)&p_wm, PV_WM, |
| 2486 | {(char_u *)0L, (char_u *)0L}}, |
| 2487 | {"wrapscan", "ws", P_BOOL|P_VI_DEF, |
| 2488 | (char_u *)&p_ws, PV_NONE, |
| 2489 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2490 | {"write", NULL, P_BOOL|P_VI_DEF, |
| 2491 | (char_u *)&p_write, PV_NONE, |
| 2492 | {(char_u *)TRUE, (char_u *)0L}}, |
| 2493 | {"writeany", "wa", P_BOOL|P_VI_DEF, |
| 2494 | (char_u *)&p_wa, PV_NONE, |
| 2495 | {(char_u *)FALSE, (char_u *)0L}}, |
| 2496 | {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM, |
| 2497 | (char_u *)&p_wb, PV_NONE, |
| 2498 | { |
| 2499 | #ifdef FEAT_WRITEBACKUP |
| 2500 | (char_u *)TRUE, |
| 2501 | #else |
| 2502 | (char_u *)FALSE, |
| 2503 | #endif |
| 2504 | (char_u *)0L}}, |
| 2505 | {"writedelay", "wd", P_NUM|P_VI_DEF, |
| 2506 | (char_u *)&p_wd, PV_NONE, |
| 2507 | {(char_u *)0L, (char_u *)0L}}, |
| 2508 | |
| 2509 | /* terminal output codes */ |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 2510 | #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] | 2511 | (char_u *)&vvv, PV_NONE, \ |
| 2512 | {(char_u *)"", (char_u *)0L}}, |
| 2513 | |
| 2514 | p_term("t_AB", T_CAB) |
| 2515 | p_term("t_AF", T_CAF) |
| 2516 | p_term("t_AL", T_CAL) |
| 2517 | p_term("t_al", T_AL) |
| 2518 | p_term("t_bc", T_BC) |
| 2519 | p_term("t_cd", T_CD) |
| 2520 | p_term("t_ce", T_CE) |
| 2521 | p_term("t_cl", T_CL) |
| 2522 | p_term("t_cm", T_CM) |
| 2523 | p_term("t_Co", T_CCO) |
| 2524 | p_term("t_CS", T_CCS) |
| 2525 | p_term("t_cs", T_CS) |
| 2526 | #ifdef FEAT_VERTSPLIT |
| 2527 | p_term("t_CV", T_CSV) |
| 2528 | #endif |
| 2529 | p_term("t_ut", T_UT) |
| 2530 | p_term("t_da", T_DA) |
| 2531 | p_term("t_db", T_DB) |
| 2532 | p_term("t_DL", T_CDL) |
| 2533 | p_term("t_dl", T_DL) |
| 2534 | p_term("t_fs", T_FS) |
| 2535 | p_term("t_IE", T_CIE) |
| 2536 | p_term("t_IS", T_CIS) |
| 2537 | p_term("t_ke", T_KE) |
| 2538 | p_term("t_ks", T_KS) |
| 2539 | p_term("t_le", T_LE) |
| 2540 | p_term("t_mb", T_MB) |
| 2541 | p_term("t_md", T_MD) |
| 2542 | p_term("t_me", T_ME) |
| 2543 | p_term("t_mr", T_MR) |
| 2544 | p_term("t_ms", T_MS) |
| 2545 | p_term("t_nd", T_ND) |
| 2546 | p_term("t_op", T_OP) |
| 2547 | p_term("t_RI", T_CRI) |
| 2548 | p_term("t_RV", T_CRV) |
| 2549 | p_term("t_Sb", T_CSB) |
| 2550 | p_term("t_Sf", T_CSF) |
| 2551 | p_term("t_se", T_SE) |
| 2552 | p_term("t_so", T_SO) |
| 2553 | p_term("t_sr", T_SR) |
| 2554 | p_term("t_ts", T_TS) |
| 2555 | p_term("t_te", T_TE) |
| 2556 | p_term("t_ti", T_TI) |
| 2557 | p_term("t_ue", T_UE) |
| 2558 | p_term("t_us", T_US) |
| 2559 | p_term("t_vb", T_VB) |
| 2560 | p_term("t_ve", T_VE) |
| 2561 | p_term("t_vi", T_VI) |
| 2562 | p_term("t_vs", T_VS) |
| 2563 | p_term("t_WP", T_CWP) |
| 2564 | p_term("t_WS", T_CWS) |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 2565 | p_term("t_SI", T_CSI) |
| 2566 | p_term("t_EI", T_CEI) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2567 | p_term("t_xs", T_XS) |
| 2568 | p_term("t_ZH", T_CZH) |
| 2569 | p_term("t_ZR", T_CZR) |
| 2570 | |
| 2571 | /* terminal key codes are not in here */ |
| 2572 | |
| 2573 | {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL}} /* end marker */ |
| 2574 | }; |
| 2575 | |
| 2576 | #define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption)) |
| 2577 | |
| 2578 | #ifdef FEAT_MBYTE |
| 2579 | static char *(p_ambw_values[]) = {"single", "double", NULL}; |
| 2580 | #endif |
| 2581 | static char *(p_bg_values[]) = {"light", "dark", NULL}; |
| 2582 | static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL}; |
| 2583 | static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL}; |
Bram Moolenaar | b5bf5b8 | 2004-12-24 14:35:23 +0000 | [diff] [blame] | 2584 | #ifdef FEAT_CMDL_COMPL |
| 2585 | static char *(p_wop_values[]) = {"tagfile", NULL}; |
| 2586 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2587 | #ifdef FEAT_WAK |
| 2588 | static char *(p_wak_values[]) = {"yes", "menu", "no", NULL}; |
| 2589 | #endif |
| 2590 | static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL}; |
| 2591 | #ifdef FEAT_VISUAL |
| 2592 | static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL}; |
| 2593 | static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL}; |
| 2594 | #endif |
| 2595 | #ifdef FEAT_VISUAL |
| 2596 | static char *(p_km_values[]) = {"startsel", "stopsel", NULL}; |
| 2597 | #endif |
| 2598 | #ifdef FEAT_BROWSE |
| 2599 | static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL}; |
| 2600 | #endif |
| 2601 | #ifdef FEAT_SCROLLBIND |
| 2602 | static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL}; |
| 2603 | #endif |
| 2604 | static char *(p_swb_values[]) = {"useopen", "split", NULL}; |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 2605 | static char *(p_debug_values[]) = {"msg", "beep", NULL}; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2606 | #ifdef FEAT_VERTSPLIT |
| 2607 | static char *(p_ead_values[]) = {"both", "ver", "hor", NULL}; |
| 2608 | #endif |
| 2609 | #if defined(FEAT_QUICKFIX) |
Bram Moolenaar | 21cf823 | 2004-07-16 20:18:37 +0000 | [diff] [blame] | 2610 | # ifdef FEAT_AUTOCMD |
| 2611 | static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL}; |
| 2612 | # else |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2613 | static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL}; |
Bram Moolenaar | 21cf823 | 2004-07-16 20:18:37 +0000 | [diff] [blame] | 2614 | # endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2615 | static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL}; |
| 2616 | #endif |
| 2617 | static char *(p_bs_values[]) = {"indent", "eol", "start", NULL}; |
| 2618 | #ifdef FEAT_FOLDING |
| 2619 | static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax", |
Bram Moolenaar | 1c7715d | 2005-10-03 22:02:18 +0000 | [diff] [blame] | 2620 | # ifdef FEAT_DIFF |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2621 | "diff", |
Bram Moolenaar | 1c7715d | 2005-10-03 22:02:18 +0000 | [diff] [blame] | 2622 | # endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2623 | NULL}; |
| 2624 | static char *(p_fcl_values[]) = {"all", NULL}; |
| 2625 | #endif |
Bram Moolenaar | 1c7715d | 2005-10-03 22:02:18 +0000 | [diff] [blame] | 2626 | #ifdef FEAT_INS_EXPAND |
| 2627 | static char *(p_cot_values[]) = {"menu", NULL}; |
| 2628 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2629 | |
| 2630 | static void set_option_default __ARGS((int, int opt_flags, int compatible)); |
| 2631 | static void set_options_default __ARGS((int opt_flags)); |
| 2632 | static char_u *illegal_char __ARGS((char_u *, int)); |
| 2633 | static int string_to_key __ARGS((char_u *arg)); |
| 2634 | #ifdef FEAT_CMDWIN |
| 2635 | static char_u *check_cedit __ARGS((void)); |
| 2636 | #endif |
| 2637 | #ifdef FEAT_TITLE |
| 2638 | static void did_set_title __ARGS((int icon)); |
| 2639 | #endif |
| 2640 | static char_u *option_expand __ARGS((int opt_idx, char_u *val)); |
| 2641 | static void didset_options __ARGS((void)); |
| 2642 | static void check_string_option __ARGS((char_u **pp)); |
| 2643 | static void set_string_option_global __ARGS((int opt_idx, char_u **varp)); |
| 2644 | static void set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags)); |
| 2645 | 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)); |
| 2646 | static char_u *set_chars_option __ARGS((char_u **varp)); |
| 2647 | #ifdef FEAT_CLIPBOARD |
| 2648 | static char_u *check_clipboard_option __ARGS((void)); |
| 2649 | #endif |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 2650 | #ifdef FEAT_SYN_HL |
Bram Moolenaar | 0dc065e | 2005-07-04 22:49:24 +0000 | [diff] [blame] | 2651 | static char_u *compile_cap_prog __ARGS((buf_T *buf)); |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 2652 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2653 | static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags)); |
Bram Moolenaar | 555b280 | 2005-05-19 21:08:39 +0000 | [diff] [blame] | 2654 | static char_u *set_num_option __ARGS((int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags)); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2655 | static void check_redraw __ARGS((long_u flags)); |
| 2656 | static int findoption __ARGS((char_u *)); |
| 2657 | static int find_key_option __ARGS((char_u *)); |
| 2658 | static void showoptions __ARGS((int all, int opt_flags)); |
| 2659 | static int optval_default __ARGS((struct vimoption *, char_u *varp)); |
| 2660 | static void showoneopt __ARGS((struct vimoption *, int opt_flags)); |
| 2661 | static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand)); |
| 2662 | static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep)); |
| 2663 | static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value)); |
| 2664 | static int istermoption __ARGS((struct vimoption *)); |
| 2665 | static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags)); |
| 2666 | static char_u *get_varp __ARGS((struct vimoption *)); |
| 2667 | static void option_value2string __ARGS((struct vimoption *, int opt_flags)); |
| 2668 | static int wc_use_keyname __ARGS((char_u *varp, long *wcp)); |
| 2669 | #ifdef FEAT_LANGMAP |
| 2670 | static void langmap_init __ARGS((void)); |
| 2671 | static void langmap_set __ARGS((void)); |
| 2672 | #endif |
| 2673 | static void paste_option_changed __ARGS((void)); |
| 2674 | static void compatible_set __ARGS((void)); |
| 2675 | #ifdef FEAT_LINEBREAK |
| 2676 | static void fill_breakat_flags __ARGS((void)); |
| 2677 | #endif |
| 2678 | static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list)); |
| 2679 | static int check_opt_strings __ARGS((char_u *val, char **values, int)); |
| 2680 | static int check_opt_wim __ARGS((void)); |
| 2681 | |
| 2682 | /* |
| 2683 | * Initialize the options, first part. |
| 2684 | * |
| 2685 | * Called only once from main(), just after creating the first buffer. |
| 2686 | */ |
| 2687 | void |
| 2688 | set_init_1() |
| 2689 | { |
| 2690 | char_u *p; |
| 2691 | int opt_idx; |
| 2692 | long n; |
| 2693 | |
| 2694 | #ifdef FEAT_LANGMAP |
| 2695 | langmap_init(); |
| 2696 | #endif |
| 2697 | |
| 2698 | /* Be Vi compatible by default */ |
| 2699 | p_cp = TRUE; |
| 2700 | |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 2701 | /* Use POSIX compatibility when $VIM_POSIX is set. */ |
| 2702 | if (mch_getenv((char_u *)"VIM_POSIX") != NULL) |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 2703 | { |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 2704 | set_string_default("cpo", (char_u *)CPO_ALL); |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 2705 | set_string_default("shm", (char_u *)"A"); |
| 2706 | } |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 2707 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2708 | /* |
| 2709 | * Find default value for 'shell' option. |
Bram Moolenaar | 7c62692 | 2005-02-07 22:01:03 +0000 | [diff] [blame] | 2710 | * Don't use it if it is empty. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2711 | */ |
Bram Moolenaar | 7c62692 | 2005-02-07 22:01:03 +0000 | [diff] [blame] | 2712 | if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2713 | #if defined(MSDOS) || defined(MSWIN) || defined(OS2) |
| 2714 | # ifdef __EMX__ |
Bram Moolenaar | 7c62692 | 2005-02-07 22:01:03 +0000 | [diff] [blame] | 2715 | || ((p = mch_getenv((char_u *)"EMXSHELL")) != NULL && *p != NUL) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2716 | # endif |
Bram Moolenaar | 7c62692 | 2005-02-07 22:01:03 +0000 | [diff] [blame] | 2717 | || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2718 | # ifdef WIN3264 |
Bram Moolenaar | 7c62692 | 2005-02-07 22:01:03 +0000 | [diff] [blame] | 2719 | || ((p = default_shell()) != NULL && *p != NUL) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2720 | # endif |
| 2721 | #endif |
Bram Moolenaar | 7c62692 | 2005-02-07 22:01:03 +0000 | [diff] [blame] | 2722 | ) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2723 | set_string_default("sh", p); |
| 2724 | |
| 2725 | #ifdef FEAT_WILDIGN |
| 2726 | /* |
| 2727 | * Set the default for 'backupskip' to include environment variables for |
| 2728 | * temp files. |
| 2729 | */ |
| 2730 | { |
| 2731 | # ifdef UNIX |
| 2732 | static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"}; |
| 2733 | # else |
| 2734 | static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"}; |
| 2735 | # endif |
Bram Moolenaar | 05159a0 | 2005-02-26 23:04:13 +0000 | [diff] [blame] | 2736 | int len; |
| 2737 | garray_T ga; |
| 2738 | int mustfree; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2739 | |
| 2740 | ga_init2(&ga, 1, 100); |
| 2741 | for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n) |
| 2742 | { |
Bram Moolenaar | 05159a0 | 2005-02-26 23:04:13 +0000 | [diff] [blame] | 2743 | mustfree = FALSE; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2744 | # ifdef UNIX |
| 2745 | if (*names[n] == NUL) |
| 2746 | p = (char_u *)"/tmp"; |
| 2747 | else |
| 2748 | # endif |
Bram Moolenaar | 05159a0 | 2005-02-26 23:04:13 +0000 | [diff] [blame] | 2749 | p = vim_getenv((char_u *)names[n], &mustfree); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2750 | if (p != NULL && *p != NUL) |
| 2751 | { |
| 2752 | /* First time count the NUL, otherwise count the ','. */ |
| 2753 | len = STRLEN(p) + 3; |
| 2754 | if (ga_grow(&ga, len) == OK) |
| 2755 | { |
| 2756 | if (ga.ga_len > 0) |
| 2757 | STRCAT(ga.ga_data, ","); |
| 2758 | STRCAT(ga.ga_data, p); |
| 2759 | add_pathsep(ga.ga_data); |
| 2760 | STRCAT(ga.ga_data, "*"); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2761 | ga.ga_len += len; |
| 2762 | } |
| 2763 | } |
Bram Moolenaar | 05159a0 | 2005-02-26 23:04:13 +0000 | [diff] [blame] | 2764 | if (mustfree) |
| 2765 | vim_free(p); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2766 | } |
| 2767 | if (ga.ga_data != NULL) |
| 2768 | { |
| 2769 | set_string_default("bsk", ga.ga_data); |
| 2770 | vim_free(ga.ga_data); |
| 2771 | } |
| 2772 | } |
| 2773 | #endif |
| 2774 | |
| 2775 | /* |
| 2776 | * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory |
| 2777 | */ |
| 2778 | opt_idx = findoption((char_u *)"maxmemtot"); |
| 2779 | #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
| 2780 | if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) |
| 2781 | #endif |
| 2782 | { |
| 2783 | #ifdef HAVE_AVAIL_MEM |
| 2784 | /* Use amount of memory available at this moment. */ |
| 2785 | n = (mch_avail_mem(FALSE) >> 11); |
| 2786 | #else |
| 2787 | # ifdef HAVE_TOTAL_MEM |
| 2788 | /* Use amount of memory available to Vim. */ |
| 2789 | n = (mch_total_mem(FALSE) >> 11); |
| 2790 | # else |
| 2791 | n = (0x7fffffff >> 11); |
| 2792 | # endif |
| 2793 | #endif |
| 2794 | options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; |
| 2795 | opt_idx = findoption((char_u *)"maxmem"); |
| 2796 | #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
| 2797 | if ((long)options[opt_idx].def_val[VI_DEFAULT] > n |
| 2798 | || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L) |
| 2799 | #endif |
| 2800 | options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; |
| 2801 | } |
| 2802 | |
| 2803 | #ifdef FEAT_GUI_W32 |
| 2804 | /* force 'shortname' for Win32s */ |
| 2805 | if (gui_is_win32s()) |
| 2806 | options[findoption((char_u *)"shortname")].def_val[VI_DEFAULT] = |
| 2807 | (char_u *)TRUE; |
| 2808 | #endif |
| 2809 | |
| 2810 | #ifdef FEAT_SEARCHPATH |
| 2811 | { |
| 2812 | char_u *cdpath; |
| 2813 | char_u *buf; |
| 2814 | int i; |
| 2815 | int j; |
Bram Moolenaar | 05159a0 | 2005-02-26 23:04:13 +0000 | [diff] [blame] | 2816 | int mustfree = FALSE; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2817 | |
| 2818 | /* Initialize the 'cdpath' option's default value. */ |
Bram Moolenaar | 05159a0 | 2005-02-26 23:04:13 +0000 | [diff] [blame] | 2819 | cdpath = vim_getenv((char_u *)"CDPATH", &mustfree); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2820 | if (cdpath != NULL) |
| 2821 | { |
| 2822 | buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2)); |
| 2823 | if (buf != NULL) |
| 2824 | { |
| 2825 | buf[0] = ','; /* start with ",", current dir first */ |
| 2826 | j = 1; |
| 2827 | for (i = 0; cdpath[i] != NUL; ++i) |
| 2828 | { |
| 2829 | if (vim_ispathlistsep(cdpath[i])) |
| 2830 | buf[j++] = ','; |
| 2831 | else |
| 2832 | { |
| 2833 | if (cdpath[i] == ' ' || cdpath[i] == ',') |
| 2834 | buf[j++] = '\\'; |
| 2835 | buf[j++] = cdpath[i]; |
| 2836 | } |
| 2837 | } |
| 2838 | buf[j] = NUL; |
| 2839 | opt_idx = findoption((char_u *)"cdpath"); |
| 2840 | options[opt_idx].def_val[VI_DEFAULT] = buf; |
| 2841 | options[opt_idx].flags |= P_DEF_ALLOCED; |
| 2842 | } |
Bram Moolenaar | 05159a0 | 2005-02-26 23:04:13 +0000 | [diff] [blame] | 2843 | if (mustfree) |
| 2844 | vim_free(cdpath); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2845 | } |
| 2846 | } |
| 2847 | #endif |
| 2848 | |
| 2849 | #if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(OS2) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux)) |
| 2850 | /* Set print encoding on platforms that don't default to latin1 */ |
| 2851 | set_string_default("penc", |
| 2852 | # if defined(MSWIN) || defined(OS2) |
| 2853 | (char_u *)"cp1252" |
| 2854 | # else |
| 2855 | # ifdef VMS |
| 2856 | (char_u *)"dec-mcs" |
| 2857 | # else |
| 2858 | # ifdef EBCDIC |
| 2859 | (char_u *)"ebcdic-uk" |
| 2860 | # else |
| 2861 | # ifdef MAC |
| 2862 | (char_u *)"mac-roman" |
| 2863 | # else /* HPUX */ |
| 2864 | (char_u *)"hp-roman8" |
| 2865 | # endif |
| 2866 | # endif |
| 2867 | # endif |
| 2868 | # endif |
| 2869 | ); |
| 2870 | #endif |
| 2871 | |
| 2872 | #ifdef FEAT_POSTSCRIPT |
| 2873 | /* 'printexpr' must be allocated to be able to evaluate it. */ |
| 2874 | set_string_default("pexpr", |
Bram Moolenaar | ed20346 | 2004-06-16 11:19:22 +0000 | [diff] [blame] | 2875 | # if defined(MSWIN) || defined(MSDOS) || defined(OS2) |
| 2876 | (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] | 2877 | # else |
| 2878 | # ifdef VMS |
| 2879 | (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)" |
| 2880 | |
| 2881 | # else |
| 2882 | (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error" |
| 2883 | # endif |
| 2884 | # endif |
| 2885 | ); |
| 2886 | #endif |
| 2887 | |
| 2888 | /* |
| 2889 | * Set all the options (except the terminal options) to their default |
| 2890 | * value. Also set the global value for local options. |
| 2891 | */ |
| 2892 | set_options_default(0); |
| 2893 | |
| 2894 | #ifdef FEAT_GUI |
| 2895 | if (found_reverse_arg) |
| 2896 | set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0); |
| 2897 | #endif |
| 2898 | |
| 2899 | curbuf->b_p_initialized = TRUE; |
| 2900 | curbuf->b_p_ar = -1; /* no local 'autoread' value */ |
| 2901 | check_buf_options(curbuf); |
| 2902 | check_win_options(curwin); |
| 2903 | check_options(); |
| 2904 | |
| 2905 | /* Must be before option_expand(), because that one needs vim_isIDc() */ |
| 2906 | didset_options(); |
| 2907 | |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 2908 | #ifdef FEAT_SYN_HL |
| 2909 | /* Use the current chartab for the generic chartab. */ |
| 2910 | init_spell_chartab(); |
| 2911 | #endif |
| 2912 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2913 | #ifdef FEAT_LINEBREAK |
| 2914 | /* |
| 2915 | * initialize the table for 'breakat'. |
| 2916 | */ |
| 2917 | fill_breakat_flags(); |
| 2918 | #endif |
| 2919 | |
| 2920 | /* |
| 2921 | * Expand environment variables and things like "~" for the defaults. |
| 2922 | * If option_expand() returns non-NULL the variable is expanded. This can |
| 2923 | * only happen for non-indirect options. |
| 2924 | * Also set the default to the expanded value, so ":set" does not list |
| 2925 | * them. |
| 2926 | * Don't set the P_ALLOCED flag, because we don't want to free the |
| 2927 | * default. |
| 2928 | */ |
| 2929 | for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) |
| 2930 | { |
| 2931 | if ((options[opt_idx].flags & P_GETTEXT) |
| 2932 | && options[opt_idx].var != NULL) |
| 2933 | p = (char_u *)_(*(char **)options[opt_idx].var); |
| 2934 | else |
| 2935 | p = option_expand(opt_idx, NULL); |
| 2936 | if (p != NULL && (p = vim_strsave(p)) != NULL) |
| 2937 | { |
| 2938 | *(char_u **)options[opt_idx].var = p; |
| 2939 | /* VIMEXP |
| 2940 | * Defaults for all expanded options are currently the same for Vi |
| 2941 | * and Vim. When this changes, add some code here! Also need to |
| 2942 | * split P_DEF_ALLOCED in two. |
| 2943 | */ |
| 2944 | if (options[opt_idx].flags & P_DEF_ALLOCED) |
| 2945 | vim_free(options[opt_idx].def_val[VI_DEFAULT]); |
| 2946 | options[opt_idx].def_val[VI_DEFAULT] = p; |
| 2947 | options[opt_idx].flags |= P_DEF_ALLOCED; |
| 2948 | } |
| 2949 | } |
| 2950 | |
| 2951 | /* Initialize the highlight_attr[] table. */ |
| 2952 | highlight_changed(); |
| 2953 | |
| 2954 | save_file_ff(curbuf); /* Buffer is unchanged */ |
| 2955 | |
| 2956 | /* Parse default for 'wildmode' */ |
| 2957 | check_opt_wim(); |
| 2958 | |
| 2959 | #if defined(FEAT_ARABIC) |
| 2960 | /* Detect use of mlterm. |
| 2961 | * Mlterm is a terminal emulator akin to xterm that has some special |
| 2962 | * abilities (bidi namely). |
| 2963 | * NOTE: mlterm's author is being asked to 'set' a variable |
| 2964 | * instead of an environment variable due to inheritance. |
| 2965 | */ |
| 2966 | if (mch_getenv((char_u *)"MLTERM") != NULL) |
| 2967 | set_option_value((char_u *)"tbidi", 1L, NULL, 0); |
| 2968 | #endif |
| 2969 | |
| 2970 | #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
| 2971 | /* Parse default for 'fillchars'. */ |
| 2972 | (void)set_chars_option(&p_fcs); |
| 2973 | #endif |
| 2974 | |
| 2975 | #ifdef FEAT_CLIPBOARD |
| 2976 | /* Parse default for 'clipboard' */ |
| 2977 | (void)check_clipboard_option(); |
| 2978 | #endif |
| 2979 | |
| 2980 | #ifdef FEAT_MBYTE |
| 2981 | # if defined(WIN3264) && defined(FEAT_GETTEXT) |
| 2982 | /* |
| 2983 | * If $LANG isn't set, try to get a good value for it. This makes the |
| 2984 | * right language be used automatically. Don't do this for English. |
| 2985 | */ |
| 2986 | if (mch_getenv((char_u *)"LANG") == NULL) |
| 2987 | { |
| 2988 | char buf[20]; |
| 2989 | |
| 2990 | /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95. |
| 2991 | * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use |
| 2992 | * only the first two. */ |
| 2993 | n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, |
| 2994 | (LPTSTR)buf, 20); |
| 2995 | if (n >= 2 && STRNICMP(buf, "en", 2) != 0) |
| 2996 | { |
| 2997 | /* There are a few exceptions (probably more) */ |
| 2998 | if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0) |
| 2999 | STRCPY(buf, "zh_TW"); |
| 3000 | else if (STRNICMP(buf, "chs", 3) == 0 |
| 3001 | || STRNICMP(buf, "zhc", 3) == 0) |
| 3002 | STRCPY(buf, "zh_CN"); |
| 3003 | else if (STRNICMP(buf, "jp", 2) == 0) |
| 3004 | STRCPY(buf, "ja"); |
| 3005 | else |
| 3006 | buf[2] = NUL; /* truncate to two-letter code */ |
| 3007 | vim_setenv("LANG", buf); |
| 3008 | } |
| 3009 | } |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 3010 | # else |
| 3011 | # ifdef MACOS |
| 3012 | if (mch_getenv((char_u *)"LANG") == NULL) |
| 3013 | { |
| 3014 | char buf[20]; |
| 3015 | if (LocaleRefGetPartString(NULL, |
| 3016 | kLocaleLanguageMask | kLocaleLanguageVariantMask | |
| 3017 | kLocaleRegionMask | kLocaleRegionVariantMask, |
| 3018 | sizeof buf, buf) == noErr && *buf) |
| 3019 | { |
Bram Moolenaar | da2303d | 2005-08-30 21:55:26 +0000 | [diff] [blame] | 3020 | vim_setenv((char_u *)"LANG", (char_u *)buf); |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 3021 | # ifdef HAVE_LOCALE_H |
| 3022 | setlocale(LC_ALL, ""); |
| 3023 | # endif |
| 3024 | } |
| 3025 | } |
| 3026 | # endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3027 | # endif |
| 3028 | |
| 3029 | /* enc_locale() will try to find the encoding of the current locale. */ |
| 3030 | p = enc_locale(); |
| 3031 | if (p != NULL) |
| 3032 | { |
| 3033 | char_u *save_enc; |
| 3034 | |
| 3035 | /* Try setting 'encoding' and check if the value is valid. |
| 3036 | * If not, go back to the default "latin1". */ |
| 3037 | save_enc = p_enc; |
| 3038 | p_enc = p; |
| 3039 | if (mb_init() == NULL) |
| 3040 | { |
| 3041 | opt_idx = findoption((char_u *)"encoding"); |
| 3042 | options[opt_idx].def_val[VI_DEFAULT] = p_enc; |
| 3043 | options[opt_idx].flags |= P_DEF_ALLOCED; |
| 3044 | |
Bram Moolenaar | c0197e2 | 2004-09-13 20:26:32 +0000 | [diff] [blame] | 3045 | #if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \ |
| 3046 | || defined(VMS) |
| 3047 | if (STRCMP(p_enc, "latin1") == 0 |
| 3048 | # ifdef FEAT_MBYTE |
| 3049 | || enc_utf8 |
| 3050 | # endif |
| 3051 | ) |
| 3052 | { |
| 3053 | /* Adjust the default for 'isprint' to match latin1. */ |
| 3054 | set_string_option_direct((char_u *)"isp", -1, |
| 3055 | (char_u *)"@,161-255", OPT_FREE); |
| 3056 | (void)init_chartab(); |
| 3057 | } |
| 3058 | #endif |
| 3059 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3060 | # if defined(WIN3264) && !defined(FEAT_GUI) |
| 3061 | /* Win32 console: When GetACP() returns a different value from |
| 3062 | * GetConsoleCP() set 'termencoding'. */ |
| 3063 | if (GetACP() != GetConsoleCP()) |
| 3064 | { |
| 3065 | char buf[50]; |
| 3066 | |
| 3067 | sprintf(buf, "cp%ld", (long)GetConsoleCP()); |
| 3068 | p_tenc = vim_strsave((char_u *)buf); |
| 3069 | if (p_tenc != NULL) |
| 3070 | { |
| 3071 | opt_idx = findoption((char_u *)"termencoding"); |
| 3072 | options[opt_idx].def_val[VI_DEFAULT] = p_tenc; |
| 3073 | options[opt_idx].flags |= P_DEF_ALLOCED; |
| 3074 | convert_setup(&input_conv, p_tenc, p_enc); |
| 3075 | convert_setup(&output_conv, p_enc, p_tenc); |
| 3076 | } |
| 3077 | else |
| 3078 | p_tenc = empty_option; |
| 3079 | } |
| 3080 | # endif |
Bram Moolenaar | 05159a0 | 2005-02-26 23:04:13 +0000 | [diff] [blame] | 3081 | # if defined(WIN3264) && defined(FEAT_MBYTE) |
| 3082 | /* $HOME may have characters in active code page. */ |
| 3083 | init_homedir(); |
| 3084 | # endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3085 | } |
| 3086 | else |
| 3087 | { |
| 3088 | vim_free(p_enc); |
| 3089 | p_enc = save_enc; |
| 3090 | } |
| 3091 | } |
| 3092 | #endif |
| 3093 | |
| 3094 | #ifdef FEAT_MULTI_LANG |
| 3095 | /* Set the default for 'helplang'. */ |
| 3096 | set_helplang_default(get_mess_lang()); |
| 3097 | #endif |
| 3098 | } |
| 3099 | |
| 3100 | /* |
| 3101 | * Set an option to its default value. |
| 3102 | * This does not take care of side effects! |
| 3103 | */ |
| 3104 | static void |
| 3105 | set_option_default(opt_idx, opt_flags, compatible) |
| 3106 | int opt_idx; |
| 3107 | int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ |
| 3108 | int compatible; /* use Vi default value */ |
| 3109 | { |
| 3110 | char_u *varp; /* pointer to variable for current option */ |
| 3111 | int dvi; /* index in def_val[] */ |
| 3112 | long_u flags; |
| 3113 | int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
| 3114 | |
| 3115 | varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); |
| 3116 | flags = options[opt_idx].flags; |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 3117 | if (varp != NULL) /* skip hidden option, nothing to do for it */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3118 | { |
| 3119 | dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; |
| 3120 | if (flags & P_STRING) |
| 3121 | { |
| 3122 | /* Use set_string_option_direct() for local options to handle |
| 3123 | * freeing and allocating the value. */ |
| 3124 | if (options[opt_idx].indir != PV_NONE) |
| 3125 | set_string_option_direct(NULL, opt_idx, |
| 3126 | options[opt_idx].def_val[dvi], opt_flags); |
| 3127 | else |
| 3128 | { |
| 3129 | if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED)) |
| 3130 | free_string_option(*(char_u **)(varp)); |
| 3131 | *(char_u **)varp = options[opt_idx].def_val[dvi]; |
| 3132 | options[opt_idx].flags &= ~P_ALLOCED; |
| 3133 | } |
| 3134 | } |
| 3135 | else if (flags & P_NUM) |
| 3136 | { |
| 3137 | if (varp == (char_u *)PV_SCROLL) |
| 3138 | win_comp_scroll(curwin); |
| 3139 | else |
| 3140 | { |
| 3141 | *(long *)varp = (long)options[opt_idx].def_val[dvi]; |
| 3142 | /* May also set global value for local option. */ |
| 3143 | if (both) |
| 3144 | *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = |
| 3145 | *(long *)varp; |
| 3146 | } |
| 3147 | } |
| 3148 | else /* P_BOOL */ |
| 3149 | { |
| 3150 | /* the cast to long is required for Manx C */ |
| 3151 | *(int *)varp = (int)(long)options[opt_idx].def_val[dvi]; |
| 3152 | /* May also set global value for local option. */ |
| 3153 | if (both) |
| 3154 | *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = |
| 3155 | *(int *)varp; |
| 3156 | } |
| 3157 | } |
| 3158 | |
| 3159 | #ifdef FEAT_EVAL |
| 3160 | /* Remember where the option was set. */ |
| 3161 | options[opt_idx].scriptID = current_SID; |
| 3162 | #endif |
| 3163 | } |
| 3164 | |
| 3165 | /* |
| 3166 | * Set all options (except terminal options) to their default value. |
| 3167 | */ |
| 3168 | static void |
| 3169 | set_options_default(opt_flags) |
| 3170 | int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ |
| 3171 | { |
| 3172 | int i; |
| 3173 | #ifdef FEAT_WINDOWS |
| 3174 | win_T *wp; |
| 3175 | #endif |
| 3176 | |
| 3177 | for (i = 0; !istermoption(&options[i]); i++) |
| 3178 | if (!(options[i].flags & P_NODEFAULT)) |
| 3179 | set_option_default(i, opt_flags, p_cp); |
| 3180 | |
| 3181 | #ifdef FEAT_WINDOWS |
| 3182 | /* The 'scroll' option must be computed for all windows. */ |
| 3183 | for (wp = firstwin; wp != NULL; wp = wp->w_next) |
| 3184 | win_comp_scroll(wp); |
| 3185 | #else |
| 3186 | win_comp_scroll(curwin); |
| 3187 | #endif |
| 3188 | } |
| 3189 | |
| 3190 | /* |
| 3191 | * Set the Vi-default value of a string option. |
| 3192 | * Used for 'sh', 'backupskip' and 'term'. |
| 3193 | */ |
| 3194 | void |
| 3195 | set_string_default(name, val) |
| 3196 | char *name; |
| 3197 | char_u *val; |
| 3198 | { |
| 3199 | char_u *p; |
| 3200 | int opt_idx; |
| 3201 | |
| 3202 | p = vim_strsave(val); |
| 3203 | if (p != NULL) /* we don't want a NULL */ |
| 3204 | { |
| 3205 | opt_idx = findoption((char_u *)name); |
| 3206 | if (options[opt_idx].flags & P_DEF_ALLOCED) |
| 3207 | vim_free(options[opt_idx].def_val[VI_DEFAULT]); |
| 3208 | options[opt_idx].def_val[VI_DEFAULT] = p; |
| 3209 | options[opt_idx].flags |= P_DEF_ALLOCED; |
| 3210 | } |
| 3211 | } |
| 3212 | |
| 3213 | /* |
| 3214 | * Set the Vi-default value of a number option. |
| 3215 | * Used for 'lines' and 'columns'. |
| 3216 | */ |
| 3217 | void |
| 3218 | set_number_default(name, val) |
| 3219 | char *name; |
| 3220 | long val; |
| 3221 | { |
| 3222 | options[findoption((char_u *)name)].def_val[VI_DEFAULT] = (char_u *)val; |
| 3223 | } |
| 3224 | |
Bram Moolenaar | f461c8e | 2005-06-25 23:04:51 +0000 | [diff] [blame] | 3225 | #if defined(EXITFREE) || defined(PROTO) |
| 3226 | /* |
| 3227 | * Free all options. |
| 3228 | */ |
| 3229 | void |
| 3230 | free_all_options() |
| 3231 | { |
| 3232 | int i; |
| 3233 | |
| 3234 | for (i = 0; !istermoption(&options[i]); i++) |
| 3235 | { |
| 3236 | if (options[i].indir == PV_NONE) |
| 3237 | { |
| 3238 | /* global option: free value and default value. */ |
| 3239 | if (options[i].flags & P_ALLOCED && options[i].var != NULL) |
| 3240 | free_string_option(*(char_u **)options[i].var); |
| 3241 | if (options[i].flags & P_DEF_ALLOCED) |
| 3242 | free_string_option(options[i].def_val[VI_DEFAULT]); |
| 3243 | } |
| 3244 | else if (options[i].var != VAR_WIN |
| 3245 | && (options[i].flags & P_STRING)) |
| 3246 | /* buffer-local option: free global value */ |
| 3247 | free_string_option(*(char_u **)options[i].var); |
| 3248 | } |
| 3249 | } |
| 3250 | #endif |
| 3251 | |
| 3252 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3253 | /* |
| 3254 | * Initialize the options, part two: After getting Rows and Columns and |
| 3255 | * setting 'term'. |
| 3256 | */ |
| 3257 | void |
| 3258 | set_init_2() |
| 3259 | { |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 3260 | int idx; |
| 3261 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3262 | /* |
| 3263 | * 'scroll' defaults to half the window height. Note that this default is |
| 3264 | * wrong when the window height changes. |
| 3265 | */ |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 3266 | set_number_default("scroll", (long_u)Rows >> 1); |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 3267 | idx = findoption((char_u *)"scroll"); |
| 3268 | if (!(options[idx].flags & P_WAS_SET)) |
| 3269 | set_option_default(idx, OPT_LOCAL, p_cp); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3270 | comp_col(); |
| 3271 | |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 3272 | /* |
| 3273 | * 'window' is only for backwards compatibility with Vi. |
| 3274 | * Default is Rows - 1. |
| 3275 | */ |
| 3276 | idx = findoption((char_u *)"wi"); |
| 3277 | if (!(options[idx].flags & P_WAS_SET)) |
| 3278 | p_window = Rows - 1; |
| 3279 | set_number_default("window", Rows - 1); |
| 3280 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3281 | #if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI)) |
| 3282 | { |
Bram Moolenaar | ac6e65f | 2005-08-29 22:25:38 +0000 | [diff] [blame] | 3283 | char_u *p; |
| 3284 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3285 | /* |
| 3286 | * If 'background' wasn't set by the user, try guessing the value, |
| 3287 | * depending on the terminal name. Only need to check for terminals |
Bram Moolenaar | a21b29a | 2005-02-27 22:40:05 +0000 | [diff] [blame] | 3288 | * with a dark background, that can handle color. Recognized are: |
| 3289 | * "linux" Linux console |
| 3290 | * "screen.linux" Linux console with screen |
Bram Moolenaar | 19a09a1 | 2005-03-04 23:39:37 +0000 | [diff] [blame] | 3291 | * "cygwin" Cygwin shell |
Bram Moolenaar | 482aaeb | 2005-09-29 18:26:07 +0000 | [diff] [blame] | 3292 | * "putty" Putty program |
Bram Moolenaar | ac6e65f | 2005-08-29 22:25:38 +0000 | [diff] [blame] | 3293 | * We also check the COLORFGBG environment variable, which is set by |
| 3294 | * rxvt and derivatives. This variable contains either two or three |
| 3295 | * values separated by semicolons; we want the last value in either |
| 3296 | * case. If this value is 0-6 or 8, our background is dark. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3297 | */ |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 3298 | idx = findoption((char_u *)"bg"); |
Bram Moolenaar | a21b29a | 2005-02-27 22:40:05 +0000 | [diff] [blame] | 3299 | if (!(options[idx].flags & P_WAS_SET) |
| 3300 | && (STRCMP(T_NAME, "linux") == 0 |
Bram Moolenaar | 19a09a1 | 2005-03-04 23:39:37 +0000 | [diff] [blame] | 3301 | || STRCMP(T_NAME, "screen.linux") == 0 |
Bram Moolenaar | ac6e65f | 2005-08-29 22:25:38 +0000 | [diff] [blame] | 3302 | || STRCMP(T_NAME, "cygwin") == 0 |
Bram Moolenaar | 482aaeb | 2005-09-29 18:26:07 +0000 | [diff] [blame] | 3303 | || STRCMP(T_NAME, "putty") == 0 |
Bram Moolenaar | 4615234 | 2005-09-07 21:18:43 +0000 | [diff] [blame] | 3304 | || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL |
Bram Moolenaar | ac6e65f | 2005-08-29 22:25:38 +0000 | [diff] [blame] | 3305 | && (p = vim_strrchr(p, ';')) != NULL |
| 3306 | && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8') |
| 3307 | && p[2] == NUL))) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3308 | { |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 3309 | set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE); |
Bram Moolenaar | ac6e65f | 2005-08-29 22:25:38 +0000 | [diff] [blame] | 3310 | /* don't mark it as set, when starting the GUI it may be |
| 3311 | * changed again */ |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 3312 | options[idx].flags &= ~P_WAS_SET; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3313 | } |
| 3314 | } |
| 3315 | #endif |
Bram Moolenaar | 58d9823 | 2005-07-23 22:25:46 +0000 | [diff] [blame] | 3316 | |
| 3317 | #ifdef CURSOR_SHAPE |
| 3318 | parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */ |
| 3319 | #endif |
| 3320 | #ifdef FEAT_MOUSESHAPE |
| 3321 | parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */ |
| 3322 | #endif |
| 3323 | #ifdef FEAT_PRINTER |
| 3324 | (void)parse_printoptions(); /* parse 'printoptions' default value */ |
| 3325 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3326 | } |
| 3327 | |
| 3328 | /* |
| 3329 | * Initialize the options, part three: After reading the .vimrc |
| 3330 | */ |
| 3331 | void |
| 3332 | set_init_3() |
| 3333 | { |
| 3334 | #if defined(UNIX) || defined(OS2) || defined(WIN3264) |
| 3335 | /* |
| 3336 | * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. |
| 3337 | * This is done after other initializations, where 'shell' might have been |
| 3338 | * set, but only if they have not been set before. |
| 3339 | */ |
| 3340 | char_u *p; |
| 3341 | int idx_srr; |
| 3342 | int do_srr; |
| 3343 | #ifdef FEAT_QUICKFIX |
| 3344 | int idx_sp; |
| 3345 | int do_sp; |
| 3346 | #endif |
| 3347 | |
| 3348 | idx_srr = findoption((char_u *)"srr"); |
| 3349 | do_srr = !(options[idx_srr].flags & P_WAS_SET); |
| 3350 | #ifdef FEAT_QUICKFIX |
| 3351 | idx_sp = findoption((char_u *)"sp"); |
| 3352 | do_sp = !(options[idx_sp].flags & P_WAS_SET); |
| 3353 | #endif |
| 3354 | |
| 3355 | /* |
| 3356 | * Isolate the name of the shell: |
| 3357 | * - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f". |
| 3358 | * - Remove any argument. E.g., "csh -f" -> "csh". |
| 3359 | */ |
| 3360 | p = gettail(p_sh); |
| 3361 | p = vim_strnsave(p, (int)(skiptowhite(p) - p)); |
| 3362 | if (p != NULL) |
| 3363 | { |
| 3364 | /* |
| 3365 | * Default for p_sp is "| tee", for p_srr is ">". |
| 3366 | * For known shells it is changed here to include stderr. |
| 3367 | */ |
| 3368 | if ( fnamecmp(p, "csh") == 0 |
| 3369 | || fnamecmp(p, "tcsh") == 0 |
| 3370 | # if defined(OS2) || defined(WIN3264) /* also check with .exe extension */ |
| 3371 | || fnamecmp(p, "csh.exe") == 0 |
| 3372 | || fnamecmp(p, "tcsh.exe") == 0 |
| 3373 | # endif |
| 3374 | ) |
| 3375 | { |
| 3376 | #if defined(FEAT_QUICKFIX) |
| 3377 | if (do_sp) |
| 3378 | { |
| 3379 | # ifdef WIN3264 |
| 3380 | p_sp = (char_u *)">&"; |
| 3381 | # else |
| 3382 | p_sp = (char_u *)"|& tee"; |
| 3383 | # endif |
| 3384 | options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
| 3385 | } |
| 3386 | #endif |
| 3387 | if (do_srr) |
| 3388 | { |
| 3389 | p_srr = (char_u *)">&"; |
| 3390 | options[idx_srr].def_val[VI_DEFAULT] = p_srr; |
| 3391 | } |
| 3392 | } |
| 3393 | else |
| 3394 | # ifndef OS2 /* Always use bourne shell style redirection if we reach this */ |
| 3395 | if ( fnamecmp(p, "sh") == 0 |
| 3396 | || fnamecmp(p, "ksh") == 0 |
| 3397 | || fnamecmp(p, "zsh") == 0 |
| 3398 | || fnamecmp(p, "bash") == 0 |
| 3399 | # ifdef WIN3264 |
| 3400 | || fnamecmp(p, "cmd") == 0 |
| 3401 | || fnamecmp(p, "sh.exe") == 0 |
| 3402 | || fnamecmp(p, "ksh.exe") == 0 |
| 3403 | || fnamecmp(p, "zsh.exe") == 0 |
| 3404 | || fnamecmp(p, "bash.exe") == 0 |
| 3405 | || fnamecmp(p, "cmd.exe") == 0 |
| 3406 | # endif |
| 3407 | ) |
| 3408 | # endif |
| 3409 | { |
| 3410 | #if defined(FEAT_QUICKFIX) |
| 3411 | if (do_sp) |
| 3412 | { |
| 3413 | # ifdef WIN3264 |
| 3414 | p_sp = (char_u *)">%s 2>&1"; |
| 3415 | # else |
| 3416 | p_sp = (char_u *)"2>&1| tee"; |
| 3417 | # endif |
| 3418 | options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
| 3419 | } |
| 3420 | #endif |
| 3421 | if (do_srr) |
| 3422 | { |
| 3423 | p_srr = (char_u *)">%s 2>&1"; |
| 3424 | options[idx_srr].def_val[VI_DEFAULT] = p_srr; |
| 3425 | } |
| 3426 | } |
| 3427 | vim_free(p); |
| 3428 | } |
| 3429 | #endif |
| 3430 | |
| 3431 | #if defined(MSDOS) || defined(WIN3264) || defined(OS2) |
| 3432 | /* |
| 3433 | * Set 'shellcmdflag and 'shellquote' depending on the 'shell' option. |
| 3434 | * This is done after other initializations, where 'shell' might have been |
| 3435 | * set, but only if they have not been set before. Default for p_shcf is |
| 3436 | * "/c", for p_shq is "". For "sh" like shells it is changed here to |
| 3437 | * "-c" and "\"", but not for DJGPP, because it starts the shell without |
| 3438 | * command.com. And for Win32 we need to set p_sxq instead. |
| 3439 | */ |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 3440 | if (strstr((char *)gettail(p_sh), "sh") != NULL) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3441 | { |
| 3442 | int idx3; |
| 3443 | |
| 3444 | idx3 = findoption((char_u *)"shcf"); |
| 3445 | if (!(options[idx3].flags & P_WAS_SET)) |
| 3446 | { |
| 3447 | p_shcf = (char_u *)"-c"; |
| 3448 | options[idx3].def_val[VI_DEFAULT] = p_shcf; |
| 3449 | } |
| 3450 | |
| 3451 | # ifndef DJGPP |
| 3452 | # ifdef WIN3264 |
| 3453 | /* Somehow Win32 requires the quotes around the redirection too */ |
| 3454 | idx3 = findoption((char_u *)"sxq"); |
| 3455 | if (!(options[idx3].flags & P_WAS_SET)) |
| 3456 | { |
| 3457 | p_sxq = (char_u *)"\""; |
| 3458 | options[idx3].def_val[VI_DEFAULT] = p_sxq; |
| 3459 | } |
| 3460 | # else |
| 3461 | idx3 = findoption((char_u *)"shq"); |
| 3462 | if (!(options[idx3].flags & P_WAS_SET)) |
| 3463 | { |
| 3464 | p_shq = (char_u *)"\""; |
| 3465 | options[idx3].def_val[VI_DEFAULT] = p_shq; |
| 3466 | } |
| 3467 | # endif |
| 3468 | # endif |
| 3469 | } |
| 3470 | #endif |
| 3471 | |
| 3472 | #ifdef FEAT_TITLE |
| 3473 | set_title_defaults(); |
| 3474 | #endif |
| 3475 | } |
| 3476 | |
| 3477 | #if defined(FEAT_MULTI_LANG) || defined(PROTO) |
| 3478 | /* |
| 3479 | * When 'helplang' is still at its default value, set it to "lang". |
| 3480 | * Only the first two characters of "lang" are used. |
| 3481 | */ |
| 3482 | void |
| 3483 | set_helplang_default(lang) |
| 3484 | char_u *lang; |
| 3485 | { |
| 3486 | int idx; |
| 3487 | |
| 3488 | if (lang == NULL || STRLEN(lang) < 2) /* safety check */ |
| 3489 | return; |
| 3490 | idx = findoption((char_u *)"hlg"); |
| 3491 | if (!(options[idx].flags & P_WAS_SET)) |
| 3492 | { |
| 3493 | if (options[idx].flags & P_ALLOCED) |
| 3494 | free_string_option(p_hlg); |
| 3495 | p_hlg = vim_strsave(lang); |
| 3496 | if (p_hlg == NULL) |
| 3497 | p_hlg = empty_option; |
| 3498 | else |
Bram Moolenaar | ab79bcb | 2004-07-18 21:34:53 +0000 | [diff] [blame] | 3499 | { |
| 3500 | /* zh_CN becomes "cn", zh_TW becomes "tw". */ |
| 3501 | if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) |
| 3502 | { |
| 3503 | p_hlg[0] = TOLOWER_ASC(p_hlg[3]); |
| 3504 | p_hlg[1] = TOLOWER_ASC(p_hlg[4]); |
| 3505 | } |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3506 | p_hlg[2] = NUL; |
Bram Moolenaar | ab79bcb | 2004-07-18 21:34:53 +0000 | [diff] [blame] | 3507 | } |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3508 | options[idx].flags |= P_ALLOCED; |
| 3509 | } |
| 3510 | } |
| 3511 | #endif |
| 3512 | |
| 3513 | #ifdef FEAT_GUI |
| 3514 | static char_u *gui_bg_default __ARGS((void)); |
| 3515 | |
| 3516 | static char_u * |
| 3517 | gui_bg_default() |
| 3518 | { |
| 3519 | if (gui_get_lightness(gui.back_pixel) < 127) |
| 3520 | return (char_u *)"dark"; |
| 3521 | return (char_u *)"light"; |
| 3522 | } |
| 3523 | |
| 3524 | /* |
| 3525 | * Option initializations that can only be done after opening the GUI window. |
| 3526 | */ |
| 3527 | void |
| 3528 | init_gui_options() |
| 3529 | { |
| 3530 | /* Set the 'background' option according to the lightness of the |
| 3531 | * background color, unless the user has set it already. */ |
| 3532 | if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0) |
| 3533 | { |
| 3534 | set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0); |
| 3535 | highlight_changed(); |
| 3536 | } |
| 3537 | } |
| 3538 | #endif |
| 3539 | |
| 3540 | #ifdef FEAT_TITLE |
| 3541 | /* |
| 3542 | * 'title' and 'icon' only default to true if they have not been set or reset |
| 3543 | * in .vimrc and we can read the old value. |
| 3544 | * When 'title' and 'icon' have been reset in .vimrc, we won't even check if |
| 3545 | * they can be reset. This reduces startup time when using X on a remote |
| 3546 | * machine. |
| 3547 | */ |
| 3548 | void |
| 3549 | set_title_defaults() |
| 3550 | { |
| 3551 | int idx1; |
| 3552 | long val; |
| 3553 | |
| 3554 | /* |
| 3555 | * If GUI is (going to be) used, we can always set the window title and |
| 3556 | * icon name. Saves a bit of time, because the X11 display server does |
| 3557 | * not need to be contacted. |
| 3558 | */ |
| 3559 | idx1 = findoption((char_u *)"title"); |
| 3560 | if (!(options[idx1].flags & P_WAS_SET)) |
| 3561 | { |
| 3562 | #ifdef FEAT_GUI |
| 3563 | if (gui.starting || gui.in_use) |
| 3564 | val = TRUE; |
| 3565 | else |
| 3566 | #endif |
| 3567 | val = mch_can_restore_title(); |
| 3568 | options[idx1].def_val[VI_DEFAULT] = (char_u *)val; |
| 3569 | p_title = val; |
| 3570 | } |
| 3571 | idx1 = findoption((char_u *)"icon"); |
| 3572 | if (!(options[idx1].flags & P_WAS_SET)) |
| 3573 | { |
| 3574 | #ifdef FEAT_GUI |
| 3575 | if (gui.starting || gui.in_use) |
| 3576 | val = TRUE; |
| 3577 | else |
| 3578 | #endif |
| 3579 | val = mch_can_restore_icon(); |
| 3580 | options[idx1].def_val[VI_DEFAULT] = (char_u *)val; |
| 3581 | p_icon = val; |
| 3582 | } |
| 3583 | } |
| 3584 | #endif |
| 3585 | |
| 3586 | /* |
| 3587 | * Parse 'arg' for option settings. |
| 3588 | * |
| 3589 | * 'arg' may be IObuff, but only when no errors can be present and option |
| 3590 | * does not need to be expanded with option_expand(). |
| 3591 | * "opt_flags": |
| 3592 | * 0 for ":set" |
| 3593 | * OPT_GLOBAL for ":setglobal" |
| 3594 | * OPT_LOCAL for ":setlocal" and a modeline |
| 3595 | * OPT_MODELINE for a modeline |
| 3596 | * |
| 3597 | * returns FAIL if an error is detected, OK otherwise |
| 3598 | */ |
| 3599 | int |
| 3600 | do_set(arg, opt_flags) |
| 3601 | char_u *arg; /* option string (may be written to!) */ |
| 3602 | int opt_flags; |
| 3603 | { |
| 3604 | int opt_idx; |
| 3605 | char_u *errmsg; |
| 3606 | char_u errbuf[80]; |
| 3607 | char_u *startarg; |
| 3608 | int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */ |
| 3609 | int nextchar; /* next non-white char after option name */ |
| 3610 | int afterchar; /* character just after option name */ |
| 3611 | int len; |
| 3612 | int i; |
| 3613 | long value; |
| 3614 | int key; |
| 3615 | long_u flags; /* flags for current option */ |
| 3616 | char_u *varp = NULL; /* pointer to variable for current option */ |
| 3617 | int did_show = FALSE; /* already showed one value */ |
| 3618 | int adding; /* "opt+=arg" */ |
| 3619 | int prepending; /* "opt^=arg" */ |
| 3620 | int removing; /* "opt-=arg" */ |
| 3621 | int cp_val = 0; |
| 3622 | char_u key_name[2]; |
| 3623 | |
| 3624 | if (*arg == NUL) |
| 3625 | { |
| 3626 | showoptions(0, opt_flags); |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 3627 | did_show = TRUE; |
| 3628 | goto theend; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3629 | } |
| 3630 | |
| 3631 | while (*arg != NUL) /* loop to process all options */ |
| 3632 | { |
| 3633 | errmsg = NULL; |
| 3634 | startarg = arg; /* remember for error message */ |
| 3635 | |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 3636 | if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3]) |
| 3637 | && !(opt_flags & OPT_MODELINE)) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3638 | { |
| 3639 | /* |
| 3640 | * ":set all" show all options. |
| 3641 | * ":set all&" set all options to their default value. |
| 3642 | */ |
| 3643 | arg += 3; |
| 3644 | if (*arg == '&') |
| 3645 | { |
| 3646 | ++arg; |
| 3647 | /* Only for :set command set global value of local options. */ |
| 3648 | set_options_default(OPT_FREE | opt_flags); |
| 3649 | } |
| 3650 | else |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 3651 | { |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3652 | showoptions(1, opt_flags); |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 3653 | did_show = TRUE; |
| 3654 | } |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3655 | } |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 3656 | else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3657 | { |
| 3658 | showoptions(2, opt_flags); |
| 3659 | show_termcodes(); |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 3660 | did_show = TRUE; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3661 | arg += 7; |
| 3662 | } |
| 3663 | else |
| 3664 | { |
| 3665 | prefix = 1; |
| 3666 | if (STRNCMP(arg, "no", 2) == 0) |
| 3667 | { |
| 3668 | prefix = 0; |
| 3669 | arg += 2; |
| 3670 | } |
| 3671 | else if (STRNCMP(arg, "inv", 3) == 0) |
| 3672 | { |
| 3673 | prefix = 2; |
| 3674 | arg += 3; |
| 3675 | } |
| 3676 | |
| 3677 | /* find end of name */ |
| 3678 | key = 0; |
| 3679 | if (*arg == '<') |
| 3680 | { |
| 3681 | nextchar = 0; |
| 3682 | opt_idx = -1; |
| 3683 | /* look out for <t_>;> */ |
| 3684 | if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) |
| 3685 | len = 5; |
| 3686 | else |
| 3687 | { |
| 3688 | len = 1; |
| 3689 | while (arg[len] != NUL && arg[len] != '>') |
| 3690 | ++len; |
| 3691 | } |
| 3692 | if (arg[len] != '>') |
| 3693 | { |
| 3694 | errmsg = e_invarg; |
| 3695 | goto skip; |
| 3696 | } |
| 3697 | arg[len] = NUL; /* put NUL after name */ |
| 3698 | if (arg[1] == 't' && arg[2] == '_') /* could be term code */ |
| 3699 | opt_idx = findoption(arg + 1); |
| 3700 | arg[len++] = '>'; /* restore '>' */ |
| 3701 | if (opt_idx == -1) |
| 3702 | key = find_key_option(arg + 1); |
| 3703 | } |
| 3704 | else |
| 3705 | { |
| 3706 | len = 0; |
| 3707 | /* |
| 3708 | * The two characters after "t_" may not be alphanumeric. |
| 3709 | */ |
| 3710 | if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) |
| 3711 | len = 4; |
| 3712 | else |
| 3713 | while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') |
| 3714 | ++len; |
| 3715 | nextchar = arg[len]; |
| 3716 | arg[len] = NUL; /* put NUL after name */ |
| 3717 | opt_idx = findoption(arg); |
| 3718 | arg[len] = nextchar; /* restore nextchar */ |
| 3719 | if (opt_idx == -1) |
| 3720 | key = find_key_option(arg); |
| 3721 | } |
| 3722 | |
| 3723 | /* remember character after option name */ |
| 3724 | afterchar = arg[len]; |
| 3725 | |
| 3726 | /* skip white space, allow ":set ai ?" */ |
| 3727 | while (vim_iswhite(arg[len])) |
| 3728 | ++len; |
| 3729 | |
| 3730 | adding = FALSE; |
| 3731 | prepending = FALSE; |
| 3732 | removing = FALSE; |
| 3733 | if (arg[len] != NUL && arg[len + 1] == '=') |
| 3734 | { |
| 3735 | if (arg[len] == '+') |
| 3736 | { |
| 3737 | adding = TRUE; /* "+=" */ |
| 3738 | ++len; |
| 3739 | } |
| 3740 | else if (arg[len] == '^') |
| 3741 | { |
| 3742 | prepending = TRUE; /* "^=" */ |
| 3743 | ++len; |
| 3744 | } |
| 3745 | else if (arg[len] == '-') |
| 3746 | { |
| 3747 | removing = TRUE; /* "-=" */ |
| 3748 | ++len; |
| 3749 | } |
| 3750 | } |
| 3751 | nextchar = arg[len]; |
| 3752 | |
| 3753 | if (opt_idx == -1 && key == 0) /* found a mismatch: skip */ |
| 3754 | { |
| 3755 | errmsg = (char_u *)N_("E518: Unknown option"); |
| 3756 | goto skip; |
| 3757 | } |
| 3758 | |
| 3759 | if (opt_idx >= 0) |
| 3760 | { |
| 3761 | if (options[opt_idx].var == NULL) /* hidden option: skip */ |
| 3762 | { |
| 3763 | /* Only give an error message when requesting the value of |
| 3764 | * a hidden option, ignore setting it. */ |
| 3765 | if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL |
| 3766 | && (!(options[opt_idx].flags & P_BOOL) |
| 3767 | || nextchar == '?')) |
| 3768 | errmsg = (char_u *)N_("E519: Option not supported"); |
| 3769 | goto skip; |
| 3770 | } |
| 3771 | |
| 3772 | flags = options[opt_idx].flags; |
| 3773 | varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
| 3774 | } |
| 3775 | else |
| 3776 | { |
| 3777 | flags = P_STRING; |
| 3778 | if (key < 0) |
| 3779 | { |
| 3780 | key_name[0] = KEY2TERMCAP0(key); |
| 3781 | key_name[1] = KEY2TERMCAP1(key); |
| 3782 | } |
| 3783 | else |
| 3784 | { |
| 3785 | key_name[0] = KS_KEY; |
| 3786 | key_name[1] = (key & 0xff); |
| 3787 | } |
| 3788 | } |
| 3789 | |
| 3790 | /* Disallow changing some options from modelines */ |
| 3791 | if ((opt_flags & OPT_MODELINE) && (flags & P_SECURE)) |
| 3792 | { |
| 3793 | errmsg = (char_u *)_("E520: Not allowed in a modeline"); |
| 3794 | goto skip; |
| 3795 | } |
| 3796 | |
Bram Moolenaar | 15d0a8c | 2004-09-06 17:44:46 +0000 | [diff] [blame] | 3797 | /* Skip all options that are not window-local (used when showing |
| 3798 | * an already loaded buffer in a window). */ |
| 3799 | if ((opt_flags & OPT_WINONLY) |
| 3800 | && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) |
| 3801 | goto skip; |
| 3802 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3803 | #ifdef HAVE_SANDBOX |
| 3804 | /* Disallow changing some options in the sandbox */ |
| 3805 | if (sandbox > 0 && (flags & P_SECURE)) |
| 3806 | { |
| 3807 | errmsg = (char_u *)_(e_sandbox); |
| 3808 | goto skip; |
| 3809 | } |
| 3810 | #endif |
| 3811 | |
| 3812 | if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) |
| 3813 | { |
| 3814 | arg += len; |
| 3815 | cp_val = p_cp; |
| 3816 | if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') |
| 3817 | { |
| 3818 | if (arg[3] == 'm') /* "opt&vim": set to Vim default */ |
| 3819 | { |
| 3820 | cp_val = FALSE; |
| 3821 | arg += 3; |
| 3822 | } |
| 3823 | else /* "opt&vi": set to Vi default */ |
| 3824 | { |
| 3825 | cp_val = TRUE; |
| 3826 | arg += 2; |
| 3827 | } |
| 3828 | } |
| 3829 | if (vim_strchr((char_u *)"?!&<", nextchar) != NULL |
| 3830 | && arg[1] != NUL && !vim_iswhite(arg[1])) |
| 3831 | { |
| 3832 | errmsg = e_trailing; |
| 3833 | goto skip; |
| 3834 | } |
| 3835 | } |
| 3836 | |
| 3837 | /* |
| 3838 | * allow '=' and ':' as MSDOS command.com allows only one |
| 3839 | * '=' character per "set" command line. grrr. (jw) |
| 3840 | */ |
| 3841 | if (nextchar == '?' |
| 3842 | || (prefix == 1 |
| 3843 | && vim_strchr((char_u *)"=:&<", nextchar) == NULL |
| 3844 | && !(flags & P_BOOL))) |
| 3845 | { |
| 3846 | /* |
| 3847 | * print value |
| 3848 | */ |
| 3849 | if (did_show) |
| 3850 | msg_putchar('\n'); /* cursor below last one */ |
| 3851 | else |
| 3852 | { |
| 3853 | gotocmdline(TRUE); /* cursor at status line */ |
| 3854 | did_show = TRUE; /* remember that we did a line */ |
| 3855 | } |
| 3856 | if (opt_idx >= 0) |
| 3857 | { |
| 3858 | showoneopt(&options[opt_idx], opt_flags); |
| 3859 | #ifdef FEAT_EVAL |
| 3860 | if (p_verbose > 0) |
Bram Moolenaar | 661b182 | 2005-07-28 22:36:45 +0000 | [diff] [blame] | 3861 | last_set_msg(options[opt_idx].scriptID); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3862 | #endif |
| 3863 | } |
| 3864 | else |
| 3865 | { |
| 3866 | char_u *p; |
| 3867 | |
| 3868 | p = find_termcode(key_name); |
| 3869 | if (p == NULL) |
| 3870 | { |
| 3871 | errmsg = (char_u *)N_("E518: Unknown option"); |
| 3872 | goto skip; |
| 3873 | } |
| 3874 | else |
| 3875 | (void)show_one_termcode(key_name, p, TRUE); |
| 3876 | } |
| 3877 | if (nextchar != '?' |
| 3878 | && nextchar != NUL && !vim_iswhite(afterchar)) |
| 3879 | errmsg = e_trailing; |
| 3880 | } |
| 3881 | else |
| 3882 | { |
| 3883 | if (flags & P_BOOL) /* boolean */ |
| 3884 | { |
| 3885 | if (nextchar == '=' || nextchar == ':') |
| 3886 | { |
| 3887 | errmsg = e_invarg; |
| 3888 | goto skip; |
| 3889 | } |
| 3890 | |
| 3891 | /* |
| 3892 | * ":set opt!": invert |
| 3893 | * ":set opt&": reset to default value |
| 3894 | * ":set opt<": reset to global value |
| 3895 | */ |
| 3896 | if (nextchar == '!') |
| 3897 | value = *(int *)(varp) ^ 1; |
| 3898 | else if (nextchar == '&') |
| 3899 | value = (int)(long)options[opt_idx].def_val[ |
| 3900 | ((flags & P_VI_DEF) || cp_val) |
| 3901 | ? VI_DEFAULT : VIM_DEFAULT]; |
| 3902 | else if (nextchar == '<') |
| 3903 | { |
| 3904 | /* For 'autoread' -1 means to use global value. */ |
| 3905 | if ((int *)varp == &curbuf->b_p_ar |
| 3906 | && opt_flags == OPT_LOCAL) |
| 3907 | value = -1; |
| 3908 | else |
| 3909 | value = *(int *)get_varp_scope(&(options[opt_idx]), |
| 3910 | OPT_GLOBAL); |
| 3911 | } |
| 3912 | else |
| 3913 | { |
| 3914 | /* |
| 3915 | * ":set invopt": invert |
| 3916 | * ":set opt" or ":set noopt": set or reset |
| 3917 | */ |
| 3918 | if (nextchar != NUL && !vim_iswhite(afterchar)) |
| 3919 | { |
| 3920 | errmsg = e_trailing; |
| 3921 | goto skip; |
| 3922 | } |
| 3923 | if (prefix == 2) /* inv */ |
| 3924 | value = *(int *)(varp) ^ 1; |
| 3925 | else |
| 3926 | value = prefix; |
| 3927 | } |
| 3928 | |
| 3929 | errmsg = set_bool_option(opt_idx, varp, (int)value, |
| 3930 | opt_flags); |
| 3931 | } |
| 3932 | else /* numeric or string */ |
| 3933 | { |
| 3934 | if (vim_strchr((char_u *)"=:&<", nextchar) == NULL |
| 3935 | || prefix != 1) |
| 3936 | { |
| 3937 | errmsg = e_invarg; |
| 3938 | goto skip; |
| 3939 | } |
| 3940 | |
| 3941 | if (flags & P_NUM) /* numeric */ |
| 3942 | { |
| 3943 | /* |
| 3944 | * Different ways to set a number option: |
| 3945 | * & set to default value |
| 3946 | * < set to global value |
| 3947 | * <xx> accept special key codes for 'wildchar' |
| 3948 | * c accept any non-digit for 'wildchar' |
| 3949 | * [-]0-9 set number |
| 3950 | * other error |
| 3951 | */ |
| 3952 | ++arg; |
| 3953 | if (nextchar == '&') |
| 3954 | value = (long)options[opt_idx].def_val[ |
| 3955 | ((flags & P_VI_DEF) || cp_val) |
| 3956 | ? VI_DEFAULT : VIM_DEFAULT]; |
| 3957 | else if (nextchar == '<') |
| 3958 | value = *(long *)get_varp_scope(&(options[opt_idx]), |
| 3959 | OPT_GLOBAL); |
| 3960 | else if (((long *)varp == &p_wc |
| 3961 | || (long *)varp == &p_wcm) |
| 3962 | && (*arg == '<' |
| 3963 | || *arg == '^' |
| 3964 | || ((!arg[1] || vim_iswhite(arg[1])) |
| 3965 | && !VIM_ISDIGIT(*arg)))) |
| 3966 | { |
| 3967 | value = string_to_key(arg); |
| 3968 | if (value == 0 && (long *)varp != &p_wcm) |
| 3969 | { |
| 3970 | errmsg = e_invarg; |
| 3971 | goto skip; |
| 3972 | } |
| 3973 | } |
| 3974 | /* allow negative numbers (for 'undolevels') */ |
| 3975 | else if (*arg == '-' || VIM_ISDIGIT(*arg)) |
| 3976 | { |
| 3977 | i = 0; |
| 3978 | if (*arg == '-') |
| 3979 | i = 1; |
| 3980 | #ifdef HAVE_STRTOL |
| 3981 | value = strtol((char *)arg, NULL, 0); |
| 3982 | if (arg[i] == '0' && TOLOWER_ASC(arg[i + 1]) == 'x') |
| 3983 | i += 2; |
| 3984 | #else |
| 3985 | value = atol((char *)arg); |
| 3986 | #endif |
| 3987 | while (VIM_ISDIGIT(arg[i])) |
| 3988 | ++i; |
| 3989 | if (arg[i] != NUL && !vim_iswhite(arg[i])) |
| 3990 | { |
| 3991 | errmsg = e_invarg; |
| 3992 | goto skip; |
| 3993 | } |
| 3994 | } |
| 3995 | else |
| 3996 | { |
| 3997 | errmsg = (char_u *)N_("E521: Number required after ="); |
| 3998 | goto skip; |
| 3999 | } |
| 4000 | |
| 4001 | if (adding) |
| 4002 | value = *(long *)varp + value; |
| 4003 | if (prepending) |
| 4004 | value = *(long *)varp * value; |
| 4005 | if (removing) |
| 4006 | value = *(long *)varp - value; |
| 4007 | errmsg = set_num_option(opt_idx, varp, value, |
Bram Moolenaar | 555b280 | 2005-05-19 21:08:39 +0000 | [diff] [blame] | 4008 | errbuf, sizeof(errbuf), opt_flags); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4009 | } |
| 4010 | else if (opt_idx >= 0) /* string */ |
| 4011 | { |
| 4012 | char_u *save_arg = NULL; |
| 4013 | char_u *s = NULL; |
| 4014 | char_u *oldval; /* previous value if *varp */ |
| 4015 | char_u *newval; |
| 4016 | char_u *origval; |
| 4017 | unsigned newlen; |
| 4018 | int comma; |
| 4019 | int bs; |
| 4020 | int new_value_alloced; /* new string option |
| 4021 | was allocated */ |
| 4022 | |
| 4023 | /* When using ":set opt=val" for a global option |
| 4024 | * with a local value the local value will be |
| 4025 | * reset, use the global value here. */ |
| 4026 | if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
| 4027 | && (int)options[opt_idx].indir >= PV_BOTH) |
| 4028 | varp = options[opt_idx].var; |
| 4029 | |
| 4030 | /* The old value is kept until we are sure that the |
| 4031 | * new value is valid. */ |
| 4032 | oldval = *(char_u **)varp; |
| 4033 | if (nextchar == '&') /* set to default val */ |
| 4034 | { |
| 4035 | newval = options[opt_idx].def_val[ |
| 4036 | ((flags & P_VI_DEF) || cp_val) |
| 4037 | ? VI_DEFAULT : VIM_DEFAULT]; |
| 4038 | if ((char_u **)varp == &p_bg) |
| 4039 | { |
| 4040 | /* guess the value of 'background' */ |
| 4041 | #ifdef FEAT_GUI |
| 4042 | if (gui.in_use) |
| 4043 | newval = gui_bg_default(); |
| 4044 | else |
| 4045 | #endif |
| 4046 | if (STRCMP(T_NAME, "linux") == 0) |
| 4047 | newval = (char_u *)"dark"; |
| 4048 | } |
| 4049 | |
| 4050 | /* expand environment variables and ~ (since the |
| 4051 | * default value was already expanded, only |
| 4052 | * required when an environment variable was set |
| 4053 | * later */ |
| 4054 | if (newval == NULL) |
| 4055 | newval = empty_option; |
| 4056 | else |
| 4057 | { |
| 4058 | s = option_expand(opt_idx, newval); |
| 4059 | if (s == NULL) |
| 4060 | s = newval; |
| 4061 | newval = vim_strsave(s); |
| 4062 | } |
| 4063 | new_value_alloced = TRUE; |
| 4064 | } |
| 4065 | else if (nextchar == '<') /* set to global val */ |
| 4066 | { |
| 4067 | newval = vim_strsave(*(char_u **)get_varp_scope( |
| 4068 | &(options[opt_idx]), OPT_GLOBAL)); |
| 4069 | new_value_alloced = TRUE; |
| 4070 | } |
| 4071 | else |
| 4072 | { |
| 4073 | ++arg; /* jump to after the '=' or ':' */ |
| 4074 | |
| 4075 | /* |
| 4076 | * Set 'keywordprg' to ":help" if an empty |
| 4077 | * value was passed to :set by the user. |
| 4078 | * Misuse errbuf[] for the resulting string. |
| 4079 | */ |
| 4080 | if (varp == (char_u *)&p_kp |
| 4081 | && (*arg == NUL || *arg == ' ')) |
| 4082 | { |
| 4083 | STRCPY(errbuf, ":help"); |
| 4084 | save_arg = arg; |
| 4085 | arg = errbuf; |
| 4086 | } |
| 4087 | /* |
| 4088 | * Convert 'whichwrap' number to string, for |
| 4089 | * backwards compatibility with Vim 3.0. |
| 4090 | * Misuse errbuf[] for the resulting string. |
| 4091 | */ |
| 4092 | else if (varp == (char_u *)&p_ww |
| 4093 | && VIM_ISDIGIT(*arg)) |
| 4094 | { |
| 4095 | *errbuf = NUL; |
| 4096 | i = getdigits(&arg); |
| 4097 | if (i & 1) |
| 4098 | STRCAT(errbuf, "b,"); |
| 4099 | if (i & 2) |
| 4100 | STRCAT(errbuf, "s,"); |
| 4101 | if (i & 4) |
| 4102 | STRCAT(errbuf, "h,l,"); |
| 4103 | if (i & 8) |
| 4104 | STRCAT(errbuf, "<,>,"); |
| 4105 | if (i & 16) |
| 4106 | STRCAT(errbuf, "[,],"); |
| 4107 | if (*errbuf != NUL) /* remove trailing , */ |
| 4108 | errbuf[STRLEN(errbuf) - 1] = NUL; |
| 4109 | save_arg = arg; |
| 4110 | arg = errbuf; |
| 4111 | } |
| 4112 | /* |
| 4113 | * Remove '>' before 'dir' and 'bdir', for |
| 4114 | * backwards compatibility with version 3.0 |
| 4115 | */ |
| 4116 | else if ( *arg == '>' |
| 4117 | && (varp == (char_u *)&p_dir |
| 4118 | || varp == (char_u *)&p_bdir)) |
| 4119 | { |
| 4120 | ++arg; |
| 4121 | } |
| 4122 | |
| 4123 | /* When setting the local value of a global |
| 4124 | * option, the old value may be the global value. */ |
| 4125 | if ((int)options[opt_idx].indir >= PV_BOTH |
| 4126 | && (opt_flags & OPT_LOCAL)) |
| 4127 | origval = *(char_u **)get_varp( |
| 4128 | &options[opt_idx]); |
| 4129 | else |
| 4130 | origval = oldval; |
| 4131 | |
| 4132 | /* |
| 4133 | * Copy the new string into allocated memory. |
| 4134 | * Can't use set_string_option_direct(), because |
| 4135 | * we need to remove the backslashes. |
| 4136 | */ |
| 4137 | /* get a bit too much */ |
| 4138 | newlen = (unsigned)STRLEN(arg) + 1; |
| 4139 | if (adding || prepending || removing) |
| 4140 | newlen += (unsigned)STRLEN(origval) + 1; |
| 4141 | newval = alloc(newlen); |
| 4142 | if (newval == NULL) /* out of mem, don't change */ |
| 4143 | break; |
| 4144 | s = newval; |
| 4145 | |
| 4146 | /* |
| 4147 | * Copy the string, skip over escaped chars. |
| 4148 | * For MS-DOS and WIN32 backslashes before normal |
| 4149 | * file name characters are not removed, and keep |
| 4150 | * backslash at start, for "\\machine\path", but |
| 4151 | * do remove it for "\\\\machine\\path". |
| 4152 | * The reverse is found in ExpandOldSetting(). |
| 4153 | */ |
| 4154 | while (*arg && !vim_iswhite(*arg)) |
| 4155 | { |
| 4156 | if (*arg == '\\' && arg[1] != NUL |
| 4157 | #ifdef BACKSLASH_IN_FILENAME |
| 4158 | && !((flags & P_EXPAND) |
| 4159 | && vim_isfilec(arg[1]) |
| 4160 | && (arg[1] != '\\' |
| 4161 | || (s == newval |
| 4162 | && arg[2] != '\\'))) |
| 4163 | #endif |
| 4164 | ) |
| 4165 | ++arg; /* remove backslash */ |
| 4166 | #ifdef FEAT_MBYTE |
| 4167 | if (has_mbyte |
Bram Moolenaar | 0fa313a | 2005-08-10 21:07:57 +0000 | [diff] [blame] | 4168 | && (i = (*mb_ptr2len)(arg)) > 1) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4169 | { |
| 4170 | /* copy multibyte char */ |
| 4171 | mch_memmove(s, arg, (size_t)i); |
| 4172 | arg += i; |
| 4173 | s += i; |
| 4174 | } |
| 4175 | else |
| 4176 | #endif |
| 4177 | *s++ = *arg++; |
| 4178 | } |
| 4179 | *s = NUL; |
| 4180 | |
| 4181 | /* |
| 4182 | * Expand environment variables and ~. |
| 4183 | * Don't do it when adding without inserting a |
| 4184 | * comma. |
| 4185 | */ |
| 4186 | if (!(adding || prepending || removing) |
| 4187 | || (flags & P_COMMA)) |
| 4188 | { |
| 4189 | s = option_expand(opt_idx, newval); |
| 4190 | if (s != NULL) |
| 4191 | { |
| 4192 | vim_free(newval); |
| 4193 | newlen = (unsigned)STRLEN(s) + 1; |
| 4194 | if (adding || prepending || removing) |
| 4195 | newlen += (unsigned)STRLEN(origval) + 1; |
| 4196 | newval = alloc(newlen); |
| 4197 | if (newval == NULL) |
| 4198 | break; |
| 4199 | STRCPY(newval, s); |
| 4200 | } |
| 4201 | } |
| 4202 | |
| 4203 | /* locate newval[] in origval[] when removing it |
| 4204 | * and when adding to avoid duplicates */ |
| 4205 | i = 0; /* init for GCC */ |
| 4206 | if (removing || (flags & P_NODUP)) |
| 4207 | { |
| 4208 | i = (int)STRLEN(newval); |
| 4209 | bs = 0; |
| 4210 | for (s = origval; *s; ++s) |
| 4211 | { |
| 4212 | if ((!(flags & P_COMMA) |
| 4213 | || s == origval |
| 4214 | || (s[-1] == ',' && !(bs & 1))) |
| 4215 | && STRNCMP(s, newval, i) == 0 |
| 4216 | && (!(flags & P_COMMA) |
| 4217 | || s[i] == ',' |
| 4218 | || s[i] == NUL)) |
| 4219 | break; |
| 4220 | /* Count backspaces. Only a comma with an |
| 4221 | * even number of backspaces before it is |
| 4222 | * recognized as a separator */ |
| 4223 | if (s > origval && s[-1] == '\\') |
| 4224 | ++bs; |
| 4225 | else |
| 4226 | bs = 0; |
| 4227 | } |
| 4228 | |
| 4229 | /* do not add if already there */ |
| 4230 | if ((adding || prepending) && *s) |
| 4231 | { |
| 4232 | prepending = FALSE; |
| 4233 | adding = FALSE; |
| 4234 | STRCPY(newval, origval); |
| 4235 | } |
| 4236 | } |
| 4237 | |
| 4238 | /* concatenate the two strings; add a ',' if |
| 4239 | * needed */ |
| 4240 | if (adding || prepending) |
| 4241 | { |
| 4242 | comma = ((flags & P_COMMA) && *origval != NUL |
| 4243 | && *newval != NUL); |
| 4244 | if (adding) |
| 4245 | { |
| 4246 | i = (int)STRLEN(origval); |
| 4247 | mch_memmove(newval + i + comma, newval, |
| 4248 | STRLEN(newval) + 1); |
| 4249 | mch_memmove(newval, origval, (size_t)i); |
| 4250 | } |
| 4251 | else |
| 4252 | { |
| 4253 | i = (int)STRLEN(newval); |
| 4254 | mch_memmove(newval + i + comma, origval, |
| 4255 | STRLEN(origval) + 1); |
| 4256 | } |
| 4257 | if (comma) |
| 4258 | newval[i] = ','; |
| 4259 | } |
| 4260 | |
| 4261 | /* Remove newval[] from origval[]. (Note: "i" has |
| 4262 | * been set above and is used here). */ |
| 4263 | if (removing) |
| 4264 | { |
| 4265 | STRCPY(newval, origval); |
| 4266 | if (*s) |
| 4267 | { |
| 4268 | /* may need to remove a comma */ |
| 4269 | if (flags & P_COMMA) |
| 4270 | { |
| 4271 | if (s == origval) |
| 4272 | { |
| 4273 | /* include comma after string */ |
| 4274 | if (s[i] == ',') |
| 4275 | ++i; |
| 4276 | } |
| 4277 | else |
| 4278 | { |
| 4279 | /* include comma before string */ |
| 4280 | --s; |
| 4281 | ++i; |
| 4282 | } |
| 4283 | } |
| 4284 | mch_memmove(newval + (s - origval), s + i, |
| 4285 | STRLEN(s + i) + 1); |
| 4286 | } |
| 4287 | } |
| 4288 | |
| 4289 | if (flags & P_FLAGLIST) |
| 4290 | { |
| 4291 | /* Remove flags that appear twice. */ |
| 4292 | for (s = newval; *s; ++s) |
| 4293 | if ((!(flags & P_COMMA) || *s != ',') |
| 4294 | && vim_strchr(s + 1, *s) != NULL) |
| 4295 | { |
| 4296 | STRCPY(s, s + 1); |
| 4297 | --s; |
| 4298 | } |
| 4299 | } |
| 4300 | |
| 4301 | if (save_arg != NULL) /* number for 'whichwrap' */ |
| 4302 | arg = save_arg; |
| 4303 | new_value_alloced = TRUE; |
| 4304 | } |
| 4305 | |
| 4306 | /* Set the new value. */ |
| 4307 | *(char_u **)(varp) = newval; |
| 4308 | |
| 4309 | /* Handle side effects, and set the global value for |
| 4310 | * ":set" on local options. */ |
| 4311 | errmsg = did_set_string_option(opt_idx, (char_u **)varp, |
| 4312 | new_value_alloced, oldval, errbuf, opt_flags); |
| 4313 | |
| 4314 | /* If error detected, print the error message. */ |
| 4315 | if (errmsg != NULL) |
| 4316 | goto skip; |
| 4317 | } |
| 4318 | else /* key code option */ |
| 4319 | { |
| 4320 | char_u *p; |
| 4321 | |
| 4322 | if (nextchar == '&') |
| 4323 | { |
| 4324 | if (add_termcap_entry(key_name, TRUE) == FAIL) |
| 4325 | errmsg = (char_u *)N_("E522: Not found in termcap"); |
| 4326 | } |
| 4327 | else |
| 4328 | { |
| 4329 | ++arg; /* jump to after the '=' or ':' */ |
| 4330 | for (p = arg; *p && !vim_iswhite(*p); ++p) |
| 4331 | if (*p == '\\' && p[1] != NUL) |
| 4332 | ++p; |
| 4333 | nextchar = *p; |
| 4334 | *p = NUL; |
| 4335 | add_termcode(key_name, arg, FALSE); |
| 4336 | *p = nextchar; |
| 4337 | } |
| 4338 | if (full_screen) |
| 4339 | ttest(FALSE); |
| 4340 | redraw_all_later(CLEAR); |
| 4341 | } |
| 4342 | } |
| 4343 | if (opt_idx >= 0) |
| 4344 | options[opt_idx].flags |= P_WAS_SET; |
| 4345 | } |
| 4346 | |
| 4347 | skip: |
| 4348 | /* |
| 4349 | * Advance to next argument. |
| 4350 | * - skip until a blank found, taking care of backslashes |
| 4351 | * - skip blanks |
| 4352 | * - skip one "=val" argument (for hidden options ":set gfn =xx") |
| 4353 | */ |
| 4354 | for (i = 0; i < 2 ; ++i) |
| 4355 | { |
| 4356 | while (*arg != NUL && !vim_iswhite(*arg)) |
| 4357 | if (*arg++ == '\\' && *arg != NUL) |
| 4358 | ++arg; |
| 4359 | arg = skipwhite(arg); |
| 4360 | if (*arg != '=') |
| 4361 | break; |
| 4362 | } |
| 4363 | } |
| 4364 | |
| 4365 | if (errmsg != NULL) |
| 4366 | { |
Bram Moolenaar | ce0842a | 2005-07-18 21:58:11 +0000 | [diff] [blame] | 4367 | vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4368 | i = STRLEN(IObuff) + 2; |
| 4369 | if (i + (arg - startarg) < IOSIZE) |
| 4370 | { |
| 4371 | /* append the argument with the error */ |
| 4372 | STRCAT(IObuff, ": "); |
| 4373 | mch_memmove(IObuff + i, startarg, (arg - startarg)); |
| 4374 | IObuff[i + (arg - startarg)] = NUL; |
| 4375 | } |
| 4376 | /* make sure all characters are printable */ |
| 4377 | trans_characters(IObuff, IOSIZE); |
| 4378 | |
| 4379 | ++no_wait_return; /* wait_return done later */ |
| 4380 | emsg(IObuff); /* show error highlighted */ |
| 4381 | --no_wait_return; |
| 4382 | |
| 4383 | return FAIL; |
| 4384 | } |
| 4385 | |
| 4386 | arg = skipwhite(arg); |
| 4387 | } |
| 4388 | |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 4389 | theend: |
| 4390 | if (silent_mode && did_show) |
| 4391 | { |
| 4392 | /* After displaying option values in silent mode. */ |
| 4393 | silent_mode = FALSE; |
| 4394 | info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ |
| 4395 | msg_putchar('\n'); |
| 4396 | cursor_on(); /* msg_start() switches it off */ |
| 4397 | out_flush(); |
| 4398 | silent_mode = TRUE; |
| 4399 | info_message = FALSE; /* use mch_msg(), not mch_errmsg() */ |
| 4400 | } |
| 4401 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4402 | return OK; |
| 4403 | } |
| 4404 | |
| 4405 | static char_u * |
| 4406 | illegal_char(errbuf, c) |
| 4407 | char_u *errbuf; |
| 4408 | int c; |
| 4409 | { |
| 4410 | if (errbuf == NULL) |
| 4411 | return (char_u *)""; |
| 4412 | sprintf((char *)errbuf, _("E539: Illegal character <%s>"), |
Bram Moolenaar | 555b280 | 2005-05-19 21:08:39 +0000 | [diff] [blame] | 4413 | (char *)transchar(c)); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4414 | return errbuf; |
| 4415 | } |
| 4416 | |
| 4417 | /* |
| 4418 | * Convert a key name or string into a key value. |
| 4419 | * Used for 'wildchar' and 'cedit' options. |
| 4420 | */ |
| 4421 | static int |
| 4422 | string_to_key(arg) |
| 4423 | char_u *arg; |
| 4424 | { |
| 4425 | if (*arg == '<') |
| 4426 | return find_key_option(arg + 1); |
| 4427 | if (*arg == '^') |
| 4428 | return Ctrl_chr(arg[1]); |
| 4429 | return *arg; |
| 4430 | } |
| 4431 | |
| 4432 | #ifdef FEAT_CMDWIN |
| 4433 | /* |
| 4434 | * Check value of 'cedit' and set cedit_key. |
| 4435 | * Returns NULL if value is OK, error message otherwise. |
| 4436 | */ |
| 4437 | static char_u * |
| 4438 | check_cedit() |
| 4439 | { |
| 4440 | int n; |
| 4441 | |
| 4442 | if (*p_cedit == NUL) |
| 4443 | cedit_key = -1; |
| 4444 | else |
| 4445 | { |
| 4446 | n = string_to_key(p_cedit); |
| 4447 | if (vim_isprintc(n)) |
| 4448 | return e_invarg; |
| 4449 | cedit_key = n; |
| 4450 | } |
| 4451 | return NULL; |
| 4452 | } |
| 4453 | #endif |
| 4454 | |
| 4455 | #ifdef FEAT_TITLE |
| 4456 | /* |
| 4457 | * When changing 'title', 'titlestring', 'icon' or 'iconstring', call |
| 4458 | * maketitle() to create and display it. |
| 4459 | * When switching the title or icon off, call mch_restore_title() to get |
| 4460 | * the old value back. |
| 4461 | */ |
| 4462 | static void |
| 4463 | did_set_title(icon) |
| 4464 | int icon; /* Did set icon instead of title */ |
| 4465 | { |
| 4466 | if (starting != NO_SCREEN |
| 4467 | #ifdef FEAT_GUI |
| 4468 | && !gui.starting |
| 4469 | #endif |
| 4470 | ) |
| 4471 | { |
| 4472 | maketitle(); |
| 4473 | if (icon) |
| 4474 | { |
| 4475 | if (!p_icon) |
| 4476 | mch_restore_title(2); |
| 4477 | } |
| 4478 | else |
| 4479 | { |
| 4480 | if (!p_title) |
| 4481 | mch_restore_title(1); |
| 4482 | } |
| 4483 | } |
| 4484 | } |
| 4485 | #endif |
| 4486 | |
| 4487 | /* |
| 4488 | * set_options_bin - called when 'bin' changes value. |
| 4489 | */ |
| 4490 | void |
| 4491 | set_options_bin(oldval, newval, opt_flags) |
| 4492 | int oldval; |
| 4493 | int newval; |
| 4494 | int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ |
| 4495 | { |
| 4496 | /* |
| 4497 | * The option values that are changed when 'bin' changes are |
| 4498 | * copied when 'bin is set and restored when 'bin' is reset. |
| 4499 | */ |
| 4500 | if (newval) |
| 4501 | { |
| 4502 | if (!oldval) /* switched on */ |
| 4503 | { |
| 4504 | if (!(opt_flags & OPT_GLOBAL)) |
| 4505 | { |
| 4506 | curbuf->b_p_tw_nobin = curbuf->b_p_tw; |
| 4507 | curbuf->b_p_wm_nobin = curbuf->b_p_wm; |
| 4508 | curbuf->b_p_ml_nobin = curbuf->b_p_ml; |
| 4509 | curbuf->b_p_et_nobin = curbuf->b_p_et; |
| 4510 | } |
| 4511 | if (!(opt_flags & OPT_LOCAL)) |
| 4512 | { |
| 4513 | p_tw_nobin = p_tw; |
| 4514 | p_wm_nobin = p_wm; |
| 4515 | p_ml_nobin = p_ml; |
| 4516 | p_et_nobin = p_et; |
| 4517 | } |
| 4518 | } |
| 4519 | |
| 4520 | if (!(opt_flags & OPT_GLOBAL)) |
| 4521 | { |
| 4522 | curbuf->b_p_tw = 0; /* no automatic line wrap */ |
| 4523 | curbuf->b_p_wm = 0; /* no automatic line wrap */ |
| 4524 | curbuf->b_p_ml = 0; /* no modelines */ |
| 4525 | curbuf->b_p_et = 0; /* no expandtab */ |
| 4526 | } |
| 4527 | if (!(opt_flags & OPT_LOCAL)) |
| 4528 | { |
| 4529 | p_tw = 0; |
| 4530 | p_wm = 0; |
| 4531 | p_ml = FALSE; |
| 4532 | p_et = FALSE; |
| 4533 | p_bin = TRUE; /* needed when called for the "-b" argument */ |
| 4534 | } |
| 4535 | } |
| 4536 | else if (oldval) /* switched off */ |
| 4537 | { |
| 4538 | if (!(opt_flags & OPT_GLOBAL)) |
| 4539 | { |
| 4540 | curbuf->b_p_tw = curbuf->b_p_tw_nobin; |
| 4541 | curbuf->b_p_wm = curbuf->b_p_wm_nobin; |
| 4542 | curbuf->b_p_ml = curbuf->b_p_ml_nobin; |
| 4543 | curbuf->b_p_et = curbuf->b_p_et_nobin; |
| 4544 | } |
| 4545 | if (!(opt_flags & OPT_LOCAL)) |
| 4546 | { |
| 4547 | p_tw = p_tw_nobin; |
| 4548 | p_wm = p_wm_nobin; |
| 4549 | p_ml = p_ml_nobin; |
| 4550 | p_et = p_et_nobin; |
| 4551 | } |
| 4552 | } |
| 4553 | } |
| 4554 | |
| 4555 | #ifdef FEAT_VIMINFO |
| 4556 | /* |
| 4557 | * Find the parameter represented by the given character (eg ', :, ", or /), |
| 4558 | * and return its associated value in the 'viminfo' string. |
| 4559 | * Only works for number parameters, not for 'r' or 'n'. |
Bram Moolenaar | 15d0a8c | 2004-09-06 17:44:46 +0000 | [diff] [blame] | 4560 | * If the parameter is not specified in the string or there is no following |
| 4561 | * number, return -1. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4562 | */ |
| 4563 | int |
| 4564 | get_viminfo_parameter(type) |
| 4565 | int type; |
| 4566 | { |
| 4567 | char_u *p; |
| 4568 | |
| 4569 | p = find_viminfo_parameter(type); |
| 4570 | if (p != NULL && VIM_ISDIGIT(*p)) |
| 4571 | return atoi((char *)p); |
| 4572 | return -1; |
| 4573 | } |
| 4574 | |
| 4575 | /* |
| 4576 | * Find the parameter represented by the given character (eg ''', ':', '"', or |
| 4577 | * '/') in the 'viminfo' option and return a pointer to the string after it. |
| 4578 | * Return NULL if the parameter is not specified in the string. |
| 4579 | */ |
| 4580 | char_u * |
| 4581 | find_viminfo_parameter(type) |
| 4582 | int type; |
| 4583 | { |
| 4584 | char_u *p; |
| 4585 | |
| 4586 | for (p = p_viminfo; *p; ++p) |
| 4587 | { |
| 4588 | if (*p == type) |
| 4589 | return p + 1; |
| 4590 | if (*p == 'n') /* 'n' is always the last one */ |
| 4591 | break; |
| 4592 | p = vim_strchr(p, ','); /* skip until next ',' */ |
| 4593 | if (p == NULL) /* hit the end without finding parameter */ |
| 4594 | break; |
| 4595 | } |
| 4596 | return NULL; |
| 4597 | } |
| 4598 | #endif |
| 4599 | |
| 4600 | /* |
| 4601 | * Expand environment variables for some string options. |
| 4602 | * These string options cannot be indirect! |
| 4603 | * If "val" is NULL expand the current value of the option. |
| 4604 | * Return pointer to NameBuff, or NULL when not expanded. |
| 4605 | */ |
| 4606 | static char_u * |
| 4607 | option_expand(opt_idx, val) |
| 4608 | int opt_idx; |
| 4609 | char_u *val; |
| 4610 | { |
| 4611 | /* if option doesn't need expansion nothing to do */ |
| 4612 | if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) |
| 4613 | return NULL; |
| 4614 | |
| 4615 | /* If val is longer than MAXPATHL no meaningful expansion can be done, |
| 4616 | * expand_env() would truncate the string. */ |
| 4617 | if (val != NULL && STRLEN(val) > MAXPATHL) |
| 4618 | return NULL; |
| 4619 | |
| 4620 | if (val == NULL) |
| 4621 | val = *(char_u **)options[opt_idx].var; |
| 4622 | |
| 4623 | /* |
| 4624 | * Expanding this with NameBuff, expand_env() must not be passed IObuff. |
| 4625 | * Escape spaces when expanding 'tags', they are used to separate file |
| 4626 | * names. |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 4627 | * For 'spellsuggest' expand after "file:". |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4628 | */ |
| 4629 | expand_env_esc(val, NameBuff, MAXPATHL, |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 4630 | (char_u **)options[opt_idx].var == &p_tags, |
| 4631 | #ifdef FEAT_SYN_HL |
| 4632 | (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : |
| 4633 | #endif |
| 4634 | NULL); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4635 | if (STRCMP(NameBuff, val) == 0) /* they are the same */ |
| 4636 | return NULL; |
| 4637 | |
| 4638 | return NameBuff; |
| 4639 | } |
| 4640 | |
| 4641 | /* |
| 4642 | * After setting various option values: recompute variables that depend on |
| 4643 | * option values. |
| 4644 | */ |
| 4645 | static void |
| 4646 | didset_options() |
| 4647 | { |
| 4648 | /* initialize the table for 'iskeyword' et.al. */ |
| 4649 | (void)init_chartab(); |
| 4650 | |
| 4651 | (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE); |
| 4652 | (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE); |
| 4653 | #ifdef FEAT_SESSION |
| 4654 | (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE); |
| 4655 | (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE); |
| 4656 | #endif |
| 4657 | #ifdef FEAT_FOLDING |
| 4658 | (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE); |
| 4659 | #endif |
| 4660 | (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE); |
| 4661 | #ifdef FEAT_VIRTUALEDIT |
| 4662 | (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE); |
| 4663 | #endif |
| 4664 | #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) |
| 4665 | (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE); |
| 4666 | #endif |
Bram Moolenaar | d857f0e | 2005-06-21 22:37:39 +0000 | [diff] [blame] | 4667 | #ifdef FEAT_SYN_HL |
Bram Moolenaar | 8aff23a | 2005-08-19 20:40:30 +0000 | [diff] [blame] | 4668 | (void)spell_check_msm(); |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 4669 | (void)spell_check_sps(); |
Bram Moolenaar | 0dc065e | 2005-07-04 22:49:24 +0000 | [diff] [blame] | 4670 | (void)compile_cap_prog(curbuf); |
Bram Moolenaar | d857f0e | 2005-06-21 22:37:39 +0000 | [diff] [blame] | 4671 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4672 | #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) |
| 4673 | (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE); |
| 4674 | #endif |
| 4675 | #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2) |
| 4676 | (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE); |
| 4677 | #endif |
| 4678 | #ifdef FEAT_CMDWIN |
| 4679 | /* set cedit_key */ |
| 4680 | (void)check_cedit(); |
| 4681 | #endif |
| 4682 | } |
| 4683 | |
| 4684 | /* |
| 4685 | * Check for string options that are NULL (normally only termcap options). |
| 4686 | */ |
| 4687 | void |
| 4688 | check_options() |
| 4689 | { |
| 4690 | int opt_idx; |
| 4691 | |
| 4692 | for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) |
| 4693 | if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL) |
| 4694 | check_string_option((char_u **)get_varp(&(options[opt_idx]))); |
| 4695 | } |
| 4696 | |
| 4697 | /* |
| 4698 | * Check string options in a buffer for NULL value. |
| 4699 | */ |
| 4700 | void |
| 4701 | check_buf_options(buf) |
| 4702 | buf_T *buf; |
| 4703 | { |
| 4704 | #if defined(FEAT_QUICKFIX) |
| 4705 | check_string_option(&buf->b_p_bh); |
| 4706 | check_string_option(&buf->b_p_bt); |
| 4707 | #endif |
| 4708 | #ifdef FEAT_MBYTE |
| 4709 | check_string_option(&buf->b_p_fenc); |
| 4710 | #endif |
| 4711 | check_string_option(&buf->b_p_ff); |
| 4712 | #ifdef FEAT_FIND_ID |
| 4713 | check_string_option(&buf->b_p_def); |
| 4714 | check_string_option(&buf->b_p_inc); |
| 4715 | # ifdef FEAT_EVAL |
| 4716 | check_string_option(&buf->b_p_inex); |
| 4717 | # endif |
| 4718 | #endif |
| 4719 | #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) |
| 4720 | check_string_option(&buf->b_p_inde); |
| 4721 | check_string_option(&buf->b_p_indk); |
| 4722 | #endif |
| 4723 | #ifdef FEAT_CRYPT |
| 4724 | check_string_option(&buf->b_p_key); |
| 4725 | #endif |
| 4726 | check_string_option(&buf->b_p_kp); |
| 4727 | check_string_option(&buf->b_p_mps); |
| 4728 | check_string_option(&buf->b_p_fo); |
Bram Moolenaar | 86b6835 | 2004-12-27 21:59:20 +0000 | [diff] [blame] | 4729 | check_string_option(&buf->b_p_flp); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4730 | check_string_option(&buf->b_p_isk); |
| 4731 | #ifdef FEAT_COMMENTS |
| 4732 | check_string_option(&buf->b_p_com); |
| 4733 | #endif |
| 4734 | #ifdef FEAT_FOLDING |
| 4735 | check_string_option(&buf->b_p_cms); |
| 4736 | #endif |
| 4737 | check_string_option(&buf->b_p_nf); |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 4738 | #ifdef FEAT_TEXTOBJ |
| 4739 | check_string_option(&buf->b_p_qe); |
| 4740 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4741 | #ifdef FEAT_SYN_HL |
| 4742 | check_string_option(&buf->b_p_syn); |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 4743 | check_string_option(&buf->b_p_spc); |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 4744 | check_string_option(&buf->b_p_spf); |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 4745 | check_string_option(&buf->b_p_spl); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4746 | #endif |
| 4747 | #ifdef FEAT_SEARCHPATH |
| 4748 | check_string_option(&buf->b_p_sua); |
| 4749 | #endif |
| 4750 | #ifdef FEAT_CINDENT |
| 4751 | check_string_option(&buf->b_p_cink); |
| 4752 | check_string_option(&buf->b_p_cino); |
| 4753 | #endif |
| 4754 | #ifdef FEAT_AUTOCMD |
| 4755 | check_string_option(&buf->b_p_ft); |
| 4756 | #endif |
| 4757 | #ifdef FEAT_OSFILETYPE |
| 4758 | check_string_option(&buf->b_p_oft); |
| 4759 | #endif |
| 4760 | #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) |
| 4761 | check_string_option(&buf->b_p_cinw); |
| 4762 | #endif |
| 4763 | #ifdef FEAT_INS_EXPAND |
| 4764 | check_string_option(&buf->b_p_cpt); |
| 4765 | #endif |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 4766 | #ifdef FEAT_COMPL_FUNC |
| 4767 | check_string_option(&buf->b_p_cfu); |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 4768 | check_string_option(&buf->b_p_ofu); |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 4769 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4770 | #ifdef FEAT_KEYMAP |
| 4771 | check_string_option(&buf->b_p_keymap); |
| 4772 | #endif |
| 4773 | #ifdef FEAT_QUICKFIX |
| 4774 | check_string_option(&buf->b_p_gp); |
| 4775 | check_string_option(&buf->b_p_mp); |
| 4776 | check_string_option(&buf->b_p_efm); |
| 4777 | #endif |
| 4778 | check_string_option(&buf->b_p_ep); |
| 4779 | check_string_option(&buf->b_p_path); |
| 4780 | check_string_option(&buf->b_p_tags); |
| 4781 | #ifdef FEAT_INS_EXPAND |
| 4782 | check_string_option(&buf->b_p_dict); |
| 4783 | check_string_option(&buf->b_p_tsr); |
| 4784 | #endif |
| 4785 | } |
| 4786 | |
| 4787 | /* |
| 4788 | * Free the string allocated for an option. |
| 4789 | * Checks for the string being empty_option. This may happen if we're out of |
| 4790 | * memory, vim_strsave() returned NULL, which was replaced by empty_option by |
| 4791 | * check_options(). |
| 4792 | * Does NOT check for P_ALLOCED flag! |
| 4793 | */ |
| 4794 | void |
| 4795 | free_string_option(p) |
| 4796 | char_u *p; |
| 4797 | { |
| 4798 | if (p != empty_option) |
| 4799 | vim_free(p); |
| 4800 | } |
| 4801 | |
| 4802 | void |
| 4803 | clear_string_option(pp) |
| 4804 | char_u **pp; |
| 4805 | { |
| 4806 | if (*pp != empty_option) |
| 4807 | vim_free(*pp); |
| 4808 | *pp = empty_option; |
| 4809 | } |
| 4810 | |
| 4811 | static void |
| 4812 | check_string_option(pp) |
| 4813 | char_u **pp; |
| 4814 | { |
| 4815 | if (*pp == NULL) |
| 4816 | *pp = empty_option; |
| 4817 | } |
| 4818 | |
| 4819 | /* |
| 4820 | * Mark a terminal option as allocated, found by a pointer into term_strings[]. |
| 4821 | */ |
| 4822 | void |
| 4823 | set_term_option_alloced(p) |
| 4824 | char_u **p; |
| 4825 | { |
| 4826 | int opt_idx; |
| 4827 | |
| 4828 | for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) |
| 4829 | if (options[opt_idx].var == (char_u *)p) |
| 4830 | { |
| 4831 | options[opt_idx].flags |= P_ALLOCED; |
| 4832 | return; |
| 4833 | } |
| 4834 | return; /* cannot happen: didn't find it! */ |
| 4835 | } |
| 4836 | |
| 4837 | /* |
| 4838 | * Set a string option to a new value (without checking the effect). |
| 4839 | * The string is copied into allocated memory. |
| 4840 | * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used. |
| 4841 | */ |
| 4842 | void |
| 4843 | set_string_option_direct(name, opt_idx, val, opt_flags) |
| 4844 | char_u *name; |
| 4845 | int opt_idx; |
| 4846 | char_u *val; |
| 4847 | int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ |
| 4848 | { |
| 4849 | char_u *s; |
| 4850 | char_u **varp; |
| 4851 | int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
| 4852 | |
| 4853 | if (opt_idx == -1) /* use name */ |
| 4854 | { |
| 4855 | opt_idx = findoption(name); |
| 4856 | if (opt_idx == -1) /* not found (should not happen) */ |
| 4857 | return; |
| 4858 | } |
| 4859 | |
| 4860 | if (options[opt_idx].var == NULL) /* can't set hidden option */ |
| 4861 | return; |
| 4862 | |
| 4863 | s = vim_strsave(val); |
| 4864 | if (s != NULL) |
| 4865 | { |
| 4866 | varp = (char_u **)get_varp_scope(&(options[opt_idx]), |
| 4867 | both ? OPT_LOCAL : opt_flags); |
| 4868 | if ((opt_flags & OPT_FREE) && (options[opt_idx].flags & P_ALLOCED)) |
| 4869 | free_string_option(*varp); |
| 4870 | *varp = s; |
| 4871 | |
| 4872 | /* For buffer/window local option may also set the global value. */ |
| 4873 | if (both) |
| 4874 | set_string_option_global(opt_idx, varp); |
| 4875 | |
| 4876 | options[opt_idx].flags |= P_ALLOCED; |
| 4877 | |
| 4878 | /* When setting both values of a global option with a local value, |
| 4879 | * make the local value empty, so that the global value is used. */ |
| 4880 | if ((int)options[opt_idx].indir >= PV_BOTH && both) |
| 4881 | { |
| 4882 | free_string_option(*varp); |
| 4883 | *varp = empty_option; |
| 4884 | } |
| 4885 | } |
| 4886 | } |
| 4887 | |
| 4888 | /* |
| 4889 | * Set global value for string option when it's a local option. |
| 4890 | */ |
| 4891 | static void |
| 4892 | set_string_option_global(opt_idx, varp) |
| 4893 | int opt_idx; /* option index */ |
| 4894 | char_u **varp; /* pointer to option variable */ |
| 4895 | { |
| 4896 | char_u **p, *s; |
| 4897 | |
| 4898 | /* the global value is always allocated */ |
| 4899 | if (options[opt_idx].var == VAR_WIN) |
| 4900 | p = (char_u **)GLOBAL_WO(varp); |
| 4901 | else |
| 4902 | p = (char_u **)options[opt_idx].var; |
| 4903 | if (options[opt_idx].indir != PV_NONE |
| 4904 | && p != varp |
| 4905 | && (s = vim_strsave(*varp)) != NULL) |
| 4906 | { |
| 4907 | free_string_option(*p); |
| 4908 | *p = s; |
| 4909 | } |
| 4910 | } |
| 4911 | |
| 4912 | /* |
| 4913 | * Set a string option to a new value, and handle the effects. |
| 4914 | */ |
| 4915 | static void |
| 4916 | set_string_option(opt_idx, value, opt_flags) |
| 4917 | int opt_idx; |
| 4918 | char_u *value; |
| 4919 | int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ |
| 4920 | { |
| 4921 | char_u *s; |
| 4922 | char_u **varp; |
| 4923 | char_u *oldval; |
| 4924 | |
| 4925 | if (options[opt_idx].var == NULL) /* don't set hidden option */ |
| 4926 | return; |
| 4927 | |
| 4928 | s = vim_strsave(value); |
| 4929 | if (s != NULL) |
| 4930 | { |
| 4931 | varp = (char_u **)get_varp_scope(&(options[opt_idx]), |
| 4932 | (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
| 4933 | ? ((int)options[opt_idx].indir >= PV_BOTH |
| 4934 | ? OPT_GLOBAL : OPT_LOCAL) |
| 4935 | : opt_flags); |
| 4936 | oldval = *varp; |
| 4937 | *varp = s; |
| 4938 | options[opt_idx].flags |= P_WAS_SET; |
| 4939 | (void)did_set_string_option(opt_idx, varp, TRUE, oldval, NULL, |
| 4940 | opt_flags); |
| 4941 | } |
| 4942 | } |
| 4943 | |
| 4944 | /* |
| 4945 | * Handle string options that need some action to perform when changed. |
| 4946 | * Returns NULL for success, or an error message for an error. |
| 4947 | */ |
| 4948 | static char_u * |
| 4949 | did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf, |
| 4950 | opt_flags) |
| 4951 | int opt_idx; /* index in options[] table */ |
| 4952 | char_u **varp; /* pointer to the option variable */ |
| 4953 | int new_value_alloced; /* new value was allocated */ |
| 4954 | char_u *oldval; /* previous value of the option */ |
| 4955 | char_u *errbuf; /* buffer for errors, or NULL */ |
| 4956 | int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ |
| 4957 | { |
| 4958 | char_u *errmsg = NULL; |
| 4959 | char_u *s, *p; |
| 4960 | int did_chartab = FALSE; |
| 4961 | char_u **gvarp; |
Bram Moolenaar | c0197e2 | 2004-09-13 20:26:32 +0000 | [diff] [blame] | 4962 | int free_oldval = (options[opt_idx].flags & P_ALLOCED); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4963 | |
| 4964 | /* Get the global option to compare with, otherwise we would have to check |
| 4965 | * two values for all local options. */ |
| 4966 | gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL); |
| 4967 | |
| 4968 | /* Disallow changing some options from secure mode */ |
| 4969 | if ((secure |
| 4970 | #ifdef HAVE_SANDBOX |
| 4971 | || sandbox != 0 |
| 4972 | #endif |
| 4973 | ) && (options[opt_idx].flags & P_SECURE)) |
| 4974 | { |
| 4975 | errmsg = e_secure; |
| 4976 | } |
| 4977 | |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 4978 | /* Check for a "normal" file name in some options. Disallow a path |
| 4979 | * separator (slash and/or backslash), wildcards and characters that are |
| 4980 | * often illegal in a file name. */ |
| 4981 | else if ((options[opt_idx].flags & P_NFNAME) |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame] | 4982 | && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL) |
Bram Moolenaar | 293ee4d | 2004-12-09 21:34:53 +0000 | [diff] [blame] | 4983 | { |
| 4984 | errmsg = e_invarg; |
| 4985 | } |
| 4986 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4987 | /* 'term' */ |
| 4988 | else if (varp == &T_NAME) |
| 4989 | { |
| 4990 | if (T_NAME[0] == NUL) |
| 4991 | errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string"); |
| 4992 | #ifdef FEAT_GUI |
| 4993 | if (gui.in_use) |
| 4994 | errmsg = (char_u *)N_("E530: Cannot change term in GUI"); |
| 4995 | else if (term_is_gui(T_NAME)) |
| 4996 | errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI"); |
| 4997 | #endif |
| 4998 | else if (set_termname(T_NAME) == FAIL) |
| 4999 | errmsg = (char_u *)N_("E522: Not found in termcap"); |
| 5000 | else |
| 5001 | /* Screen colors may have changed. */ |
| 5002 | redraw_later_clear(); |
| 5003 | } |
| 5004 | |
| 5005 | /* 'backupcopy' */ |
| 5006 | else if (varp == &p_bkc) |
| 5007 | { |
| 5008 | if (opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE) != OK) |
| 5009 | errmsg = e_invarg; |
| 5010 | if (((bkc_flags & BKC_AUTO) != 0) |
| 5011 | + ((bkc_flags & BKC_YES) != 0) |
| 5012 | + ((bkc_flags & BKC_NO) != 0) != 1) |
| 5013 | { |
| 5014 | /* Must have exactly one of "auto", "yes" and "no". */ |
| 5015 | (void)opt_strings_flags(oldval, p_bkc_values, &bkc_flags, TRUE); |
| 5016 | errmsg = e_invarg; |
| 5017 | } |
| 5018 | } |
| 5019 | |
| 5020 | /* 'backupext' and 'patchmode' */ |
| 5021 | else if (varp == &p_bex || varp == &p_pm) |
| 5022 | { |
| 5023 | if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex, |
| 5024 | *p_pm == '.' ? p_pm + 1 : p_pm) == 0) |
| 5025 | errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal"); |
| 5026 | } |
| 5027 | |
| 5028 | /* |
| 5029 | * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[] |
| 5030 | * If the new option is invalid, use old value. 'lisp' option: refill |
| 5031 | * chartab[] for '-' char |
| 5032 | */ |
| 5033 | else if ( varp == &p_isi |
| 5034 | || varp == &(curbuf->b_p_isk) |
| 5035 | || varp == &p_isp |
| 5036 | || varp == &p_isf) |
| 5037 | { |
| 5038 | if (init_chartab() == FAIL) |
| 5039 | { |
| 5040 | did_chartab = TRUE; /* need to restore it below */ |
| 5041 | errmsg = e_invarg; /* error in value */ |
| 5042 | } |
| 5043 | } |
| 5044 | |
| 5045 | /* 'helpfile' */ |
| 5046 | else if (varp == &p_hf) |
| 5047 | { |
| 5048 | /* May compute new values for $VIM and $VIMRUNTIME */ |
| 5049 | if (didset_vim) |
| 5050 | { |
| 5051 | vim_setenv((char_u *)"VIM", (char_u *)""); |
| 5052 | didset_vim = FALSE; |
| 5053 | } |
| 5054 | if (didset_vimruntime) |
| 5055 | { |
| 5056 | vim_setenv((char_u *)"VIMRUNTIME", (char_u *)""); |
| 5057 | didset_vimruntime = FALSE; |
| 5058 | } |
| 5059 | } |
| 5060 | |
| 5061 | #ifdef FEAT_MULTI_LANG |
| 5062 | /* 'helplang' */ |
| 5063 | else if (varp == &p_hlg) |
| 5064 | { |
| 5065 | /* Check for "", "ab", "ab,cd", etc. */ |
| 5066 | for (s = p_hlg; *s != NUL; s += 3) |
| 5067 | { |
| 5068 | if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) |
| 5069 | { |
| 5070 | errmsg = e_invarg; |
| 5071 | break; |
| 5072 | } |
| 5073 | if (s[2] == NUL) |
| 5074 | break; |
| 5075 | } |
| 5076 | } |
| 5077 | #endif |
| 5078 | |
| 5079 | /* 'highlight' */ |
| 5080 | else if (varp == &p_hl) |
| 5081 | { |
| 5082 | if (highlight_changed() == FAIL) |
| 5083 | errmsg = e_invarg; /* invalid flags */ |
| 5084 | } |
| 5085 | |
| 5086 | /* 'nrformats' */ |
| 5087 | else if (gvarp == &p_nf) |
| 5088 | { |
| 5089 | if (check_opt_strings(*varp, p_nf_values, TRUE) != OK) |
| 5090 | errmsg = e_invarg; |
| 5091 | } |
| 5092 | |
| 5093 | #ifdef FEAT_SESSION |
| 5094 | /* 'sessionoptions' */ |
| 5095 | else if (varp == &p_ssop) |
| 5096 | { |
| 5097 | if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK) |
| 5098 | errmsg = e_invarg; |
| 5099 | if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR)) |
| 5100 | { |
| 5101 | /* Don't allow both "sesdir" and "curdir". */ |
| 5102 | (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE); |
| 5103 | errmsg = e_invarg; |
| 5104 | } |
| 5105 | } |
| 5106 | /* 'viewoptions' */ |
| 5107 | else if (varp == &p_vop) |
| 5108 | { |
| 5109 | if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK) |
| 5110 | errmsg = e_invarg; |
| 5111 | } |
| 5112 | #endif |
| 5113 | |
| 5114 | /* 'scrollopt' */ |
| 5115 | #ifdef FEAT_SCROLLBIND |
| 5116 | else if (varp == &p_sbo) |
| 5117 | { |
| 5118 | if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK) |
| 5119 | errmsg = e_invarg; |
| 5120 | } |
| 5121 | #endif |
| 5122 | |
| 5123 | /* 'ambiwidth' */ |
| 5124 | #ifdef FEAT_MBYTE |
| 5125 | else if (varp == &p_ambw) |
| 5126 | { |
| 5127 | if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK) |
| 5128 | errmsg = e_invarg; |
| 5129 | } |
| 5130 | #endif |
| 5131 | |
| 5132 | /* 'background' */ |
| 5133 | else if (varp == &p_bg) |
| 5134 | { |
| 5135 | if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK) |
| 5136 | { |
| 5137 | #ifdef FEAT_EVAL |
| 5138 | int dark = (*p_bg == 'd'); |
| 5139 | #endif |
| 5140 | |
| 5141 | init_highlight(FALSE, FALSE); |
| 5142 | |
| 5143 | #ifdef FEAT_EVAL |
| 5144 | if (dark != (*p_bg == 'd') |
| 5145 | && get_var_value((char_u *)"g:colors_name") != NULL) |
| 5146 | { |
| 5147 | /* The color scheme must have set 'background' back to another |
| 5148 | * value, that's not what we want here. Disable the color |
| 5149 | * scheme and set the colors again. */ |
Bram Moolenaar | 2ce06f6 | 2005-01-31 19:19:04 +0000 | [diff] [blame] | 5150 | do_unlet((char_u *)"g:colors_name", TRUE); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5151 | free_string_option(p_bg); |
| 5152 | p_bg = vim_strsave((char_u *)(dark ? "dark" : "light")); |
| 5153 | check_string_option(&p_bg); |
| 5154 | init_highlight(FALSE, FALSE); |
| 5155 | } |
| 5156 | #endif |
| 5157 | } |
| 5158 | else |
| 5159 | errmsg = e_invarg; |
| 5160 | } |
| 5161 | |
| 5162 | /* 'wildmode' */ |
| 5163 | else if (varp == &p_wim) |
| 5164 | { |
| 5165 | if (check_opt_wim() == FAIL) |
| 5166 | errmsg = e_invarg; |
| 5167 | } |
| 5168 | |
Bram Moolenaar | b5bf5b8 | 2004-12-24 14:35:23 +0000 | [diff] [blame] | 5169 | #ifdef FEAT_CMDL_COMPL |
| 5170 | /* 'wildoptions' */ |
| 5171 | else if (varp == &p_wop) |
| 5172 | { |
| 5173 | if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK) |
| 5174 | errmsg = e_invarg; |
| 5175 | } |
| 5176 | #endif |
| 5177 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5178 | #ifdef FEAT_WAK |
| 5179 | /* 'winaltkeys' */ |
| 5180 | else if (varp == &p_wak) |
| 5181 | { |
| 5182 | if (*p_wak == NUL |
| 5183 | || check_opt_strings(p_wak, p_wak_values, FALSE) != OK) |
| 5184 | errmsg = e_invarg; |
| 5185 | # ifdef FEAT_MENU |
| 5186 | # ifdef FEAT_GUI_MOTIF |
| 5187 | else if (gui.in_use) |
| 5188 | gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm'); |
| 5189 | # else |
| 5190 | # ifdef FEAT_GUI_GTK |
| 5191 | else if (gui.in_use) |
| 5192 | gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm'); |
| 5193 | # endif |
| 5194 | # endif |
| 5195 | # endif |
| 5196 | } |
| 5197 | #endif |
| 5198 | |
| 5199 | #ifdef FEAT_AUTOCMD |
| 5200 | /* 'eventignore' */ |
| 5201 | else if (varp == &p_ei) |
| 5202 | { |
| 5203 | if (check_ei() == FAIL) |
| 5204 | errmsg = e_invarg; |
| 5205 | } |
| 5206 | #endif |
| 5207 | |
| 5208 | #ifdef FEAT_MBYTE |
| 5209 | /* 'encoding' and 'fileencoding' */ |
| 5210 | else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc) |
| 5211 | { |
| 5212 | if (gvarp == &p_fenc) |
| 5213 | { |
| 5214 | if (!curbuf->b_p_ma) |
| 5215 | errmsg = e_modifiable; |
| 5216 | else if (vim_strchr(*varp, ',') != NULL) |
| 5217 | /* No comma allowed in 'fileencoding'; catches confusing it |
| 5218 | * with 'fileencodings'. */ |
| 5219 | errmsg = e_invarg; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5220 | else |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame] | 5221 | { |
| 5222 | # ifdef FEAT_TITLE |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5223 | /* May show a "+" in the title now. */ |
| 5224 | need_maketitle = TRUE; |
| 5225 | # endif |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame] | 5226 | /* Add 'fileencoding' to the swap file. */ |
| 5227 | ml_setflags(curbuf); |
| 5228 | } |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5229 | } |
| 5230 | if (errmsg == NULL) |
| 5231 | { |
| 5232 | /* canonize the value, so that STRCMP() can be used on it */ |
| 5233 | p = enc_canonize(*varp); |
| 5234 | if (p != NULL) |
| 5235 | { |
| 5236 | vim_free(*varp); |
| 5237 | *varp = p; |
| 5238 | } |
| 5239 | if (varp == &p_enc) |
| 5240 | { |
| 5241 | errmsg = mb_init(); |
| 5242 | # ifdef FEAT_TITLE |
| 5243 | need_maketitle = TRUE; |
| 5244 | # endif |
| 5245 | } |
| 5246 | } |
| 5247 | |
| 5248 | # if defined(FEAT_GUI_GTK) && defined(HAVE_GTK2) |
| 5249 | if (errmsg == NULL && varp == &p_tenc && gui.in_use) |
| 5250 | { |
| 5251 | /* GTK+ 2 uses only a single encoding, and that is UTF-8. */ |
| 5252 | if (STRCMP(p_tenc, "utf-8") != 0) |
| 5253 | errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI"); |
| 5254 | } |
| 5255 | # endif |
| 5256 | |
| 5257 | if (errmsg == NULL) |
| 5258 | { |
| 5259 | # ifdef FEAT_KEYMAP |
| 5260 | /* When 'keymap' is used and 'encoding' changes, reload the keymap |
| 5261 | * (with another encoding). */ |
| 5262 | if (varp == &p_enc && *curbuf->b_p_keymap != NUL) |
| 5263 | (void)keymap_init(); |
| 5264 | # endif |
| 5265 | |
| 5266 | /* When 'termencoding' is not empty and 'encoding' changes or when |
| 5267 | * 'termencoding' changes, need to setup for keyboard input and |
| 5268 | * display output conversion. */ |
| 5269 | if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc)) |
| 5270 | { |
| 5271 | convert_setup(&input_conv, p_tenc, p_enc); |
| 5272 | convert_setup(&output_conv, p_enc, p_tenc); |
| 5273 | } |
Bram Moolenaar | 05159a0 | 2005-02-26 23:04:13 +0000 | [diff] [blame] | 5274 | |
| 5275 | # if defined(WIN3264) && defined(FEAT_MBYTE) |
| 5276 | /* $HOME may have characters in active code page. */ |
| 5277 | if (varp == &p_enc) |
| 5278 | init_homedir(); |
| 5279 | # endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5280 | } |
| 5281 | } |
| 5282 | #endif |
| 5283 | |
| 5284 | #if defined(FEAT_POSTSCRIPT) |
| 5285 | else if (varp == &p_penc) |
| 5286 | { |
| 5287 | /* Canonize printencoding if VIM standard one */ |
| 5288 | p = enc_canonize(p_penc); |
| 5289 | if (p != NULL) |
| 5290 | { |
| 5291 | vim_free(p_penc); |
| 5292 | p_penc = p; |
| 5293 | } |
| 5294 | else |
| 5295 | { |
| 5296 | /* Ensure lower case and '-' for '_' */ |
| 5297 | for (s = p_penc; *s != NUL; s++) |
| 5298 | { |
| 5299 | if (*s == '_') |
| 5300 | *s = '-'; |
| 5301 | else |
| 5302 | *s = TOLOWER_ASC(*s); |
| 5303 | } |
| 5304 | } |
| 5305 | } |
| 5306 | #endif |
| 5307 | |
Bram Moolenaar | 9372a11 | 2005-12-06 19:59:18 +0000 | [diff] [blame] | 5308 | #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5309 | else if (varp == &p_imak) |
| 5310 | { |
| 5311 | if (gui.in_use && !im_xim_isvalid_imactivate()) |
| 5312 | errmsg = e_invarg; |
| 5313 | } |
| 5314 | #endif |
| 5315 | |
| 5316 | #ifdef FEAT_KEYMAP |
| 5317 | else if (varp == &curbuf->b_p_keymap) |
| 5318 | { |
| 5319 | /* load or unload key mapping tables */ |
| 5320 | errmsg = keymap_init(); |
| 5321 | |
| 5322 | /* When successfully installed a new keymap switch on using it. */ |
| 5323 | if (*curbuf->b_p_keymap != NUL && errmsg == NULL) |
| 5324 | { |
| 5325 | curbuf->b_p_iminsert = B_IMODE_LMAP; |
| 5326 | if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT) |
| 5327 | curbuf->b_p_imsearch = B_IMODE_LMAP; |
| 5328 | set_iminsert_global(); |
| 5329 | set_imsearch_global(); |
| 5330 | # ifdef FEAT_WINDOWS |
| 5331 | status_redraw_curbuf(); |
| 5332 | # endif |
| 5333 | } |
| 5334 | } |
| 5335 | #endif |
| 5336 | |
| 5337 | /* 'fileformat' */ |
| 5338 | else if (gvarp == &p_ff) |
| 5339 | { |
| 5340 | if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL)) |
| 5341 | errmsg = e_modifiable; |
| 5342 | else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK) |
| 5343 | errmsg = e_invarg; |
| 5344 | else |
| 5345 | { |
| 5346 | /* may also change 'textmode' */ |
| 5347 | if (get_fileformat(curbuf) == EOL_DOS) |
| 5348 | curbuf->b_p_tx = TRUE; |
| 5349 | else |
| 5350 | curbuf->b_p_tx = FALSE; |
| 5351 | #ifdef FEAT_TITLE |
| 5352 | need_maketitle = TRUE; |
| 5353 | #endif |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame] | 5354 | /* update flag in swap file */ |
| 5355 | ml_setflags(curbuf); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5356 | } |
| 5357 | } |
| 5358 | |
| 5359 | /* 'fileformats' */ |
| 5360 | else if (varp == &p_ffs) |
| 5361 | { |
| 5362 | if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK) |
| 5363 | errmsg = e_invarg; |
| 5364 | else |
| 5365 | { |
| 5366 | /* also change 'textauto' */ |
| 5367 | if (*p_ffs == NUL) |
| 5368 | p_ta = FALSE; |
| 5369 | else |
| 5370 | p_ta = TRUE; |
| 5371 | } |
| 5372 | } |
| 5373 | |
| 5374 | #if defined(FEAT_CRYPT) && defined(FEAT_CMDHIST) |
| 5375 | /* 'cryptkey' */ |
| 5376 | else if (gvarp == &p_key) |
| 5377 | { |
| 5378 | /* Make sure the ":set" command doesn't show the new value in the |
| 5379 | * history. */ |
| 5380 | remove_key_from_history(); |
| 5381 | } |
| 5382 | #endif |
| 5383 | |
| 5384 | /* 'matchpairs' */ |
| 5385 | else if (gvarp == &p_mps) |
| 5386 | { |
| 5387 | /* Check for "x:y,x:y" */ |
| 5388 | for (p = *varp; *p != NUL; p += 4) |
| 5389 | { |
| 5390 | if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ',')) |
| 5391 | { |
| 5392 | errmsg = e_invarg; |
| 5393 | break; |
| 5394 | } |
| 5395 | if (p[3] == NUL) |
| 5396 | break; |
| 5397 | } |
| 5398 | } |
| 5399 | |
| 5400 | #ifdef FEAT_COMMENTS |
| 5401 | /* 'comments' */ |
| 5402 | else if (gvarp == &p_com) |
| 5403 | { |
| 5404 | for (s = *varp; *s; ) |
| 5405 | { |
| 5406 | while (*s && *s != ':') |
| 5407 | { |
| 5408 | if (vim_strchr((char_u *)COM_ALL, *s) == NULL |
| 5409 | && !VIM_ISDIGIT(*s) && *s != '-') |
| 5410 | { |
| 5411 | errmsg = illegal_char(errbuf, *s); |
| 5412 | break; |
| 5413 | } |
| 5414 | ++s; |
| 5415 | } |
| 5416 | if (*s++ == NUL) |
| 5417 | errmsg = (char_u *)N_("E524: Missing colon"); |
| 5418 | else if (*s == ',' || *s == NUL) |
| 5419 | errmsg = (char_u *)N_("E525: Zero length string"); |
| 5420 | if (errmsg != NULL) |
| 5421 | break; |
| 5422 | while (*s && *s != ',') |
| 5423 | { |
| 5424 | if (*s == '\\' && s[1] != NUL) |
| 5425 | ++s; |
| 5426 | ++s; |
| 5427 | } |
| 5428 | s = skip_to_option_part(s); |
| 5429 | } |
| 5430 | } |
| 5431 | #endif |
| 5432 | |
| 5433 | /* 'listchars' */ |
| 5434 | else if (varp == &p_lcs) |
| 5435 | { |
| 5436 | errmsg = set_chars_option(varp); |
| 5437 | } |
| 5438 | |
| 5439 | #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
| 5440 | /* 'fillchars' */ |
| 5441 | else if (varp == &p_fcs) |
| 5442 | { |
| 5443 | errmsg = set_chars_option(varp); |
| 5444 | } |
| 5445 | #endif |
| 5446 | |
| 5447 | #ifdef FEAT_CMDWIN |
| 5448 | /* 'cedit' */ |
| 5449 | else if (varp == &p_cedit) |
| 5450 | { |
| 5451 | errmsg = check_cedit(); |
| 5452 | } |
| 5453 | #endif |
| 5454 | |
Bram Moolenaar | 54ee775 | 2005-05-31 22:22:17 +0000 | [diff] [blame] | 5455 | /* 'verbosefile' */ |
| 5456 | else if (varp == &p_vfile) |
| 5457 | { |
| 5458 | verbose_stop(); |
| 5459 | if (*p_vfile != NUL && verbose_open() == FAIL) |
| 5460 | errmsg = e_invarg; |
| 5461 | } |
| 5462 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5463 | #ifdef FEAT_VIMINFO |
| 5464 | /* 'viminfo' */ |
| 5465 | else if (varp == &p_viminfo) |
| 5466 | { |
| 5467 | for (s = p_viminfo; *s;) |
| 5468 | { |
| 5469 | /* Check it's a valid character */ |
| 5470 | if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) |
| 5471 | { |
| 5472 | errmsg = illegal_char(errbuf, *s); |
| 5473 | break; |
| 5474 | } |
| 5475 | if (*s == 'n') /* name is always last one */ |
| 5476 | { |
| 5477 | break; |
| 5478 | } |
| 5479 | else if (*s == 'r') /* skip until next ',' */ |
| 5480 | { |
| 5481 | while (*++s && *s != ',') |
| 5482 | ; |
| 5483 | } |
Bram Moolenaar | 15d0a8c | 2004-09-06 17:44:46 +0000 | [diff] [blame] | 5484 | else if (*s == '%') |
| 5485 | { |
| 5486 | /* optional number */ |
| 5487 | while (vim_isdigit(*++s)) |
| 5488 | ; |
| 5489 | } |
| 5490 | else if (*s == '!' || *s == 'h' || *s == 'c') |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5491 | ++s; /* no extra chars */ |
| 5492 | else /* must have a number */ |
| 5493 | { |
| 5494 | while (vim_isdigit(*++s)) |
| 5495 | ; |
| 5496 | |
| 5497 | if (!VIM_ISDIGIT(*(s - 1))) |
| 5498 | { |
| 5499 | if (errbuf != NULL) |
| 5500 | { |
Bram Moolenaar | 8f999f1 | 2005-01-25 22:12:55 +0000 | [diff] [blame] | 5501 | sprintf((char *)errbuf, |
| 5502 | _("E526: Missing number after <%s>"), |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5503 | transchar_byte(*(s - 1))); |
| 5504 | errmsg = errbuf; |
| 5505 | } |
| 5506 | else |
| 5507 | errmsg = (char_u *)""; |
| 5508 | break; |
| 5509 | } |
| 5510 | } |
| 5511 | if (*s == ',') |
| 5512 | ++s; |
| 5513 | else if (*s) |
| 5514 | { |
| 5515 | if (errbuf != NULL) |
| 5516 | errmsg = (char_u *)N_("E527: Missing comma"); |
| 5517 | else |
| 5518 | errmsg = (char_u *)""; |
| 5519 | break; |
| 5520 | } |
| 5521 | } |
| 5522 | if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0) |
| 5523 | errmsg = (char_u *)N_("E528: Must specify a ' value"); |
| 5524 | } |
| 5525 | #endif /* FEAT_VIMINFO */ |
| 5526 | |
| 5527 | /* terminal options */ |
| 5528 | else if (istermoption(&options[opt_idx]) && full_screen) |
| 5529 | { |
| 5530 | /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */ |
| 5531 | if (varp == &T_CCO) |
| 5532 | { |
| 5533 | t_colors = atoi((char *)T_CCO); |
| 5534 | if (t_colors <= 1) |
| 5535 | { |
| 5536 | if (new_value_alloced) |
| 5537 | vim_free(T_CCO); |
| 5538 | T_CCO = empty_option; |
| 5539 | } |
| 5540 | /* We now have a different color setup, initialize it again. */ |
| 5541 | init_highlight(TRUE, FALSE); |
| 5542 | } |
| 5543 | ttest(FALSE); |
| 5544 | if (varp == &T_ME) |
| 5545 | { |
| 5546 | out_str(T_ME); |
| 5547 | redraw_later(CLEAR); |
| 5548 | #if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32)) |
| 5549 | /* Since t_me has been set, this probably means that the user |
| 5550 | * wants to use this as default colors. Need to reset default |
| 5551 | * background/foreground colors. */ |
| 5552 | mch_set_normal_colors(); |
| 5553 | #endif |
| 5554 | } |
| 5555 | } |
| 5556 | |
| 5557 | #ifdef FEAT_LINEBREAK |
| 5558 | /* 'showbreak' */ |
| 5559 | else if (varp == &p_sbr) |
| 5560 | { |
| 5561 | for (s = p_sbr; *s; ) |
| 5562 | { |
| 5563 | if (ptr2cells(s) != 1) |
| 5564 | errmsg = (char_u *)N_("E595: contains unprintable or wide character"); |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame] | 5565 | mb_ptr_adv(s); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5566 | } |
| 5567 | } |
| 5568 | #endif |
| 5569 | |
| 5570 | #ifdef FEAT_GUI |
| 5571 | /* 'guifont' */ |
| 5572 | else if (varp == &p_guifont) |
| 5573 | { |
| 5574 | if (gui.in_use) |
| 5575 | { |
| 5576 | p = p_guifont; |
Bram Moolenaar | 9372a11 | 2005-12-06 19:59:18 +0000 | [diff] [blame] | 5577 | # if defined(FEAT_GUI_GTK) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5578 | /* |
| 5579 | * Put up a font dialog and let the user select a new value. |
| 5580 | * If this is cancelled go back to the old value but don't |
| 5581 | * give an error message. |
| 5582 | */ |
| 5583 | if (STRCMP(p, "*") == 0) |
| 5584 | { |
| 5585 | p = gui_mch_font_dialog(oldval); |
| 5586 | |
| 5587 | if (new_value_alloced) |
| 5588 | free_string_option(p_guifont); |
| 5589 | |
| 5590 | p_guifont = (p != NULL) ? p : vim_strsave(oldval); |
| 5591 | new_value_alloced = TRUE; |
| 5592 | } |
| 5593 | # endif |
| 5594 | if (p != NULL && gui_init_font(p_guifont, FALSE) != OK) |
| 5595 | { |
| 5596 | # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON) |
| 5597 | if (STRCMP(p_guifont, "*") == 0) |
| 5598 | { |
| 5599 | /* Dialog was cancelled: Keep the old value without giving |
| 5600 | * an error message. */ |
| 5601 | if (new_value_alloced) |
| 5602 | free_string_option(p_guifont); |
| 5603 | p_guifont = vim_strsave(oldval); |
| 5604 | new_value_alloced = TRUE; |
| 5605 | } |
| 5606 | else |
| 5607 | # endif |
| 5608 | errmsg = (char_u *)N_("E596: Invalid font(s)"); |
| 5609 | } |
| 5610 | } |
| 5611 | } |
| 5612 | # ifdef FEAT_XFONTSET |
| 5613 | else if (varp == &p_guifontset) |
| 5614 | { |
| 5615 | if (STRCMP(p_guifontset, "*") == 0) |
| 5616 | errmsg = (char_u *)N_("E597: can't select fontset"); |
| 5617 | else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK) |
| 5618 | errmsg = (char_u *)N_("E598: Invalid fontset"); |
| 5619 | } |
| 5620 | # endif |
| 5621 | # ifdef FEAT_MBYTE |
| 5622 | else if (varp == &p_guifontwide) |
| 5623 | { |
| 5624 | if (STRCMP(p_guifontwide, "*") == 0) |
| 5625 | errmsg = (char_u *)N_("E533: can't select wide font"); |
| 5626 | else if (gui_get_wide_font() == FAIL) |
| 5627 | errmsg = (char_u *)N_("E534: Invalid wide font"); |
| 5628 | } |
| 5629 | # endif |
| 5630 | #endif |
| 5631 | |
| 5632 | #ifdef CURSOR_SHAPE |
| 5633 | /* 'guicursor' */ |
| 5634 | else if (varp == &p_guicursor) |
| 5635 | errmsg = parse_shape_opt(SHAPE_CURSOR); |
| 5636 | #endif |
| 5637 | |
| 5638 | #ifdef FEAT_MOUSESHAPE |
| 5639 | /* 'mouseshape' */ |
| 5640 | else if (varp == &p_mouseshape) |
| 5641 | { |
| 5642 | errmsg = parse_shape_opt(SHAPE_MOUSE); |
| 5643 | update_mouseshape(-1); |
| 5644 | } |
| 5645 | #endif |
| 5646 | |
| 5647 | #ifdef FEAT_PRINTER |
| 5648 | else if (varp == &p_popt) |
Bram Moolenaar | 58d9823 | 2005-07-23 22:25:46 +0000 | [diff] [blame] | 5649 | errmsg = parse_printoptions(); |
Bram Moolenaar | 2df6dcc | 2004-07-12 15:53:54 +0000 | [diff] [blame] | 5650 | # if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT) |
Bram Moolenaar | 8299df9 | 2004-07-10 09:47:34 +0000 | [diff] [blame] | 5651 | else if (varp == &p_pmfn) |
Bram Moolenaar | 58d9823 | 2005-07-23 22:25:46 +0000 | [diff] [blame] | 5652 | errmsg = parse_printmbfont(); |
Bram Moolenaar | 8299df9 | 2004-07-10 09:47:34 +0000 | [diff] [blame] | 5653 | # endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5654 | #endif |
| 5655 | |
| 5656 | #ifdef FEAT_LANGMAP |
| 5657 | /* 'langmap' */ |
| 5658 | else if (varp == &p_langmap) |
| 5659 | langmap_set(); |
| 5660 | #endif |
| 5661 | |
| 5662 | #ifdef FEAT_LINEBREAK |
| 5663 | /* 'breakat' */ |
| 5664 | else if (varp == &p_breakat) |
| 5665 | fill_breakat_flags(); |
| 5666 | #endif |
| 5667 | |
| 5668 | #ifdef FEAT_TITLE |
| 5669 | /* 'titlestring' and 'iconstring' */ |
| 5670 | else if (varp == &p_titlestring || varp == &p_iconstring) |
| 5671 | { |
| 5672 | # ifdef FEAT_STL_OPT |
| 5673 | int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON; |
| 5674 | |
| 5675 | /* NULL => statusline syntax */ |
| 5676 | if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL) |
| 5677 | stl_syntax |= flagval; |
| 5678 | else |
| 5679 | stl_syntax &= ~flagval; |
| 5680 | # endif |
| 5681 | did_set_title(varp == &p_iconstring); |
| 5682 | |
| 5683 | } |
| 5684 | #endif |
| 5685 | |
| 5686 | #ifdef FEAT_GUI |
| 5687 | /* 'guioptions' */ |
| 5688 | else if (varp == &p_go) |
| 5689 | gui_init_which_components(oldval); |
| 5690 | #endif |
| 5691 | |
| 5692 | #if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS)) |
| 5693 | /* 'ttymouse' */ |
| 5694 | else if (varp == &p_ttym) |
| 5695 | { |
Bram Moolenaar | f1f8bc5 | 2005-03-07 23:20:08 +0000 | [diff] [blame] | 5696 | /* Switch the mouse off before changing the escape sequences used for |
| 5697 | * that. */ |
| 5698 | mch_setmouse(FALSE); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5699 | if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK) |
| 5700 | errmsg = e_invarg; |
| 5701 | else |
| 5702 | check_mouse_termcode(); |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 5703 | if (termcap_active) |
| 5704 | setmouse(); /* may switch it on again */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5705 | } |
| 5706 | #endif |
| 5707 | |
| 5708 | #ifdef FEAT_VISUAL |
| 5709 | /* 'selection' */ |
| 5710 | else if (varp == &p_sel) |
| 5711 | { |
| 5712 | if (*p_sel == NUL |
| 5713 | || check_opt_strings(p_sel, p_sel_values, FALSE) != OK) |
| 5714 | errmsg = e_invarg; |
| 5715 | } |
| 5716 | |
| 5717 | /* 'selectmode' */ |
| 5718 | else if (varp == &p_slm) |
| 5719 | { |
| 5720 | if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK) |
| 5721 | errmsg = e_invarg; |
| 5722 | } |
| 5723 | #endif |
| 5724 | |
| 5725 | #ifdef FEAT_BROWSE |
| 5726 | /* 'browsedir' */ |
| 5727 | else if (varp == &p_bsdir) |
| 5728 | { |
| 5729 | if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK |
| 5730 | && !mch_isdir(p_bsdir)) |
| 5731 | errmsg = e_invarg; |
| 5732 | } |
| 5733 | #endif |
| 5734 | |
| 5735 | #ifdef FEAT_VISUAL |
| 5736 | /* 'keymodel' */ |
| 5737 | else if (varp == &p_km) |
| 5738 | { |
| 5739 | if (check_opt_strings(p_km, p_km_values, TRUE) != OK) |
| 5740 | errmsg = e_invarg; |
| 5741 | else |
| 5742 | { |
| 5743 | km_stopsel = (vim_strchr(p_km, 'o') != NULL); |
| 5744 | km_startsel = (vim_strchr(p_km, 'a') != NULL); |
| 5745 | } |
| 5746 | } |
| 5747 | #endif |
| 5748 | |
| 5749 | /* 'mousemodel' */ |
| 5750 | else if (varp == &p_mousem) |
| 5751 | { |
| 5752 | if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK) |
| 5753 | errmsg = e_invarg; |
| 5754 | #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002) |
| 5755 | else if (*p_mousem != *oldval) |
| 5756 | /* Changed from "extend" to "popup" or "popup_setpos" or vv: need |
| 5757 | * to create or delete the popup menus. */ |
| 5758 | gui_motif_update_mousemodel(root_menu); |
| 5759 | #endif |
| 5760 | } |
| 5761 | |
| 5762 | /* 'switchbuf' */ |
| 5763 | else if (varp == &p_swb) |
| 5764 | { |
| 5765 | if (check_opt_strings(p_swb, p_swb_values, TRUE) != OK) |
| 5766 | errmsg = e_invarg; |
| 5767 | } |
| 5768 | |
| 5769 | /* 'debug' */ |
| 5770 | else if (varp == &p_debug) |
| 5771 | { |
| 5772 | if (check_opt_strings(p_debug, p_debug_values, FALSE) != OK) |
| 5773 | errmsg = e_invarg; |
| 5774 | } |
| 5775 | |
| 5776 | /* 'display' */ |
| 5777 | else if (varp == &p_dy) |
| 5778 | { |
| 5779 | if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK) |
| 5780 | errmsg = e_invarg; |
| 5781 | else |
| 5782 | (void)init_chartab(); |
| 5783 | |
| 5784 | } |
| 5785 | |
| 5786 | #ifdef FEAT_VERTSPLIT |
| 5787 | /* 'eadirection' */ |
| 5788 | else if (varp == &p_ead) |
| 5789 | { |
| 5790 | if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK) |
| 5791 | errmsg = e_invarg; |
| 5792 | } |
| 5793 | #endif |
| 5794 | |
| 5795 | #ifdef FEAT_CLIPBOARD |
| 5796 | /* 'clipboard' */ |
| 5797 | else if (varp == &p_cb) |
| 5798 | errmsg = check_clipboard_option(); |
| 5799 | #endif |
| 5800 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 5801 | #ifdef FEAT_SYN_HL |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 5802 | /* When 'spelllang' or 'spellfile' is set and there is a window for this |
| 5803 | * buffer in which 'spell' is set load the wordlists. */ |
| 5804 | else if (varp == &(curbuf->b_p_spl) || varp == &(curbuf->b_p_spf)) |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 5805 | { |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 5806 | win_T *wp; |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 5807 | int l; |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 5808 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 5809 | if (varp == &(curbuf->b_p_spf)) |
| 5810 | { |
| 5811 | l = STRLEN(curbuf->b_p_spf); |
| 5812 | if (l > 0 && (l < 4 || STRCMP(curbuf->b_p_spf + l - 4, |
| 5813 | ".add") != 0)) |
| 5814 | errmsg = e_invarg; |
| 5815 | } |
| 5816 | |
| 5817 | if (errmsg == NULL) |
| 5818 | { |
| 5819 | FOR_ALL_WINDOWS(wp) |
| 5820 | if (wp->w_buffer == curbuf && wp->w_p_spell) |
| 5821 | { |
| 5822 | errmsg = did_set_spelllang(curbuf); |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 5823 | # ifdef FEAT_WINDOWS |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 5824 | break; |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 5825 | # endif |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 5826 | } |
| 5827 | } |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 5828 | } |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 5829 | /* When 'spellcapcheck' is set compile the regexp program. */ |
| 5830 | else if (varp == &(curbuf->b_p_spc)) |
| 5831 | { |
Bram Moolenaar | 0dc065e | 2005-07-04 22:49:24 +0000 | [diff] [blame] | 5832 | errmsg = compile_cap_prog(curbuf); |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 5833 | } |
Bram Moolenaar | d857f0e | 2005-06-21 22:37:39 +0000 | [diff] [blame] | 5834 | /* 'spellsuggest' */ |
| 5835 | else if (varp == &p_sps) |
| 5836 | { |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 5837 | if (spell_check_sps() != OK) |
Bram Moolenaar | d857f0e | 2005-06-21 22:37:39 +0000 | [diff] [blame] | 5838 | errmsg = e_invarg; |
| 5839 | } |
Bram Moolenaar | 8aff23a | 2005-08-19 20:40:30 +0000 | [diff] [blame] | 5840 | /* 'mkspellmem' */ |
| 5841 | else if (varp == &p_msm) |
| 5842 | { |
| 5843 | if (spell_check_msm() != OK) |
| 5844 | errmsg = e_invarg; |
| 5845 | } |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 5846 | #endif |
| 5847 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5848 | #ifdef FEAT_QUICKFIX |
| 5849 | /* When 'bufhidden' is set, check for valid value. */ |
| 5850 | else if (gvarp == &p_bh) |
| 5851 | { |
| 5852 | if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK) |
| 5853 | errmsg = e_invarg; |
| 5854 | } |
| 5855 | |
| 5856 | /* When 'buftype' is set, check for valid value. */ |
| 5857 | else if (gvarp == &p_bt) |
| 5858 | { |
| 5859 | if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK) |
| 5860 | errmsg = e_invarg; |
| 5861 | else |
| 5862 | { |
| 5863 | # ifdef FEAT_WINDOWS |
| 5864 | if (curwin->w_status_height) |
| 5865 | { |
| 5866 | curwin->w_redr_status = TRUE; |
| 5867 | redraw_later(VALID); |
| 5868 | } |
| 5869 | # endif |
| 5870 | curbuf->b_help = (curbuf->b_p_bt[0] == 'h'); |
| 5871 | } |
| 5872 | } |
| 5873 | #endif |
| 5874 | |
| 5875 | #ifdef FEAT_STL_OPT |
| 5876 | /* 'statusline' or 'rulerformat' */ |
Bram Moolenaar | b5bf5b8 | 2004-12-24 14:35:23 +0000 | [diff] [blame] | 5877 | else if (gvarp == &p_stl || varp == &p_ruf) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5878 | { |
| 5879 | int wid; |
| 5880 | |
| 5881 | if (varp == &p_ruf) /* reset ru_wid first */ |
| 5882 | ru_wid = 0; |
| 5883 | s = *varp; |
| 5884 | if (varp == &p_ruf && *s == '%') |
| 5885 | { |
| 5886 | /* set ru_wid if 'ruf' starts with "%99(" */ |
| 5887 | if (*++s == '-') /* ignore a '-' */ |
| 5888 | s++; |
| 5889 | wid = getdigits(&s); |
| 5890 | if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL) |
| 5891 | ru_wid = wid; |
| 5892 | else |
| 5893 | errmsg = check_stl_option(p_ruf); |
| 5894 | } |
| 5895 | else |
| 5896 | errmsg = check_stl_option(s); |
Bram Moolenaar | b5bf5b8 | 2004-12-24 14:35:23 +0000 | [diff] [blame] | 5897 | if (varp == &p_ruf && errmsg == NULL) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5898 | comp_col(); |
| 5899 | } |
| 5900 | #endif |
| 5901 | |
| 5902 | #ifdef FEAT_INS_EXPAND |
| 5903 | /* check if it is a valid value for 'complete' -- Acevedo */ |
| 5904 | else if (gvarp == &p_cpt) |
| 5905 | { |
| 5906 | for (s = *varp; *s;) |
| 5907 | { |
| 5908 | while(*s == ',' || *s == ' ') |
| 5909 | s++; |
| 5910 | if (!*s) |
| 5911 | break; |
| 5912 | if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL) |
| 5913 | { |
| 5914 | errmsg = illegal_char(errbuf, *s); |
| 5915 | break; |
| 5916 | } |
| 5917 | if (*++s != NUL && *s != ',' && *s != ' ') |
| 5918 | { |
| 5919 | if (s[-1] == 'k' || s[-1] == 's') |
| 5920 | { |
| 5921 | /* skip optional filename after 'k' and 's' */ |
| 5922 | while (*s && *s != ',' && *s != ' ') |
| 5923 | { |
| 5924 | if (*s == '\\') |
| 5925 | ++s; |
| 5926 | ++s; |
| 5927 | } |
| 5928 | } |
| 5929 | else |
| 5930 | { |
| 5931 | if (errbuf != NULL) |
| 5932 | { |
| 5933 | sprintf((char *)errbuf, |
| 5934 | _("E535: Illegal character after <%c>"), |
| 5935 | *--s); |
| 5936 | errmsg = errbuf; |
| 5937 | } |
| 5938 | else |
| 5939 | errmsg = (char_u *)""; |
| 5940 | break; |
| 5941 | } |
| 5942 | } |
| 5943 | } |
| 5944 | } |
Bram Moolenaar | 1c7715d | 2005-10-03 22:02:18 +0000 | [diff] [blame] | 5945 | |
| 5946 | /* 'completeopt' */ |
| 5947 | else if (varp == &p_cot) |
| 5948 | { |
| 5949 | if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK) |
| 5950 | errmsg = e_invarg; |
| 5951 | } |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5952 | #endif /* FEAT_INS_EXPAND */ |
| 5953 | |
| 5954 | |
| 5955 | #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) |
| 5956 | else if (varp == &p_toolbar) |
| 5957 | { |
| 5958 | if (opt_strings_flags(p_toolbar, p_toolbar_values, |
| 5959 | &toolbar_flags, TRUE) != OK) |
| 5960 | errmsg = e_invarg; |
| 5961 | else |
| 5962 | { |
| 5963 | out_flush(); |
| 5964 | gui_mch_show_toolbar((toolbar_flags & |
| 5965 | (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0); |
| 5966 | } |
| 5967 | } |
| 5968 | #endif |
| 5969 | |
| 5970 | #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2) |
| 5971 | /* 'toolbariconsize': GTK+ 2 only */ |
| 5972 | else if (varp == &p_tbis) |
| 5973 | { |
| 5974 | if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK) |
| 5975 | errmsg = e_invarg; |
| 5976 | else |
| 5977 | { |
| 5978 | out_flush(); |
| 5979 | gui_mch_show_toolbar((toolbar_flags & |
| 5980 | (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0); |
| 5981 | } |
| 5982 | } |
| 5983 | #endif |
| 5984 | |
| 5985 | /* 'pastetoggle': translate key codes like in a mapping */ |
| 5986 | else if (varp == &p_pt) |
| 5987 | { |
| 5988 | if (*p_pt) |
| 5989 | { |
| 5990 | (void)replace_termcodes(p_pt, &p, TRUE, TRUE); |
| 5991 | if (p != NULL) |
| 5992 | { |
| 5993 | if (new_value_alloced) |
| 5994 | free_string_option(p_pt); |
| 5995 | p_pt = p; |
| 5996 | new_value_alloced = TRUE; |
| 5997 | } |
| 5998 | } |
| 5999 | } |
| 6000 | |
| 6001 | /* 'backspace' */ |
| 6002 | else if (varp == &p_bs) |
| 6003 | { |
| 6004 | if (VIM_ISDIGIT(*p_bs)) |
| 6005 | { |
| 6006 | if (*p_bs >'2' || p_bs[1] != NUL) |
| 6007 | errmsg = e_invarg; |
| 6008 | } |
| 6009 | else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK) |
| 6010 | errmsg = e_invarg; |
| 6011 | } |
| 6012 | |
| 6013 | /* 'casemap' */ |
| 6014 | else if (varp == &p_cmp) |
| 6015 | { |
| 6016 | if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK) |
| 6017 | errmsg = e_invarg; |
| 6018 | } |
| 6019 | |
| 6020 | #ifdef FEAT_DIFF |
| 6021 | /* 'diffopt' */ |
| 6022 | else if (varp == &p_dip) |
| 6023 | { |
| 6024 | if (diffopt_changed() == FAIL) |
| 6025 | errmsg = e_invarg; |
| 6026 | } |
| 6027 | #endif |
| 6028 | |
| 6029 | #ifdef FEAT_FOLDING |
| 6030 | /* 'foldmethod' */ |
| 6031 | else if (gvarp == &curwin->w_allbuf_opt.wo_fdm) |
| 6032 | { |
| 6033 | if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK |
| 6034 | || *curwin->w_p_fdm == NUL) |
| 6035 | errmsg = e_invarg; |
| 6036 | else |
| 6037 | foldUpdateAll(curwin); |
| 6038 | } |
| 6039 | # ifdef FEAT_EVAL |
| 6040 | /* 'foldexpr' */ |
| 6041 | else if (varp == &curwin->w_p_fde) |
| 6042 | { |
| 6043 | if (foldmethodIsExpr(curwin)) |
| 6044 | foldUpdateAll(curwin); |
| 6045 | } |
| 6046 | # endif |
| 6047 | /* 'foldmarker' */ |
| 6048 | else if (gvarp == &curwin->w_allbuf_opt.wo_fmr) |
| 6049 | { |
| 6050 | p = vim_strchr(*varp, ','); |
| 6051 | if (p == NULL) |
| 6052 | errmsg = (char_u *)N_("E536: comma required"); |
| 6053 | else if (p == *varp || p[1] == NUL) |
| 6054 | errmsg = e_invarg; |
| 6055 | else if (foldmethodIsMarker(curwin)) |
| 6056 | foldUpdateAll(curwin); |
| 6057 | } |
| 6058 | /* 'commentstring' */ |
| 6059 | else if (gvarp == &p_cms) |
| 6060 | { |
| 6061 | if (**varp != NUL && strstr((char *)*varp, "%s") == NULL) |
| 6062 | errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s"); |
| 6063 | } |
| 6064 | /* 'foldopen' */ |
| 6065 | else if (varp == &p_fdo) |
| 6066 | { |
| 6067 | if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK) |
| 6068 | errmsg = e_invarg; |
| 6069 | } |
| 6070 | /* 'foldclose' */ |
| 6071 | else if (varp == &p_fcl) |
| 6072 | { |
| 6073 | if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK) |
| 6074 | errmsg = e_invarg; |
| 6075 | } |
| 6076 | #endif |
| 6077 | |
| 6078 | #ifdef FEAT_VIRTUALEDIT |
| 6079 | /* 'virtualedit' */ |
| 6080 | else if (varp == &p_ve) |
| 6081 | { |
| 6082 | if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK) |
| 6083 | errmsg = e_invarg; |
| 6084 | else if (STRCMP(p_ve, oldval) != 0) |
| 6085 | { |
| 6086 | /* Recompute cursor position in case the new 've' setting |
| 6087 | * changes something. */ |
| 6088 | validate_virtcol(); |
| 6089 | coladvance(curwin->w_virtcol); |
| 6090 | } |
| 6091 | } |
| 6092 | #endif |
| 6093 | |
| 6094 | #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX) |
| 6095 | else if (varp == &p_csqf) |
| 6096 | { |
| 6097 | if (p_csqf != NULL) |
| 6098 | { |
| 6099 | p = p_csqf; |
| 6100 | while (*p != NUL) |
| 6101 | { |
| 6102 | if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL |
| 6103 | || p[1] == NUL |
| 6104 | || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL |
| 6105 | || (p[2] != NUL && p[2] != ',')) |
| 6106 | { |
| 6107 | errmsg = e_invarg; |
| 6108 | break; |
| 6109 | } |
| 6110 | else if (p[2] == NUL) |
| 6111 | break; |
| 6112 | else |
| 6113 | p += 3; |
| 6114 | } |
| 6115 | } |
| 6116 | } |
| 6117 | #endif |
| 6118 | |
| 6119 | /* Options that are a list of flags. */ |
| 6120 | else |
| 6121 | { |
| 6122 | p = NULL; |
| 6123 | if (varp == &p_ww) |
| 6124 | p = (char_u *)WW_ALL; |
| 6125 | if (varp == &p_shm) |
| 6126 | p = (char_u *)SHM_ALL; |
| 6127 | else if (varp == &(p_cpo)) |
| 6128 | p = (char_u *)CPO_ALL; |
| 6129 | else if (varp == &(curbuf->b_p_fo)) |
| 6130 | p = (char_u *)FO_ALL; |
| 6131 | else if (varp == &p_mouse) |
| 6132 | { |
| 6133 | #ifdef FEAT_MOUSE |
| 6134 | p = (char_u *)MOUSE_ALL; |
| 6135 | #else |
| 6136 | if (*p_mouse != NUL) |
| 6137 | errmsg = (char_u *)N_("E538: No mouse support"); |
| 6138 | #endif |
| 6139 | } |
| 6140 | #if defined(FEAT_GUI) |
| 6141 | else if (varp == &p_go) |
| 6142 | p = (char_u *)GO_ALL; |
| 6143 | #endif |
| 6144 | if (p != NULL) |
| 6145 | { |
| 6146 | for (s = *varp; *s; ++s) |
| 6147 | if (vim_strchr(p, *s) == NULL) |
| 6148 | { |
| 6149 | errmsg = illegal_char(errbuf, *s); |
| 6150 | break; |
| 6151 | } |
| 6152 | } |
| 6153 | } |
| 6154 | |
| 6155 | /* |
| 6156 | * If error detected, restore the previous value. |
| 6157 | */ |
| 6158 | if (errmsg != NULL) |
| 6159 | { |
| 6160 | if (new_value_alloced) |
| 6161 | free_string_option(*varp); |
| 6162 | *varp = oldval; |
| 6163 | /* |
| 6164 | * When resetting some values, need to act on it. |
| 6165 | */ |
| 6166 | if (did_chartab) |
| 6167 | (void)init_chartab(); |
| 6168 | if (varp == &p_hl) |
| 6169 | (void)highlight_changed(); |
| 6170 | } |
| 6171 | else |
| 6172 | { |
| 6173 | #ifdef FEAT_EVAL |
| 6174 | /* Remember where the option was set. */ |
| 6175 | options[opt_idx].scriptID = current_SID; |
| 6176 | #endif |
| 6177 | /* |
| 6178 | * Free string options that are in allocated memory. |
Bram Moolenaar | c0197e2 | 2004-09-13 20:26:32 +0000 | [diff] [blame] | 6179 | * Use "free_oldval", because recursiveness may change the flags under |
| 6180 | * our fingers (esp. init_highlight()). |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6181 | */ |
Bram Moolenaar | c0197e2 | 2004-09-13 20:26:32 +0000 | [diff] [blame] | 6182 | if (free_oldval) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6183 | free_string_option(oldval); |
| 6184 | if (new_value_alloced) |
| 6185 | options[opt_idx].flags |= P_ALLOCED; |
| 6186 | else |
| 6187 | options[opt_idx].flags &= ~P_ALLOCED; |
| 6188 | |
| 6189 | if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
| 6190 | && (int)options[opt_idx].indir >= PV_BOTH) |
| 6191 | { |
| 6192 | /* global option with local value set to use global value; free |
| 6193 | * the local value and make it empty */ |
| 6194 | p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL); |
| 6195 | free_string_option(*(char_u **)p); |
| 6196 | *(char_u **)p = empty_option; |
| 6197 | } |
| 6198 | |
| 6199 | /* May set global value for local option. */ |
| 6200 | else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL) |
| 6201 | set_string_option_global(opt_idx, varp); |
Bram Moolenaar | 90cfdbe | 2005-08-12 19:59:19 +0000 | [diff] [blame] | 6202 | |
| 6203 | #ifdef FEAT_AUTOCMD |
| 6204 | /* |
| 6205 | * Trigger the autocommand only after setting the flags. |
| 6206 | */ |
| 6207 | # ifdef FEAT_SYN_HL |
| 6208 | /* When 'syntax' is set, load the syntax of that name */ |
| 6209 | if (varp == &(curbuf->b_p_syn)) |
| 6210 | { |
| 6211 | apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, |
| 6212 | curbuf->b_fname, TRUE, curbuf); |
| 6213 | } |
| 6214 | # endif |
| 6215 | else if (varp == &(curbuf->b_p_ft)) |
| 6216 | { |
| 6217 | /* 'filetype' is set, trigger the FileType autocommand */ |
| 6218 | did_filetype = TRUE; |
| 6219 | apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, |
| 6220 | curbuf->b_fname, TRUE, curbuf); |
| 6221 | } |
| 6222 | #endif |
| 6223 | #ifdef FEAT_SYN_HL |
| 6224 | if (varp == &(curbuf->b_p_spl)) |
| 6225 | { |
| 6226 | char_u fname[200]; |
| 6227 | |
| 6228 | /* |
| 6229 | * Source the spell/LANG.vim in 'runtimepath'. |
| 6230 | * They could set 'spellcapcheck' depending on the language. |
| 6231 | * Use the first name in 'spelllang' up to '_region' or |
| 6232 | * '.encoding'. |
| 6233 | */ |
| 6234 | for (p = curbuf->b_p_spl; *p != NUL; ++p) |
| 6235 | if (vim_strchr((char_u *)"_.,", *p) != NULL) |
| 6236 | break; |
| 6237 | vim_snprintf((char *)fname, 200, "spell/%.*s.vim", |
| 6238 | (int)(p - curbuf->b_p_spl), curbuf->b_p_spl); |
| 6239 | source_runtime(fname, TRUE); |
| 6240 | } |
| 6241 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6242 | } |
| 6243 | |
| 6244 | #ifdef FEAT_MOUSE |
| 6245 | if (varp == &p_mouse) |
| 6246 | { |
| 6247 | # ifdef FEAT_MOUSE_TTY |
| 6248 | if (*p_mouse == NUL) |
| 6249 | mch_setmouse(FALSE); /* switch mouse off */ |
| 6250 | else |
| 6251 | # endif |
| 6252 | setmouse(); /* in case 'mouse' changed */ |
| 6253 | } |
| 6254 | #endif |
| 6255 | |
| 6256 | if (curwin->w_curswant != MAXCOL) |
| 6257 | curwin->w_set_curswant = TRUE; /* in case 'showbreak' changed */ |
| 6258 | check_redraw(options[opt_idx].flags); |
| 6259 | |
| 6260 | return errmsg; |
| 6261 | } |
| 6262 | |
| 6263 | /* |
| 6264 | * Handle setting 'listchars' or 'fillchars'. |
| 6265 | * Returns error message, NULL if it's OK. |
| 6266 | */ |
| 6267 | static char_u * |
| 6268 | set_chars_option(varp) |
| 6269 | char_u **varp; |
| 6270 | { |
| 6271 | int round, i, len, entries; |
| 6272 | char_u *p, *s; |
| 6273 | int c1, c2 = 0; |
| 6274 | struct charstab |
| 6275 | { |
| 6276 | int *cp; |
| 6277 | char *name; |
| 6278 | }; |
| 6279 | #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
| 6280 | static struct charstab filltab[] = |
| 6281 | { |
| 6282 | {&fill_stl, "stl"}, |
| 6283 | {&fill_stlnc, "stlnc"}, |
| 6284 | {&fill_vert, "vert"}, |
| 6285 | {&fill_fold, "fold"}, |
| 6286 | {&fill_diff, "diff"}, |
| 6287 | }; |
| 6288 | #endif |
| 6289 | static struct charstab lcstab[] = |
| 6290 | { |
| 6291 | {&lcs_eol, "eol"}, |
| 6292 | {&lcs_ext, "extends"}, |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 6293 | {&lcs_nbsp, "nbsp"}, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6294 | {&lcs_prec, "precedes"}, |
| 6295 | {&lcs_tab2, "tab"}, |
| 6296 | {&lcs_trail, "trail"}, |
| 6297 | }; |
| 6298 | struct charstab *tab; |
| 6299 | |
| 6300 | #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
| 6301 | if (varp == &p_lcs) |
| 6302 | #endif |
| 6303 | { |
| 6304 | tab = lcstab; |
| 6305 | entries = sizeof(lcstab) / sizeof(struct charstab); |
| 6306 | } |
| 6307 | #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
| 6308 | else |
| 6309 | { |
| 6310 | tab = filltab; |
| 6311 | entries = sizeof(filltab) / sizeof(struct charstab); |
| 6312 | } |
| 6313 | #endif |
| 6314 | |
| 6315 | /* first round: check for valid value, second round: assign values */ |
| 6316 | for (round = 0; round <= 1; ++round) |
| 6317 | { |
| 6318 | if (round) |
| 6319 | { |
| 6320 | /* After checking that the value is valid: set defaults: space for |
| 6321 | * 'fillchars', NUL for 'listchars' */ |
| 6322 | for (i = 0; i < entries; ++i) |
| 6323 | *(tab[i].cp) = (varp == &p_lcs ? NUL : ' '); |
| 6324 | if (varp == &p_lcs) |
| 6325 | lcs_tab1 = NUL; |
| 6326 | #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) |
| 6327 | else |
| 6328 | fill_diff = '-'; |
| 6329 | #endif |
| 6330 | } |
| 6331 | p = *varp; |
| 6332 | while (*p) |
| 6333 | { |
| 6334 | for (i = 0; i < entries; ++i) |
| 6335 | { |
| 6336 | len = (int)STRLEN(tab[i].name); |
| 6337 | if (STRNCMP(p, tab[i].name, len) == 0 |
| 6338 | && p[len] == ':' |
| 6339 | && p[len + 1] != NUL) |
| 6340 | { |
| 6341 | s = p + len + 1; |
| 6342 | #ifdef FEAT_MBYTE |
| 6343 | c1 = mb_ptr2char_adv(&s); |
| 6344 | #else |
| 6345 | c1 = *s++; |
| 6346 | #endif |
| 6347 | if (tab[i].cp == &lcs_tab2) |
| 6348 | { |
| 6349 | if (*s == NUL) |
| 6350 | continue; |
| 6351 | #ifdef FEAT_MBYTE |
| 6352 | c2 = mb_ptr2char_adv(&s); |
| 6353 | #else |
| 6354 | c2 = *s++; |
| 6355 | #endif |
| 6356 | } |
| 6357 | if (*s == ',' || *s == NUL) |
| 6358 | { |
| 6359 | if (round) |
| 6360 | { |
| 6361 | if (tab[i].cp == &lcs_tab2) |
| 6362 | { |
| 6363 | lcs_tab1 = c1; |
| 6364 | lcs_tab2 = c2; |
| 6365 | } |
| 6366 | else |
| 6367 | *(tab[i].cp) = c1; |
| 6368 | |
| 6369 | } |
| 6370 | p = s; |
| 6371 | break; |
| 6372 | } |
| 6373 | } |
| 6374 | } |
| 6375 | |
| 6376 | if (i == entries) |
| 6377 | return e_invarg; |
| 6378 | if (*p == ',') |
| 6379 | ++p; |
| 6380 | } |
| 6381 | } |
| 6382 | |
| 6383 | return NULL; /* no error */ |
| 6384 | } |
| 6385 | |
| 6386 | #ifdef FEAT_STL_OPT |
| 6387 | /* |
| 6388 | * Check validity of options with the 'statusline' format. |
| 6389 | * Return error message or NULL. |
| 6390 | */ |
| 6391 | char_u * |
| 6392 | check_stl_option(s) |
| 6393 | char_u *s; |
| 6394 | { |
| 6395 | int itemcnt = 0; |
| 6396 | int groupdepth = 0; |
| 6397 | static char_u errbuf[80]; |
| 6398 | |
| 6399 | while (*s && itemcnt < STL_MAX_ITEM) |
| 6400 | { |
| 6401 | /* Check for valid keys after % sequences */ |
| 6402 | while (*s && *s != '%') |
| 6403 | s++; |
| 6404 | if (!*s) |
| 6405 | break; |
| 6406 | s++; |
| 6407 | if (*s != '%' && *s != ')') |
| 6408 | ++itemcnt; |
| 6409 | if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK) |
| 6410 | { |
| 6411 | s++; |
| 6412 | continue; |
| 6413 | } |
| 6414 | if (*s == ')') |
| 6415 | { |
| 6416 | s++; |
| 6417 | if (--groupdepth < 0) |
| 6418 | break; |
| 6419 | continue; |
| 6420 | } |
| 6421 | if (*s == '-') |
| 6422 | s++; |
| 6423 | while (VIM_ISDIGIT(*s)) |
| 6424 | s++; |
| 6425 | if (*s == STL_HIGHLIGHT) |
| 6426 | continue; |
| 6427 | if (*s == '.') |
| 6428 | { |
| 6429 | s++; |
| 6430 | while (*s && VIM_ISDIGIT(*s)) |
| 6431 | s++; |
| 6432 | } |
| 6433 | if (*s == '(') |
| 6434 | { |
| 6435 | groupdepth++; |
| 6436 | continue; |
| 6437 | } |
| 6438 | if (vim_strchr(STL_ALL, *s) == NULL) |
| 6439 | { |
| 6440 | return illegal_char(errbuf, *s); |
| 6441 | } |
| 6442 | if (*s == '{') |
| 6443 | { |
| 6444 | s++; |
| 6445 | while (*s != '}' && *s) |
| 6446 | s++; |
| 6447 | if (*s != '}') |
| 6448 | return (char_u *)N_("E540: Unclosed expression sequence"); |
| 6449 | } |
| 6450 | } |
| 6451 | if (itemcnt >= STL_MAX_ITEM) |
| 6452 | return (char_u *)N_("E541: too many items"); |
| 6453 | if (groupdepth != 0) |
| 6454 | return (char_u *)N_("E542: unbalanced groups"); |
| 6455 | return NULL; |
| 6456 | } |
| 6457 | #endif |
| 6458 | |
| 6459 | #ifdef FEAT_CLIPBOARD |
| 6460 | /* |
| 6461 | * Extract the items in the 'clipboard' option and set global values. |
| 6462 | */ |
| 6463 | static char_u * |
| 6464 | check_clipboard_option() |
| 6465 | { |
| 6466 | int new_unnamed = FALSE; |
| 6467 | int new_autoselect = FALSE; |
| 6468 | int new_autoselectml = FALSE; |
| 6469 | regprog_T *new_exclude_prog = NULL; |
| 6470 | char_u *errmsg = NULL; |
| 6471 | char_u *p; |
| 6472 | |
| 6473 | for (p = p_cb; *p != NUL; ) |
| 6474 | { |
| 6475 | if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL)) |
| 6476 | { |
| 6477 | new_unnamed = TRUE; |
| 6478 | p += 7; |
| 6479 | } |
| 6480 | else if (STRNCMP(p, "autoselect", 10) == 0 |
| 6481 | && (p[10] == ',' || p[10] == NUL)) |
| 6482 | { |
| 6483 | new_autoselect = TRUE; |
| 6484 | p += 10; |
| 6485 | } |
| 6486 | else if (STRNCMP(p, "autoselectml", 12) == 0 |
| 6487 | && (p[12] == ',' || p[12] == NUL)) |
| 6488 | { |
| 6489 | new_autoselectml = TRUE; |
| 6490 | p += 12; |
| 6491 | } |
| 6492 | else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL) |
| 6493 | { |
| 6494 | p += 8; |
| 6495 | new_exclude_prog = vim_regcomp(p, RE_MAGIC); |
| 6496 | if (new_exclude_prog == NULL) |
| 6497 | errmsg = e_invarg; |
| 6498 | break; |
| 6499 | } |
| 6500 | else |
| 6501 | { |
| 6502 | errmsg = e_invarg; |
| 6503 | break; |
| 6504 | } |
| 6505 | if (*p == ',') |
| 6506 | ++p; |
| 6507 | } |
| 6508 | if (errmsg == NULL) |
| 6509 | { |
| 6510 | clip_unnamed = new_unnamed; |
| 6511 | clip_autoselect = new_autoselect; |
| 6512 | clip_autoselectml = new_autoselectml; |
| 6513 | vim_free(clip_exclude_prog); |
| 6514 | clip_exclude_prog = new_exclude_prog; |
| 6515 | } |
| 6516 | else |
| 6517 | vim_free(new_exclude_prog); |
| 6518 | |
| 6519 | return errmsg; |
| 6520 | } |
| 6521 | #endif |
| 6522 | |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 6523 | #ifdef FEAT_SYN_HL |
| 6524 | /* |
| 6525 | * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'. |
| 6526 | * Return error message when failed, NULL when OK. |
| 6527 | */ |
| 6528 | static char_u * |
Bram Moolenaar | 0dc065e | 2005-07-04 22:49:24 +0000 | [diff] [blame] | 6529 | compile_cap_prog(buf) |
| 6530 | buf_T *buf; |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 6531 | { |
Bram Moolenaar | 0dc065e | 2005-07-04 22:49:24 +0000 | [diff] [blame] | 6532 | regprog_T *rp = buf->b_cap_prog; |
Bram Moolenaar | 18f9a79 | 2005-12-08 22:02:51 +0000 | [diff] [blame] | 6533 | char_u *re; |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 6534 | |
Bram Moolenaar | 0dc065e | 2005-07-04 22:49:24 +0000 | [diff] [blame] | 6535 | if (*buf->b_p_spc == NUL) |
Bram Moolenaar | 0dc065e | 2005-07-04 22:49:24 +0000 | [diff] [blame] | 6536 | buf->b_cap_prog = NULL; |
Bram Moolenaar | 18f9a79 | 2005-12-08 22:02:51 +0000 | [diff] [blame] | 6537 | else |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 6538 | { |
Bram Moolenaar | 18f9a79 | 2005-12-08 22:02:51 +0000 | [diff] [blame] | 6539 | /* Prepend a ^ so that we only match at one column */ |
| 6540 | re = concat_str((char_u *)"^", buf->b_p_spc); |
| 6541 | if (re != NULL) |
| 6542 | { |
| 6543 | buf->b_cap_prog = vim_regcomp(re, RE_MAGIC); |
| 6544 | if (buf->b_cap_prog == NULL) |
| 6545 | { |
| 6546 | buf->b_cap_prog = rp; /* restore the previous program */ |
| 6547 | return e_invarg; |
| 6548 | } |
| 6549 | vim_free(re); |
| 6550 | } |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 6551 | } |
| 6552 | |
| 6553 | vim_free(rp); |
| 6554 | return NULL; |
| 6555 | } |
| 6556 | #endif |
| 6557 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6558 | /* |
| 6559 | * Set the value of a boolean option, and take care of side effects. |
| 6560 | * Returns NULL for success, or an error message for an error. |
| 6561 | */ |
| 6562 | static char_u * |
| 6563 | set_bool_option(opt_idx, varp, value, opt_flags) |
| 6564 | int opt_idx; /* index in options[] table */ |
| 6565 | char_u *varp; /* pointer to the option variable */ |
| 6566 | int value; /* new value */ |
| 6567 | int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ |
| 6568 | { |
| 6569 | int old_value = *(int *)varp; |
| 6570 | |
| 6571 | #ifdef FEAT_GUI |
| 6572 | need_mouse_correct = TRUE; |
| 6573 | #endif |
| 6574 | |
| 6575 | /* Disallow changing some options from secure mode */ |
| 6576 | if ((secure |
| 6577 | #ifdef HAVE_SANDBOX |
| 6578 | || sandbox != 0 |
| 6579 | #endif |
| 6580 | ) && (options[opt_idx].flags & P_SECURE)) |
| 6581 | return e_secure; |
| 6582 | |
| 6583 | *(int *)varp = value; /* set the new value */ |
| 6584 | #ifdef FEAT_EVAL |
| 6585 | /* Remember where the option was set. */ |
| 6586 | options[opt_idx].scriptID = current_SID; |
| 6587 | #endif |
| 6588 | |
| 6589 | /* May set global value for local option. */ |
| 6590 | if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
| 6591 | *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; |
| 6592 | |
| 6593 | /* |
| 6594 | * Handle side effects of changing a bool option. |
| 6595 | */ |
| 6596 | |
| 6597 | /* 'compatible' */ |
| 6598 | if ((int *)varp == &p_cp) |
| 6599 | { |
| 6600 | compatible_set(); |
| 6601 | } |
| 6602 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6603 | else if ((int *)varp == &curbuf->b_p_ro) |
| 6604 | { |
Bram Moolenaar | d5cdbeb | 2005-10-10 20:59:28 +0000 | [diff] [blame] | 6605 | /* when 'readonly' is reset globally, also reset readonlymode */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6606 | if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) |
| 6607 | readonlymode = FALSE; |
Bram Moolenaar | d5cdbeb | 2005-10-10 20:59:28 +0000 | [diff] [blame] | 6608 | |
| 6609 | /* when 'readonly' is set may give W10 again */ |
| 6610 | if (curbuf->b_p_ro) |
| 6611 | curbuf->b_did_warn = FALSE; |
| 6612 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6613 | #ifdef FEAT_TITLE |
| 6614 | need_maketitle = TRUE; |
| 6615 | #endif |
| 6616 | } |
| 6617 | |
| 6618 | #ifdef FEAT_TITLE |
| 6619 | /* when 'modifiable' is changed, redraw the window title */ |
| 6620 | else if ((int *)varp == &curbuf->b_p_ma) |
| 6621 | need_maketitle = TRUE; |
| 6622 | /* when 'endofline' is changed, redraw the window title */ |
| 6623 | else if ((int *)varp == &curbuf->b_p_eol) |
| 6624 | need_maketitle = TRUE; |
| 6625 | #endif |
| 6626 | |
| 6627 | /* when 'bin' is set also set some other options */ |
| 6628 | else if ((int *)varp == &curbuf->b_p_bin) |
| 6629 | { |
| 6630 | set_options_bin(old_value, curbuf->b_p_bin, opt_flags); |
| 6631 | #ifdef FEAT_TITLE |
| 6632 | need_maketitle = TRUE; |
| 6633 | #endif |
| 6634 | } |
| 6635 | |
| 6636 | #ifdef FEAT_AUTOCMD |
| 6637 | /* when 'buflisted' changes, trigger autocommands */ |
| 6638 | else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) |
| 6639 | { |
| 6640 | apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, |
| 6641 | NULL, NULL, TRUE, curbuf); |
| 6642 | } |
| 6643 | #endif |
| 6644 | |
| 6645 | /* when 'swf' is set, create swapfile, when reset remove swapfile */ |
| 6646 | else if ((int *)varp == &curbuf->b_p_swf) |
| 6647 | { |
| 6648 | if (curbuf->b_p_swf && p_uc) |
| 6649 | ml_open_file(curbuf); /* create the swap file */ |
| 6650 | else |
| 6651 | mf_close_file(curbuf, TRUE); /* remove the swap file */ |
| 6652 | } |
| 6653 | |
| 6654 | /* when 'terse' is set change 'shortmess' */ |
| 6655 | else if ((int *)varp == &p_terse) |
| 6656 | { |
| 6657 | char_u *p; |
| 6658 | |
| 6659 | p = vim_strchr(p_shm, SHM_SEARCH); |
| 6660 | |
| 6661 | /* insert 's' in p_shm */ |
| 6662 | if (p_terse && p == NULL) |
| 6663 | { |
| 6664 | STRCPY(IObuff, p_shm); |
| 6665 | STRCAT(IObuff, "s"); |
| 6666 | set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE); |
| 6667 | } |
| 6668 | /* remove 's' from p_shm */ |
| 6669 | else if (!p_terse && p != NULL) |
| 6670 | mch_memmove(p, p + 1, STRLEN(p)); |
| 6671 | } |
| 6672 | |
| 6673 | /* when 'paste' is set or reset also change other options */ |
| 6674 | else if ((int *)varp == &p_paste) |
| 6675 | { |
| 6676 | paste_option_changed(); |
| 6677 | } |
| 6678 | |
| 6679 | /* when 'insertmode' is set from an autocommand need to do work here */ |
| 6680 | else if ((int *)varp == &p_im) |
| 6681 | { |
| 6682 | if (p_im) |
| 6683 | { |
| 6684 | if ((State & INSERT) == 0) |
| 6685 | need_start_insertmode = TRUE; |
| 6686 | stop_insert_mode = FALSE; |
| 6687 | } |
| 6688 | else |
| 6689 | { |
| 6690 | need_start_insertmode = FALSE; |
| 6691 | stop_insert_mode = TRUE; |
| 6692 | if (p_smd && restart_edit != 0) |
| 6693 | clear_cmdline = TRUE; /* remove "(insert)" */ |
| 6694 | restart_edit = 0; |
| 6695 | } |
| 6696 | } |
| 6697 | |
| 6698 | /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */ |
| 6699 | else if ((int *)varp == &p_ic && p_hls) |
| 6700 | { |
| 6701 | redraw_all_later(NOT_VALID); |
| 6702 | } |
| 6703 | |
| 6704 | #ifdef FEAT_SEARCH_EXTRA |
| 6705 | /* when 'hlsearch' is set or reset: reset no_hlsearch */ |
| 6706 | else if ((int *)varp == &p_hls) |
| 6707 | { |
| 6708 | no_hlsearch = FALSE; |
| 6709 | } |
| 6710 | #endif |
| 6711 | |
| 6712 | #ifdef FEAT_SCROLLBIND |
| 6713 | /* when 'scrollbind' is set: snapshot the current position to avoid a jump |
| 6714 | * at the end of normal_cmd() */ |
| 6715 | else if ((int *)varp == &curwin->w_p_scb) |
| 6716 | { |
| 6717 | if (curwin->w_p_scb) |
| 6718 | do_check_scrollbind(FALSE); |
| 6719 | } |
| 6720 | #endif |
| 6721 | |
| 6722 | #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) |
| 6723 | /* There can be only one window with 'previewwindow' set. */ |
| 6724 | else if ((int *)varp == &curwin->w_p_pvw) |
| 6725 | { |
| 6726 | if (curwin->w_p_pvw) |
| 6727 | { |
| 6728 | win_T *win; |
| 6729 | |
| 6730 | for (win = firstwin; win != NULL; win = win->w_next) |
| 6731 | if (win->w_p_pvw && win != curwin) |
| 6732 | { |
| 6733 | curwin->w_p_pvw = FALSE; |
| 6734 | return (char_u *)N_("E590: A preview window already exists"); |
| 6735 | } |
| 6736 | } |
| 6737 | } |
| 6738 | #endif |
| 6739 | |
| 6740 | /* when 'textmode' is set or reset also change 'fileformat' */ |
| 6741 | else if ((int *)varp == &curbuf->b_p_tx) |
| 6742 | { |
| 6743 | set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); |
| 6744 | } |
| 6745 | |
| 6746 | /* when 'textauto' is set or reset also change 'fileformats' */ |
| 6747 | else if ((int *)varp == &p_ta) |
| 6748 | { |
| 6749 | set_string_option_direct((char_u *)"ffs", -1, |
| 6750 | p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", |
| 6751 | OPT_FREE | opt_flags); |
| 6752 | } |
| 6753 | |
| 6754 | /* |
| 6755 | * When 'lisp' option changes include/exclude '-' in |
| 6756 | * keyword characters. |
| 6757 | */ |
| 6758 | #ifdef FEAT_LISP |
| 6759 | else if (varp == (char_u *)&(curbuf->b_p_lisp)) |
| 6760 | { |
| 6761 | (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */ |
| 6762 | } |
| 6763 | #endif |
| 6764 | |
| 6765 | #ifdef FEAT_TITLE |
| 6766 | /* when 'title' changed, may need to change the title; same for 'icon' */ |
| 6767 | else if ((int *)varp == &p_title) |
| 6768 | { |
| 6769 | did_set_title(FALSE); |
| 6770 | } |
| 6771 | |
| 6772 | else if ((int *)varp == &p_icon) |
| 6773 | { |
| 6774 | did_set_title(TRUE); |
| 6775 | } |
| 6776 | #endif |
| 6777 | |
| 6778 | else if ((int *)varp == &curbuf->b_changed) |
| 6779 | { |
| 6780 | if (!value) |
| 6781 | save_file_ff(curbuf); /* Buffer is unchanged */ |
| 6782 | #ifdef FEAT_TITLE |
| 6783 | need_maketitle = TRUE; |
| 6784 | #endif |
| 6785 | #ifdef FEAT_AUTOCMD |
| 6786 | modified_was_set = value; |
| 6787 | #endif |
| 6788 | } |
| 6789 | |
| 6790 | #ifdef BACKSLASH_IN_FILENAME |
| 6791 | else if ((int *)varp == &p_ssl) |
| 6792 | { |
| 6793 | if (p_ssl) |
| 6794 | { |
| 6795 | psepc = '/'; |
| 6796 | psepcN = '\\'; |
| 6797 | pseps[0] = '/'; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6798 | } |
| 6799 | else |
| 6800 | { |
| 6801 | psepc = '\\'; |
| 6802 | psepcN = '/'; |
| 6803 | pseps[0] = '\\'; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6804 | } |
| 6805 | |
| 6806 | /* need to adjust the file name arguments and buffer names. */ |
| 6807 | buflist_slash_adjust(); |
| 6808 | alist_slash_adjust(); |
| 6809 | # ifdef FEAT_EVAL |
| 6810 | scriptnames_slash_adjust(); |
| 6811 | # endif |
| 6812 | } |
| 6813 | #endif |
| 6814 | |
| 6815 | /* If 'wrap' is set, set w_leftcol to zero. */ |
| 6816 | else if ((int *)varp == &curwin->w_p_wrap) |
| 6817 | { |
| 6818 | if (curwin->w_p_wrap) |
| 6819 | curwin->w_leftcol = 0; |
| 6820 | } |
| 6821 | |
| 6822 | #ifdef FEAT_WINDOWS |
| 6823 | else if ((int *)varp == &p_ea) |
| 6824 | { |
| 6825 | if (p_ea && !old_value) |
| 6826 | win_equal(curwin, FALSE, 0); |
| 6827 | } |
| 6828 | #endif |
| 6829 | |
| 6830 | else if ((int *)varp == &p_wiv) |
| 6831 | { |
| 6832 | /* |
| 6833 | * When 'weirdinvert' changed, set/reset 't_xs'. |
| 6834 | * Then set 'weirdinvert' according to value of 't_xs'. |
| 6835 | */ |
| 6836 | if (p_wiv && !old_value) |
| 6837 | T_XS = (char_u *)"y"; |
| 6838 | else if (!p_wiv && old_value) |
| 6839 | T_XS = empty_option; |
| 6840 | p_wiv = (*T_XS != NUL); |
| 6841 | } |
| 6842 | |
Bram Moolenaar | f1f8bc5 | 2005-03-07 23:20:08 +0000 | [diff] [blame] | 6843 | #ifdef FEAT_BEVAL |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6844 | else if ((int *)varp == &p_beval) |
| 6845 | { |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6846 | if (p_beval == TRUE) |
| 6847 | gui_mch_enable_beval_area(balloonEval); |
| 6848 | else |
| 6849 | gui_mch_disable_beval_area(balloonEval); |
| 6850 | } |
| 6851 | |
Bram Moolenaar | f1f8bc5 | 2005-03-07 23:20:08 +0000 | [diff] [blame] | 6852 | # if defined(FEAT_NETBEANS_INTG) || defined(FEAT_SUN_WORKSHOP) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6853 | else if ((int *)varp == &p_acd) |
| 6854 | { |
| 6855 | if (p_acd && curbuf->b_ffname != NULL |
| 6856 | && vim_chdirfile(curbuf->b_ffname) == OK) |
| 6857 | shorten_fnames(TRUE); |
| 6858 | } |
Bram Moolenaar | f1f8bc5 | 2005-03-07 23:20:08 +0000 | [diff] [blame] | 6859 | # endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6860 | #endif |
| 6861 | |
| 6862 | #ifdef FEAT_DIFF |
| 6863 | /* 'diff' */ |
| 6864 | else if ((int *)varp == &curwin->w_p_diff) |
| 6865 | { |
Bram Moolenaar | 2df6dcc | 2004-07-12 15:53:54 +0000 | [diff] [blame] | 6866 | /* May add or remove the buffer from the list of diff buffers. */ |
| 6867 | diff_buf_adjust(curwin); |
| 6868 | # ifdef FEAT_FOLDING |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6869 | if (foldmethodIsDiff(curwin)) |
| 6870 | foldUpdateAll(curwin); |
Bram Moolenaar | 2df6dcc | 2004-07-12 15:53:54 +0000 | [diff] [blame] | 6871 | # endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6872 | } |
| 6873 | #endif |
| 6874 | |
| 6875 | #ifdef USE_IM_CONTROL |
| 6876 | /* 'imdisable' */ |
| 6877 | else if ((int *)varp == &p_imdisable) |
| 6878 | { |
| 6879 | /* Only de-activate it here, it will be enabled when changing mode. */ |
| 6880 | if (p_imdisable) |
| 6881 | im_set_active(FALSE); |
| 6882 | } |
| 6883 | #endif |
| 6884 | |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 6885 | #ifdef FEAT_SYN_HL |
| 6886 | /* 'spell' */ |
| 6887 | else if ((int *)varp == &curwin->w_p_spell) |
| 6888 | { |
| 6889 | if (curwin->w_p_spell) |
| 6890 | { |
| 6891 | char_u *errmsg = did_set_spelllang(curbuf); |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 6892 | |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 6893 | if (errmsg != NULL) |
| 6894 | EMSG(_(errmsg)); |
| 6895 | } |
| 6896 | } |
| 6897 | #endif |
| 6898 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6899 | #ifdef FEAT_FKMAP |
| 6900 | else if ((int *)varp == &p_altkeymap) |
| 6901 | { |
| 6902 | if (old_value != p_altkeymap) |
| 6903 | { |
| 6904 | if (!p_altkeymap) |
| 6905 | { |
| 6906 | p_hkmap = p_fkmap; |
| 6907 | p_fkmap = 0; |
| 6908 | } |
| 6909 | else |
| 6910 | { |
| 6911 | p_fkmap = p_hkmap; |
| 6912 | p_hkmap = 0; |
| 6913 | } |
| 6914 | (void)init_chartab(); |
| 6915 | } |
| 6916 | } |
| 6917 | |
| 6918 | /* |
| 6919 | * In case some second language keymapping options have changed, check |
| 6920 | * and correct the setting in a consistent way. |
| 6921 | */ |
| 6922 | |
| 6923 | /* |
| 6924 | * If hkmap or fkmap are set, reset Arabic keymapping. |
| 6925 | */ |
| 6926 | if ((p_hkmap || p_fkmap) && p_altkeymap) |
| 6927 | { |
| 6928 | p_altkeymap = p_fkmap; |
| 6929 | # ifdef FEAT_ARABIC |
| 6930 | curwin->w_p_arab = FALSE; |
| 6931 | # endif |
| 6932 | (void)init_chartab(); |
| 6933 | } |
| 6934 | |
| 6935 | /* |
| 6936 | * If hkmap set, reset Farsi keymapping. |
| 6937 | */ |
| 6938 | if (p_hkmap && p_altkeymap) |
| 6939 | { |
| 6940 | p_altkeymap = 0; |
| 6941 | p_fkmap = 0; |
| 6942 | # ifdef FEAT_ARABIC |
| 6943 | curwin->w_p_arab = FALSE; |
| 6944 | # endif |
| 6945 | (void)init_chartab(); |
| 6946 | } |
| 6947 | |
| 6948 | /* |
| 6949 | * If fkmap set, reset Hebrew keymapping. |
| 6950 | */ |
| 6951 | if (p_fkmap && !p_altkeymap) |
| 6952 | { |
| 6953 | p_altkeymap = 1; |
| 6954 | p_hkmap = 0; |
| 6955 | # ifdef FEAT_ARABIC |
| 6956 | curwin->w_p_arab = FALSE; |
| 6957 | # endif |
| 6958 | (void)init_chartab(); |
| 6959 | } |
| 6960 | #endif |
| 6961 | |
| 6962 | #ifdef FEAT_ARABIC |
| 6963 | if ((int *)varp == &curwin->w_p_arab) |
| 6964 | { |
| 6965 | if (curwin->w_p_arab) |
| 6966 | { |
| 6967 | /* |
| 6968 | * 'arabic' is set, handle various sub-settings. |
| 6969 | */ |
| 6970 | if (!p_tbidi) |
| 6971 | { |
| 6972 | /* set rightleft mode */ |
| 6973 | if (!curwin->w_p_rl) |
| 6974 | { |
| 6975 | curwin->w_p_rl = TRUE; |
| 6976 | changed_window_setting(); |
| 6977 | } |
| 6978 | |
| 6979 | /* Enable Arabic shaping (major part of what Arabic requires) */ |
| 6980 | if (!p_arshape) |
| 6981 | { |
| 6982 | p_arshape = TRUE; |
| 6983 | redraw_later_clear(); |
| 6984 | } |
| 6985 | } |
| 6986 | |
| 6987 | /* Arabic requires a utf-8 encoding, inform the user if its not |
| 6988 | * set. */ |
| 6989 | if (STRCMP(p_enc, "utf-8") != 0) |
Bram Moolenaar | 2df6dcc | 2004-07-12 15:53:54 +0000 | [diff] [blame] | 6990 | { |
| 6991 | msg_source(hl_attr(HLF_W)); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6992 | MSG_ATTR(_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"), |
| 6993 | hl_attr(HLF_W)); |
Bram Moolenaar | 2df6dcc | 2004-07-12 15:53:54 +0000 | [diff] [blame] | 6994 | } |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6995 | |
| 6996 | # ifdef FEAT_MBYTE |
| 6997 | /* set 'delcombine' */ |
| 6998 | p_deco = TRUE; |
| 6999 | # endif |
| 7000 | |
| 7001 | # ifdef FEAT_KEYMAP |
| 7002 | /* Force-set the necessary keymap for arabic */ |
| 7003 | set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", |
| 7004 | OPT_LOCAL); |
| 7005 | # endif |
| 7006 | # ifdef FEAT_FKMAP |
| 7007 | p_altkeymap = 0; |
| 7008 | p_hkmap = 0; |
| 7009 | p_fkmap = 0; |
| 7010 | (void)init_chartab(); |
| 7011 | # endif |
| 7012 | } |
| 7013 | else |
| 7014 | { |
| 7015 | /* |
| 7016 | * 'arabic' is reset, handle various sub-settings. |
| 7017 | */ |
| 7018 | if (!p_tbidi) |
| 7019 | { |
| 7020 | /* reset rightleft mode */ |
| 7021 | if (curwin->w_p_rl) |
| 7022 | { |
| 7023 | curwin->w_p_rl = FALSE; |
| 7024 | changed_window_setting(); |
| 7025 | } |
| 7026 | |
| 7027 | /* 'arabicshape' isn't reset, it is a global option and |
| 7028 | * another window may still need it "on". */ |
| 7029 | } |
| 7030 | |
| 7031 | /* 'delcombine' isn't reset, it is a global option and another |
| 7032 | * window may still want it "on". */ |
| 7033 | |
| 7034 | # ifdef FEAT_KEYMAP |
| 7035 | /* Revert to the default keymap */ |
| 7036 | curbuf->b_p_iminsert = B_IMODE_NONE; |
| 7037 | curbuf->b_p_imsearch = B_IMODE_USE_INSERT; |
| 7038 | # endif |
| 7039 | } |
| 7040 | } |
| 7041 | #endif |
| 7042 | |
| 7043 | /* |
| 7044 | * End of handling side effects for bool options. |
| 7045 | */ |
| 7046 | |
| 7047 | options[opt_idx].flags |= P_WAS_SET; |
| 7048 | |
| 7049 | comp_col(); /* in case 'ruler' or 'showcmd' changed */ |
| 7050 | if (curwin->w_curswant != MAXCOL) |
| 7051 | curwin->w_set_curswant = TRUE; /* in case 'list' changed */ |
| 7052 | check_redraw(options[opt_idx].flags); |
| 7053 | |
| 7054 | return NULL; |
| 7055 | } |
| 7056 | |
| 7057 | /* |
| 7058 | * Set the value of a number option, and take care of side effects. |
| 7059 | * Returns NULL for success, or an error message for an error. |
| 7060 | */ |
| 7061 | static char_u * |
Bram Moolenaar | 555b280 | 2005-05-19 21:08:39 +0000 | [diff] [blame] | 7062 | set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7063 | int opt_idx; /* index in options[] table */ |
| 7064 | char_u *varp; /* pointer to the option variable */ |
| 7065 | long value; /* new value */ |
| 7066 | char_u *errbuf; /* buffer for error messages */ |
Bram Moolenaar | 555b280 | 2005-05-19 21:08:39 +0000 | [diff] [blame] | 7067 | size_t errbuflen; /* length of "errbuf" */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7068 | int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and |
| 7069 | OPT_MODELINE */ |
| 7070 | { |
| 7071 | char_u *errmsg = NULL; |
| 7072 | long old_value = *(long *)varp; |
| 7073 | long old_Rows = Rows; /* remember old Rows */ |
| 7074 | long old_Columns = Columns; /* remember old Columns */ |
| 7075 | long *pp = (long *)varp; |
| 7076 | |
| 7077 | #ifdef FEAT_GUI |
| 7078 | need_mouse_correct = TRUE; |
| 7079 | #endif |
| 7080 | |
| 7081 | *pp = value; |
| 7082 | #ifdef FEAT_EVAL |
| 7083 | /* Remember where the option was set. */ |
| 7084 | options[opt_idx].scriptID = current_SID; |
| 7085 | #endif |
| 7086 | |
| 7087 | if (curbuf->b_p_sw <= 0) |
| 7088 | { |
| 7089 | errmsg = e_positive; |
| 7090 | curbuf->b_p_sw = curbuf->b_p_ts; |
| 7091 | } |
| 7092 | |
| 7093 | /* |
| 7094 | * Number options that need some action when changed |
| 7095 | */ |
| 7096 | #ifdef FEAT_WINDOWS |
| 7097 | if (pp == &p_wh || pp == &p_hh) |
| 7098 | { |
| 7099 | if (p_wh < 1) |
| 7100 | { |
| 7101 | errmsg = e_positive; |
| 7102 | p_wh = 1; |
| 7103 | } |
| 7104 | if (p_wmh > p_wh) |
| 7105 | { |
| 7106 | errmsg = e_winheight; |
| 7107 | p_wh = p_wmh; |
| 7108 | } |
| 7109 | if (p_hh < 0) |
| 7110 | { |
| 7111 | errmsg = e_positive; |
| 7112 | p_hh = 0; |
| 7113 | } |
| 7114 | |
| 7115 | /* Change window height NOW */ |
| 7116 | if (lastwin != firstwin) |
| 7117 | { |
| 7118 | if (pp == &p_wh && curwin->w_height < p_wh) |
| 7119 | win_setheight((int)p_wh); |
| 7120 | if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) |
| 7121 | win_setheight((int)p_hh); |
| 7122 | } |
| 7123 | } |
| 7124 | |
| 7125 | /* 'winminheight' */ |
| 7126 | else if (pp == &p_wmh) |
| 7127 | { |
| 7128 | if (p_wmh < 0) |
| 7129 | { |
| 7130 | errmsg = e_positive; |
| 7131 | p_wmh = 0; |
| 7132 | } |
| 7133 | if (p_wmh > p_wh) |
| 7134 | { |
| 7135 | errmsg = e_winheight; |
| 7136 | p_wmh = p_wh; |
| 7137 | } |
| 7138 | win_setminheight(); |
| 7139 | } |
| 7140 | |
| 7141 | # ifdef FEAT_VERTSPLIT |
Bram Moolenaar | 592e0a2 | 2004-07-03 16:05:59 +0000 | [diff] [blame] | 7142 | else if (pp == &p_wiw) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7143 | { |
| 7144 | if (p_wiw < 1) |
| 7145 | { |
| 7146 | errmsg = e_positive; |
| 7147 | p_wiw = 1; |
| 7148 | } |
| 7149 | if (p_wmw > p_wiw) |
| 7150 | { |
| 7151 | errmsg = e_winwidth; |
| 7152 | p_wiw = p_wmw; |
| 7153 | } |
| 7154 | |
| 7155 | /* Change window width NOW */ |
| 7156 | if (lastwin != firstwin && curwin->w_width < p_wiw) |
| 7157 | win_setwidth((int)p_wiw); |
| 7158 | } |
| 7159 | |
| 7160 | /* 'winminwidth' */ |
| 7161 | else if (pp == &p_wmw) |
| 7162 | { |
| 7163 | if (p_wmw < 0) |
| 7164 | { |
| 7165 | errmsg = e_positive; |
| 7166 | p_wmw = 0; |
| 7167 | } |
| 7168 | if (p_wmw > p_wiw) |
| 7169 | { |
| 7170 | errmsg = e_winwidth; |
| 7171 | p_wmw = p_wiw; |
| 7172 | } |
| 7173 | win_setminheight(); |
| 7174 | } |
| 7175 | # endif |
| 7176 | |
| 7177 | #endif |
| 7178 | |
| 7179 | #ifdef FEAT_WINDOWS |
| 7180 | /* (re)set last window status line */ |
| 7181 | else if (pp == &p_ls) |
| 7182 | { |
| 7183 | last_status(FALSE); |
| 7184 | } |
| 7185 | #endif |
| 7186 | |
| 7187 | #ifdef FEAT_GUI |
| 7188 | else if (pp == &p_linespace) |
| 7189 | { |
Bram Moolenaar | 0274363 | 2005-07-25 20:42:36 +0000 | [diff] [blame] | 7190 | /* Recompute gui.char_height and resize the Vim window to keep the |
| 7191 | * same number of lines. */ |
| 7192 | if (gui.in_use && gui_mch_adjust_charheight() == OK) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7193 | gui_set_shellsize(FALSE, FALSE); |
| 7194 | } |
| 7195 | #endif |
| 7196 | |
| 7197 | #ifdef FEAT_FOLDING |
| 7198 | /* 'foldlevel' */ |
| 7199 | else if (pp == &curwin->w_p_fdl) |
| 7200 | { |
| 7201 | if (curwin->w_p_fdl < 0) |
| 7202 | curwin->w_p_fdl = 0; |
| 7203 | newFoldLevel(); |
| 7204 | } |
| 7205 | |
| 7206 | /* 'foldminlevel' */ |
| 7207 | else if (pp == &curwin->w_p_fml) |
| 7208 | { |
| 7209 | foldUpdateAll(curwin); |
| 7210 | } |
| 7211 | |
| 7212 | /* 'foldnestmax' */ |
| 7213 | else if (pp == &curwin->w_p_fdn) |
| 7214 | { |
| 7215 | if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) |
| 7216 | foldUpdateAll(curwin); |
| 7217 | } |
| 7218 | |
| 7219 | /* 'foldcolumn' */ |
| 7220 | else if (pp == &curwin->w_p_fdc) |
| 7221 | { |
| 7222 | if (curwin->w_p_fdc < 0) |
| 7223 | { |
| 7224 | errmsg = e_positive; |
| 7225 | curwin->w_p_fdc = 0; |
| 7226 | } |
| 7227 | else if (curwin->w_p_fdc > 12) |
| 7228 | { |
| 7229 | errmsg = e_invarg; |
| 7230 | curwin->w_p_fdc = 12; |
| 7231 | } |
| 7232 | } |
| 7233 | |
| 7234 | /* 'shiftwidth' or 'tabstop' */ |
| 7235 | else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) |
| 7236 | { |
| 7237 | if (foldmethodIsIndent(curwin)) |
| 7238 | foldUpdateAll(curwin); |
| 7239 | } |
| 7240 | #endif /* FEAT_FOLDING */ |
| 7241 | |
| 7242 | else if (pp == &curbuf->b_p_iminsert) |
| 7243 | { |
| 7244 | if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) |
| 7245 | { |
| 7246 | errmsg = e_invarg; |
| 7247 | curbuf->b_p_iminsert = B_IMODE_NONE; |
| 7248 | } |
| 7249 | p_iminsert = curbuf->b_p_iminsert; |
| 7250 | if (termcap_active) /* don't do this in the alternate screen */ |
| 7251 | showmode(); |
| 7252 | #if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP) |
| 7253 | /* Show/unshow value of 'keymap' in status lines. */ |
| 7254 | status_redraw_curbuf(); |
| 7255 | #endif |
| 7256 | } |
| 7257 | |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 7258 | else if (pp == &p_window) |
| 7259 | { |
| 7260 | if (p_window < 1) |
| 7261 | p_window = 1; |
| 7262 | else if (p_window >= Rows) |
| 7263 | p_window = Rows - 1; |
| 7264 | } |
| 7265 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7266 | else if (pp == &curbuf->b_p_imsearch) |
| 7267 | { |
| 7268 | if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) |
| 7269 | { |
| 7270 | errmsg = e_invarg; |
| 7271 | curbuf->b_p_imsearch = B_IMODE_NONE; |
| 7272 | } |
| 7273 | p_imsearch = curbuf->b_p_imsearch; |
| 7274 | } |
| 7275 | |
| 7276 | #ifdef FEAT_TITLE |
| 7277 | /* if 'titlelen' has changed, redraw the title */ |
| 7278 | else if (pp == &p_titlelen) |
| 7279 | { |
| 7280 | if (p_titlelen < 0) |
| 7281 | { |
| 7282 | errmsg = e_positive; |
| 7283 | p_titlelen = 85; |
| 7284 | } |
| 7285 | if (starting != NO_SCREEN && old_value != p_titlelen) |
| 7286 | need_maketitle = TRUE; |
| 7287 | } |
| 7288 | #endif |
| 7289 | |
| 7290 | /* if p_ch changed value, change the command line height */ |
| 7291 | else if (pp == &p_ch) |
| 7292 | { |
| 7293 | if (p_ch < 1) |
| 7294 | { |
| 7295 | errmsg = e_positive; |
| 7296 | p_ch = 1; |
| 7297 | } |
| 7298 | |
| 7299 | /* Only compute the new window layout when startup has been |
| 7300 | * completed. Otherwise the frame sizes may be wrong. */ |
| 7301 | if (p_ch != old_value && full_screen |
| 7302 | #ifdef FEAT_GUI |
| 7303 | && !gui.starting |
| 7304 | #endif |
| 7305 | ) |
| 7306 | command_height(old_value); |
| 7307 | } |
| 7308 | |
| 7309 | /* when 'updatecount' changes from zero to non-zero, open swap files */ |
| 7310 | else if (pp == &p_uc) |
| 7311 | { |
| 7312 | if (p_uc < 0) |
| 7313 | { |
| 7314 | errmsg = e_positive; |
| 7315 | p_uc = 100; |
| 7316 | } |
| 7317 | if (p_uc && !old_value) |
| 7318 | ml_open_files(); |
| 7319 | } |
Bram Moolenaar | 2df6dcc | 2004-07-12 15:53:54 +0000 | [diff] [blame] | 7320 | #ifdef MZSCHEME_GUI_THREADS |
Bram Moolenaar | 325b7a2 | 2004-07-05 15:58:32 +0000 | [diff] [blame] | 7321 | else if (pp == &p_mzq) |
| 7322 | mzvim_reset_timer(); |
| 7323 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7324 | |
| 7325 | /* sync undo before 'undolevels' changes */ |
| 7326 | else if (pp == &p_ul) |
| 7327 | { |
| 7328 | /* use the old value, otherwise u_sync() may not work properly */ |
| 7329 | p_ul = old_value; |
| 7330 | u_sync(); |
| 7331 | p_ul = value; |
| 7332 | } |
| 7333 | |
Bram Moolenaar | 592e0a2 | 2004-07-03 16:05:59 +0000 | [diff] [blame] | 7334 | #ifdef FEAT_LINEBREAK |
| 7335 | /* 'numberwidth' must be positive */ |
| 7336 | else if (pp == &curwin->w_p_nuw) |
| 7337 | { |
| 7338 | if (curwin->w_p_nuw < 1) |
| 7339 | { |
| 7340 | errmsg = e_positive; |
| 7341 | curwin->w_p_nuw = 1; |
| 7342 | } |
| 7343 | if (curwin->w_p_nuw > 10) |
| 7344 | { |
| 7345 | errmsg = e_invarg; |
| 7346 | curwin->w_p_nuw = 10; |
| 7347 | } |
| 7348 | curwin->w_nrwidth_line_count = 0; |
| 7349 | } |
| 7350 | #endif |
| 7351 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7352 | /* |
| 7353 | * Check the bounds for numeric options here |
| 7354 | */ |
| 7355 | if (Rows < min_rows() && full_screen) |
| 7356 | { |
| 7357 | if (errbuf != NULL) |
| 7358 | { |
Bram Moolenaar | 555b280 | 2005-05-19 21:08:39 +0000 | [diff] [blame] | 7359 | vim_snprintf((char *)errbuf, errbuflen, |
| 7360 | _("E593: Need at least %d lines"), min_rows()); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7361 | errmsg = errbuf; |
| 7362 | } |
| 7363 | Rows = min_rows(); |
| 7364 | } |
| 7365 | if (Columns < MIN_COLUMNS && full_screen) |
| 7366 | { |
| 7367 | if (errbuf != NULL) |
| 7368 | { |
Bram Moolenaar | 555b280 | 2005-05-19 21:08:39 +0000 | [diff] [blame] | 7369 | vim_snprintf((char *)errbuf, errbuflen, |
| 7370 | _("E594: Need at least %d columns"), MIN_COLUMNS); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7371 | errmsg = errbuf; |
| 7372 | } |
| 7373 | Columns = MIN_COLUMNS; |
| 7374 | } |
Bram Moolenaar | 482aaeb | 2005-09-29 18:26:07 +0000 | [diff] [blame] | 7375 | /* Limit the values to avoid an overflow in Rows * Columns. */ |
| 7376 | if (Columns > 10000) |
| 7377 | Columns = 10000; |
| 7378 | if (Rows > 1000) |
| 7379 | Rows = 1000; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7380 | |
| 7381 | #ifdef DJGPP |
| 7382 | /* avoid a crash by checking for a too large value of 'columns' */ |
| 7383 | if (old_Columns != Columns && full_screen && term_console) |
| 7384 | mch_check_columns(); |
| 7385 | #endif |
| 7386 | |
| 7387 | /* |
| 7388 | * If the screen (shell) height has been changed, assume it is the |
| 7389 | * physical screenheight. |
| 7390 | */ |
| 7391 | if (old_Rows != Rows || old_Columns != Columns) |
| 7392 | { |
| 7393 | /* Changing the screen size is not allowed while updating the screen. */ |
| 7394 | if (updating_screen) |
| 7395 | *pp = old_value; |
| 7396 | else if (full_screen |
| 7397 | #ifdef FEAT_GUI |
| 7398 | && !gui.starting |
| 7399 | #endif |
| 7400 | ) |
| 7401 | set_shellsize((int)Columns, (int)Rows, TRUE); |
| 7402 | else |
| 7403 | { |
| 7404 | /* Postpone the resizing; check the size and cmdline position for |
| 7405 | * messages. */ |
| 7406 | check_shellsize(); |
| 7407 | if (cmdline_row > Rows - p_ch && Rows > p_ch) |
| 7408 | cmdline_row = Rows - p_ch; |
| 7409 | } |
Bram Moolenaar | 4399ef4 | 2005-02-12 14:29:27 +0000 | [diff] [blame] | 7410 | if (p_window >= Rows) |
| 7411 | p_window = Rows - 1; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7412 | } |
| 7413 | |
| 7414 | if (curbuf->b_p_sts < 0) |
| 7415 | { |
| 7416 | errmsg = e_positive; |
| 7417 | curbuf->b_p_sts = 0; |
| 7418 | } |
| 7419 | if (curbuf->b_p_ts <= 0) |
| 7420 | { |
| 7421 | errmsg = e_positive; |
| 7422 | curbuf->b_p_ts = 8; |
| 7423 | } |
| 7424 | if (curbuf->b_p_tw < 0) |
| 7425 | { |
| 7426 | errmsg = e_positive; |
| 7427 | curbuf->b_p_tw = 0; |
| 7428 | } |
| 7429 | if (p_tm < 0) |
| 7430 | { |
| 7431 | errmsg = e_positive; |
| 7432 | p_tm = 0; |
| 7433 | } |
| 7434 | if ((curwin->w_p_scr <= 0 |
| 7435 | || (curwin->w_p_scr > curwin->w_height |
| 7436 | && curwin->w_height > 0)) |
| 7437 | && full_screen) |
| 7438 | { |
| 7439 | if (pp == &(curwin->w_p_scr)) |
| 7440 | { |
| 7441 | if (curwin->w_p_scr != 0) |
| 7442 | errmsg = e_scroll; |
| 7443 | win_comp_scroll(curwin); |
| 7444 | } |
| 7445 | /* If 'scroll' became invalid because of a side effect silently adjust |
| 7446 | * it. */ |
| 7447 | else if (curwin->w_p_scr <= 0) |
| 7448 | curwin->w_p_scr = 1; |
| 7449 | else /* curwin->w_p_scr > curwin->w_height */ |
| 7450 | curwin->w_p_scr = curwin->w_height; |
| 7451 | } |
| 7452 | if (p_report < 0) |
| 7453 | { |
| 7454 | errmsg = e_positive; |
| 7455 | p_report = 1; |
| 7456 | } |
Bram Moolenaar | 1e01546 | 2005-09-25 22:16:38 +0000 | [diff] [blame] | 7457 | if ((p_sj < -100 || p_sj >= Rows) && full_screen) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7458 | { |
| 7459 | if (Rows != old_Rows) /* Rows changed, just adjust p_sj */ |
| 7460 | p_sj = Rows / 2; |
| 7461 | else |
| 7462 | { |
| 7463 | errmsg = e_scroll; |
| 7464 | p_sj = 1; |
| 7465 | } |
| 7466 | } |
| 7467 | if (p_so < 0 && full_screen) |
| 7468 | { |
| 7469 | errmsg = e_scroll; |
| 7470 | p_so = 0; |
| 7471 | } |
| 7472 | if (p_siso < 0 && full_screen) |
| 7473 | { |
| 7474 | errmsg = e_positive; |
| 7475 | p_siso = 0; |
| 7476 | } |
| 7477 | #ifdef FEAT_CMDWIN |
| 7478 | if (p_cwh < 1) |
| 7479 | { |
| 7480 | errmsg = e_positive; |
| 7481 | p_cwh = 1; |
| 7482 | } |
| 7483 | #endif |
| 7484 | if (p_ut < 0) |
| 7485 | { |
| 7486 | errmsg = e_positive; |
| 7487 | p_ut = 2000; |
| 7488 | } |
| 7489 | if (p_ss < 0) |
| 7490 | { |
| 7491 | errmsg = e_positive; |
| 7492 | p_ss = 0; |
| 7493 | } |
| 7494 | |
| 7495 | /* May set global value for local option. */ |
| 7496 | if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
| 7497 | *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; |
| 7498 | |
| 7499 | options[opt_idx].flags |= P_WAS_SET; |
| 7500 | |
| 7501 | comp_col(); /* in case 'columns' or 'ls' changed */ |
| 7502 | if (curwin->w_curswant != MAXCOL) |
| 7503 | curwin->w_set_curswant = TRUE; /* in case 'tabstop' changed */ |
| 7504 | check_redraw(options[opt_idx].flags); |
| 7505 | |
| 7506 | return errmsg; |
| 7507 | } |
| 7508 | |
| 7509 | /* |
| 7510 | * Called after an option changed: check if something needs to be redrawn. |
| 7511 | */ |
| 7512 | static void |
| 7513 | check_redraw(flags) |
| 7514 | long_u flags; |
| 7515 | { |
| 7516 | /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */ |
| 7517 | int clear = (flags & P_RCLR) == P_RCLR; |
| 7518 | int all = ((flags & P_RALL) == P_RALL || clear); |
| 7519 | |
| 7520 | #ifdef FEAT_WINDOWS |
| 7521 | if ((flags & P_RSTAT) || all) /* mark all status lines dirty */ |
| 7522 | status_redraw_all(); |
| 7523 | #endif |
| 7524 | |
| 7525 | if ((flags & P_RBUF) || (flags & P_RWIN) || all) |
| 7526 | changed_window_setting(); |
| 7527 | if (flags & P_RBUF) |
| 7528 | redraw_curbuf_later(NOT_VALID); |
| 7529 | if (clear) |
| 7530 | redraw_all_later(CLEAR); |
| 7531 | else if (all) |
| 7532 | redraw_all_later(NOT_VALID); |
| 7533 | } |
| 7534 | |
| 7535 | /* |
| 7536 | * Find index for option 'arg'. |
| 7537 | * Return -1 if not found. |
| 7538 | */ |
| 7539 | static int |
| 7540 | findoption(arg) |
| 7541 | char_u *arg; |
| 7542 | { |
| 7543 | int opt_idx; |
| 7544 | char *s, *p; |
| 7545 | static short quick_tab[27] = {0, 0}; /* quick access table */ |
| 7546 | int is_term_opt; |
| 7547 | |
| 7548 | /* |
| 7549 | * For first call: Initialize the quick-access table. |
| 7550 | * It contains the index for the first option that starts with a certain |
| 7551 | * letter. There are 26 letters, plus the first "t_" option. |
| 7552 | */ |
| 7553 | if (quick_tab[1] == 0) |
| 7554 | { |
| 7555 | p = options[0].fullname; |
| 7556 | for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) |
| 7557 | { |
| 7558 | if (s[0] != p[0]) |
| 7559 | { |
| 7560 | if (s[0] == 't' && s[1] == '_') |
| 7561 | quick_tab[26] = opt_idx; |
| 7562 | else |
| 7563 | quick_tab[CharOrdLow(s[0])] = opt_idx; |
| 7564 | } |
| 7565 | p = s; |
| 7566 | } |
| 7567 | } |
| 7568 | |
| 7569 | /* |
| 7570 | * Check for name starting with an illegal character. |
| 7571 | */ |
| 7572 | #ifdef EBCDIC |
| 7573 | if (!islower(arg[0])) |
| 7574 | #else |
| 7575 | if (arg[0] < 'a' || arg[0] > 'z') |
| 7576 | #endif |
| 7577 | return -1; |
| 7578 | |
| 7579 | is_term_opt = (arg[0] == 't' && arg[1] == '_'); |
| 7580 | if (is_term_opt) |
| 7581 | opt_idx = quick_tab[26]; |
| 7582 | else |
| 7583 | opt_idx = quick_tab[CharOrdLow(arg[0])]; |
| 7584 | for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) |
| 7585 | { |
| 7586 | if (STRCMP(arg, s) == 0) /* match full name */ |
| 7587 | break; |
| 7588 | } |
| 7589 | if (s == NULL && !is_term_opt) |
| 7590 | { |
| 7591 | opt_idx = quick_tab[CharOrdLow(arg[0])]; |
| 7592 | for ( ; options[opt_idx].fullname != NULL; opt_idx++) |
| 7593 | { |
| 7594 | s = options[opt_idx].shortname; |
| 7595 | if (s != NULL && STRCMP(arg, s) == 0) /* match short name */ |
| 7596 | break; |
| 7597 | s = NULL; |
| 7598 | } |
| 7599 | } |
| 7600 | if (s == NULL) |
| 7601 | opt_idx = -1; |
| 7602 | return opt_idx; |
| 7603 | } |
| 7604 | |
Bram Moolenaar | 325b7a2 | 2004-07-05 15:58:32 +0000 | [diff] [blame] | 7605 | #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7606 | /* |
| 7607 | * Get the value for an option. |
| 7608 | * |
| 7609 | * Returns: |
| 7610 | * Number or Toggle option: 1, *numval gets value. |
| 7611 | * String option: 0, *stringval gets allocated string. |
| 7612 | * Hidden Number or Toggle option: -1. |
| 7613 | * hidden String option: -2. |
| 7614 | * unknown option: -3. |
| 7615 | */ |
| 7616 | int |
| 7617 | get_option_value(name, numval, stringval, opt_flags) |
| 7618 | char_u *name; |
| 7619 | long *numval; |
| 7620 | char_u **stringval; /* NULL when only checking existance */ |
| 7621 | int opt_flags; |
| 7622 | { |
| 7623 | int opt_idx; |
| 7624 | char_u *varp; |
| 7625 | |
| 7626 | opt_idx = findoption(name); |
| 7627 | if (opt_idx < 0) /* unknown option */ |
| 7628 | return -3; |
| 7629 | |
| 7630 | varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
| 7631 | |
| 7632 | if (options[opt_idx].flags & P_STRING) |
| 7633 | { |
| 7634 | if (varp == NULL) /* hidden option */ |
| 7635 | return -2; |
| 7636 | if (stringval != NULL) |
| 7637 | { |
| 7638 | #ifdef FEAT_CRYPT |
| 7639 | /* never return the value of the crypt key */ |
| 7640 | if ((char_u **)varp == &curbuf->b_p_key) |
| 7641 | *stringval = vim_strsave((char_u *)"*****"); |
| 7642 | else |
| 7643 | #endif |
| 7644 | *stringval = vim_strsave(*(char_u **)(varp)); |
| 7645 | } |
| 7646 | return 0; |
| 7647 | } |
| 7648 | |
| 7649 | if (varp == NULL) /* hidden option */ |
| 7650 | return -1; |
| 7651 | if (options[opt_idx].flags & P_NUM) |
| 7652 | *numval = *(long *)varp; |
| 7653 | else |
| 7654 | { |
| 7655 | /* Special case: 'modified' is b_changed, but we also want to consider |
| 7656 | * it set when 'ff' or 'fenc' changed. */ |
| 7657 | if ((int *)varp == &curbuf->b_changed) |
| 7658 | *numval = curbufIsChanged(); |
| 7659 | else |
| 7660 | *numval = *(int *)varp; |
| 7661 | } |
| 7662 | return 1; |
| 7663 | } |
| 7664 | #endif |
| 7665 | |
| 7666 | /* |
| 7667 | * Set the value of option "name". |
| 7668 | * Use "string" for string options, use "number" for other options. |
| 7669 | */ |
| 7670 | void |
| 7671 | set_option_value(name, number, string, opt_flags) |
| 7672 | char_u *name; |
| 7673 | long number; |
| 7674 | char_u *string; |
| 7675 | int opt_flags; /* OPT_LOCAL or 0 (both) */ |
| 7676 | { |
| 7677 | int opt_idx; |
| 7678 | char_u *varp; |
| 7679 | int flags; |
| 7680 | |
| 7681 | opt_idx = findoption(name); |
| 7682 | if (opt_idx == -1) |
| 7683 | EMSG2(_("E355: Unknown option: %s"), name); |
| 7684 | else |
| 7685 | { |
| 7686 | flags = options[opt_idx].flags; |
| 7687 | #ifdef HAVE_SANDBOX |
| 7688 | /* Disallow changing some options in the sandbox */ |
| 7689 | if (sandbox > 0 && (flags & P_SECURE)) |
| 7690 | EMSG(_(e_sandbox)); |
| 7691 | else |
| 7692 | #endif |
| 7693 | if (flags & P_STRING) |
| 7694 | set_string_option(opt_idx, string, opt_flags); |
| 7695 | else |
| 7696 | { |
| 7697 | varp = get_varp(&options[opt_idx]); |
| 7698 | if (varp != NULL) /* hidden option is not changed */ |
| 7699 | { |
| 7700 | if (flags & P_NUM) |
Bram Moolenaar | 555b280 | 2005-05-19 21:08:39 +0000 | [diff] [blame] | 7701 | (void)set_num_option(opt_idx, varp, number, |
| 7702 | NULL, 0, opt_flags); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7703 | else |
| 7704 | (void)set_bool_option(opt_idx, varp, (int)number, opt_flags); |
| 7705 | } |
| 7706 | } |
| 7707 | } |
| 7708 | } |
| 7709 | |
| 7710 | /* |
| 7711 | * Get the terminal code for a terminal option. |
| 7712 | * Returns NULL when not found. |
| 7713 | */ |
| 7714 | char_u * |
| 7715 | get_term_code(tname) |
| 7716 | char_u *tname; |
| 7717 | { |
| 7718 | int opt_idx; |
| 7719 | char_u *varp; |
| 7720 | |
| 7721 | if (tname[0] != 't' || tname[1] != '_' || |
| 7722 | tname[2] == NUL || tname[3] == NUL) |
| 7723 | return NULL; |
| 7724 | if ((opt_idx = findoption(tname)) >= 0) |
| 7725 | { |
| 7726 | varp = get_varp(&(options[opt_idx])); |
| 7727 | if (varp != NULL) |
| 7728 | varp = *(char_u **)(varp); |
| 7729 | return varp; |
| 7730 | } |
| 7731 | return find_termcode(tname + 2); |
| 7732 | } |
| 7733 | |
| 7734 | char_u * |
| 7735 | get_highlight_default() |
| 7736 | { |
| 7737 | int i; |
| 7738 | |
| 7739 | i = findoption((char_u *)"hl"); |
| 7740 | if (i >= 0) |
| 7741 | return options[i].def_val[VI_DEFAULT]; |
| 7742 | return (char_u *)NULL; |
| 7743 | } |
| 7744 | |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame] | 7745 | #if defined(FEAT_MBYTE) || defined(PROTO) |
| 7746 | char_u * |
| 7747 | get_encoding_default() |
| 7748 | { |
| 7749 | int i; |
| 7750 | |
| 7751 | i = findoption((char_u *)"enc"); |
| 7752 | if (i >= 0) |
| 7753 | return options[i].def_val[VI_DEFAULT]; |
| 7754 | return (char_u *)NULL; |
| 7755 | } |
| 7756 | #endif |
| 7757 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7758 | /* |
| 7759 | * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number. |
| 7760 | */ |
| 7761 | static int |
| 7762 | find_key_option(arg) |
| 7763 | char_u *arg; |
| 7764 | { |
| 7765 | int key; |
| 7766 | int modifiers; |
| 7767 | |
| 7768 | /* |
| 7769 | * Don't use get_special_key_code() for t_xx, we don't want it to call |
| 7770 | * add_termcap_entry(). |
| 7771 | */ |
| 7772 | if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) |
| 7773 | key = TERMCAP2KEY(arg[2], arg[3]); |
| 7774 | else |
| 7775 | { |
| 7776 | --arg; /* put arg at the '<' */ |
| 7777 | modifiers = 0; |
| 7778 | key = find_special_key(&arg, &modifiers, TRUE); |
| 7779 | if (modifiers) /* can't handle modifiers here */ |
| 7780 | key = 0; |
| 7781 | } |
| 7782 | return key; |
| 7783 | } |
| 7784 | |
| 7785 | /* |
| 7786 | * if 'all' == 0: show changed options |
| 7787 | * if 'all' == 1: show all normal options |
| 7788 | * if 'all' == 2: show all terminal options |
| 7789 | */ |
| 7790 | static void |
| 7791 | showoptions(all, opt_flags) |
| 7792 | int all; |
| 7793 | int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ |
| 7794 | { |
| 7795 | struct vimoption *p; |
| 7796 | int col; |
| 7797 | int isterm; |
| 7798 | char_u *varp; |
| 7799 | struct vimoption **items; |
| 7800 | int item_count; |
| 7801 | int run; |
| 7802 | int row, rows; |
| 7803 | int cols; |
| 7804 | int i; |
| 7805 | int len; |
| 7806 | |
| 7807 | #define INC 20 |
| 7808 | #define GAP 3 |
| 7809 | |
| 7810 | items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) * |
| 7811 | PARAM_COUNT)); |
| 7812 | if (items == NULL) |
| 7813 | return; |
| 7814 | |
| 7815 | /* Highlight title */ |
| 7816 | if (all == 2) |
| 7817 | MSG_PUTS_TITLE(_("\n--- Terminal codes ---")); |
| 7818 | else if (opt_flags & OPT_GLOBAL) |
| 7819 | MSG_PUTS_TITLE(_("\n--- Global option values ---")); |
| 7820 | else if (opt_flags & OPT_LOCAL) |
| 7821 | MSG_PUTS_TITLE(_("\n--- Local option values ---")); |
| 7822 | else |
| 7823 | MSG_PUTS_TITLE(_("\n--- Options ---")); |
| 7824 | |
| 7825 | /* |
| 7826 | * do the loop two times: |
| 7827 | * 1. display the short items |
| 7828 | * 2. display the long items (only strings and numbers) |
| 7829 | */ |
| 7830 | for (run = 1; run <= 2 && !got_int; ++run) |
| 7831 | { |
| 7832 | /* |
| 7833 | * collect the items in items[] |
| 7834 | */ |
| 7835 | item_count = 0; |
| 7836 | for (p = &options[0]; p->fullname != NULL; p++) |
| 7837 | { |
| 7838 | varp = NULL; |
| 7839 | isterm = istermoption(p); |
| 7840 | if (opt_flags != 0) |
| 7841 | { |
| 7842 | if (p->indir != PV_NONE && !isterm) |
| 7843 | varp = get_varp_scope(p, opt_flags); |
| 7844 | } |
| 7845 | else |
| 7846 | varp = get_varp(p); |
| 7847 | if (varp != NULL |
| 7848 | && ((all == 2 && isterm) |
| 7849 | || (all == 1 && !isterm) |
| 7850 | || (all == 0 && !optval_default(p, varp)))) |
| 7851 | { |
| 7852 | if (p->flags & P_BOOL) |
| 7853 | len = 1; /* a toggle option fits always */ |
| 7854 | else |
| 7855 | { |
| 7856 | option_value2string(p, opt_flags); |
| 7857 | len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; |
| 7858 | } |
| 7859 | if ((len <= INC - GAP && run == 1) || |
| 7860 | (len > INC - GAP && run == 2)) |
| 7861 | items[item_count++] = p; |
| 7862 | } |
| 7863 | } |
| 7864 | |
| 7865 | /* |
| 7866 | * display the items |
| 7867 | */ |
| 7868 | if (run == 1) |
| 7869 | { |
| 7870 | cols = (Columns + GAP - 3) / INC; |
| 7871 | if (cols == 0) |
| 7872 | cols = 1; |
| 7873 | rows = (item_count + cols - 1) / cols; |
| 7874 | } |
| 7875 | else /* run == 2 */ |
| 7876 | rows = item_count; |
| 7877 | for (row = 0; row < rows && !got_int; ++row) |
| 7878 | { |
| 7879 | msg_putchar('\n'); /* go to next line */ |
| 7880 | if (got_int) /* 'q' typed in more */ |
| 7881 | break; |
| 7882 | col = 0; |
| 7883 | for (i = row; i < item_count; i += rows) |
| 7884 | { |
| 7885 | msg_col = col; /* make columns */ |
| 7886 | showoneopt(items[i], opt_flags); |
| 7887 | col += INC; |
| 7888 | } |
| 7889 | out_flush(); |
| 7890 | ui_breakcheck(); |
| 7891 | } |
| 7892 | } |
| 7893 | vim_free(items); |
| 7894 | } |
| 7895 | |
| 7896 | /* |
| 7897 | * Return TRUE if option "p" has its default value. |
| 7898 | */ |
| 7899 | static int |
| 7900 | optval_default(p, varp) |
| 7901 | struct vimoption *p; |
| 7902 | char_u *varp; |
| 7903 | { |
| 7904 | int dvi; |
| 7905 | |
| 7906 | if (varp == NULL) |
| 7907 | return TRUE; /* hidden option is always at default */ |
| 7908 | dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT; |
| 7909 | if (p->flags & P_NUM) |
| 7910 | return (*(long *)varp == (long)p->def_val[dvi]); |
| 7911 | if (p->flags & P_BOOL) |
| 7912 | /* the cast to long is required for Manx C */ |
| 7913 | return (*(int *)varp == (int)(long)p->def_val[dvi]); |
| 7914 | /* P_STRING */ |
| 7915 | return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); |
| 7916 | } |
| 7917 | |
| 7918 | /* |
| 7919 | * showoneopt: show the value of one option |
| 7920 | * must not be called with a hidden option! |
| 7921 | */ |
| 7922 | static void |
| 7923 | showoneopt(p, opt_flags) |
| 7924 | struct vimoption *p; |
| 7925 | int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */ |
| 7926 | { |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 7927 | char_u *varp; |
| 7928 | int save_silent = silent_mode; |
| 7929 | |
| 7930 | silent_mode = FALSE; |
| 7931 | info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7932 | |
| 7933 | varp = get_varp_scope(p, opt_flags); |
| 7934 | |
| 7935 | /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */ |
| 7936 | if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed |
| 7937 | ? !curbufIsChanged() : !*(int *)varp)) |
| 7938 | MSG_PUTS("no"); |
| 7939 | else if ((p->flags & P_BOOL) && *(int *)varp < 0) |
| 7940 | MSG_PUTS("--"); |
| 7941 | else |
| 7942 | MSG_PUTS(" "); |
| 7943 | MSG_PUTS(p->fullname); |
| 7944 | if (!(p->flags & P_BOOL)) |
| 7945 | { |
| 7946 | msg_putchar('='); |
| 7947 | /* put value string in NameBuff */ |
| 7948 | option_value2string(p, opt_flags); |
| 7949 | msg_outtrans(NameBuff); |
| 7950 | } |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 7951 | |
| 7952 | silent_mode = save_silent; |
| 7953 | info_message = FALSE; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7954 | } |
| 7955 | |
| 7956 | /* |
| 7957 | * Write modified options as ":set" commands to a file. |
| 7958 | * |
| 7959 | * There are three values for "opt_flags": |
| 7960 | * OPT_GLOBAL: Write global option values and fresh values of |
| 7961 | * buffer-local options (used for start of a session |
| 7962 | * file). |
| 7963 | * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for |
| 7964 | * curwin (used for a vimrc file). |
| 7965 | * OPT_LOCAL: Write buffer-local option values for curbuf, fresh |
| 7966 | * and local values for window-local options of |
| 7967 | * curwin. Local values are also written when at the |
| 7968 | * default value, because a modeline or autocommand |
| 7969 | * may have set them when doing ":edit file" and the |
| 7970 | * user has set them back at the default or fresh |
| 7971 | * value. |
| 7972 | * When "local_only" is TRUE, don't write fresh |
| 7973 | * values, only local values (for ":mkview"). |
| 7974 | * (fresh value = value used for a new buffer or window for a local option). |
| 7975 | * |
| 7976 | * Return FAIL on error, OK otherwise. |
| 7977 | */ |
| 7978 | int |
| 7979 | makeset(fd, opt_flags, local_only) |
| 7980 | FILE *fd; |
| 7981 | int opt_flags; |
| 7982 | int local_only; |
| 7983 | { |
| 7984 | struct vimoption *p; |
| 7985 | char_u *varp; /* currently used value */ |
| 7986 | char_u *varp_fresh; /* local value */ |
| 7987 | char_u *varp_local = NULL; /* fresh value */ |
| 7988 | char *cmd; |
| 7989 | int round; |
| 7990 | |
| 7991 | /* |
| 7992 | * The options that don't have a default (terminal name, columns, lines) |
| 7993 | * are never written. Terminal options are also not written. |
| 7994 | */ |
| 7995 | for (p = &options[0]; !istermoption(p); p++) |
| 7996 | if (!(p->flags & P_NO_MKRC) && !istermoption(p)) |
| 7997 | { |
| 7998 | /* skip global option when only doing locals */ |
| 7999 | if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) |
| 8000 | continue; |
| 8001 | |
| 8002 | /* Do not store options like 'bufhidden' and 'syntax' in a vimrc |
| 8003 | * file, they are always buffer-specific. */ |
| 8004 | if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) |
| 8005 | continue; |
| 8006 | |
| 8007 | /* Global values are only written when not at the default value. */ |
| 8008 | varp = get_varp_scope(p, opt_flags); |
| 8009 | if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp)) |
| 8010 | continue; |
| 8011 | |
| 8012 | round = 2; |
| 8013 | if (p->indir != PV_NONE) |
| 8014 | { |
| 8015 | if (p->var == VAR_WIN) |
| 8016 | { |
| 8017 | /* skip window-local option when only doing globals */ |
| 8018 | if (!(opt_flags & OPT_LOCAL)) |
| 8019 | continue; |
| 8020 | /* When fresh value of window-local option is not at the |
| 8021 | * default, need to write it too. */ |
| 8022 | if (!(opt_flags & OPT_GLOBAL) && !local_only) |
| 8023 | { |
| 8024 | varp_fresh = get_varp_scope(p, OPT_GLOBAL); |
| 8025 | if (!optval_default(p, varp_fresh)) |
| 8026 | { |
| 8027 | round = 1; |
| 8028 | varp_local = varp; |
| 8029 | varp = varp_fresh; |
| 8030 | } |
| 8031 | } |
| 8032 | } |
| 8033 | } |
| 8034 | |
| 8035 | /* Round 1: fresh value for window-local options. |
| 8036 | * Round 2: other values */ |
| 8037 | for ( ; round <= 2; varp = varp_local, ++round) |
| 8038 | { |
| 8039 | if (round == 1 || (opt_flags & OPT_GLOBAL)) |
| 8040 | cmd = "set"; |
| 8041 | else |
| 8042 | cmd = "setlocal"; |
| 8043 | |
| 8044 | if (p->flags & P_BOOL) |
| 8045 | { |
| 8046 | if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) |
| 8047 | return FAIL; |
| 8048 | } |
| 8049 | else if (p->flags & P_NUM) |
| 8050 | { |
| 8051 | if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) |
| 8052 | return FAIL; |
| 8053 | } |
| 8054 | else /* P_STRING */ |
| 8055 | { |
| 8056 | /* Don't set 'syntax' and 'filetype' again if the value is |
| 8057 | * already right, avoids reloading the syntax file. */ |
| 8058 | if (p->indir == PV_SYN || p->indir == PV_FT) |
| 8059 | { |
| 8060 | if (fprintf(fd, "if &%s != '%s'", p->fullname, |
| 8061 | *(char_u **)(varp)) < 0 |
| 8062 | || put_eol(fd) < 0) |
| 8063 | return FAIL; |
| 8064 | } |
| 8065 | if (put_setstring(fd, cmd, p->fullname, (char_u **)varp, |
| 8066 | (p->flags & P_EXPAND) != 0) == FAIL) |
| 8067 | return FAIL; |
| 8068 | if (p->indir == PV_SYN || p->indir == PV_FT) |
| 8069 | { |
| 8070 | if (put_line(fd, "endif") == FAIL) |
| 8071 | return FAIL; |
| 8072 | } |
| 8073 | } |
| 8074 | } |
| 8075 | } |
| 8076 | return OK; |
| 8077 | } |
| 8078 | |
| 8079 | #if defined(FEAT_FOLDING) || defined(PROTO) |
| 8080 | /* |
| 8081 | * Generate set commands for the local fold options only. Used when |
| 8082 | * 'sessionoptions' or 'viewoptions' contains "folds" but not "options". |
| 8083 | */ |
| 8084 | int |
| 8085 | makefoldset(fd) |
| 8086 | FILE *fd; |
| 8087 | { |
| 8088 | if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL |
| 8089 | # ifdef FEAT_EVAL |
| 8090 | || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE) |
| 8091 | == FAIL |
| 8092 | # endif |
| 8093 | || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE) |
| 8094 | == FAIL |
| 8095 | || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE) |
| 8096 | == FAIL |
| 8097 | || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL |
| 8098 | || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL |
| 8099 | || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL |
| 8100 | || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL |
| 8101 | ) |
| 8102 | return FAIL; |
| 8103 | |
| 8104 | return OK; |
| 8105 | } |
| 8106 | #endif |
| 8107 | |
| 8108 | static int |
| 8109 | put_setstring(fd, cmd, name, valuep, expand) |
| 8110 | FILE *fd; |
| 8111 | char *cmd; |
| 8112 | char *name; |
| 8113 | char_u **valuep; |
| 8114 | int expand; |
| 8115 | { |
| 8116 | char_u *s; |
| 8117 | char_u buf[MAXPATHL]; |
| 8118 | |
| 8119 | if (fprintf(fd, "%s %s=", cmd, name) < 0) |
| 8120 | return FAIL; |
| 8121 | if (*valuep != NULL) |
| 8122 | { |
| 8123 | /* Output 'pastetoggle' as key names. For other |
| 8124 | * options some characters have to be escaped with |
| 8125 | * CTRL-V or backslash */ |
| 8126 | if (valuep == &p_pt) |
| 8127 | { |
| 8128 | s = *valuep; |
| 8129 | while (*s != NUL) |
| 8130 | if (fputs((char *)str2special(&s, FALSE), fd) < 0) |
| 8131 | return FAIL; |
| 8132 | } |
| 8133 | else if (expand) |
| 8134 | { |
| 8135 | home_replace(NULL, *valuep, buf, MAXPATHL, FALSE); |
| 8136 | if (put_escstr(fd, buf, 2) == FAIL) |
| 8137 | return FAIL; |
| 8138 | } |
| 8139 | else if (put_escstr(fd, *valuep, 2) == FAIL) |
| 8140 | return FAIL; |
| 8141 | } |
| 8142 | if (put_eol(fd) < 0) |
| 8143 | return FAIL; |
| 8144 | return OK; |
| 8145 | } |
| 8146 | |
| 8147 | static int |
| 8148 | put_setnum(fd, cmd, name, valuep) |
| 8149 | FILE *fd; |
| 8150 | char *cmd; |
| 8151 | char *name; |
| 8152 | long *valuep; |
| 8153 | { |
| 8154 | long wc; |
| 8155 | |
| 8156 | if (fprintf(fd, "%s %s=", cmd, name) < 0) |
| 8157 | return FAIL; |
| 8158 | if (wc_use_keyname((char_u *)valuep, &wc)) |
| 8159 | { |
| 8160 | /* print 'wildchar' and 'wildcharm' as a key name */ |
| 8161 | if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) |
| 8162 | return FAIL; |
| 8163 | } |
| 8164 | else if (fprintf(fd, "%ld", *valuep) < 0) |
| 8165 | return FAIL; |
| 8166 | if (put_eol(fd) < 0) |
| 8167 | return FAIL; |
| 8168 | return OK; |
| 8169 | } |
| 8170 | |
| 8171 | static int |
| 8172 | put_setbool(fd, cmd, name, value) |
| 8173 | FILE *fd; |
| 8174 | char *cmd; |
| 8175 | char *name; |
| 8176 | int value; |
| 8177 | { |
| 8178 | if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 |
| 8179 | || put_eol(fd) < 0) |
| 8180 | return FAIL; |
| 8181 | return OK; |
| 8182 | } |
| 8183 | |
| 8184 | /* |
| 8185 | * Clear all the terminal options. |
| 8186 | * If the option has been allocated, free the memory. |
| 8187 | * Terminal options are never hidden or indirect. |
| 8188 | */ |
| 8189 | void |
| 8190 | clear_termoptions() |
| 8191 | { |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8192 | /* |
| 8193 | * Reset a few things before clearing the old options. This may cause |
| 8194 | * outputting a few things that the terminal doesn't understand, but the |
| 8195 | * screen will be cleared later, so this is OK. |
| 8196 | */ |
| 8197 | #ifdef FEAT_MOUSE_TTY |
| 8198 | mch_setmouse(FALSE); /* switch mouse off */ |
| 8199 | #endif |
| 8200 | #ifdef FEAT_TITLE |
| 8201 | mch_restore_title(3); /* restore window titles */ |
| 8202 | #endif |
| 8203 | #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI) |
| 8204 | /* When starting the GUI close the display opened for the clipboard. |
| 8205 | * After restoring the title, because that will need the display. */ |
| 8206 | if (gui.starting) |
| 8207 | clear_xterm_clip(); |
| 8208 | #endif |
| 8209 | #ifdef WIN3264 |
| 8210 | /* |
| 8211 | * Check if this is allowed now. |
| 8212 | */ |
| 8213 | if (can_end_termcap_mode(FALSE) == TRUE) |
| 8214 | #endif |
| 8215 | stoptermcap(); /* stop termcap mode */ |
| 8216 | |
Bram Moolenaar | f461c8e | 2005-06-25 23:04:51 +0000 | [diff] [blame] | 8217 | free_termoptions(); |
| 8218 | } |
| 8219 | |
| 8220 | void |
| 8221 | free_termoptions() |
| 8222 | { |
| 8223 | struct vimoption *p; |
| 8224 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8225 | for (p = &options[0]; p->fullname != NULL; p++) |
| 8226 | if (istermoption(p)) |
| 8227 | { |
| 8228 | if (p->flags & P_ALLOCED) |
| 8229 | free_string_option(*(char_u **)(p->var)); |
| 8230 | if (p->flags & P_DEF_ALLOCED) |
| 8231 | free_string_option(p->def_val[VI_DEFAULT]); |
| 8232 | *(char_u **)(p->var) = empty_option; |
| 8233 | p->def_val[VI_DEFAULT] = empty_option; |
| 8234 | p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED); |
| 8235 | } |
| 8236 | clear_termcodes(); |
| 8237 | } |
| 8238 | |
| 8239 | /* |
| 8240 | * Set the terminal option defaults to the current value. |
| 8241 | * Used after setting the terminal name. |
| 8242 | */ |
| 8243 | void |
| 8244 | set_term_defaults() |
| 8245 | { |
| 8246 | struct vimoption *p; |
| 8247 | |
| 8248 | for (p = &options[0]; p->fullname != NULL; p++) |
| 8249 | { |
| 8250 | if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) |
| 8251 | { |
| 8252 | if (p->flags & P_DEF_ALLOCED) |
| 8253 | { |
| 8254 | free_string_option(p->def_val[VI_DEFAULT]); |
| 8255 | p->flags &= ~P_DEF_ALLOCED; |
| 8256 | } |
| 8257 | p->def_val[VI_DEFAULT] = *(char_u **)(p->var); |
| 8258 | if (p->flags & P_ALLOCED) |
| 8259 | { |
| 8260 | p->flags |= P_DEF_ALLOCED; |
| 8261 | p->flags &= ~P_ALLOCED; /* don't free the value now */ |
| 8262 | } |
| 8263 | } |
| 8264 | } |
| 8265 | } |
| 8266 | |
| 8267 | /* |
| 8268 | * return TRUE if 'p' starts with 't_' |
| 8269 | */ |
| 8270 | static int |
| 8271 | istermoption(p) |
| 8272 | struct vimoption *p; |
| 8273 | { |
| 8274 | return (p->fullname[0] == 't' && p->fullname[1] == '_'); |
| 8275 | } |
| 8276 | |
| 8277 | /* |
| 8278 | * Compute columns for ruler and shown command. 'sc_col' is also used to |
| 8279 | * decide what the maximum length of a message on the status line can be. |
| 8280 | * If there is a status line for the last window, 'sc_col' is independent |
| 8281 | * of 'ru_col'. |
| 8282 | */ |
| 8283 | |
| 8284 | #define COL_RULER 17 /* columns needed by standard ruler */ |
| 8285 | |
| 8286 | void |
| 8287 | comp_col() |
| 8288 | { |
| 8289 | #if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS) |
| 8290 | int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin)); |
| 8291 | |
| 8292 | sc_col = 0; |
| 8293 | ru_col = 0; |
| 8294 | if (p_ru) |
| 8295 | { |
| 8296 | #ifdef FEAT_STL_OPT |
| 8297 | ru_col = (ru_wid ? ru_wid : COL_RULER) + 1; |
| 8298 | #else |
| 8299 | ru_col = COL_RULER + 1; |
| 8300 | #endif |
| 8301 | /* no last status line, adjust sc_col */ |
| 8302 | if (!last_has_status) |
| 8303 | sc_col = ru_col; |
| 8304 | } |
| 8305 | if (p_sc) |
| 8306 | { |
| 8307 | sc_col += SHOWCMD_COLS; |
| 8308 | if (!p_ru || last_has_status) /* no need for separating space */ |
| 8309 | ++sc_col; |
| 8310 | } |
| 8311 | sc_col = Columns - sc_col; |
| 8312 | ru_col = Columns - ru_col; |
| 8313 | if (sc_col <= 0) /* screen too narrow, will become a mess */ |
| 8314 | sc_col = 1; |
| 8315 | if (ru_col <= 0) |
| 8316 | ru_col = 1; |
| 8317 | #else |
| 8318 | sc_col = Columns; |
| 8319 | ru_col = Columns; |
| 8320 | #endif |
| 8321 | } |
| 8322 | |
| 8323 | /* |
| 8324 | * Get pointer to option variable, depending on local or global scope. |
| 8325 | */ |
| 8326 | static char_u * |
| 8327 | get_varp_scope(p, opt_flags) |
| 8328 | struct vimoption *p; |
| 8329 | int opt_flags; |
| 8330 | { |
| 8331 | if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE) |
| 8332 | { |
| 8333 | if (p->var == VAR_WIN) |
| 8334 | return (char_u *)GLOBAL_WO(get_varp(p)); |
| 8335 | return p->var; |
| 8336 | } |
| 8337 | if ((opt_flags & OPT_LOCAL) && (int)p->indir >= PV_BOTH) |
| 8338 | { |
| 8339 | switch ((int)p->indir) |
| 8340 | { |
| 8341 | #ifdef FEAT_QUICKFIX |
| 8342 | case OPT_BOTH(PV_GP): return (char_u *)&(curbuf->b_p_gp); |
| 8343 | case OPT_BOTH(PV_MP): return (char_u *)&(curbuf->b_p_mp); |
| 8344 | case OPT_BOTH(PV_EFM): return (char_u *)&(curbuf->b_p_efm); |
| 8345 | #endif |
| 8346 | case OPT_BOTH(PV_EP): return (char_u *)&(curbuf->b_p_ep); |
| 8347 | case OPT_BOTH(PV_KP): return (char_u *)&(curbuf->b_p_kp); |
| 8348 | case OPT_BOTH(PV_PATH): return (char_u *)&(curbuf->b_p_path); |
| 8349 | case OPT_BOTH(PV_AR): return (char_u *)&(curbuf->b_p_ar); |
| 8350 | case OPT_BOTH(PV_TAGS): return (char_u *)&(curbuf->b_p_tags); |
| 8351 | #ifdef FEAT_FIND_ID |
| 8352 | case OPT_BOTH(PV_DEF): return (char_u *)&(curbuf->b_p_def); |
| 8353 | case OPT_BOTH(PV_INC): return (char_u *)&(curbuf->b_p_inc); |
| 8354 | #endif |
| 8355 | #ifdef FEAT_INS_EXPAND |
| 8356 | case OPT_BOTH(PV_DICT): return (char_u *)&(curbuf->b_p_dict); |
| 8357 | case OPT_BOTH(PV_TSR): return (char_u *)&(curbuf->b_p_tsr); |
| 8358 | #endif |
Bram Moolenaar | b5bf5b8 | 2004-12-24 14:35:23 +0000 | [diff] [blame] | 8359 | #ifdef FEAT_STL_OPT |
| 8360 | case OPT_BOTH(PV_STL): return (char_u *)&(curwin->w_p_stl); |
| 8361 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8362 | } |
| 8363 | return NULL; /* "cannot happen" */ |
| 8364 | } |
| 8365 | return get_varp(p); |
| 8366 | } |
| 8367 | |
| 8368 | /* |
| 8369 | * Get pointer to option variable. |
| 8370 | */ |
| 8371 | static char_u * |
| 8372 | get_varp(p) |
| 8373 | struct vimoption *p; |
| 8374 | { |
| 8375 | /* hidden option, always return NULL */ |
| 8376 | if (p->var == NULL) |
| 8377 | return NULL; |
| 8378 | |
| 8379 | switch ((int)p->indir) |
| 8380 | { |
| 8381 | case PV_NONE: return p->var; |
| 8382 | |
| 8383 | /* global option with local value: use local value if it's been set */ |
| 8384 | case OPT_BOTH(PV_EP): return *curbuf->b_p_ep != NUL |
| 8385 | ? (char_u *)&curbuf->b_p_ep : p->var; |
| 8386 | case OPT_BOTH(PV_KP): return *curbuf->b_p_kp != NUL |
| 8387 | ? (char_u *)&curbuf->b_p_kp : p->var; |
| 8388 | case OPT_BOTH(PV_PATH): return *curbuf->b_p_path != NUL |
| 8389 | ? (char_u *)&(curbuf->b_p_path) : p->var; |
| 8390 | case OPT_BOTH(PV_AR): return curbuf->b_p_ar >= 0 |
| 8391 | ? (char_u *)&(curbuf->b_p_ar) : p->var; |
| 8392 | case OPT_BOTH(PV_TAGS): return *curbuf->b_p_tags != NUL |
| 8393 | ? (char_u *)&(curbuf->b_p_tags) : p->var; |
| 8394 | #ifdef FEAT_FIND_ID |
| 8395 | case OPT_BOTH(PV_DEF): return *curbuf->b_p_def != NUL |
| 8396 | ? (char_u *)&(curbuf->b_p_def) : p->var; |
| 8397 | case OPT_BOTH(PV_INC): return *curbuf->b_p_inc != NUL |
| 8398 | ? (char_u *)&(curbuf->b_p_inc) : p->var; |
| 8399 | #endif |
| 8400 | #ifdef FEAT_INS_EXPAND |
| 8401 | case OPT_BOTH(PV_DICT): return *curbuf->b_p_dict != NUL |
| 8402 | ? (char_u *)&(curbuf->b_p_dict) : p->var; |
| 8403 | case OPT_BOTH(PV_TSR): return *curbuf->b_p_tsr != NUL |
| 8404 | ? (char_u *)&(curbuf->b_p_tsr) : p->var; |
| 8405 | #endif |
| 8406 | #ifdef FEAT_QUICKFIX |
| 8407 | case OPT_BOTH(PV_GP): return *curbuf->b_p_gp != NUL |
| 8408 | ? (char_u *)&(curbuf->b_p_gp) : p->var; |
| 8409 | case OPT_BOTH(PV_MP): return *curbuf->b_p_mp != NUL |
| 8410 | ? (char_u *)&(curbuf->b_p_mp) : p->var; |
| 8411 | case OPT_BOTH(PV_EFM): return *curbuf->b_p_efm != NUL |
| 8412 | ? (char_u *)&(curbuf->b_p_efm) : p->var; |
| 8413 | #endif |
Bram Moolenaar | b5bf5b8 | 2004-12-24 14:35:23 +0000 | [diff] [blame] | 8414 | #ifdef FEAT_STL_OPT |
| 8415 | case OPT_BOTH(PV_STL): return *curwin->w_p_stl != NUL |
| 8416 | ? (char_u *)&(curwin->w_p_stl) : p->var; |
| 8417 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8418 | |
| 8419 | #ifdef FEAT_ARABIC |
| 8420 | case PV_ARAB: return (char_u *)&(curwin->w_p_arab); |
| 8421 | #endif |
| 8422 | case PV_LIST: return (char_u *)&(curwin->w_p_list); |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 8423 | #ifdef FEAT_SYN_HL |
| 8424 | case PV_SPELL: return (char_u *)&(curwin->w_p_spell); |
| 8425 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8426 | #ifdef FEAT_DIFF |
| 8427 | case PV_DIFF: return (char_u *)&(curwin->w_p_diff); |
| 8428 | #endif |
| 8429 | #ifdef FEAT_FOLDING |
| 8430 | case PV_FDC: return (char_u *)&(curwin->w_p_fdc); |
| 8431 | case PV_FEN: return (char_u *)&(curwin->w_p_fen); |
| 8432 | case PV_FDI: return (char_u *)&(curwin->w_p_fdi); |
| 8433 | case PV_FDL: return (char_u *)&(curwin->w_p_fdl); |
| 8434 | case PV_FDM: return (char_u *)&(curwin->w_p_fdm); |
| 8435 | case PV_FML: return (char_u *)&(curwin->w_p_fml); |
| 8436 | case PV_FDN: return (char_u *)&(curwin->w_p_fdn); |
| 8437 | # ifdef FEAT_EVAL |
| 8438 | case PV_FDE: return (char_u *)&(curwin->w_p_fde); |
| 8439 | case PV_FDT: return (char_u *)&(curwin->w_p_fdt); |
| 8440 | # endif |
| 8441 | case PV_FMR: return (char_u *)&(curwin->w_p_fmr); |
| 8442 | #endif |
| 8443 | case PV_NU: return (char_u *)&(curwin->w_p_nu); |
Bram Moolenaar | 592e0a2 | 2004-07-03 16:05:59 +0000 | [diff] [blame] | 8444 | #ifdef FEAT_LINEBREAK |
| 8445 | case PV_NUW: return (char_u *)&(curwin->w_p_nuw); |
| 8446 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8447 | #if defined(FEAT_WINDOWS) |
| 8448 | case PV_WFH: return (char_u *)&(curwin->w_p_wfh); |
| 8449 | #endif |
| 8450 | #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) |
| 8451 | case PV_PVW: return (char_u *)&(curwin->w_p_pvw); |
| 8452 | #endif |
| 8453 | #ifdef FEAT_RIGHTLEFT |
| 8454 | case PV_RL: return (char_u *)&(curwin->w_p_rl); |
| 8455 | case PV_RLC: return (char_u *)&(curwin->w_p_rlc); |
| 8456 | #endif |
| 8457 | case PV_SCROLL: return (char_u *)&(curwin->w_p_scr); |
| 8458 | case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); |
| 8459 | #ifdef FEAT_LINEBREAK |
| 8460 | case PV_LBR: return (char_u *)&(curwin->w_p_lbr); |
| 8461 | #endif |
| 8462 | #ifdef FEAT_SCROLLBIND |
| 8463 | case PV_SCBIND: return (char_u *)&(curwin->w_p_scb); |
| 8464 | #endif |
| 8465 | |
| 8466 | case PV_AI: return (char_u *)&(curbuf->b_p_ai); |
| 8467 | case PV_BIN: return (char_u *)&(curbuf->b_p_bin); |
| 8468 | #ifdef FEAT_MBYTE |
| 8469 | case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); |
| 8470 | #endif |
| 8471 | #if defined(FEAT_QUICKFIX) |
| 8472 | case PV_BH: return (char_u *)&(curbuf->b_p_bh); |
| 8473 | case PV_BT: return (char_u *)&(curbuf->b_p_bt); |
| 8474 | #endif |
| 8475 | case PV_BL: return (char_u *)&(curbuf->b_p_bl); |
| 8476 | case PV_CI: return (char_u *)&(curbuf->b_p_ci); |
| 8477 | #ifdef FEAT_CINDENT |
| 8478 | case PV_CIN: return (char_u *)&(curbuf->b_p_cin); |
| 8479 | case PV_CINK: return (char_u *)&(curbuf->b_p_cink); |
| 8480 | case PV_CINO: return (char_u *)&(curbuf->b_p_cino); |
| 8481 | #endif |
| 8482 | #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) |
| 8483 | case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); |
| 8484 | #endif |
| 8485 | #ifdef FEAT_COMMENTS |
| 8486 | case PV_COM: return (char_u *)&(curbuf->b_p_com); |
| 8487 | #endif |
| 8488 | #ifdef FEAT_FOLDING |
| 8489 | case PV_CMS: return (char_u *)&(curbuf->b_p_cms); |
| 8490 | #endif |
| 8491 | #ifdef FEAT_INS_EXPAND |
| 8492 | case PV_CPT: return (char_u *)&(curbuf->b_p_cpt); |
| 8493 | #endif |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 8494 | #ifdef FEAT_COMPL_FUNC |
| 8495 | case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 8496 | case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 8497 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8498 | case PV_EOL: return (char_u *)&(curbuf->b_p_eol); |
| 8499 | case PV_ET: return (char_u *)&(curbuf->b_p_et); |
| 8500 | #ifdef FEAT_MBYTE |
| 8501 | case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); |
| 8502 | #endif |
| 8503 | case PV_FF: return (char_u *)&(curbuf->b_p_ff); |
| 8504 | #ifdef FEAT_AUTOCMD |
| 8505 | case PV_FT: return (char_u *)&(curbuf->b_p_ft); |
| 8506 | #endif |
| 8507 | case PV_FO: return (char_u *)&(curbuf->b_p_fo); |
Bram Moolenaar | 86b6835 | 2004-12-27 21:59:20 +0000 | [diff] [blame] | 8508 | case PV_FLP: return (char_u *)&(curbuf->b_p_flp); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8509 | case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); |
| 8510 | case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); |
| 8511 | case PV_INF: return (char_u *)&(curbuf->b_p_inf); |
| 8512 | case PV_ISK: return (char_u *)&(curbuf->b_p_isk); |
| 8513 | #ifdef FEAT_FIND_ID |
| 8514 | # ifdef FEAT_EVAL |
| 8515 | case PV_INEX: return (char_u *)&(curbuf->b_p_inex); |
| 8516 | # endif |
| 8517 | #endif |
| 8518 | #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) |
| 8519 | case PV_INDE: return (char_u *)&(curbuf->b_p_inde); |
| 8520 | case PV_INDK: return (char_u *)&(curbuf->b_p_indk); |
| 8521 | #endif |
| 8522 | #ifdef FEAT_CRYPT |
| 8523 | case PV_KEY: return (char_u *)&(curbuf->b_p_key); |
| 8524 | #endif |
| 8525 | #ifdef FEAT_LISP |
| 8526 | case PV_LISP: return (char_u *)&(curbuf->b_p_lisp); |
| 8527 | #endif |
| 8528 | case PV_ML: return (char_u *)&(curbuf->b_p_ml); |
| 8529 | case PV_MPS: return (char_u *)&(curbuf->b_p_mps); |
| 8530 | case PV_MA: return (char_u *)&(curbuf->b_p_ma); |
| 8531 | case PV_MOD: return (char_u *)&(curbuf->b_changed); |
| 8532 | case PV_NF: return (char_u *)&(curbuf->b_p_nf); |
| 8533 | #ifdef FEAT_OSFILETYPE |
| 8534 | case PV_OFT: return (char_u *)&(curbuf->b_p_oft); |
| 8535 | #endif |
| 8536 | case PV_PI: return (char_u *)&(curbuf->b_p_pi); |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 8537 | #ifdef FEAT_TEXTOBJ |
| 8538 | case PV_QE: return (char_u *)&(curbuf->b_p_qe); |
| 8539 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8540 | case PV_RO: return (char_u *)&(curbuf->b_p_ro); |
| 8541 | #ifdef FEAT_SMARTINDENT |
| 8542 | case PV_SI: return (char_u *)&(curbuf->b_p_si); |
| 8543 | #endif |
| 8544 | #ifndef SHORT_FNAME |
| 8545 | case PV_SN: return (char_u *)&(curbuf->b_p_sn); |
| 8546 | #endif |
| 8547 | case PV_STS: return (char_u *)&(curbuf->b_p_sts); |
| 8548 | #ifdef FEAT_SEARCHPATH |
| 8549 | case PV_SUA: return (char_u *)&(curbuf->b_p_sua); |
| 8550 | #endif |
| 8551 | case PV_SWF: return (char_u *)&(curbuf->b_p_swf); |
| 8552 | #ifdef FEAT_SYN_HL |
Bram Moolenaar | 3b56eb3 | 2005-07-11 22:40:32 +0000 | [diff] [blame] | 8553 | case PV_SMC: return (char_u *)&(curbuf->b_p_smc); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8554 | case PV_SYN: return (char_u *)&(curbuf->b_p_syn); |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 8555 | case PV_SPC: return (char_u *)&(curbuf->b_p_spc); |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 8556 | case PV_SPF: return (char_u *)&(curbuf->b_p_spf); |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 8557 | case PV_SPL: return (char_u *)&(curbuf->b_p_spl); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8558 | #endif |
| 8559 | case PV_SW: return (char_u *)&(curbuf->b_p_sw); |
| 8560 | case PV_TS: return (char_u *)&(curbuf->b_p_ts); |
| 8561 | case PV_TW: return (char_u *)&(curbuf->b_p_tw); |
| 8562 | case PV_TX: return (char_u *)&(curbuf->b_p_tx); |
| 8563 | case PV_WM: return (char_u *)&(curbuf->b_p_wm); |
| 8564 | #ifdef FEAT_KEYMAP |
| 8565 | case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); |
| 8566 | #endif |
| 8567 | default: EMSG(_("E356: get_varp ERROR")); |
| 8568 | } |
| 8569 | /* always return a valid pointer to avoid a crash! */ |
| 8570 | return (char_u *)&(curbuf->b_p_wm); |
| 8571 | } |
| 8572 | |
| 8573 | /* |
| 8574 | * Get the value of 'equalprg', either the buffer-local one or the global one. |
| 8575 | */ |
| 8576 | char_u * |
| 8577 | get_equalprg() |
| 8578 | { |
| 8579 | if (*curbuf->b_p_ep == NUL) |
| 8580 | return p_ep; |
| 8581 | return curbuf->b_p_ep; |
| 8582 | } |
| 8583 | |
| 8584 | #if defined(FEAT_WINDOWS) || defined(PROTO) |
| 8585 | /* |
| 8586 | * Copy options from one window to another. |
| 8587 | * Used when splitting a window. |
| 8588 | */ |
| 8589 | void |
| 8590 | win_copy_options(wp_from, wp_to) |
| 8591 | win_T *wp_from; |
| 8592 | win_T *wp_to; |
| 8593 | { |
| 8594 | copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); |
| 8595 | copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt); |
| 8596 | # ifdef FEAT_RIGHTLEFT |
| 8597 | # ifdef FEAT_FKMAP |
| 8598 | /* Is this right? */ |
| 8599 | wp_to->w_farsi = wp_from->w_farsi; |
| 8600 | # endif |
| 8601 | # endif |
| 8602 | } |
| 8603 | #endif |
| 8604 | |
| 8605 | /* |
| 8606 | * Copy the options from one winopt_T to another. |
| 8607 | * Doesn't free the old option values in "to", use clear_winopt() for that. |
| 8608 | * The 'scroll' option is not copied, because it depends on the window height. |
| 8609 | * The 'previewwindow' option is reset, there can be only one preview window. |
| 8610 | */ |
| 8611 | void |
| 8612 | copy_winopt(from, to) |
| 8613 | winopt_T *from; |
| 8614 | winopt_T *to; |
| 8615 | { |
| 8616 | #ifdef FEAT_ARABIC |
| 8617 | to->wo_arab = from->wo_arab; |
| 8618 | #endif |
| 8619 | to->wo_list = from->wo_list; |
| 8620 | to->wo_nu = from->wo_nu; |
Bram Moolenaar | 592e0a2 | 2004-07-03 16:05:59 +0000 | [diff] [blame] | 8621 | #ifdef FEAT_LINEBREAK |
| 8622 | to->wo_nuw = from->wo_nuw; |
| 8623 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8624 | #ifdef FEAT_RIGHTLEFT |
| 8625 | to->wo_rl = from->wo_rl; |
| 8626 | to->wo_rlc = vim_strsave(from->wo_rlc); |
| 8627 | #endif |
Bram Moolenaar | b5bf5b8 | 2004-12-24 14:35:23 +0000 | [diff] [blame] | 8628 | #ifdef FEAT_STL_OPT |
| 8629 | to->wo_stl = vim_strsave(from->wo_stl); |
| 8630 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8631 | to->wo_wrap = from->wo_wrap; |
| 8632 | #ifdef FEAT_LINEBREAK |
| 8633 | to->wo_lbr = from->wo_lbr; |
| 8634 | #endif |
| 8635 | #ifdef FEAT_SCROLLBIND |
| 8636 | to->wo_scb = from->wo_scb; |
| 8637 | #endif |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 8638 | #ifdef FEAT_SYN_HL |
| 8639 | to->wo_spell = from->wo_spell; |
| 8640 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8641 | #ifdef FEAT_DIFF |
| 8642 | to->wo_diff = from->wo_diff; |
| 8643 | #endif |
| 8644 | #ifdef FEAT_FOLDING |
| 8645 | to->wo_fdc = from->wo_fdc; |
| 8646 | to->wo_fen = from->wo_fen; |
| 8647 | to->wo_fdi = vim_strsave(from->wo_fdi); |
| 8648 | to->wo_fml = from->wo_fml; |
| 8649 | to->wo_fdl = from->wo_fdl; |
| 8650 | to->wo_fdm = vim_strsave(from->wo_fdm); |
| 8651 | to->wo_fdn = from->wo_fdn; |
| 8652 | # ifdef FEAT_EVAL |
| 8653 | to->wo_fde = vim_strsave(from->wo_fde); |
| 8654 | to->wo_fdt = vim_strsave(from->wo_fdt); |
| 8655 | # endif |
| 8656 | to->wo_fmr = vim_strsave(from->wo_fmr); |
| 8657 | #endif |
| 8658 | check_winopt(to); /* don't want NULL pointers */ |
| 8659 | } |
| 8660 | |
| 8661 | /* |
| 8662 | * Check string options in a window for a NULL value. |
| 8663 | */ |
| 8664 | void |
| 8665 | check_win_options(win) |
| 8666 | win_T *win; |
| 8667 | { |
| 8668 | check_winopt(&win->w_onebuf_opt); |
| 8669 | check_winopt(&win->w_allbuf_opt); |
| 8670 | } |
| 8671 | |
| 8672 | /* |
| 8673 | * Check for NULL pointers in a winopt_T and replace them with empty_option. |
| 8674 | */ |
| 8675 | /*ARGSUSED*/ |
| 8676 | void |
| 8677 | check_winopt(wop) |
| 8678 | winopt_T *wop; |
| 8679 | { |
| 8680 | #ifdef FEAT_FOLDING |
| 8681 | check_string_option(&wop->wo_fdi); |
| 8682 | check_string_option(&wop->wo_fdm); |
| 8683 | # ifdef FEAT_EVAL |
| 8684 | check_string_option(&wop->wo_fde); |
| 8685 | check_string_option(&wop->wo_fdt); |
| 8686 | # endif |
| 8687 | check_string_option(&wop->wo_fmr); |
| 8688 | #endif |
| 8689 | #ifdef FEAT_RIGHTLEFT |
| 8690 | check_string_option(&wop->wo_rlc); |
| 8691 | #endif |
Bram Moolenaar | b5bf5b8 | 2004-12-24 14:35:23 +0000 | [diff] [blame] | 8692 | #ifdef FEAT_STL_OPT |
| 8693 | check_string_option(&wop->wo_stl); |
| 8694 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8695 | } |
| 8696 | |
| 8697 | /* |
| 8698 | * Free the allocated memory inside a winopt_T. |
| 8699 | */ |
| 8700 | /*ARGSUSED*/ |
| 8701 | void |
| 8702 | clear_winopt(wop) |
| 8703 | winopt_T *wop; |
| 8704 | { |
| 8705 | #ifdef FEAT_FOLDING |
| 8706 | clear_string_option(&wop->wo_fdi); |
| 8707 | clear_string_option(&wop->wo_fdm); |
| 8708 | # ifdef FEAT_EVAL |
| 8709 | clear_string_option(&wop->wo_fde); |
| 8710 | clear_string_option(&wop->wo_fdt); |
| 8711 | # endif |
| 8712 | clear_string_option(&wop->wo_fmr); |
| 8713 | #endif |
| 8714 | #ifdef FEAT_RIGHTLEFT |
| 8715 | clear_string_option(&wop->wo_rlc); |
| 8716 | #endif |
Bram Moolenaar | b5bf5b8 | 2004-12-24 14:35:23 +0000 | [diff] [blame] | 8717 | #ifdef FEAT_STL_OPT |
| 8718 | clear_string_option(&wop->wo_stl); |
| 8719 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8720 | } |
| 8721 | |
| 8722 | /* |
| 8723 | * Copy global option values to local options for one buffer. |
| 8724 | * Used when creating a new buffer and sometimes when entering a buffer. |
| 8725 | * flags: |
| 8726 | * BCO_ENTER We will enter the buf buffer. |
| 8727 | * BCO_ALWAYS Always copy the options, but only set b_p_initialized when |
| 8728 | * appropriate. |
| 8729 | * BCO_NOHELP Don't copy the values to a help buffer. |
| 8730 | */ |
| 8731 | void |
| 8732 | buf_copy_options(buf, flags) |
| 8733 | buf_T *buf; |
| 8734 | int flags; |
| 8735 | { |
| 8736 | int should_copy = TRUE; |
| 8737 | char_u *save_p_isk = NULL; /* init for GCC */ |
| 8738 | int dont_do_help; |
| 8739 | int did_isk = FALSE; |
| 8740 | |
| 8741 | /* |
| 8742 | * Don't do anything of the buffer is invalid. |
| 8743 | */ |
| 8744 | if (buf == NULL || !buf_valid(buf)) |
| 8745 | return; |
| 8746 | |
| 8747 | /* |
| 8748 | * Skip this when the option defaults have not been set yet. Happens when |
| 8749 | * main() allocates the first buffer. |
| 8750 | */ |
| 8751 | if (p_cpo != NULL) |
| 8752 | { |
| 8753 | /* |
| 8754 | * Always copy when entering and 'cpo' contains 'S'. |
| 8755 | * Don't copy when already initialized. |
| 8756 | * Don't copy when 'cpo' contains 's' and not entering. |
| 8757 | * 'S' BCO_ENTER initialized 's' should_copy |
| 8758 | * yes yes X X TRUE |
| 8759 | * yes no yes X FALSE |
| 8760 | * no X yes X FALSE |
| 8761 | * X no no yes FALSE |
| 8762 | * X no no no TRUE |
| 8763 | * no yes no X TRUE |
| 8764 | */ |
| 8765 | if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) |
| 8766 | && (buf->b_p_initialized |
| 8767 | || (!(flags & BCO_ENTER) |
| 8768 | && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) |
| 8769 | should_copy = FALSE; |
| 8770 | |
| 8771 | if (should_copy || (flags & BCO_ALWAYS)) |
| 8772 | { |
| 8773 | /* Don't copy the options specific to a help buffer when |
| 8774 | * BCO_NOHELP is given or the options were initialized already |
| 8775 | * (jumping back to a help file with CTRL-T or CTRL-O) */ |
| 8776 | dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) |
| 8777 | || buf->b_p_initialized; |
| 8778 | if (dont_do_help) /* don't free b_p_isk */ |
| 8779 | { |
| 8780 | save_p_isk = buf->b_p_isk; |
| 8781 | buf->b_p_isk = NULL; |
| 8782 | } |
| 8783 | /* |
| 8784 | * Always free the allocated strings. |
| 8785 | * If not already initialized, set 'readonly' and copy 'fileformat'. |
| 8786 | */ |
| 8787 | if (!buf->b_p_initialized) |
| 8788 | { |
| 8789 | free_buf_options(buf, TRUE); |
| 8790 | buf->b_p_ro = FALSE; /* don't copy readonly */ |
| 8791 | buf->b_p_tx = p_tx; |
| 8792 | #ifdef FEAT_MBYTE |
| 8793 | buf->b_p_fenc = vim_strsave(p_fenc); |
| 8794 | #endif |
| 8795 | buf->b_p_ff = vim_strsave(p_ff); |
| 8796 | #if defined(FEAT_QUICKFIX) |
| 8797 | buf->b_p_bh = empty_option; |
| 8798 | buf->b_p_bt = empty_option; |
| 8799 | #endif |
| 8800 | } |
| 8801 | else |
| 8802 | free_buf_options(buf, FALSE); |
| 8803 | |
| 8804 | buf->b_p_ai = p_ai; |
| 8805 | buf->b_p_ai_nopaste = p_ai_nopaste; |
| 8806 | buf->b_p_sw = p_sw; |
| 8807 | buf->b_p_tw = p_tw; |
| 8808 | buf->b_p_tw_nopaste = p_tw_nopaste; |
| 8809 | buf->b_p_tw_nobin = p_tw_nobin; |
| 8810 | buf->b_p_wm = p_wm; |
| 8811 | buf->b_p_wm_nopaste = p_wm_nopaste; |
| 8812 | buf->b_p_wm_nobin = p_wm_nobin; |
| 8813 | buf->b_p_bin = p_bin; |
Bram Moolenaar | e8bb255 | 2005-07-08 22:26:47 +0000 | [diff] [blame] | 8814 | #ifdef FEAT_MBYTE |
| 8815 | buf->b_p_bomb = p_bomb; |
| 8816 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8817 | buf->b_p_et = p_et; |
| 8818 | buf->b_p_et_nobin = p_et_nobin; |
| 8819 | buf->b_p_ml = p_ml; |
| 8820 | buf->b_p_ml_nobin = p_ml_nobin; |
| 8821 | buf->b_p_inf = p_inf; |
| 8822 | buf->b_p_swf = p_swf; |
| 8823 | #ifdef FEAT_INS_EXPAND |
| 8824 | buf->b_p_cpt = vim_strsave(p_cpt); |
| 8825 | #endif |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 8826 | #ifdef FEAT_COMPL_FUNC |
| 8827 | buf->b_p_cfu = vim_strsave(p_cfu); |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 8828 | buf->b_p_ofu = vim_strsave(p_ofu); |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 8829 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8830 | buf->b_p_sts = p_sts; |
| 8831 | buf->b_p_sts_nopaste = p_sts_nopaste; |
| 8832 | #ifndef SHORT_FNAME |
| 8833 | buf->b_p_sn = p_sn; |
| 8834 | #endif |
| 8835 | #ifdef FEAT_COMMENTS |
| 8836 | buf->b_p_com = vim_strsave(p_com); |
| 8837 | #endif |
| 8838 | #ifdef FEAT_FOLDING |
| 8839 | buf->b_p_cms = vim_strsave(p_cms); |
| 8840 | #endif |
| 8841 | buf->b_p_fo = vim_strsave(p_fo); |
Bram Moolenaar | 86b6835 | 2004-12-27 21:59:20 +0000 | [diff] [blame] | 8842 | buf->b_p_flp = vim_strsave(p_flp); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8843 | buf->b_p_nf = vim_strsave(p_nf); |
| 8844 | buf->b_p_mps = vim_strsave(p_mps); |
| 8845 | #ifdef FEAT_SMARTINDENT |
| 8846 | buf->b_p_si = p_si; |
| 8847 | #endif |
| 8848 | buf->b_p_ci = p_ci; |
| 8849 | #ifdef FEAT_CINDENT |
| 8850 | buf->b_p_cin = p_cin; |
| 8851 | buf->b_p_cink = vim_strsave(p_cink); |
| 8852 | buf->b_p_cino = vim_strsave(p_cino); |
| 8853 | #endif |
| 8854 | #ifdef FEAT_AUTOCMD |
| 8855 | /* Don't copy 'filetype', it must be detected */ |
| 8856 | buf->b_p_ft = empty_option; |
| 8857 | #endif |
| 8858 | #ifdef FEAT_OSFILETYPE |
| 8859 | buf->b_p_oft = vim_strsave(p_oft); |
| 8860 | #endif |
| 8861 | buf->b_p_pi = p_pi; |
| 8862 | #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) |
| 8863 | buf->b_p_cinw = vim_strsave(p_cinw); |
| 8864 | #endif |
| 8865 | #ifdef FEAT_LISP |
| 8866 | buf->b_p_lisp = p_lisp; |
| 8867 | #endif |
| 8868 | #ifdef FEAT_SYN_HL |
| 8869 | /* Don't copy 'syntax', it must be set */ |
| 8870 | buf->b_p_syn = empty_option; |
Bram Moolenaar | 3b56eb3 | 2005-07-11 22:40:32 +0000 | [diff] [blame] | 8871 | buf->b_p_smc = p_smc; |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 8872 | buf->b_p_spc = vim_strsave(p_spc); |
Bram Moolenaar | 0dc065e | 2005-07-04 22:49:24 +0000 | [diff] [blame] | 8873 | (void)compile_cap_prog(buf); |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 8874 | buf->b_p_spf = vim_strsave(p_spf); |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 8875 | buf->b_p_spl = vim_strsave(p_spl); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8876 | #endif |
| 8877 | #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) |
| 8878 | buf->b_p_inde = vim_strsave(p_inde); |
| 8879 | buf->b_p_indk = vim_strsave(p_indk); |
| 8880 | #endif |
| 8881 | #ifdef FEAT_CRYPT |
| 8882 | buf->b_p_key = vim_strsave(p_key); |
| 8883 | #endif |
| 8884 | #ifdef FEAT_SEARCHPATH |
| 8885 | buf->b_p_sua = vim_strsave(p_sua); |
| 8886 | #endif |
| 8887 | #ifdef FEAT_KEYMAP |
| 8888 | buf->b_p_keymap = vim_strsave(p_keymap); |
| 8889 | buf->b_kmap_state |= KEYMAP_INIT; |
| 8890 | #endif |
| 8891 | /* This isn't really an option, but copying the langmap and IME |
| 8892 | * state from the current buffer is better than resetting it. */ |
| 8893 | buf->b_p_iminsert = p_iminsert; |
| 8894 | buf->b_p_imsearch = p_imsearch; |
| 8895 | |
| 8896 | /* options that are normally global but also have a local value |
| 8897 | * are not copied, start using the global value */ |
| 8898 | buf->b_p_ar = -1; |
| 8899 | #ifdef FEAT_QUICKFIX |
| 8900 | buf->b_p_gp = empty_option; |
| 8901 | buf->b_p_mp = empty_option; |
| 8902 | buf->b_p_efm = empty_option; |
| 8903 | #endif |
| 8904 | buf->b_p_ep = empty_option; |
| 8905 | buf->b_p_kp = empty_option; |
| 8906 | buf->b_p_path = empty_option; |
| 8907 | buf->b_p_tags = empty_option; |
| 8908 | #ifdef FEAT_FIND_ID |
| 8909 | buf->b_p_def = empty_option; |
| 8910 | buf->b_p_inc = empty_option; |
| 8911 | # ifdef FEAT_EVAL |
| 8912 | buf->b_p_inex = vim_strsave(p_inex); |
| 8913 | # endif |
| 8914 | #endif |
| 8915 | #ifdef FEAT_INS_EXPAND |
| 8916 | buf->b_p_dict = empty_option; |
| 8917 | buf->b_p_tsr = empty_option; |
| 8918 | #endif |
Bram Moolenaar | cfbc5ee | 2004-07-02 15:38:35 +0000 | [diff] [blame] | 8919 | #ifdef FEAT_TEXTOBJ |
| 8920 | buf->b_p_qe = vim_strsave(p_qe); |
| 8921 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8922 | |
| 8923 | /* |
| 8924 | * Don't copy the options set by ex_help(), use the saved values, |
| 8925 | * when going from a help buffer to a non-help buffer. |
| 8926 | * Don't touch these at all when BCO_NOHELP is used and going from |
| 8927 | * or to a help buffer. |
| 8928 | */ |
| 8929 | if (dont_do_help) |
| 8930 | buf->b_p_isk = save_p_isk; |
| 8931 | else |
| 8932 | { |
| 8933 | buf->b_p_isk = vim_strsave(p_isk); |
| 8934 | did_isk = TRUE; |
| 8935 | buf->b_p_ts = p_ts; |
| 8936 | buf->b_help = FALSE; |
| 8937 | #ifdef FEAT_QUICKFIX |
| 8938 | if (buf->b_p_bt[0] == 'h') |
| 8939 | clear_string_option(&buf->b_p_bt); |
| 8940 | #endif |
| 8941 | buf->b_p_ma = p_ma; |
| 8942 | } |
| 8943 | } |
| 8944 | |
| 8945 | /* |
| 8946 | * When the options should be copied (ignoring BCO_ALWAYS), set the |
| 8947 | * flag that indicates that the options have been initialized. |
| 8948 | */ |
| 8949 | if (should_copy) |
| 8950 | buf->b_p_initialized = TRUE; |
| 8951 | } |
| 8952 | |
| 8953 | check_buf_options(buf); /* make sure we don't have NULLs */ |
| 8954 | if (did_isk) |
| 8955 | (void)buf_init_chartab(buf, FALSE); |
| 8956 | } |
| 8957 | |
| 8958 | /* |
| 8959 | * Reset the 'modifiable' option and its default value. |
| 8960 | */ |
| 8961 | void |
| 8962 | reset_modifiable() |
| 8963 | { |
| 8964 | int opt_idx; |
| 8965 | |
| 8966 | curbuf->b_p_ma = FALSE; |
| 8967 | p_ma = FALSE; |
| 8968 | opt_idx = findoption((char_u *)"ma"); |
| 8969 | options[opt_idx].def_val[VI_DEFAULT] = FALSE; |
| 8970 | } |
| 8971 | |
| 8972 | /* |
| 8973 | * Set the global value for 'iminsert' to the local value. |
| 8974 | */ |
| 8975 | void |
| 8976 | set_iminsert_global() |
| 8977 | { |
| 8978 | p_iminsert = curbuf->b_p_iminsert; |
| 8979 | } |
| 8980 | |
| 8981 | /* |
| 8982 | * Set the global value for 'imsearch' to the local value. |
| 8983 | */ |
| 8984 | void |
| 8985 | set_imsearch_global() |
| 8986 | { |
| 8987 | p_imsearch = curbuf->b_p_imsearch; |
| 8988 | } |
| 8989 | |
| 8990 | #if defined(FEAT_CMDL_COMPL) || defined(PROTO) |
| 8991 | static int expand_option_idx = -1; |
| 8992 | static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; |
| 8993 | static int expand_option_flags = 0; |
| 8994 | |
| 8995 | void |
| 8996 | set_context_in_set_cmd(xp, arg, opt_flags) |
| 8997 | expand_T *xp; |
| 8998 | char_u *arg; |
| 8999 | int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */ |
| 9000 | { |
| 9001 | int nextchar; |
| 9002 | long_u flags = 0; /* init for GCC */ |
| 9003 | int opt_idx = 0; /* init for GCC */ |
| 9004 | char_u *p; |
| 9005 | char_u *s; |
| 9006 | int is_term_option = FALSE; |
| 9007 | int key; |
| 9008 | |
| 9009 | expand_option_flags = opt_flags; |
| 9010 | |
| 9011 | xp->xp_context = EXPAND_SETTINGS; |
| 9012 | if (*arg == NUL) |
| 9013 | { |
| 9014 | xp->xp_pattern = arg; |
| 9015 | return; |
| 9016 | } |
| 9017 | p = arg + STRLEN(arg) - 1; |
| 9018 | if (*p == ' ' && *(p - 1) != '\\') |
| 9019 | { |
| 9020 | xp->xp_pattern = p + 1; |
| 9021 | return; |
| 9022 | } |
| 9023 | while (p > arg) |
| 9024 | { |
| 9025 | s = p; |
| 9026 | /* count number of backslashes before ' ' or ',' */ |
| 9027 | if (*p == ' ' || *p == ',') |
| 9028 | { |
| 9029 | while (s > arg && *(s - 1) == '\\') |
| 9030 | --s; |
| 9031 | } |
| 9032 | /* break at a space with an even number of backslashes */ |
| 9033 | if (*p == ' ' && ((p - s) & 1) == 0) |
| 9034 | { |
| 9035 | ++p; |
| 9036 | break; |
| 9037 | } |
| 9038 | --p; |
| 9039 | } |
| 9040 | if (STRNCMP(p, "no", 2) == 0) |
| 9041 | { |
| 9042 | xp->xp_context = EXPAND_BOOL_SETTINGS; |
| 9043 | p += 2; |
| 9044 | } |
| 9045 | if (STRNCMP(p, "inv", 3) == 0) |
| 9046 | { |
| 9047 | xp->xp_context = EXPAND_BOOL_SETTINGS; |
| 9048 | p += 3; |
| 9049 | } |
| 9050 | xp->xp_pattern = arg = p; |
| 9051 | if (*arg == '<') |
| 9052 | { |
| 9053 | while (*p != '>') |
| 9054 | if (*p++ == NUL) /* expand terminal option name */ |
| 9055 | return; |
| 9056 | key = get_special_key_code(arg + 1); |
| 9057 | if (key == 0) /* unknown name */ |
| 9058 | { |
| 9059 | xp->xp_context = EXPAND_NOTHING; |
| 9060 | return; |
| 9061 | } |
| 9062 | nextchar = *++p; |
| 9063 | is_term_option = TRUE; |
| 9064 | expand_option_name[2] = KEY2TERMCAP0(key); |
| 9065 | expand_option_name[3] = KEY2TERMCAP1(key); |
| 9066 | } |
| 9067 | else |
| 9068 | { |
| 9069 | if (p[0] == 't' && p[1] == '_') |
| 9070 | { |
| 9071 | p += 2; |
| 9072 | if (*p != NUL) |
| 9073 | ++p; |
| 9074 | if (*p == NUL) |
| 9075 | return; /* expand option name */ |
| 9076 | nextchar = *++p; |
| 9077 | is_term_option = TRUE; |
| 9078 | expand_option_name[2] = p[-2]; |
| 9079 | expand_option_name[3] = p[-1]; |
| 9080 | } |
| 9081 | else |
| 9082 | { |
| 9083 | /* Allow * wildcard */ |
| 9084 | while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') |
| 9085 | p++; |
| 9086 | if (*p == NUL) |
| 9087 | return; |
| 9088 | nextchar = *p; |
| 9089 | *p = NUL; |
| 9090 | opt_idx = findoption(arg); |
| 9091 | *p = nextchar; |
| 9092 | if (opt_idx == -1 || options[opt_idx].var == NULL) |
| 9093 | { |
| 9094 | xp->xp_context = EXPAND_NOTHING; |
| 9095 | return; |
| 9096 | } |
| 9097 | flags = options[opt_idx].flags; |
| 9098 | if (flags & P_BOOL) |
| 9099 | { |
| 9100 | xp->xp_context = EXPAND_NOTHING; |
| 9101 | return; |
| 9102 | } |
| 9103 | } |
| 9104 | } |
| 9105 | /* handle "-=" and "+=" */ |
| 9106 | if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') |
| 9107 | { |
| 9108 | ++p; |
| 9109 | nextchar = '='; |
| 9110 | } |
| 9111 | if ((nextchar != '=' && nextchar != ':') |
| 9112 | || xp->xp_context == EXPAND_BOOL_SETTINGS) |
| 9113 | { |
| 9114 | xp->xp_context = EXPAND_UNSUCCESSFUL; |
| 9115 | return; |
| 9116 | } |
| 9117 | if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) |
| 9118 | { |
| 9119 | xp->xp_context = EXPAND_OLD_SETTING; |
| 9120 | if (is_term_option) |
| 9121 | expand_option_idx = -1; |
| 9122 | else |
| 9123 | expand_option_idx = opt_idx; |
| 9124 | xp->xp_pattern = p + 1; |
| 9125 | return; |
| 9126 | } |
| 9127 | xp->xp_context = EXPAND_NOTHING; |
| 9128 | if (is_term_option || (flags & P_NUM)) |
| 9129 | return; |
| 9130 | |
| 9131 | xp->xp_pattern = p + 1; |
| 9132 | |
| 9133 | if (flags & P_EXPAND) |
| 9134 | { |
| 9135 | p = options[opt_idx].var; |
| 9136 | if (p == (char_u *)&p_bdir |
| 9137 | || p == (char_u *)&p_dir |
| 9138 | || p == (char_u *)&p_path |
| 9139 | || p == (char_u *)&p_rtp |
| 9140 | #ifdef FEAT_SEARCHPATH |
| 9141 | || p == (char_u *)&p_cdpath |
| 9142 | #endif |
| 9143 | #ifdef FEAT_SESSION |
| 9144 | || p == (char_u *)&p_vdir |
| 9145 | #endif |
| 9146 | ) |
| 9147 | { |
| 9148 | xp->xp_context = EXPAND_DIRECTORIES; |
| 9149 | if (p == (char_u *)&p_path |
| 9150 | #ifdef FEAT_SEARCHPATH |
| 9151 | || p == (char_u *)&p_cdpath |
| 9152 | #endif |
| 9153 | ) |
| 9154 | xp->xp_backslash = XP_BS_THREE; |
| 9155 | else |
| 9156 | xp->xp_backslash = XP_BS_ONE; |
| 9157 | } |
| 9158 | else |
| 9159 | { |
| 9160 | xp->xp_context = EXPAND_FILES; |
| 9161 | /* for 'tags' need three backslashes for a space */ |
| 9162 | if (p == (char_u *)&p_tags) |
| 9163 | xp->xp_backslash = XP_BS_THREE; |
| 9164 | else |
| 9165 | xp->xp_backslash = XP_BS_ONE; |
| 9166 | } |
| 9167 | } |
| 9168 | |
| 9169 | /* For an option that is a list of file names, find the start of the |
| 9170 | * last file name. */ |
| 9171 | for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) |
| 9172 | { |
| 9173 | /* count number of backslashes before ' ' or ',' */ |
| 9174 | if (*p == ' ' || *p == ',') |
| 9175 | { |
| 9176 | s = p; |
| 9177 | while (s > xp->xp_pattern && *(s - 1) == '\\') |
| 9178 | --s; |
| 9179 | if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) |
| 9180 | || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) |
| 9181 | { |
| 9182 | xp->xp_pattern = p + 1; |
| 9183 | break; |
| 9184 | } |
| 9185 | } |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 9186 | |
| 9187 | #ifdef FEAT_SYN_HL |
| 9188 | /* for 'spellsuggest' start at "file:" */ |
| 9189 | if (options[opt_idx].var == (char_u *)&p_sps |
| 9190 | && STRNCMP(p, "file:", 5) == 0) |
| 9191 | { |
| 9192 | xp->xp_pattern = p + 5; |
| 9193 | break; |
| 9194 | } |
| 9195 | #endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9196 | } |
| 9197 | |
| 9198 | return; |
| 9199 | } |
| 9200 | |
| 9201 | int |
| 9202 | ExpandSettings(xp, regmatch, num_file, file) |
| 9203 | expand_T *xp; |
| 9204 | regmatch_T *regmatch; |
| 9205 | int *num_file; |
| 9206 | char_u ***file; |
| 9207 | { |
| 9208 | int num_normal = 0; /* Nr of matching non-term-code settings */ |
| 9209 | int num_term = 0; /* Nr of matching terminal code settings */ |
| 9210 | int opt_idx; |
| 9211 | int match; |
| 9212 | int count = 0; |
| 9213 | char_u *str; |
| 9214 | int loop; |
| 9215 | int is_term_opt; |
| 9216 | char_u name_buf[MAX_KEY_NAME_LEN]; |
| 9217 | static char *(names[]) = {"all", "termcap"}; |
| 9218 | int ic = regmatch->rm_ic; /* remember the ignore-case flag */ |
| 9219 | |
| 9220 | /* do this loop twice: |
| 9221 | * loop == 0: count the number of matching options |
| 9222 | * loop == 1: copy the matching options into allocated memory |
| 9223 | */ |
| 9224 | for (loop = 0; loop <= 1; ++loop) |
| 9225 | { |
| 9226 | regmatch->rm_ic = ic; |
| 9227 | if (xp->xp_context != EXPAND_BOOL_SETTINGS) |
| 9228 | { |
| 9229 | for (match = 0; match < sizeof(names) / sizeof(char *); ++match) |
| 9230 | if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0)) |
| 9231 | { |
| 9232 | if (loop == 0) |
| 9233 | num_normal++; |
| 9234 | else |
| 9235 | (*file)[count++] = vim_strsave((char_u *)names[match]); |
| 9236 | } |
| 9237 | } |
| 9238 | for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; |
| 9239 | opt_idx++) |
| 9240 | { |
| 9241 | if (options[opt_idx].var == NULL) |
| 9242 | continue; |
| 9243 | if (xp->xp_context == EXPAND_BOOL_SETTINGS |
| 9244 | && !(options[opt_idx].flags & P_BOOL)) |
| 9245 | continue; |
| 9246 | is_term_opt = istermoption(&options[opt_idx]); |
| 9247 | if (is_term_opt && num_normal > 0) |
| 9248 | continue; |
| 9249 | match = FALSE; |
| 9250 | if (vim_regexec(regmatch, str, (colnr_T)0) |
| 9251 | || (options[opt_idx].shortname != NULL |
| 9252 | && vim_regexec(regmatch, |
| 9253 | (char_u *)options[opt_idx].shortname, (colnr_T)0))) |
| 9254 | match = TRUE; |
| 9255 | else if (is_term_opt) |
| 9256 | { |
| 9257 | name_buf[0] = '<'; |
| 9258 | name_buf[1] = 't'; |
| 9259 | name_buf[2] = '_'; |
| 9260 | name_buf[3] = str[2]; |
| 9261 | name_buf[4] = str[3]; |
| 9262 | name_buf[5] = '>'; |
| 9263 | name_buf[6] = NUL; |
| 9264 | if (vim_regexec(regmatch, name_buf, (colnr_T)0)) |
| 9265 | { |
| 9266 | match = TRUE; |
| 9267 | str = name_buf; |
| 9268 | } |
| 9269 | } |
| 9270 | if (match) |
| 9271 | { |
| 9272 | if (loop == 0) |
| 9273 | { |
| 9274 | if (is_term_opt) |
| 9275 | num_term++; |
| 9276 | else |
| 9277 | num_normal++; |
| 9278 | } |
| 9279 | else |
| 9280 | (*file)[count++] = vim_strsave(str); |
| 9281 | } |
| 9282 | } |
| 9283 | /* |
| 9284 | * Check terminal key codes, these are not in the option table |
| 9285 | */ |
| 9286 | if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) |
| 9287 | { |
| 9288 | for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) |
| 9289 | { |
| 9290 | if (!isprint(str[0]) || !isprint(str[1])) |
| 9291 | continue; |
| 9292 | |
| 9293 | name_buf[0] = 't'; |
| 9294 | name_buf[1] = '_'; |
| 9295 | name_buf[2] = str[0]; |
| 9296 | name_buf[3] = str[1]; |
| 9297 | name_buf[4] = NUL; |
| 9298 | |
| 9299 | match = FALSE; |
| 9300 | if (vim_regexec(regmatch, name_buf, (colnr_T)0)) |
| 9301 | match = TRUE; |
| 9302 | else |
| 9303 | { |
| 9304 | name_buf[0] = '<'; |
| 9305 | name_buf[1] = 't'; |
| 9306 | name_buf[2] = '_'; |
| 9307 | name_buf[3] = str[0]; |
| 9308 | name_buf[4] = str[1]; |
| 9309 | name_buf[5] = '>'; |
| 9310 | name_buf[6] = NUL; |
| 9311 | |
| 9312 | if (vim_regexec(regmatch, name_buf, (colnr_T)0)) |
| 9313 | match = TRUE; |
| 9314 | } |
| 9315 | if (match) |
| 9316 | { |
| 9317 | if (loop == 0) |
| 9318 | num_term++; |
| 9319 | else |
| 9320 | (*file)[count++] = vim_strsave(name_buf); |
| 9321 | } |
| 9322 | } |
| 9323 | |
| 9324 | /* |
| 9325 | * Check special key names. |
| 9326 | */ |
| 9327 | regmatch->rm_ic = TRUE; /* ignore case here */ |
| 9328 | for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) |
| 9329 | { |
| 9330 | name_buf[0] = '<'; |
| 9331 | STRCPY(name_buf + 1, str); |
| 9332 | STRCAT(name_buf, ">"); |
| 9333 | |
| 9334 | if (vim_regexec(regmatch, name_buf, (colnr_T)0)) |
| 9335 | { |
| 9336 | if (loop == 0) |
| 9337 | num_term++; |
| 9338 | else |
| 9339 | (*file)[count++] = vim_strsave(name_buf); |
| 9340 | } |
| 9341 | } |
| 9342 | } |
| 9343 | if (loop == 0) |
| 9344 | { |
| 9345 | if (num_normal > 0) |
| 9346 | *num_file = num_normal; |
| 9347 | else if (num_term > 0) |
| 9348 | *num_file = num_term; |
| 9349 | else |
| 9350 | return OK; |
| 9351 | *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *))); |
| 9352 | if (*file == NULL) |
| 9353 | { |
| 9354 | *file = (char_u **)""; |
| 9355 | return FAIL; |
| 9356 | } |
| 9357 | } |
| 9358 | } |
| 9359 | return OK; |
| 9360 | } |
| 9361 | |
| 9362 | int |
| 9363 | ExpandOldSetting(num_file, file) |
| 9364 | int *num_file; |
| 9365 | char_u ***file; |
| 9366 | { |
| 9367 | char_u *var = NULL; /* init for GCC */ |
| 9368 | char_u *buf; |
| 9369 | |
| 9370 | *num_file = 0; |
| 9371 | *file = (char_u **)alloc((unsigned)sizeof(char_u *)); |
| 9372 | if (*file == NULL) |
| 9373 | return FAIL; |
| 9374 | |
| 9375 | /* |
| 9376 | * For a terminal key code expand_option_idx is < 0. |
| 9377 | */ |
| 9378 | if (expand_option_idx < 0) |
| 9379 | { |
| 9380 | var = find_termcode(expand_option_name + 2); |
| 9381 | if (var == NULL) |
| 9382 | expand_option_idx = findoption(expand_option_name); |
| 9383 | } |
| 9384 | |
| 9385 | if (expand_option_idx >= 0) |
| 9386 | { |
| 9387 | /* put string of option value in NameBuff */ |
| 9388 | option_value2string(&options[expand_option_idx], expand_option_flags); |
| 9389 | var = NameBuff; |
| 9390 | } |
| 9391 | else if (var == NULL) |
| 9392 | var = (char_u *)""; |
| 9393 | |
| 9394 | /* A backslash is required before some characters. This is the reverse of |
| 9395 | * what happens in do_set(). */ |
| 9396 | buf = vim_strsave_escaped(var, escape_chars); |
| 9397 | |
| 9398 | if (buf == NULL) |
| 9399 | { |
| 9400 | vim_free(*file); |
| 9401 | *file = NULL; |
| 9402 | return FAIL; |
| 9403 | } |
| 9404 | |
| 9405 | #ifdef BACKSLASH_IN_FILENAME |
| 9406 | /* For MS-Windows et al. we don't double backslashes at the start and |
| 9407 | * before a file name character. */ |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame] | 9408 | for (var = buf; *var != NUL; mb_ptr_adv(var)) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9409 | if (var[0] == '\\' && var[1] == '\\' |
| 9410 | && expand_option_idx >= 0 |
| 9411 | && (options[expand_option_idx].flags & P_EXPAND) |
| 9412 | && vim_isfilec(var[2]) |
| 9413 | && (var[2] != '\\' || (var == buf && var[4] != '\\'))) |
| 9414 | mch_memmove(var, var + 1, STRLEN(var)); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9415 | #endif |
| 9416 | |
| 9417 | *file[0] = buf; |
| 9418 | *num_file = 1; |
| 9419 | return OK; |
| 9420 | } |
| 9421 | #endif |
| 9422 | |
| 9423 | /* |
| 9424 | * Get the value for the numeric or string option *opp in a nice format into |
| 9425 | * NameBuff[]. Must not be called with a hidden option! |
| 9426 | */ |
| 9427 | static void |
| 9428 | option_value2string(opp, opt_flags) |
| 9429 | struct vimoption *opp; |
| 9430 | int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */ |
| 9431 | { |
| 9432 | char_u *varp; |
| 9433 | |
| 9434 | varp = get_varp_scope(opp, opt_flags); |
| 9435 | |
| 9436 | if (opp->flags & P_NUM) |
| 9437 | { |
| 9438 | long wc = 0; |
| 9439 | |
| 9440 | if (wc_use_keyname(varp, &wc)) |
| 9441 | STRCPY(NameBuff, get_special_key_name((int)wc, 0)); |
| 9442 | else if (wc != 0) |
| 9443 | STRCPY(NameBuff, transchar((int)wc)); |
| 9444 | else |
| 9445 | sprintf((char *)NameBuff, "%ld", *(long *)varp); |
| 9446 | } |
| 9447 | else /* P_STRING */ |
| 9448 | { |
| 9449 | varp = *(char_u **)(varp); |
| 9450 | if (varp == NULL) /* just in case */ |
| 9451 | NameBuff[0] = NUL; |
| 9452 | #ifdef FEAT_CRYPT |
| 9453 | /* don't show the actual value of 'key', only that it's set */ |
| 9454 | if (opp->var == (char_u *)&p_key && *varp) |
| 9455 | STRCPY(NameBuff, "*****"); |
| 9456 | #endif |
| 9457 | else if (opp->flags & P_EXPAND) |
| 9458 | home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE); |
| 9459 | /* Translate 'pastetoggle' into special key names */ |
| 9460 | else if ((char_u **)opp->var == &p_pt) |
| 9461 | str2specialbuf(p_pt, NameBuff, MAXPATHL); |
| 9462 | else |
Bram Moolenaar | ce0842a | 2005-07-18 21:58:11 +0000 | [diff] [blame] | 9463 | vim_strncpy(NameBuff, varp, MAXPATHL - 1); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9464 | } |
| 9465 | } |
| 9466 | |
| 9467 | /* |
| 9468 | * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be |
| 9469 | * printed as a keyname. |
| 9470 | * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. |
| 9471 | */ |
| 9472 | static int |
| 9473 | wc_use_keyname(varp, wcp) |
| 9474 | char_u *varp; |
| 9475 | long *wcp; |
| 9476 | { |
| 9477 | if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) |
| 9478 | { |
| 9479 | *wcp = *(long *)varp; |
| 9480 | if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0) |
| 9481 | return TRUE; |
| 9482 | } |
| 9483 | return FALSE; |
| 9484 | } |
| 9485 | |
| 9486 | #ifdef FEAT_LANGMAP |
| 9487 | /* |
| 9488 | * Any character has an equivalent character. This is used for keyboards that |
| 9489 | * have a special language mode that sends characters above 128 (although |
| 9490 | * other characters can be translated too). |
| 9491 | */ |
| 9492 | |
| 9493 | /* |
| 9494 | * char_u langmap_mapchar[256]; |
| 9495 | * Normally maps each of the 128 upper chars to an <128 ascii char; used to |
| 9496 | * "translate" native lang chars in normal mode or some cases of |
| 9497 | * insert mode without having to tediously switch lang mode back&forth. |
| 9498 | */ |
| 9499 | |
| 9500 | static void |
| 9501 | langmap_init() |
| 9502 | { |
| 9503 | int i; |
| 9504 | |
| 9505 | for (i = 0; i < 256; i++) /* we init with a-one-to one map */ |
| 9506 | langmap_mapchar[i] = i; |
| 9507 | } |
| 9508 | |
| 9509 | /* |
| 9510 | * Called when langmap option is set; the language map can be |
| 9511 | * changed at any time! |
| 9512 | */ |
| 9513 | static void |
| 9514 | langmap_set() |
| 9515 | { |
| 9516 | char_u *p; |
| 9517 | char_u *p2; |
| 9518 | int from, to; |
| 9519 | |
| 9520 | langmap_init(); /* back to one-to-one map first */ |
| 9521 | |
| 9522 | for (p = p_langmap; p[0] != NUL; ) |
| 9523 | { |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame] | 9524 | for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';'; |
| 9525 | mb_ptr_adv(p2)) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9526 | { |
| 9527 | if (p2[0] == '\\' && p2[1] != NUL) |
| 9528 | ++p2; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9529 | } |
| 9530 | if (p2[0] == ';') |
| 9531 | ++p2; /* abcd;ABCD form, p2 points to A */ |
| 9532 | else |
| 9533 | p2 = NULL; /* aAbBcCdD form, p2 is NULL */ |
| 9534 | while (p[0]) |
| 9535 | { |
| 9536 | if (p[0] == '\\' && p[1] != NUL) |
| 9537 | ++p; |
| 9538 | #ifdef FEAT_MBYTE |
| 9539 | from = (*mb_ptr2char)(p); |
| 9540 | #else |
| 9541 | from = p[0]; |
| 9542 | #endif |
| 9543 | if (p2 == NULL) |
| 9544 | { |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame] | 9545 | mb_ptr_adv(p); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9546 | if (p[0] == '\\') |
| 9547 | ++p; |
| 9548 | #ifdef FEAT_MBYTE |
| 9549 | to = (*mb_ptr2char)(p); |
| 9550 | #else |
| 9551 | to = p[0]; |
| 9552 | #endif |
| 9553 | } |
| 9554 | else |
| 9555 | { |
| 9556 | if (p2[0] == '\\') |
| 9557 | ++p2; |
| 9558 | #ifdef FEAT_MBYTE |
| 9559 | to = (*mb_ptr2char)(p2); |
| 9560 | #else |
| 9561 | to = p2[0]; |
| 9562 | #endif |
| 9563 | } |
| 9564 | if (to == NUL) |
| 9565 | { |
| 9566 | EMSG2(_("E357: 'langmap': Matching character missing for %s"), |
| 9567 | transchar(from)); |
| 9568 | return; |
| 9569 | } |
| 9570 | langmap_mapchar[from & 255] = to; |
| 9571 | |
| 9572 | /* Advance to next pair */ |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame] | 9573 | mb_ptr_adv(p); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9574 | if (p2 == NULL) |
| 9575 | { |
| 9576 | if (p[0] == ',') |
| 9577 | { |
| 9578 | ++p; |
| 9579 | break; |
| 9580 | } |
| 9581 | } |
| 9582 | else |
| 9583 | { |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame] | 9584 | mb_ptr_adv(p2); |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9585 | if (*p == ';') |
| 9586 | { |
| 9587 | p = p2; |
| 9588 | if (p[0] != NUL) |
| 9589 | { |
| 9590 | if (p[0] != ',') |
| 9591 | { |
| 9592 | EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p); |
| 9593 | return; |
| 9594 | } |
| 9595 | ++p; |
| 9596 | } |
| 9597 | break; |
| 9598 | } |
| 9599 | } |
| 9600 | } |
| 9601 | } |
| 9602 | } |
| 9603 | #endif |
| 9604 | |
| 9605 | /* |
| 9606 | * Return TRUE if format option 'x' is in effect. |
| 9607 | * Take care of no formatting when 'paste' is set. |
| 9608 | */ |
| 9609 | int |
| 9610 | has_format_option(x) |
| 9611 | int x; |
| 9612 | { |
| 9613 | if (p_paste) |
| 9614 | return FALSE; |
| 9615 | return (vim_strchr(curbuf->b_p_fo, x) != NULL); |
| 9616 | } |
| 9617 | |
| 9618 | /* |
| 9619 | * Return TRUE if "x" is present in 'shortmess' option, or |
| 9620 | * 'shortmess' contains 'a' and "x" is present in SHM_A. |
| 9621 | */ |
| 9622 | int |
| 9623 | shortmess(x) |
| 9624 | int x; |
| 9625 | { |
| 9626 | return ( vim_strchr(p_shm, x) != NULL |
| 9627 | || (vim_strchr(p_shm, 'a') != NULL |
| 9628 | && vim_strchr((char_u *)SHM_A, x) != NULL)); |
| 9629 | } |
| 9630 | |
| 9631 | /* |
| 9632 | * paste_option_changed() - Called after p_paste was set or reset. |
| 9633 | */ |
| 9634 | static void |
| 9635 | paste_option_changed() |
| 9636 | { |
| 9637 | static int old_p_paste = FALSE; |
| 9638 | static int save_sm = 0; |
| 9639 | #ifdef FEAT_CMDL_INFO |
| 9640 | static int save_ru = 0; |
| 9641 | #endif |
| 9642 | #ifdef FEAT_RIGHTLEFT |
| 9643 | static int save_ri = 0; |
| 9644 | static int save_hkmap = 0; |
| 9645 | #endif |
| 9646 | buf_T *buf; |
| 9647 | |
| 9648 | if (p_paste) |
| 9649 | { |
| 9650 | /* |
| 9651 | * Paste switched from off to on. |
| 9652 | * Save the current values, so they can be restored later. |
| 9653 | */ |
| 9654 | if (!old_p_paste) |
| 9655 | { |
| 9656 | /* save options for each buffer */ |
| 9657 | for (buf = firstbuf; buf != NULL; buf = buf->b_next) |
| 9658 | { |
| 9659 | buf->b_p_tw_nopaste = buf->b_p_tw; |
| 9660 | buf->b_p_wm_nopaste = buf->b_p_wm; |
| 9661 | buf->b_p_sts_nopaste = buf->b_p_sts; |
| 9662 | buf->b_p_ai_nopaste = buf->b_p_ai; |
| 9663 | } |
| 9664 | |
| 9665 | /* save global options */ |
| 9666 | save_sm = p_sm; |
| 9667 | #ifdef FEAT_CMDL_INFO |
| 9668 | save_ru = p_ru; |
| 9669 | #endif |
| 9670 | #ifdef FEAT_RIGHTLEFT |
| 9671 | save_ri = p_ri; |
| 9672 | save_hkmap = p_hkmap; |
| 9673 | #endif |
| 9674 | /* save global values for local buffer options */ |
| 9675 | p_tw_nopaste = p_tw; |
| 9676 | p_wm_nopaste = p_wm; |
| 9677 | p_sts_nopaste = p_sts; |
| 9678 | p_ai_nopaste = p_ai; |
| 9679 | } |
| 9680 | |
| 9681 | /* |
| 9682 | * Always set the option values, also when 'paste' is set when it is |
| 9683 | * already on. |
| 9684 | */ |
| 9685 | /* set options for each buffer */ |
| 9686 | for (buf = firstbuf; buf != NULL; buf = buf->b_next) |
| 9687 | { |
| 9688 | buf->b_p_tw = 0; /* textwidth is 0 */ |
| 9689 | buf->b_p_wm = 0; /* wrapmargin is 0 */ |
| 9690 | buf->b_p_sts = 0; /* softtabstop is 0 */ |
| 9691 | buf->b_p_ai = 0; /* no auto-indent */ |
| 9692 | } |
| 9693 | |
| 9694 | /* set global options */ |
| 9695 | p_sm = 0; /* no showmatch */ |
| 9696 | #ifdef FEAT_CMDL_INFO |
| 9697 | # ifdef FEAT_WINDOWS |
| 9698 | if (p_ru) |
| 9699 | status_redraw_all(); /* redraw to remove the ruler */ |
| 9700 | # endif |
| 9701 | p_ru = 0; /* no ruler */ |
| 9702 | #endif |
| 9703 | #ifdef FEAT_RIGHTLEFT |
| 9704 | p_ri = 0; /* no reverse insert */ |
| 9705 | p_hkmap = 0; /* no Hebrew keyboard */ |
| 9706 | #endif |
| 9707 | /* set global values for local buffer options */ |
| 9708 | p_tw = 0; |
| 9709 | p_wm = 0; |
| 9710 | p_sts = 0; |
| 9711 | p_ai = 0; |
| 9712 | } |
| 9713 | |
| 9714 | /* |
| 9715 | * Paste switched from on to off: Restore saved values. |
| 9716 | */ |
| 9717 | else if (old_p_paste) |
| 9718 | { |
| 9719 | /* restore options for each buffer */ |
| 9720 | for (buf = firstbuf; buf != NULL; buf = buf->b_next) |
| 9721 | { |
| 9722 | buf->b_p_tw = buf->b_p_tw_nopaste; |
| 9723 | buf->b_p_wm = buf->b_p_wm_nopaste; |
| 9724 | buf->b_p_sts = buf->b_p_sts_nopaste; |
| 9725 | buf->b_p_ai = buf->b_p_ai_nopaste; |
| 9726 | } |
| 9727 | |
| 9728 | /* restore global options */ |
| 9729 | p_sm = save_sm; |
| 9730 | #ifdef FEAT_CMDL_INFO |
| 9731 | # ifdef FEAT_WINDOWS |
| 9732 | if (p_ru != save_ru) |
| 9733 | status_redraw_all(); /* redraw to draw the ruler */ |
| 9734 | # endif |
| 9735 | p_ru = save_ru; |
| 9736 | #endif |
| 9737 | #ifdef FEAT_RIGHTLEFT |
| 9738 | p_ri = save_ri; |
| 9739 | p_hkmap = save_hkmap; |
| 9740 | #endif |
| 9741 | /* set global values for local buffer options */ |
| 9742 | p_tw = p_tw_nopaste; |
| 9743 | p_wm = p_wm_nopaste; |
| 9744 | p_sts = p_sts_nopaste; |
| 9745 | p_ai = p_ai_nopaste; |
| 9746 | } |
| 9747 | |
| 9748 | old_p_paste = p_paste; |
| 9749 | } |
| 9750 | |
| 9751 | /* |
| 9752 | * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found. |
| 9753 | * |
| 9754 | * Reset 'compatible' and set the values for options that didn't get set yet |
| 9755 | * to the Vim defaults. |
| 9756 | * Don't do this if the 'compatible' option has been set or reset before. |
| 9757 | */ |
| 9758 | void |
| 9759 | vimrc_found() |
| 9760 | { |
| 9761 | int opt_idx; |
| 9762 | |
| 9763 | if (!option_was_set((char_u *)"cp")) |
| 9764 | { |
| 9765 | p_cp = FALSE; |
| 9766 | for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) |
| 9767 | if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF))) |
| 9768 | set_option_default(opt_idx, OPT_FREE, FALSE); |
| 9769 | didset_options(); |
| 9770 | } |
| 9771 | } |
| 9772 | |
| 9773 | /* |
| 9774 | * Set 'compatible' on or off. Called for "-C" and "-N" command line arg. |
| 9775 | */ |
| 9776 | void |
| 9777 | change_compatible(on) |
| 9778 | int on; |
| 9779 | { |
| 9780 | if (p_cp != on) |
| 9781 | { |
| 9782 | p_cp = on; |
| 9783 | compatible_set(); |
| 9784 | } |
| 9785 | options[findoption((char_u *)"cp")].flags |= P_WAS_SET; |
| 9786 | } |
| 9787 | |
| 9788 | /* |
| 9789 | * Return TRUE when option "name" has been set. |
| 9790 | */ |
| 9791 | int |
| 9792 | option_was_set(name) |
| 9793 | char_u *name; |
| 9794 | { |
| 9795 | int idx; |
| 9796 | |
| 9797 | idx = findoption(name); |
| 9798 | if (idx < 0) /* unknown option */ |
| 9799 | return FALSE; |
| 9800 | if (options[idx].flags & P_WAS_SET) |
| 9801 | return TRUE; |
| 9802 | return FALSE; |
| 9803 | } |
| 9804 | |
| 9805 | /* |
| 9806 | * compatible_set() - Called when 'compatible' has been set or unset. |
| 9807 | * |
| 9808 | * When 'compatible' set: Set all relevant options (those that have the P_VIM) |
| 9809 | * flag) to a Vi compatible value. |
| 9810 | * When 'compatible' is unset: Set all options that have a different default |
| 9811 | * for Vim (without the P_VI_DEF flag) to that default. |
| 9812 | */ |
| 9813 | static void |
| 9814 | compatible_set() |
| 9815 | { |
| 9816 | int opt_idx; |
| 9817 | |
| 9818 | for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) |
| 9819 | if ( ((options[opt_idx].flags & P_VIM) && p_cp) |
| 9820 | || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp)) |
| 9821 | set_option_default(opt_idx, OPT_FREE, p_cp); |
| 9822 | didset_options(); |
| 9823 | } |
| 9824 | |
| 9825 | #ifdef FEAT_LINEBREAK |
| 9826 | |
| 9827 | # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) |
| 9828 | /* Borland C++ screws up loop optimisation here (negri) */ |
Bram Moolenaar | 8f999f1 | 2005-01-25 22:12:55 +0000 | [diff] [blame] | 9829 | #pragma option -O-l |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9830 | # endif |
| 9831 | |
| 9832 | /* |
| 9833 | * fill_breakat_flags() -- called when 'breakat' changes value. |
| 9834 | */ |
| 9835 | static void |
| 9836 | fill_breakat_flags() |
| 9837 | { |
Bram Moolenaar | ac6e65f | 2005-08-29 22:25:38 +0000 | [diff] [blame] | 9838 | char_u *p; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9839 | int i; |
| 9840 | |
| 9841 | for (i = 0; i < 256; i++) |
| 9842 | breakat_flags[i] = FALSE; |
| 9843 | |
| 9844 | if (p_breakat != NULL) |
Bram Moolenaar | ac6e65f | 2005-08-29 22:25:38 +0000 | [diff] [blame] | 9845 | for (p = p_breakat; *p; p++) |
| 9846 | breakat_flags[*p] = TRUE; |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9847 | } |
| 9848 | |
| 9849 | # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) |
Bram Moolenaar | 8f999f1 | 2005-01-25 22:12:55 +0000 | [diff] [blame] | 9850 | #pragma option -O.l |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9851 | # endif |
| 9852 | |
| 9853 | #endif |
| 9854 | |
| 9855 | /* |
| 9856 | * Check an option that can be a range of string values. |
| 9857 | * |
| 9858 | * Return OK for correct value, FAIL otherwise. |
| 9859 | * Empty is always OK. |
| 9860 | */ |
| 9861 | static int |
| 9862 | check_opt_strings(val, values, list) |
| 9863 | char_u *val; |
| 9864 | char **values; |
| 9865 | int list; /* when TRUE: accept a list of values */ |
| 9866 | { |
| 9867 | return opt_strings_flags(val, values, NULL, list); |
| 9868 | } |
| 9869 | |
| 9870 | /* |
| 9871 | * Handle an option that can be a range of string values. |
| 9872 | * Set a flag in "*flagp" for each string present. |
| 9873 | * |
| 9874 | * Return OK for correct value, FAIL otherwise. |
| 9875 | * Empty is always OK. |
| 9876 | */ |
| 9877 | static int |
| 9878 | opt_strings_flags(val, values, flagp, list) |
| 9879 | char_u *val; /* new value */ |
| 9880 | char **values; /* array of valid string values */ |
| 9881 | unsigned *flagp; |
| 9882 | int list; /* when TRUE: accept a list of values */ |
| 9883 | { |
| 9884 | int i; |
| 9885 | int len; |
| 9886 | unsigned new_flags = 0; |
| 9887 | |
| 9888 | while (*val) |
| 9889 | { |
| 9890 | for (i = 0; ; ++i) |
| 9891 | { |
| 9892 | if (values[i] == NULL) /* val not found in values[] */ |
| 9893 | return FAIL; |
| 9894 | |
| 9895 | len = (int)STRLEN(values[i]); |
| 9896 | if (STRNCMP(values[i], val, len) == 0 |
| 9897 | && ((list && val[len] == ',') || val[len] == NUL)) |
| 9898 | { |
| 9899 | val += len + (val[len] == ','); |
| 9900 | new_flags |= (1 << i); |
| 9901 | break; /* check next item in val list */ |
| 9902 | } |
| 9903 | } |
| 9904 | } |
| 9905 | if (flagp != NULL) |
| 9906 | *flagp = new_flags; |
| 9907 | |
| 9908 | return OK; |
| 9909 | } |
| 9910 | |
| 9911 | /* |
| 9912 | * Read the 'wildmode' option, fill wim_flags[]. |
| 9913 | */ |
| 9914 | static int |
| 9915 | check_opt_wim() |
| 9916 | { |
| 9917 | char_u new_wim_flags[4]; |
| 9918 | char_u *p; |
| 9919 | int i; |
| 9920 | int idx = 0; |
| 9921 | |
| 9922 | for (i = 0; i < 4; ++i) |
| 9923 | new_wim_flags[i] = 0; |
| 9924 | |
| 9925 | for (p = p_wim; *p; ++p) |
| 9926 | { |
| 9927 | for (i = 0; ASCII_ISALPHA(p[i]); ++i) |
| 9928 | ; |
| 9929 | if (p[i] != NUL && p[i] != ',' && p[i] != ':') |
| 9930 | return FAIL; |
| 9931 | if (i == 7 && STRNCMP(p, "longest", 7) == 0) |
| 9932 | new_wim_flags[idx] |= WIM_LONGEST; |
| 9933 | else if (i == 4 && STRNCMP(p, "full", 4) == 0) |
| 9934 | new_wim_flags[idx] |= WIM_FULL; |
| 9935 | else if (i == 4 && STRNCMP(p, "list", 4) == 0) |
| 9936 | new_wim_flags[idx] |= WIM_LIST; |
| 9937 | else |
| 9938 | return FAIL; |
| 9939 | p += i; |
| 9940 | if (*p == NUL) |
| 9941 | break; |
| 9942 | if (*p == ',') |
| 9943 | { |
| 9944 | if (idx == 3) |
| 9945 | return FAIL; |
| 9946 | ++idx; |
| 9947 | } |
| 9948 | } |
| 9949 | |
| 9950 | /* fill remaining entries with last flag */ |
| 9951 | while (idx < 3) |
| 9952 | { |
| 9953 | new_wim_flags[idx + 1] = new_wim_flags[idx]; |
| 9954 | ++idx; |
| 9955 | } |
| 9956 | |
| 9957 | /* only when there are no errors, wim_flags[] is changed */ |
| 9958 | for (i = 0; i < 4; ++i) |
| 9959 | wim_flags[i] = new_wim_flags[i]; |
| 9960 | return OK; |
| 9961 | } |
| 9962 | |
| 9963 | /* |
| 9964 | * Check if backspacing over something is allowed. |
| 9965 | */ |
| 9966 | int |
| 9967 | can_bs(what) |
| 9968 | int what; /* BS_INDENT, BS_EOL or BS_START */ |
| 9969 | { |
| 9970 | switch (*p_bs) |
| 9971 | { |
| 9972 | case '2': return TRUE; |
| 9973 | case '1': return (what != BS_START); |
| 9974 | case '0': return FALSE; |
| 9975 | } |
| 9976 | return vim_strchr(p_bs, what) != NULL; |
| 9977 | } |
| 9978 | |
| 9979 | /* |
| 9980 | * Save the current values of 'fileformat' and 'fileencoding', so that we know |
| 9981 | * the file must be considered changed when the value is different. |
| 9982 | */ |
| 9983 | void |
| 9984 | save_file_ff(buf) |
| 9985 | buf_T *buf; |
| 9986 | { |
| 9987 | buf->b_start_ffc = *buf->b_p_ff; |
| 9988 | buf->b_start_eol = buf->b_p_eol; |
| 9989 | #ifdef FEAT_MBYTE |
| 9990 | /* Only use free/alloc when necessary, they take time. */ |
| 9991 | if (buf->b_start_fenc == NULL |
| 9992 | || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0) |
| 9993 | { |
| 9994 | vim_free(buf->b_start_fenc); |
| 9995 | buf->b_start_fenc = vim_strsave(buf->b_p_fenc); |
| 9996 | } |
| 9997 | #endif |
| 9998 | } |
| 9999 | |
| 10000 | /* |
| 10001 | * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value |
| 10002 | * from when editing started (save_file_ff() called). |
| 10003 | * Also when 'endofline' was changed and 'binary' is set. |
| 10004 | * Don't consider a new, empty buffer to be changed. |
| 10005 | */ |
| 10006 | int |
| 10007 | file_ff_differs(buf) |
| 10008 | buf_T *buf; |
| 10009 | { |
| 10010 | if ((buf->b_flags & BF_NEW) |
| 10011 | && buf->b_ml.ml_line_count == 1 |
| 10012 | && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL) |
| 10013 | return FALSE; |
| 10014 | if (buf->b_start_ffc != *buf->b_p_ff) |
| 10015 | return TRUE; |
| 10016 | if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol) |
| 10017 | return TRUE; |
| 10018 | #ifdef FEAT_MBYTE |
| 10019 | if (buf->b_start_fenc == NULL) |
| 10020 | return (*buf->b_p_fenc != NUL); |
| 10021 | return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0); |
| 10022 | #else |
| 10023 | return FALSE; |
| 10024 | #endif |
| 10025 | } |
| 10026 | |
| 10027 | /* |
| 10028 | * return OK if "p" is a valid fileformat name, FAIL otherwise. |
| 10029 | */ |
| 10030 | int |
| 10031 | check_ff_value(p) |
| 10032 | char_u *p; |
| 10033 | { |
| 10034 | return check_opt_strings(p, p_ff_values, FALSE); |
| 10035 | } |