Mercurial > vim
comparison src/option.c @ 692:a28f83d37113
updated for version 7.0208
author | vimboss |
---|---|
date | Mon, 27 Feb 2006 00:08:02 +0000 |
parents | bcd2edc4539e |
children | 07d199fe02ed |
comparison
equal
deleted
inserted
replaced
691:8106f3da02d0 | 692:a28f83d37113 |
---|---|
36 | 36 |
37 /* | 37 /* |
38 * The options that are local to a window or buffer have "indir" set to one of | 38 * The options that are local to a window or buffer have "indir" set to one of |
39 * these values. Special values: | 39 * these values. Special values: |
40 * PV_NONE: global option. | 40 * PV_NONE: global option. |
41 * PV_WIN is added: window-local option | |
42 * PV_BUF is added: buffer-local option | |
41 * PV_BOTH is added: global option which also has a local value. | 43 * PV_BOTH is added: global option which also has a local value. |
42 */ | 44 */ |
43 #define PV_BOTH 0x1000 | 45 #define PV_BOTH 0x1000 |
46 #define PV_WIN 0x2000 | |
47 #define PV_BUF 0x4000 | |
48 #define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x)) | |
49 #define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x)) | |
44 #define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x)) | 50 #define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x)) |
45 | 51 |
52 /* | |
53 * "indir" values for buffer-local opions | |
54 */ | |
55 enum | |
56 { | |
57 BV_AI = 0 | |
58 , BV_AR | |
59 #if defined(FEAT_QUICKFIX) | |
60 , BV_BH | |
61 #endif | |
62 , BV_BIN | |
63 , BV_BL | |
64 , BV_COUNT /* must be the last one */ | |
65 }; | |
66 | |
67 #define PV_AI OPT_BUF(BV_AI) | |
68 #define PV_AR OPT_BOTH(OPT_BUF(BV_AR)) | |
69 #if defined(FEAT_QUICKFIX) | |
70 # define PV_BH OPT_BUF(BV_BH) | |
71 #endif | |
72 #define PV_BIN OPT_BUF(BV_BIN) | |
73 #define PV_BL OPT_BUF(BV_BL) | |
74 | |
75 /* | |
76 * "indir" values for window-local options | |
77 */ | |
78 enum | |
79 { | |
80 WV_LIST = 0 | |
81 #ifdef FEAT_ARABIC | |
82 , WV_ARAB | |
83 #endif | |
84 , WV_COUNT /* must be the last one */ | |
85 }; | |
86 | |
87 #define PV_LIST OPT_WIN(WV_LIST) | |
88 #ifdef FEAT_ARABIC | |
89 # define PV_ARAB OPT_WIN(WV_ARAB) | |
90 #endif | |
91 | |
92 /* TODO: "indir" values for the rest */ | |
46 typedef enum | 93 typedef enum |
47 { | 94 { |
48 PV_NONE = 0 | 95 PV_NONE = 0 |
49 , PV_AI | |
50 , PV_AR | |
51 , PV_ARAB | |
52 , PV_BH | |
53 , PV_BIN | |
54 , PV_BL | |
55 , PV_BOMB | 96 , PV_BOMB |
56 , PV_BT | 97 , PV_BT |
57 , PV_CI | 98 , PV_CI |
58 , PV_CIN | 99 , PV_CIN |
59 , PV_CINK | 100 , PV_CINK |
98 , PV_KEY | 139 , PV_KEY |
99 , PV_KMAP | 140 , PV_KMAP |
100 , PV_KP | 141 , PV_KP |
101 , PV_LBR | 142 , PV_LBR |
102 , PV_LISP | 143 , PV_LISP |
103 , PV_LIST | |
104 , PV_MA | 144 , PV_MA |
105 , PV_ML | 145 , PV_ML |
106 , PV_MOD | 146 , PV_MOD |
107 , PV_MP | 147 , PV_MP |
108 , PV_MPS | 148 , PV_MPS |
406 {(char_u *)FALSE, (char_u *)0L}}, | 446 {(char_u *)FALSE, (char_u *)0L}}, |
407 {"autoprint", "ap", P_BOOL|P_VI_DEF, | 447 {"autoprint", "ap", P_BOOL|P_VI_DEF, |
408 (char_u *)NULL, PV_NONE, | 448 (char_u *)NULL, PV_NONE, |
409 {(char_u *)FALSE, (char_u *)0L}}, | 449 {(char_u *)FALSE, (char_u *)0L}}, |
410 {"autoread", "ar", P_BOOL|P_VI_DEF, | 450 {"autoread", "ar", P_BOOL|P_VI_DEF, |
411 (char_u *)&p_ar, OPT_BOTH(PV_AR), | 451 (char_u *)&p_ar, PV_AR, |
412 {(char_u *)FALSE, (char_u *)0L}}, | 452 {(char_u *)FALSE, (char_u *)0L}}, |
413 {"autowrite", "aw", P_BOOL|P_VI_DEF, | 453 {"autowrite", "aw", P_BOOL|P_VI_DEF, |
414 (char_u *)&p_aw, PV_NONE, | 454 (char_u *)&p_aw, PV_NONE, |
415 {(char_u *)FALSE, (char_u *)0L}}, | 455 {(char_u *)FALSE, (char_u *)0L}}, |
416 {"autowriteall","awa", P_BOOL|P_VI_DEF, | 456 {"autowriteall","awa", P_BOOL|P_VI_DEF, |
4090 | 4130 |
4091 /* When using ":set opt=val" for a global option | 4131 /* When using ":set opt=val" for a global option |
4092 * with a local value the local value will be | 4132 * with a local value the local value will be |
4093 * reset, use the global value here. */ | 4133 * reset, use the global value here. */ |
4094 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 | 4134 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
4095 && (int)options[opt_idx].indir >= PV_BOTH) | 4135 && ((int)options[opt_idx].indir & PV_BOTH)) |
4096 varp = options[opt_idx].var; | 4136 varp = options[opt_idx].var; |
4097 | 4137 |
4098 /* The old value is kept until we are sure that the | 4138 /* The old value is kept until we are sure that the |
4099 * new value is valid. */ | 4139 * new value is valid. */ |
4100 oldval = *(char_u **)varp; | 4140 oldval = *(char_u **)varp; |
4187 ++arg; | 4227 ++arg; |
4188 } | 4228 } |
4189 | 4229 |
4190 /* When setting the local value of a global | 4230 /* When setting the local value of a global |
4191 * option, the old value may be the global value. */ | 4231 * option, the old value may be the global value. */ |
4192 if ((int)options[opt_idx].indir >= PV_BOTH | 4232 if (((int)options[opt_idx].indir & PV_BOTH) |
4193 && (opt_flags & OPT_LOCAL)) | 4233 && (opt_flags & OPT_LOCAL)) |
4194 origval = *(char_u **)get_varp( | 4234 origval = *(char_u **)get_varp( |
4195 &options[opt_idx]); | 4235 &options[opt_idx]); |
4196 else | 4236 else |
4197 origval = oldval; | 4237 origval = oldval; |
5033 | 5073 |
5034 options[opt_idx].flags |= P_ALLOCED; | 5074 options[opt_idx].flags |= P_ALLOCED; |
5035 | 5075 |
5036 /* When setting both values of a global option with a local value, | 5076 /* When setting both values of a global option with a local value, |
5037 * make the local value empty, so that the global value is used. */ | 5077 * make the local value empty, so that the global value is used. */ |
5038 if ((int)options[opt_idx].indir >= PV_BOTH && both) | 5078 if (((int)options[opt_idx].indir & PV_BOTH) && both) |
5039 { | 5079 { |
5040 free_string_option(*varp); | 5080 free_string_option(*varp); |
5041 *varp = empty_option; | 5081 *varp = empty_option; |
5042 } | 5082 } |
5043 } | 5083 } |
5086 s = vim_strsave(value); | 5126 s = vim_strsave(value); |
5087 if (s != NULL) | 5127 if (s != NULL) |
5088 { | 5128 { |
5089 varp = (char_u **)get_varp_scope(&(options[opt_idx]), | 5129 varp = (char_u **)get_varp_scope(&(options[opt_idx]), |
5090 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 | 5130 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
5091 ? ((int)options[opt_idx].indir >= PV_BOTH | 5131 ? (((int)options[opt_idx].indir & PV_BOTH) |
5092 ? OPT_GLOBAL : OPT_LOCAL) | 5132 ? OPT_GLOBAL : OPT_LOCAL) |
5093 : opt_flags); | 5133 : opt_flags); |
5094 oldval = *varp; | 5134 oldval = *varp; |
5095 *varp = s; | 5135 *varp = s; |
5096 if (did_set_string_option(opt_idx, varp, TRUE, oldval, NULL, | 5136 if (did_set_string_option(opt_idx, varp, TRUE, oldval, NULL, |
6349 options[opt_idx].flags |= P_ALLOCED; | 6389 options[opt_idx].flags |= P_ALLOCED; |
6350 else | 6390 else |
6351 options[opt_idx].flags &= ~P_ALLOCED; | 6391 options[opt_idx].flags &= ~P_ALLOCED; |
6352 | 6392 |
6353 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 | 6393 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
6354 && (int)options[opt_idx].indir >= PV_BOTH) | 6394 && ((int)options[opt_idx].indir & PV_BOTH)) |
6355 { | 6395 { |
6356 /* global option with local value set to use global value; free | 6396 /* global option with local value set to use global value; free |
6357 * the local value and make it empty */ | 6397 * the local value and make it empty */ |
6358 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL); | 6398 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL); |
6359 free_string_option(*(char_u **)p); | 6399 free_string_option(*(char_u **)p); |
8536 { | 8576 { |
8537 if (p->var == VAR_WIN) | 8577 if (p->var == VAR_WIN) |
8538 return (char_u *)GLOBAL_WO(get_varp(p)); | 8578 return (char_u *)GLOBAL_WO(get_varp(p)); |
8539 return p->var; | 8579 return p->var; |
8540 } | 8580 } |
8541 if ((opt_flags & OPT_LOCAL) && (int)p->indir >= PV_BOTH) | 8581 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) |
8542 { | 8582 { |
8543 switch ((int)p->indir) | 8583 switch ((int)p->indir) |
8544 { | 8584 { |
8545 #ifdef FEAT_QUICKFIX | 8585 #ifdef FEAT_QUICKFIX |
8546 case OPT_BOTH(PV_GP): return (char_u *)&(curbuf->b_p_gp); | 8586 case OPT_BOTH(PV_GP): return (char_u *)&(curbuf->b_p_gp); |
8548 case OPT_BOTH(PV_EFM): return (char_u *)&(curbuf->b_p_efm); | 8588 case OPT_BOTH(PV_EFM): return (char_u *)&(curbuf->b_p_efm); |
8549 #endif | 8589 #endif |
8550 case OPT_BOTH(PV_EP): return (char_u *)&(curbuf->b_p_ep); | 8590 case OPT_BOTH(PV_EP): return (char_u *)&(curbuf->b_p_ep); |
8551 case OPT_BOTH(PV_KP): return (char_u *)&(curbuf->b_p_kp); | 8591 case OPT_BOTH(PV_KP): return (char_u *)&(curbuf->b_p_kp); |
8552 case OPT_BOTH(PV_PATH): return (char_u *)&(curbuf->b_p_path); | 8592 case OPT_BOTH(PV_PATH): return (char_u *)&(curbuf->b_p_path); |
8553 case OPT_BOTH(PV_AR): return (char_u *)&(curbuf->b_p_ar); | 8593 case PV_AR: return (char_u *)&(curbuf->b_p_ar); |
8554 case OPT_BOTH(PV_TAGS): return (char_u *)&(curbuf->b_p_tags); | 8594 case OPT_BOTH(PV_TAGS): return (char_u *)&(curbuf->b_p_tags); |
8555 #ifdef FEAT_FIND_ID | 8595 #ifdef FEAT_FIND_ID |
8556 case OPT_BOTH(PV_DEF): return (char_u *)&(curbuf->b_p_def); | 8596 case OPT_BOTH(PV_DEF): return (char_u *)&(curbuf->b_p_def); |
8557 case OPT_BOTH(PV_INC): return (char_u *)&(curbuf->b_p_inc); | 8597 case OPT_BOTH(PV_INC): return (char_u *)&(curbuf->b_p_inc); |
8558 #endif | 8598 #endif |
8589 ? (char_u *)&curbuf->b_p_ep : p->var; | 8629 ? (char_u *)&curbuf->b_p_ep : p->var; |
8590 case OPT_BOTH(PV_KP): return *curbuf->b_p_kp != NUL | 8630 case OPT_BOTH(PV_KP): return *curbuf->b_p_kp != NUL |
8591 ? (char_u *)&curbuf->b_p_kp : p->var; | 8631 ? (char_u *)&curbuf->b_p_kp : p->var; |
8592 case OPT_BOTH(PV_PATH): return *curbuf->b_p_path != NUL | 8632 case OPT_BOTH(PV_PATH): return *curbuf->b_p_path != NUL |
8593 ? (char_u *)&(curbuf->b_p_path) : p->var; | 8633 ? (char_u *)&(curbuf->b_p_path) : p->var; |
8594 case OPT_BOTH(PV_AR): return curbuf->b_p_ar >= 0 | 8634 case PV_AR: return curbuf->b_p_ar >= 0 |
8595 ? (char_u *)&(curbuf->b_p_ar) : p->var; | 8635 ? (char_u *)&(curbuf->b_p_ar) : p->var; |
8596 case OPT_BOTH(PV_TAGS): return *curbuf->b_p_tags != NUL | 8636 case OPT_BOTH(PV_TAGS): return *curbuf->b_p_tags != NUL |
8597 ? (char_u *)&(curbuf->b_p_tags) : p->var; | 8637 ? (char_u *)&(curbuf->b_p_tags) : p->var; |
8598 #ifdef FEAT_FIND_ID | 8638 #ifdef FEAT_FIND_ID |
8599 case OPT_BOTH(PV_DEF): return *curbuf->b_p_def != NUL | 8639 case OPT_BOTH(PV_DEF): return *curbuf->b_p_def != NUL |