Mercurial > vim
annotate src/option.c @ 18175:0f3b1cafbf8c
Added tag v8.1.2082 for changeset 1ec6539cef68c7daa0572fcc21ff384dca489ed0
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 27 Sep 2019 13:15:04 +0200 |
parents | c81370b3ede4 |
children | e2be5a6485f5 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9959
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 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. | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10205
diff
changeset
|
25 * - Add documentation! One line in doc/quickref.txt, full description in |
7 | 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" | |
18054
88b5c2b4e3d2
patch 8.1.2022: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18047
diff
changeset
|
36 #include "optiondefs.h" |
7 | 37 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
38 static void set_options_default(int opt_flags); |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
39 static void set_string_default_esc(char *name, char_u *val, int escape); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
40 static char_u *term_bg_default(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
41 static char_u *option_expand(int opt_idx, char_u *val); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
42 static void didset_options(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
43 static void didset_options2(void); |
681 | 44 #if defined(FEAT_EVAL) || defined(PROTO) |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
45 static long_u *insecure_flag(int opt_idx, int opt_flags); |
681 | 46 #else |
47 # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags) | |
48 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
49 static char *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags); |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
50 static char *set_num_option(int opt_idx, char_u *varp, long value, char *errbuf, size_t errbuflen, int opt_flags); |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
51 static int find_key_option(char_u *arg_arg, int has_lt); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
52 static void showoptions(int all, int opt_flags); |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
53 static int optval_default(struct vimoption *, char_u *varp, int compatible); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
54 static void showoneopt(struct vimoption *, int opt_flags); |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
55 static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, long_u flags); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
56 static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
57 static int put_setbool(FILE *fd, char *cmd, char *name, int value); |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
58 static int istermoption(struct vimoption *p); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
59 static char_u *get_varp_scope(struct vimoption *p, int opt_flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
60 static char_u *get_varp(struct vimoption *); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
61 static void check_win_options(win_T *win); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
62 static void option_value2string(struct vimoption *, int opt_flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
63 static void check_winopt(winopt_T *wop); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
64 static int wc_use_keyname(char_u *varp, long *wcp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
65 static void paste_option_changed(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
66 static void compatible_set(void); |
7 | 67 |
68 /* | |
69 * Initialize the options, first part. | |
70 * | |
71 * Called only once from main(), just after creating the first buffer. | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
72 * If "clean_arg" is TRUE Vim was started with --clean. |
7 | 73 */ |
74 void | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
75 set_init_1(int clean_arg) |
7 | 76 { |
77 char_u *p; | |
78 int opt_idx; | |
835 | 79 long_u n; |
7 | 80 |
81 #ifdef FEAT_LANGMAP | |
82 langmap_init(); | |
83 #endif | |
84 | |
85 /* Be Vi compatible by default */ | |
86 p_cp = TRUE; | |
87 | |
164 | 88 /* Use POSIX compatibility when $VIM_POSIX is set. */ |
89 if (mch_getenv((char_u *)"VIM_POSIX") != NULL) | |
168 | 90 { |
164 | 91 set_string_default("cpo", (char_u *)CPO_ALL); |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
92 set_string_default("shm", (char_u *)SHM_POSIX); |
168 | 93 } |
164 | 94 |
7 | 95 /* |
96 * Find default value for 'shell' option. | |
161 | 97 * Don't use it if it is empty. |
7 | 98 */ |
161 | 99 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL) |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
100 #if defined(MSWIN) |
161 | 101 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL) |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7829
diff
changeset
|
102 || ((p = (char_u *)default_shell()) != NULL && *p != NUL) |
7 | 103 #endif |
161 | 104 ) |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
105 set_string_default_esc("sh", p, TRUE); |
7 | 106 |
107 #ifdef FEAT_WILDIGN | |
108 /* | |
109 * Set the default for 'backupskip' to include environment variables for | |
110 * temp files. | |
111 */ | |
112 { | |
113 # ifdef UNIX | |
114 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"}; | |
115 # else | |
116 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"}; | |
117 # endif | |
170 | 118 int len; |
119 garray_T ga; | |
120 int mustfree; | |
7 | 121 |
122 ga_init2(&ga, 1, 100); | |
123 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n) | |
124 { | |
170 | 125 mustfree = FALSE; |
7 | 126 # ifdef UNIX |
127 if (*names[n] == NUL) | |
13664
f64c5e636c9f
patch 8.0.1704: 'backupskip' default doesn't work for Mac
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
128 # ifdef MACOS_X |
f64c5e636c9f
patch 8.0.1704: 'backupskip' default doesn't work for Mac
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
129 p = (char_u *)"/private/tmp"; |
f64c5e636c9f
patch 8.0.1704: 'backupskip' default doesn't work for Mac
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
130 # else |
7 | 131 p = (char_u *)"/tmp"; |
13664
f64c5e636c9f
patch 8.0.1704: 'backupskip' default doesn't work for Mac
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
132 # endif |
7 | 133 else |
134 # endif | |
170 | 135 p = vim_getenv((char_u *)names[n], &mustfree); |
7 | 136 if (p != NULL && *p != NUL) |
137 { | |
138 /* First time count the NUL, otherwise count the ','. */ | |
835 | 139 len = (int)STRLEN(p) + 3; |
7 | 140 if (ga_grow(&ga, len) == OK) |
141 { | |
142 if (ga.ga_len > 0) | |
143 STRCAT(ga.ga_data, ","); | |
144 STRCAT(ga.ga_data, p); | |
145 add_pathsep(ga.ga_data); | |
146 STRCAT(ga.ga_data, "*"); | |
147 ga.ga_len += len; | |
148 } | |
149 } | |
170 | 150 if (mustfree) |
151 vim_free(p); | |
7 | 152 } |
153 if (ga.ga_data != NULL) | |
154 { | |
155 set_string_default("bsk", ga.ga_data); | |
156 vim_free(ga.ga_data); | |
157 } | |
158 } | |
159 #endif | |
160 | |
161 /* | |
162 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory | |
163 */ | |
164 opt_idx = findoption((char_u *)"maxmemtot"); | |
838 | 165 if (opt_idx >= 0) |
166 { | |
7 | 167 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
838 | 168 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) |
169 #endif | |
170 { | |
7 | 171 #ifdef HAVE_AVAIL_MEM |
838 | 172 /* Use amount of memory available at this moment. */ |
3634 | 173 n = (mch_avail_mem(FALSE) >> 1); |
7 | 174 #else |
175 # ifdef HAVE_TOTAL_MEM | |
838 | 176 /* Use amount of memory available to Vim. */ |
1110 | 177 n = (mch_total_mem(FALSE) >> 1); |
7 | 178 # else |
838 | 179 n = (0x7fffffff >> 11); |
7 | 180 # endif |
181 #endif | |
182 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; | |
838 | 183 opt_idx = findoption((char_u *)"maxmem"); |
184 if (opt_idx >= 0) | |
185 { | |
186 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) | |
7328
6679f41bddea
commit https://github.com/vim/vim/commit/35be4534c029148a89ccc41e8e465d793e7ed7c2
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
187 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n |
6679f41bddea
commit https://github.com/vim/vim/commit/35be4534c029148a89ccc41e8e465d793e7ed7c2
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
188 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L) |
838 | 189 #endif |
190 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; | |
191 } | |
192 } | |
7 | 193 } |
194 | |
195 #ifdef FEAT_SEARCHPATH | |
196 { | |
197 char_u *cdpath; | |
198 char_u *buf; | |
199 int i; | |
200 int j; | |
170 | 201 int mustfree = FALSE; |
7 | 202 |
203 /* Initialize the 'cdpath' option's default value. */ | |
170 | 204 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree); |
7 | 205 if (cdpath != NULL) |
206 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16730
diff
changeset
|
207 buf = alloc((STRLEN(cdpath) << 1) + 2); |
7 | 208 if (buf != NULL) |
209 { | |
210 buf[0] = ','; /* start with ",", current dir first */ | |
211 j = 1; | |
212 for (i = 0; cdpath[i] != NUL; ++i) | |
213 { | |
214 if (vim_ispathlistsep(cdpath[i])) | |
215 buf[j++] = ','; | |
216 else | |
217 { | |
218 if (cdpath[i] == ' ' || cdpath[i] == ',') | |
219 buf[j++] = '\\'; | |
220 buf[j++] = cdpath[i]; | |
221 } | |
222 } | |
223 buf[j] = NUL; | |
224 opt_idx = findoption((char_u *)"cdpath"); | |
838 | 225 if (opt_idx >= 0) |
226 { | |
227 options[opt_idx].def_val[VI_DEFAULT] = buf; | |
228 options[opt_idx].flags |= P_DEF_ALLOCED; | |
229 } | |
2445
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
230 else |
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
231 vim_free(buf); /* cannot happen */ |
7 | 232 } |
170 | 233 if (mustfree) |
234 vim_free(cdpath); | |
7 | 235 } |
236 } | |
237 #endif | |
238 | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
239 #if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux)) |
7 | 240 /* Set print encoding on platforms that don't default to latin1 */ |
241 set_string_default("penc", | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
242 # if defined(MSWIN) |
7 | 243 (char_u *)"cp1252" |
244 # else | |
245 # ifdef VMS | |
246 (char_u *)"dec-mcs" | |
247 # else | |
248 # ifdef EBCDIC | |
249 (char_u *)"ebcdic-uk" | |
250 # else | |
251 # ifdef MAC | |
252 (char_u *)"mac-roman" | |
253 # else /* HPUX */ | |
254 (char_u *)"hp-roman8" | |
255 # endif | |
256 # endif | |
257 # endif | |
258 # endif | |
259 ); | |
260 #endif | |
261 | |
262 #ifdef FEAT_POSTSCRIPT | |
263 /* 'printexpr' must be allocated to be able to evaluate it. */ | |
264 set_string_default("pexpr", | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
265 # if defined(MSWIN) |
8 | 266 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)" |
7 | 267 # else |
268 # ifdef VMS | |
269 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)" | |
270 | |
271 # else | |
272 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error" | |
273 # endif | |
274 # endif | |
275 ); | |
276 #endif | |
277 | |
278 /* | |
279 * Set all the options (except the terminal options) to their default | |
280 * value. Also set the global value for local options. | |
281 */ | |
282 set_options_default(0); | |
283 | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
284 #ifdef CLEAN_RUNTIMEPATH |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
285 if (clean_arg) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
286 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
287 opt_idx = findoption((char_u *)"runtimepath"); |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
288 if (opt_idx >= 0) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
289 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
290 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH; |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
291 p_rtp = (char_u *)CLEAN_RUNTIMEPATH; |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
292 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
293 opt_idx = findoption((char_u *)"packpath"); |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
294 if (opt_idx >= 0) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
295 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
296 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH; |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
297 p_pp = (char_u *)CLEAN_RUNTIMEPATH; |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
298 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
299 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
300 #endif |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
301 |
7 | 302 #ifdef FEAT_GUI |
303 if (found_reverse_arg) | |
304 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0); | |
305 #endif | |
306 | |
307 curbuf->b_p_initialized = TRUE; | |
308 curbuf->b_p_ar = -1; /* no local 'autoread' value */ | |
5446 | 309 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
7 | 310 check_buf_options(curbuf); |
311 check_win_options(curwin); | |
312 check_options(); | |
313 | |
314 /* Must be before option_expand(), because that one needs vim_isIDc() */ | |
315 didset_options(); | |
316 | |
744 | 317 #ifdef FEAT_SPELL |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
318 /* Use the current chartab for the generic chartab. This is not in |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
319 * didset_options() because it only depends on 'encoding'. */ |
227 | 320 init_spell_chartab(); |
321 #endif | |
322 | |
7 | 323 /* |
324 * Expand environment variables and things like "~" for the defaults. | |
325 * If option_expand() returns non-NULL the variable is expanded. This can | |
326 * only happen for non-indirect options. | |
327 * Also set the default to the expanded value, so ":set" does not list | |
328 * them. | |
329 * Don't set the P_ALLOCED flag, because we don't want to free the | |
330 * default. | |
331 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
332 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 333 { |
334 if ((options[opt_idx].flags & P_GETTEXT) | |
335 && options[opt_idx].var != NULL) | |
336 p = (char_u *)_(*(char **)options[opt_idx].var); | |
337 else | |
338 p = option_expand(opt_idx, NULL); | |
339 if (p != NULL && (p = vim_strsave(p)) != NULL) | |
340 { | |
341 *(char_u **)options[opt_idx].var = p; | |
342 /* VIMEXP | |
343 * Defaults for all expanded options are currently the same for Vi | |
344 * and Vim. When this changes, add some code here! Also need to | |
345 * split P_DEF_ALLOCED in two. | |
346 */ | |
347 if (options[opt_idx].flags & P_DEF_ALLOCED) | |
348 vim_free(options[opt_idx].def_val[VI_DEFAULT]); | |
349 options[opt_idx].def_val[VI_DEFAULT] = p; | |
350 options[opt_idx].flags |= P_DEF_ALLOCED; | |
351 } | |
352 } | |
353 | |
354 save_file_ff(curbuf); /* Buffer is unchanged */ | |
355 | |
356 #if defined(FEAT_ARABIC) | |
357 /* Detect use of mlterm. | |
358 * Mlterm is a terminal emulator akin to xterm that has some special | |
359 * abilities (bidi namely). | |
360 * NOTE: mlterm's author is being asked to 'set' a variable | |
361 * instead of an environment variable due to inheritance. | |
362 */ | |
363 if (mch_getenv((char_u *)"MLTERM") != NULL) | |
364 set_option_value((char_u *)"tbidi", 1L, NULL, 0); | |
365 #endif | |
366 | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
367 didset_options2(); |
7 | 368 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
369 # if defined(MSWIN) && defined(FEAT_GETTEXT) |
7 | 370 /* |
371 * If $LANG isn't set, try to get a good value for it. This makes the | |
372 * right language be used automatically. Don't do this for English. | |
373 */ | |
374 if (mch_getenv((char_u *)"LANG") == NULL) | |
375 { | |
376 char buf[20]; | |
377 | |
378 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95. | |
379 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use | |
380 * only the first two. */ | |
381 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, | |
382 (LPTSTR)buf, 20); | |
383 if (n >= 2 && STRNICMP(buf, "en", 2) != 0) | |
384 { | |
385 /* There are a few exceptions (probably more) */ | |
386 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0) | |
387 STRCPY(buf, "zh_TW"); | |
388 else if (STRNICMP(buf, "chs", 3) == 0 | |
389 || STRNICMP(buf, "zhc", 3) == 0) | |
390 STRCPY(buf, "zh_CN"); | |
391 else if (STRNICMP(buf, "jp", 2) == 0) | |
392 STRCPY(buf, "ja"); | |
393 else | |
394 buf[2] = NUL; /* truncate to two-letter code */ | |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7829
diff
changeset
|
395 vim_setenv((char_u *)"LANG", (char_u *)buf); |
7 | 396 } |
397 } | |
168 | 398 # else |
767 | 399 # ifdef MACOS_CONVERT |
1622 | 400 /* Moved to os_mac_conv.c to avoid dependency problems. */ |
401 mac_lang_init(); | |
168 | 402 # endif |
7 | 403 # endif |
404 | |
405 /* enc_locale() will try to find the encoding of the current locale. */ | |
406 p = enc_locale(); | |
407 if (p != NULL) | |
408 { | |
409 char_u *save_enc; | |
410 | |
411 /* Try setting 'encoding' and check if the value is valid. | |
412 * If not, go back to the default "latin1". */ | |
413 save_enc = p_enc; | |
414 p_enc = p; | |
1080 | 415 if (STRCMP(p_enc, "gb18030") == 0) |
416 { | |
417 /* We don't support "gb18030", but "cp936" is a good substitute | |
418 * for practical purposes, thus use that. It's not an alias to | |
419 * still support conversion between gb18030 and utf-8. */ | |
420 p_enc = vim_strsave((char_u *)"cp936"); | |
421 vim_free(p); | |
422 } | |
7 | 423 if (mb_init() == NULL) |
424 { | |
425 opt_idx = findoption((char_u *)"encoding"); | |
838 | 426 if (opt_idx >= 0) |
427 { | |
428 options[opt_idx].def_val[VI_DEFAULT] = p_enc; | |
429 options[opt_idx].flags |= P_DEF_ALLOCED; | |
430 } | |
7 | 431 |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12636
diff
changeset
|
432 #if defined(MSWIN) || defined(MACOS_X) || defined(VMS) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
433 if (STRCMP(p_enc, "latin1") == 0 || enc_utf8) |
24 | 434 { |
714 | 435 /* Adjust the default for 'isprint' and 'iskeyword' to match |
436 * latin1. Also set the defaults for when 'nocompatible' is | |
437 * set. */ | |
24 | 438 set_string_option_direct((char_u *)"isp", -1, |
719 | 439 ISP_LATIN1, OPT_FREE, SID_NONE); |
714 | 440 set_string_option_direct((char_u *)"isk", -1, |
441 ISK_LATIN1, OPT_FREE, SID_NONE); | |
442 opt_idx = findoption((char_u *)"isp"); | |
838 | 443 if (opt_idx >= 0) |
444 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1; | |
714 | 445 opt_idx = findoption((char_u *)"isk"); |
838 | 446 if (opt_idx >= 0) |
447 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1; | |
24 | 448 (void)init_chartab(); |
449 } | |
450 #endif | |
451 | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
452 #if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
7 | 453 /* Win32 console: When GetACP() returns a different value from |
454 * GetConsoleCP() set 'termencoding'. */ | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
455 if ( |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
456 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
457 (!gui.in_use && !gui.starting) && |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
458 # endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
459 GetACP() != GetConsoleCP()) |
7 | 460 { |
461 char buf[50]; | |
462 | |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
463 /* Win32 console: In ConPTY, GetConsoleCP() returns zero. |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
464 * Use an alternative value. */ |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
465 if (GetConsoleCP() == 0) |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
466 sprintf(buf, "cp%ld", (long)GetACP()); |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
467 else |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
468 sprintf(buf, "cp%ld", (long)GetConsoleCP()); |
7 | 469 p_tenc = vim_strsave((char_u *)buf); |
470 if (p_tenc != NULL) | |
471 { | |
472 opt_idx = findoption((char_u *)"termencoding"); | |
838 | 473 if (opt_idx >= 0) |
474 { | |
475 options[opt_idx].def_val[VI_DEFAULT] = p_tenc; | |
476 options[opt_idx].flags |= P_DEF_ALLOCED; | |
477 } | |
7 | 478 convert_setup(&input_conv, p_tenc, p_enc); |
479 convert_setup(&output_conv, p_enc, p_tenc); | |
480 } | |
481 else | |
482 p_tenc = empty_option; | |
483 } | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
484 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
485 #if defined(MSWIN) |
170 | 486 /* $HOME may have characters in active code page. */ |
487 init_homedir(); | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
488 #endif |
7 | 489 } |
490 else | |
491 { | |
492 vim_free(p_enc); | |
493 p_enc = save_enc; | |
494 } | |
495 } | |
496 | |
497 #ifdef FEAT_MULTI_LANG | |
498 /* Set the default for 'helplang'. */ | |
499 set_helplang_default(get_mess_lang()); | |
500 #endif | |
501 } | |
502 | |
503 /* | |
504 * Set an option to its default value. | |
505 * This does not take care of side effects! | |
506 */ | |
507 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
508 set_option_default( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
509 int opt_idx, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
510 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
511 int compatible) /* use Vi default value */ |
7 | 512 { |
513 char_u *varp; /* pointer to variable for current option */ | |
514 int dvi; /* index in def_val[] */ | |
515 long_u flags; | |
681 | 516 long_u *flagsp; |
7 | 517 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
518 | |
519 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); | |
520 flags = options[opt_idx].flags; | |
320 | 521 if (varp != NULL) /* skip hidden option, nothing to do for it */ |
7 | 522 { |
523 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; | |
524 if (flags & P_STRING) | |
525 { | |
13845
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
526 /* Use set_string_option_direct() for local options to handle |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
527 * freeing and allocating the value. */ |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
528 if (options[opt_idx].indir != PV_NONE) |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
529 set_string_option_direct(NULL, opt_idx, |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
530 options[opt_idx].def_val[dvi], opt_flags, 0); |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
531 else |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
532 { |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
533 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED)) |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
534 free_string_option(*(char_u **)(varp)); |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
535 *(char_u **)varp = options[opt_idx].def_val[dvi]; |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
536 options[opt_idx].flags &= ~P_ALLOCED; |
7 | 537 } |
538 } | |
539 else if (flags & P_NUM) | |
540 { | |
1017 | 541 if (options[opt_idx].indir == PV_SCROLL) |
7 | 542 win_comp_scroll(curwin); |
543 else | |
544 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
545 long def_val = (long)(long_i)options[opt_idx].def_val[dvi]; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
546 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
547 if ((long *)varp == &curwin->w_p_so |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
548 || (long *)varp == &curwin->w_p_siso) |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
549 // 'scrolloff' and 'sidescrolloff' local values have a |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
550 // different default value than the global default. |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
551 *(long *)varp = -1; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
552 else |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
553 *(long *)varp = def_val; |
7 | 554 /* May also set global value for local option. */ |
555 if (both) | |
556 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
557 def_val; |
7 | 558 } |
559 } | |
560 else /* P_BOOL */ | |
561 { | |
840 | 562 /* the cast to long is required for Manx C, long_i is needed for |
563 * MSVC */ | |
564 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; | |
1111 | 565 #ifdef UNIX |
566 /* 'modeline' defaults to off for root */ | |
567 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) | |
568 *(int *)varp = FALSE; | |
569 #endif | |
7 | 570 /* May also set global value for local option. */ |
571 if (both) | |
572 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | |
573 *(int *)varp; | |
574 } | |
634 | 575 |
681 | 576 /* The default value is not insecure. */ |
577 flagsp = insecure_flag(opt_idx, opt_flags); | |
578 *flagsp = *flagsp & ~P_INSECURE; | |
7 | 579 } |
580 | |
581 #ifdef FEAT_EVAL | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
582 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 583 #endif |
584 } | |
585 | |
586 /* | |
587 * Set all options (except terminal options) to their default value. | |
7034
e668b160ac68
commit https://github.com/vim/vim/commit/b341dda575899458f7075614dcedf0a80ee9d080
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
588 * When "opt_flags" is non-zero skip 'encoding'. |
7 | 589 */ |
590 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
591 set_options_default( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
592 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ |
7 | 593 { |
594 int i; | |
595 win_T *wp; | |
671 | 596 tabpage_T *tp; |
7 | 597 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
598 for (i = 0; !istermoption_idx(i); i++) |
7034
e668b160ac68
commit https://github.com/vim/vim/commit/b341dda575899458f7075614dcedf0a80ee9d080
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
599 if (!(options[i].flags & P_NODEFAULT) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
600 && (opt_flags == 0 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
601 || (options[i].var != (char_u *)&p_enc |
7058
64dc5b11ad33
commit https://github.com/vim/vim/commit/5ea87a04964b0ccd017380b8247d04d2a69f6062
Christian Brabandt <cb@256bit.org>
parents:
7052
diff
changeset
|
602 # if defined(FEAT_CRYPT) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
603 && options[i].var != (char_u *)&p_cm |
7052
9ec3329823f9
commit https://github.com/vim/vim/commit/8060687905bdadc46abb68ee6d40e5660e352297
Christian Brabandt <cb@256bit.org>
parents:
7040
diff
changeset
|
604 && options[i].var != (char_u *)&p_key |
7058
64dc5b11ad33
commit https://github.com/vim/vim/commit/5ea87a04964b0ccd017380b8247d04d2a69f6062
Christian Brabandt <cb@256bit.org>
parents:
7052
diff
changeset
|
605 # endif |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
606 ))) |
7 | 607 set_option_default(i, opt_flags, p_cp); |
608 | |
609 /* The 'scroll' option must be computed for all windows. */ | |
671 | 610 FOR_ALL_TAB_WINDOWS(tp, wp) |
7 | 611 win_comp_scroll(wp); |
6205 | 612 #ifdef FEAT_CINDENT |
613 parse_cino(curbuf); | |
614 #endif | |
7 | 615 } |
616 | |
617 /* | |
618 * Set the Vi-default value of a string option. | |
619 * Used for 'sh', 'backupskip' and 'term'. | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
620 * When "escape" is TRUE escape spaces with a backslash. |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
621 */ |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
622 static void |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
623 set_string_default_esc(char *name, char_u *val, int escape) |
7 | 624 { |
625 char_u *p; | |
626 int opt_idx; | |
627 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
628 if (escape && vim_strchr(val, ' ') != NULL) |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
629 p = vim_strsave_escaped(val, (char_u *)" "); |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
630 else |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
631 p = vim_strsave(val); |
7 | 632 if (p != NULL) /* we don't want a NULL */ |
633 { | |
634 opt_idx = findoption((char_u *)name); | |
838 | 635 if (opt_idx >= 0) |
636 { | |
637 if (options[opt_idx].flags & P_DEF_ALLOCED) | |
638 vim_free(options[opt_idx].def_val[VI_DEFAULT]); | |
639 options[opt_idx].def_val[VI_DEFAULT] = p; | |
640 options[opt_idx].flags |= P_DEF_ALLOCED; | |
641 } | |
7 | 642 } |
643 } | |
644 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
645 void |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
646 set_string_default(char *name, char_u *val) |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
647 { |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
648 set_string_default_esc(name, val, FALSE); |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
649 } |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
650 |
7 | 651 /* |
652 * Set the Vi-default value of a number option. | |
653 * Used for 'lines' and 'columns'. | |
654 */ | |
655 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
656 set_number_default(char *name, long val) |
7 | 657 { |
838 | 658 int opt_idx; |
659 | |
660 opt_idx = findoption((char_u *)name); | |
661 if (opt_idx >= 0) | |
840 | 662 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 663 } |
664 | |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
665 /* |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
666 * Set all window-local and buffer-local options to the Vim default. |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
667 * local-global options will use the global value. |
17845
b6acc24df7de
patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents:
17833
diff
changeset
|
668 * When "do_buffer" is FALSE don't set buffer-local options. |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
669 */ |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
670 void |
17845
b6acc24df7de
patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents:
17833
diff
changeset
|
671 set_local_options_default(win_T *wp, int do_buffer) |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
672 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
673 win_T *save_curwin = curwin; |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
674 int i; |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
675 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
676 curwin = wp; |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
677 curbuf = curwin->w_buffer; |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
678 block_autocmds(); |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
679 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
680 for (i = 0; !istermoption_idx(i); i++) |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
681 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
682 struct vimoption *p = &(options[i]); |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
683 char_u *varp = get_varp_scope(p, OPT_LOCAL); |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
684 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
685 if (p->indir != PV_NONE |
17845
b6acc24df7de
patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents:
17833
diff
changeset
|
686 && (do_buffer || (p->indir & PV_BUF) == 0) |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
687 && !(options[i].flags & P_NODEFAULT) |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
688 && !optval_default(p, varp, FALSE)) |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
689 set_option_default(i, OPT_LOCAL, FALSE); |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
690 } |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
691 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
692 unblock_autocmds(); |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
693 curwin = save_curwin; |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
694 curbuf = curwin->w_buffer; |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
695 } |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
696 |
359 | 697 #if defined(EXITFREE) || defined(PROTO) |
698 /* | |
699 * Free all options. | |
700 */ | |
701 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
702 free_all_options(void) |
359 | 703 { |
704 int i; | |
705 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
706 for (i = 0; !istermoption_idx(i); i++) |
359 | 707 { |
708 if (options[i].indir == PV_NONE) | |
709 { | |
710 /* global option: free value and default value. */ | |
10906
7fc1df5536c9
patch 8.0.0342: double free with EXITFREE and setting 'ttytype'
Christian Brabandt <cb@256bit.org>
parents:
10887
diff
changeset
|
711 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL) |
359 | 712 free_string_option(*(char_u **)options[i].var); |
713 if (options[i].flags & P_DEF_ALLOCED) | |
714 free_string_option(options[i].def_val[VI_DEFAULT]); | |
715 } | |
716 else if (options[i].var != VAR_WIN | |
717 && (options[i].flags & P_STRING)) | |
718 /* buffer-local option: free global value */ | |
719 free_string_option(*(char_u **)options[i].var); | |
720 } | |
721 } | |
722 #endif | |
723 | |
724 | |
7 | 725 /* |
726 * Initialize the options, part two: After getting Rows and Columns and | |
727 * setting 'term'. | |
728 */ | |
729 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
730 set_init_2(void) |
7 | 731 { |
164 | 732 int idx; |
733 | |
7 | 734 /* |
12718
f8f505ffc0a6
patch 8.0.1237: ":set scroll&" often gives an error
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
735 * 'scroll' defaults to half the window height. The stored default is zero, |
f8f505ffc0a6
patch 8.0.1237: ":set scroll&" often gives an error
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
736 * which results in the actual value computed from the window height. |
7 | 737 */ |
168 | 738 idx = findoption((char_u *)"scroll"); |
838 | 739 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
168 | 740 set_option_default(idx, OPT_LOCAL, p_cp); |
7 | 741 comp_col(); |
742 | |
164 | 743 /* |
744 * 'window' is only for backwards compatibility with Vi. | |
745 * Default is Rows - 1. | |
746 */ | |
857 | 747 if (!option_was_set((char_u *)"window")) |
164 | 748 p_window = Rows - 1; |
749 set_number_default("window", Rows - 1); | |
750 | |
671 | 751 /* For DOS console the default is always black. */ |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
752 #if !((defined(MSWIN)) && !defined(FEAT_GUI)) |
671 | 753 /* |
754 * If 'background' wasn't set by the user, try guessing the value, | |
755 * depending on the terminal name. Only need to check for terminals | |
756 * with a dark background, that can handle color. | |
757 */ | |
758 idx = findoption((char_u *)"bg"); | |
838 | 759 if (idx >= 0 && !(options[idx].flags & P_WAS_SET) |
760 && *term_bg_default() == 'd') | |
671 | 761 { |
694 | 762 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0); |
671 | 763 /* don't mark it as set, when starting the GUI it may be |
764 * changed again */ | |
765 options[idx].flags &= ~P_WAS_SET; | |
7 | 766 } |
767 #endif | |
440 | 768 |
769 #ifdef CURSOR_SHAPE | |
770 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */ | |
771 #endif | |
772 #ifdef FEAT_MOUSESHAPE | |
773 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */ | |
774 #endif | |
775 #ifdef FEAT_PRINTER | |
776 (void)parse_printoptions(); /* parse 'printoptions' default value */ | |
777 #endif | |
7 | 778 } |
779 | |
780 /* | |
671 | 781 * Return "dark" or "light" depending on the kind of terminal. |
782 * This is just guessing! Recognized are: | |
783 * "linux" Linux console | |
784 * "screen.linux" Linux console with screen | |
12383
1890536614ea
patch 8.0.1071: putty-color and cygwin-color are not recognized
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
785 * "cygwin.*" Cygwin shell |
1890536614ea
patch 8.0.1071: putty-color and cygwin-color are not recognized
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
786 * "putty.*" Putty program |
671 | 787 * We also check the COLORFGBG environment variable, which is set by |
788 * rxvt and derivatives. This variable contains either two or three | |
789 * values separated by semicolons; we want the last value in either | |
790 * case. If this value is 0-6 or 8, our background is dark. | |
791 */ | |
792 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
793 term_bg_default(void) |
671 | 794 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
795 #if defined(MSWIN) |
12383
1890536614ea
patch 8.0.1071: putty-color and cygwin-color are not recognized
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
796 /* DOS console is nearly always black */ |
671 | 797 return (char_u *)"dark"; |
798 #else | |
677 | 799 char_u *p; |
800 | |
671 | 801 if (STRCMP(T_NAME, "linux") == 0 |
802 || STRCMP(T_NAME, "screen.linux") == 0 | |
12383
1890536614ea
patch 8.0.1071: putty-color and cygwin-color are not recognized
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
803 || STRNCMP(T_NAME, "cygwin", 6) == 0 |
1890536614ea
patch 8.0.1071: putty-color and cygwin-color are not recognized
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
804 || STRNCMP(T_NAME, "putty", 5) == 0 |
671 | 805 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL |
806 && (p = vim_strrchr(p, ';')) != NULL | |
807 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8') | |
808 && p[2] == NUL)) | |
809 return (char_u *)"dark"; | |
810 return (char_u *)"light"; | |
811 #endif | |
812 } | |
813 | |
814 /* | |
7 | 815 * Initialize the options, part three: After reading the .vimrc |
816 */ | |
817 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
818 set_init_3(void) |
7 | 819 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
820 #if defined(UNIX) || defined(MSWIN) |
7 | 821 /* |
822 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. | |
823 * This is done after other initializations, where 'shell' might have been | |
824 * set, but only if they have not been set before. | |
825 */ | |
826 char_u *p; | |
827 int idx_srr; | |
828 int do_srr; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
829 # ifdef FEAT_QUICKFIX |
7 | 830 int idx_sp; |
831 int do_sp; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
832 # endif |
7 | 833 |
834 idx_srr = findoption((char_u *)"srr"); | |
838 | 835 if (idx_srr < 0) |
836 do_srr = FALSE; | |
837 else | |
838 do_srr = !(options[idx_srr].flags & P_WAS_SET); | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
839 # ifdef FEAT_QUICKFIX |
7 | 840 idx_sp = findoption((char_u *)"sp"); |
838 | 841 if (idx_sp < 0) |
842 do_sp = FALSE; | |
843 else | |
844 do_sp = !(options[idx_sp].flags & P_WAS_SET); | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
845 # endif |
5867 | 846 p = get_isolated_shell_name(); |
7 | 847 if (p != NULL) |
848 { | |
849 /* | |
850 * Default for p_sp is "| tee", for p_srr is ">". | |
851 * For known shells it is changed here to include stderr. | |
852 */ | |
853 if ( fnamecmp(p, "csh") == 0 | |
854 || fnamecmp(p, "tcsh") == 0 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
855 # if defined(MSWIN) // also check with .exe extension |
7 | 856 || fnamecmp(p, "csh.exe") == 0 |
857 || fnamecmp(p, "tcsh.exe") == 0 | |
858 # endif | |
859 ) | |
860 { | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
861 # if defined(FEAT_QUICKFIX) |
7 | 862 if (do_sp) |
863 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
864 # ifdef MSWIN |
7 | 865 p_sp = (char_u *)">&"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
866 # else |
7 | 867 p_sp = (char_u *)"|& tee"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
868 # endif |
7 | 869 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
870 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
871 # endif |
7 | 872 if (do_srr) |
873 { | |
874 p_srr = (char_u *)">&"; | |
875 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
876 } | |
877 } | |
878 else | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
879 /* Always use bourne shell style redirection if we reach this */ |
7 | 880 if ( fnamecmp(p, "sh") == 0 |
881 || fnamecmp(p, "ksh") == 0 | |
2774 | 882 || fnamecmp(p, "mksh") == 0 |
883 || fnamecmp(p, "pdksh") == 0 | |
7 | 884 || fnamecmp(p, "zsh") == 0 |
836 | 885 || fnamecmp(p, "zsh-beta") == 0 |
7 | 886 || fnamecmp(p, "bash") == 0 |
5867 | 887 || fnamecmp(p, "fish") == 0 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
888 # ifdef MSWIN |
7 | 889 || fnamecmp(p, "cmd") == 0 |
890 || fnamecmp(p, "sh.exe") == 0 | |
891 || fnamecmp(p, "ksh.exe") == 0 | |
2774 | 892 || fnamecmp(p, "mksh.exe") == 0 |
893 || fnamecmp(p, "pdksh.exe") == 0 | |
7 | 894 || fnamecmp(p, "zsh.exe") == 0 |
836 | 895 || fnamecmp(p, "zsh-beta.exe") == 0 |
7 | 896 || fnamecmp(p, "bash.exe") == 0 |
897 || fnamecmp(p, "cmd.exe") == 0 | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
898 # endif |
7 | 899 ) |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
900 { |
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
901 # if defined(FEAT_QUICKFIX) |
7 | 902 if (do_sp) |
903 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
904 # ifdef MSWIN |
7 | 905 p_sp = (char_u *)">%s 2>&1"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
906 # else |
7 | 907 p_sp = (char_u *)"2>&1| tee"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
908 # endif |
7 | 909 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
910 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
911 # endif |
7 | 912 if (do_srr) |
913 { | |
914 p_srr = (char_u *)">%s 2>&1"; | |
915 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
916 } | |
917 } | |
918 vim_free(p); | |
919 } | |
920 #endif | |
921 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
922 #if defined(MSWIN) |
7 | 923 /* |
3352 | 924 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the |
925 * 'shell' option. | |
7 | 926 * This is done after other initializations, where 'shell' might have been |
927 * set, but only if they have not been set before. Default for p_shcf is | |
928 * "/c", for p_shq is "". For "sh" like shells it is changed here to | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
929 * "-c" and "\"". And for Win32 we need to set p_sxq instead. |
7 | 930 */ |
10 | 931 if (strstr((char *)gettail(p_sh), "sh") != NULL) |
7 | 932 { |
933 int idx3; | |
934 | |
935 idx3 = findoption((char_u *)"shcf"); | |
838 | 936 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 937 { |
938 p_shcf = (char_u *)"-c"; | |
939 options[idx3].def_val[VI_DEFAULT] = p_shcf; | |
940 } | |
941 | |
942 /* Somehow Win32 requires the quotes around the redirection too */ | |
943 idx3 = findoption((char_u *)"sxq"); | |
838 | 944 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 945 { |
946 p_sxq = (char_u *)"\""; | |
947 options[idx3].def_val[VI_DEFAULT] = p_sxq; | |
948 } | |
949 } | |
3352 | 950 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL) |
951 { | |
952 int idx3; | |
953 | |
954 /* | |
955 * cmd.exe on Windows will strip the first and last double quote given | |
956 * on the command line, e.g. most of the time things like: | |
957 * cmd /c "my path/to/echo" "my args to echo" | |
958 * become: | |
959 * my path/to/echo" "my args to echo | |
960 * when executed. | |
961 * | |
3357 | 962 * To avoid this, set shellxquote to surround the command in |
963 * parenthesis. This appears to make most commands work, without | |
964 * breaking commands that worked previously, such as | |
965 * '"path with spaces/cmd" "a&b"'. | |
3352 | 966 */ |
967 idx3 = findoption((char_u *)"sxq"); | |
968 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
969 { | |
3357 | 970 p_sxq = (char_u *)"("; |
3352 | 971 options[idx3].def_val[VI_DEFAULT] = p_sxq; |
972 } | |
973 | |
974 idx3 = findoption((char_u *)"shcf"); | |
975 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
976 { | |
3357 | 977 p_shcf = (char_u *)"/c"; |
3352 | 978 options[idx3].def_val[VI_DEFAULT] = p_shcf; |
979 } | |
980 } | |
7 | 981 #endif |
982 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11107
diff
changeset
|
983 if (BUFEMPTY()) |
8659
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
984 { |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
985 int idx_ffs = findoption((char_u *)"ffs"); |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
986 |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
987 /* Apply the first entry of 'fileformats' to the initial buffer. */ |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
988 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET)) |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
989 set_fileformat(default_fileformat(), OPT_LOCAL); |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
990 } |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
991 |
7 | 992 #ifdef FEAT_TITLE |
993 set_title_defaults(); | |
994 #endif | |
995 } | |
996 | |
997 #if defined(FEAT_MULTI_LANG) || defined(PROTO) | |
998 /* | |
999 * When 'helplang' is still at its default value, set it to "lang". | |
1000 * Only the first two characters of "lang" are used. | |
1001 */ | |
1002 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1003 set_helplang_default(char_u *lang) |
7 | 1004 { |
1005 int idx; | |
1006 | |
1007 if (lang == NULL || STRLEN(lang) < 2) /* safety check */ | |
1008 return; | |
1009 idx = findoption((char_u *)"hlg"); | |
838 | 1010 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
7 | 1011 { |
1012 if (options[idx].flags & P_ALLOCED) | |
1013 free_string_option(p_hlg); | |
1014 p_hlg = vim_strsave(lang); | |
1015 if (p_hlg == NULL) | |
1016 p_hlg = empty_option; | |
1017 else | |
18 | 1018 { |
14997
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1019 // zh_CN becomes "cn", zh_TW becomes "tw" |
18 | 1020 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) |
1021 { | |
1022 p_hlg[0] = TOLOWER_ASC(p_hlg[3]); | |
1023 p_hlg[1] = TOLOWER_ASC(p_hlg[4]); | |
1024 } | |
14997
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1025 // any C like setting, such as C.UTF-8, becomes "en" |
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1026 else if (STRLEN(p_hlg) >= 1 && *p_hlg == 'C') |
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1027 { |
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1028 p_hlg[0] = 'e'; |
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1029 p_hlg[1] = 'n'; |
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1030 } |
7 | 1031 p_hlg[2] = NUL; |
18 | 1032 } |
7 | 1033 options[idx].flags |= P_ALLOCED; |
1034 } | |
1035 } | |
1036 #endif | |
1037 | |
1038 #ifdef FEAT_GUI | |
1039 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1040 gui_bg_default(void) |
7 | 1041 { |
1042 if (gui_get_lightness(gui.back_pixel) < 127) | |
1043 return (char_u *)"dark"; | |
1044 return (char_u *)"light"; | |
1045 } | |
1046 | |
1047 /* | |
1048 * Option initializations that can only be done after opening the GUI window. | |
1049 */ | |
1050 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1051 init_gui_options(void) |
7 | 1052 { |
1053 /* Set the 'background' option according to the lightness of the | |
1054 * background color, unless the user has set it already. */ | |
1055 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0) | |
1056 { | |
1057 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0); | |
1058 highlight_changed(); | |
1059 } | |
1060 } | |
1061 #endif | |
1062 | |
1063 #ifdef FEAT_TITLE | |
1064 /* | |
1065 * 'title' and 'icon' only default to true if they have not been set or reset | |
1066 * in .vimrc and we can read the old value. | |
1067 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if | |
1068 * they can be reset. This reduces startup time when using X on a remote | |
1069 * machine. | |
1070 */ | |
1071 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1072 set_title_defaults(void) |
7 | 1073 { |
1074 int idx1; | |
1075 long val; | |
1076 | |
1077 /* | |
1078 * If GUI is (going to be) used, we can always set the window title and | |
1079 * icon name. Saves a bit of time, because the X11 display server does | |
1080 * not need to be contacted. | |
1081 */ | |
1082 idx1 = findoption((char_u *)"title"); | |
838 | 1083 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 1084 { |
1085 #ifdef FEAT_GUI | |
1086 if (gui.starting || gui.in_use) | |
1087 val = TRUE; | |
1088 else | |
1089 #endif | |
1090 val = mch_can_restore_title(); | |
840 | 1091 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 1092 p_title = val; |
1093 } | |
1094 idx1 = findoption((char_u *)"icon"); | |
838 | 1095 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 1096 { |
1097 #ifdef FEAT_GUI | |
1098 if (gui.starting || gui.in_use) | |
1099 val = TRUE; | |
1100 else | |
1101 #endif | |
1102 val = mch_can_restore_icon(); | |
840 | 1103 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 1104 p_icon = val; |
1105 } | |
1106 } | |
1107 #endif | |
1108 | |
1109 /* | |
1110 * Parse 'arg' for option settings. | |
1111 * | |
1112 * 'arg' may be IObuff, but only when no errors can be present and option | |
1113 * does not need to be expanded with option_expand(). | |
1114 * "opt_flags": | |
1115 * 0 for ":set" | |
717 | 1116 * OPT_GLOBAL for ":setglobal" |
1117 * OPT_LOCAL for ":setlocal" and a modeline | |
7 | 1118 * OPT_MODELINE for a modeline |
717 | 1119 * OPT_WINONLY to only set window-local options |
1120 * OPT_NOWIN to skip setting window-local options | |
7 | 1121 * |
1122 * returns FAIL if an error is detected, OK otherwise | |
1123 */ | |
1124 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1125 do_set( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1126 char_u *arg, /* option string (may be written to!) */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1127 int opt_flags) |
7 | 1128 { |
1129 int opt_idx; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1130 char *errmsg; |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1131 char errbuf[80]; |
7 | 1132 char_u *startarg; |
1133 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */ | |
1134 int nextchar; /* next non-white char after option name */ | |
1135 int afterchar; /* character just after option name */ | |
1136 int len; | |
1137 int i; | |
9389
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
1138 varnumber_T value; |
7 | 1139 int key; |
1140 long_u flags; /* flags for current option */ | |
1141 char_u *varp = NULL; /* pointer to variable for current option */ | |
1142 int did_show = FALSE; /* already showed one value */ | |
1143 int adding; /* "opt+=arg" */ | |
1144 int prepending; /* "opt^=arg" */ | |
1145 int removing; /* "opt-=arg" */ | |
1146 int cp_val = 0; | |
1147 char_u key_name[2]; | |
1148 | |
1149 if (*arg == NUL) | |
1150 { | |
1151 showoptions(0, opt_flags); | |
168 | 1152 did_show = TRUE; |
1153 goto theend; | |
7 | 1154 } |
1155 | |
1156 while (*arg != NUL) /* loop to process all options */ | |
1157 { | |
1158 errmsg = NULL; | |
1159 startarg = arg; /* remember for error message */ | |
1160 | |
36 | 1161 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3]) |
1162 && !(opt_flags & OPT_MODELINE)) | |
7 | 1163 { |
1164 /* | |
1165 * ":set all" show all options. | |
1166 * ":set all&" set all options to their default value. | |
1167 */ | |
1168 arg += 3; | |
1169 if (*arg == '&') | |
1170 { | |
1171 ++arg; | |
1172 /* Only for :set command set global value of local options. */ | |
1173 set_options_default(OPT_FREE | opt_flags); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
1174 didset_options(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
1175 didset_options2(); |
7034
e668b160ac68
commit https://github.com/vim/vim/commit/b341dda575899458f7075614dcedf0a80ee9d080
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
1176 redraw_all_later(CLEAR); |
7 | 1177 } |
1178 else | |
168 | 1179 { |
7 | 1180 showoptions(1, opt_flags); |
168 | 1181 did_show = TRUE; |
1182 } | |
7 | 1183 } |
36 | 1184 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) |
7 | 1185 { |
1186 showoptions(2, opt_flags); | |
1187 show_termcodes(); | |
168 | 1188 did_show = TRUE; |
7 | 1189 arg += 7; |
1190 } | |
1191 else | |
1192 { | |
1193 prefix = 1; | |
1911 | 1194 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0) |
7 | 1195 { |
1196 prefix = 0; | |
1197 arg += 2; | |
1198 } | |
1199 else if (STRNCMP(arg, "inv", 3) == 0) | |
1200 { | |
1201 prefix = 2; | |
1202 arg += 3; | |
1203 } | |
1204 | |
1205 /* find end of name */ | |
1206 key = 0; | |
1207 if (*arg == '<') | |
1208 { | |
1209 opt_idx = -1; | |
1210 /* look out for <t_>;> */ | |
1211 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) | |
1212 len = 5; | |
1213 else | |
1214 { | |
1215 len = 1; | |
1216 while (arg[len] != NUL && arg[len] != '>') | |
1217 ++len; | |
1218 } | |
1219 if (arg[len] != '>') | |
1220 { | |
1221 errmsg = e_invarg; | |
1222 goto skip; | |
1223 } | |
1224 arg[len] = NUL; /* put NUL after name */ | |
1225 if (arg[1] == 't' && arg[2] == '_') /* could be term code */ | |
1226 opt_idx = findoption(arg + 1); | |
1227 arg[len++] = '>'; /* restore '>' */ | |
1228 if (opt_idx == -1) | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
1229 key = find_key_option(arg + 1, TRUE); |
7 | 1230 } |
1231 else | |
1232 { | |
1233 len = 0; | |
1234 /* | |
1235 * The two characters after "t_" may not be alphanumeric. | |
1236 */ | |
1237 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
1238 len = 4; | |
1239 else | |
1240 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') | |
1241 ++len; | |
1242 nextchar = arg[len]; | |
1243 arg[len] = NUL; /* put NUL after name */ | |
1244 opt_idx = findoption(arg); | |
1245 arg[len] = nextchar; /* restore nextchar */ | |
1246 if (opt_idx == -1) | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
1247 key = find_key_option(arg, FALSE); |
7 | 1248 } |
1249 | |
1250 /* remember character after option name */ | |
1251 afterchar = arg[len]; | |
1252 | |
1253 /* skip white space, allow ":set ai ?" */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1254 while (VIM_ISWHITE(arg[len])) |
7 | 1255 ++len; |
1256 | |
1257 adding = FALSE; | |
1258 prepending = FALSE; | |
1259 removing = FALSE; | |
1260 if (arg[len] != NUL && arg[len + 1] == '=') | |
1261 { | |
1262 if (arg[len] == '+') | |
1263 { | |
1264 adding = TRUE; /* "+=" */ | |
1265 ++len; | |
1266 } | |
1267 else if (arg[len] == '^') | |
1268 { | |
1269 prepending = TRUE; /* "^=" */ | |
1270 ++len; | |
1271 } | |
1272 else if (arg[len] == '-') | |
1273 { | |
1274 removing = TRUE; /* "-=" */ | |
1275 ++len; | |
1276 } | |
1277 } | |
1278 nextchar = arg[len]; | |
1279 | |
1280 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */ | |
1281 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1282 errmsg = N_("E518: Unknown option"); |
7 | 1283 goto skip; |
1284 } | |
1285 | |
1286 if (opt_idx >= 0) | |
1287 { | |
1288 if (options[opt_idx].var == NULL) /* hidden option: skip */ | |
1289 { | |
1290 /* Only give an error message when requesting the value of | |
1291 * a hidden option, ignore setting it. */ | |
1292 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL | |
1293 && (!(options[opt_idx].flags & P_BOOL) | |
1294 || nextchar == '?')) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1295 errmsg = N_("E519: Option not supported"); |
7 | 1296 goto skip; |
1297 } | |
1298 | |
1299 flags = options[opt_idx].flags; | |
1300 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | |
1301 } | |
1302 else | |
1303 { | |
1304 flags = P_STRING; | |
1305 if (key < 0) | |
1306 { | |
1307 key_name[0] = KEY2TERMCAP0(key); | |
1308 key_name[1] = KEY2TERMCAP1(key); | |
1309 } | |
1310 else | |
1311 { | |
1312 key_name[0] = KS_KEY; | |
1313 key_name[1] = (key & 0xff); | |
1314 } | |
1315 } | |
1316 | |
634 | 1317 /* Skip all options that are not window-local (used when showing |
1318 * an already loaded buffer in a window). */ | |
1319 if ((opt_flags & OPT_WINONLY) | |
1320 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) | |
1321 goto skip; | |
1322 | |
717 | 1323 /* Skip all options that are window-local (used for :vimgrep). */ |
1324 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0 | |
1325 && options[opt_idx].var == VAR_WIN) | |
1326 goto skip; | |
1327 | |
1807 | 1328 /* Disallow changing some options from modelines. */ |
1329 if (opt_flags & OPT_MODELINE) | |
7 | 1330 { |
2317
2b2cd34569eb
Disallow setting 'enc' in a modeline. (Patrick Texier)
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
1331 if (flags & (P_SECURE | P_NO_ML)) |
1807 | 1332 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1333 errmsg = _("E520: Not allowed in a modeline"); |
1807 | 1334 goto skip; |
1335 } | |
16728
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1336 if ((flags & P_MLE) && !p_mle) |
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1337 { |
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1338 errmsg = _("E992: Not allowed in a modeline when 'modelineexpr' is off"); |
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1339 goto skip; |
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1340 } |
1810 | 1341 #ifdef FEAT_DIFF |
1807 | 1342 /* In diff mode some options are overruled. This avoids that |
1343 * 'foldmethod' becomes "marker" instead of "diff" and that | |
1344 * "wrap" gets set. */ | |
1345 if (curwin->w_p_diff | |
2445
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
1346 && opt_idx >= 0 /* shut up coverity warning */ |
11073
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1347 && ( |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1348 #ifdef FEAT_FOLDING |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1349 options[opt_idx].indir == PV_FDM || |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1350 #endif |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1351 options[opt_idx].indir == PV_WRAP)) |
1807 | 1352 goto skip; |
1810 | 1353 #endif |
7 | 1354 } |
1355 | |
1356 #ifdef HAVE_SANDBOX | |
1357 /* Disallow changing some options in the sandbox */ | |
634 | 1358 if (sandbox != 0 && (flags & P_SECURE)) |
7 | 1359 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1360 errmsg = _(e_sandbox); |
7 | 1361 goto skip; |
1362 } | |
1363 #endif | |
1364 | |
1365 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) | |
1366 { | |
1367 arg += len; | |
1368 cp_val = p_cp; | |
1369 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') | |
1370 { | |
1371 if (arg[3] == 'm') /* "opt&vim": set to Vim default */ | |
1372 { | |
1373 cp_val = FALSE; | |
1374 arg += 3; | |
1375 } | |
1376 else /* "opt&vi": set to Vi default */ | |
1377 { | |
1378 cp_val = TRUE; | |
1379 arg += 2; | |
1380 } | |
1381 } | |
1382 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1383 && arg[1] != NUL && !VIM_ISWHITE(arg[1])) |
7 | 1384 { |
1385 errmsg = e_trailing; | |
1386 goto skip; | |
1387 } | |
1388 } | |
1389 | |
1390 /* | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
1391 * allow '=' and ':' for hystorical reasons (MSDOS command.com |
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
1392 * allows only one '=' character per "set" command line. grrr. (jw) |
7 | 1393 */ |
1394 if (nextchar == '?' | |
1395 || (prefix == 1 | |
1396 && vim_strchr((char_u *)"=:&<", nextchar) == NULL | |
1397 && !(flags & P_BOOL))) | |
1398 { | |
1399 /* | |
1400 * print value | |
1401 */ | |
1402 if (did_show) | |
1403 msg_putchar('\n'); /* cursor below last one */ | |
1404 else | |
1405 { | |
1406 gotocmdline(TRUE); /* cursor at status line */ | |
1407 did_show = TRUE; /* remember that we did a line */ | |
1408 } | |
1409 if (opt_idx >= 0) | |
1410 { | |
1411 showoneopt(&options[opt_idx], opt_flags); | |
1412 #ifdef FEAT_EVAL | |
1413 if (p_verbose > 0) | |
694 | 1414 { |
1415 /* Mention where the option was last set. */ | |
1416 if (varp == options[opt_idx].var) | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
1417 last_set_msg(options[opt_idx].script_ctx); |
694 | 1418 else if ((int)options[opt_idx].indir & PV_WIN) |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
1419 last_set_msg(curwin->w_p_script_ctx[ |
694 | 1420 (int)options[opt_idx].indir & PV_MASK]); |
1421 else if ((int)options[opt_idx].indir & PV_BUF) | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
1422 last_set_msg(curbuf->b_p_script_ctx[ |
694 | 1423 (int)options[opt_idx].indir & PV_MASK]); |
1424 } | |
7 | 1425 #endif |
1426 } | |
1427 else | |
1428 { | |
1429 char_u *p; | |
1430 | |
1431 p = find_termcode(key_name); | |
1432 if (p == NULL) | |
1433 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1434 errmsg = N_("E846: Key code not set"); |
7 | 1435 goto skip; |
1436 } | |
1437 else | |
1438 (void)show_one_termcode(key_name, p, TRUE); | |
1439 } | |
1440 if (nextchar != '?' | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1441 && nextchar != NUL && !VIM_ISWHITE(afterchar)) |
7 | 1442 errmsg = e_trailing; |
1443 } | |
1444 else | |
1445 { | |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1446 int value_is_replaced = !prepending && !adding && !removing; |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
1447 int value_checked = FALSE; |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1448 |
7 | 1449 if (flags & P_BOOL) /* boolean */ |
1450 { | |
1451 if (nextchar == '=' || nextchar == ':') | |
1452 { | |
1453 errmsg = e_invarg; | |
1454 goto skip; | |
1455 } | |
1456 | |
1457 /* | |
1458 * ":set opt!": invert | |
1459 * ":set opt&": reset to default value | |
1460 * ":set opt<": reset to global value | |
1461 */ | |
1462 if (nextchar == '!') | |
1463 value = *(int *)(varp) ^ 1; | |
1464 else if (nextchar == '&') | |
840 | 1465 value = (int)(long)(long_i)options[opt_idx].def_val[ |
7 | 1466 ((flags & P_VI_DEF) || cp_val) |
1467 ? VI_DEFAULT : VIM_DEFAULT]; | |
1468 else if (nextchar == '<') | |
1469 { | |
1470 /* For 'autoread' -1 means to use global value. */ | |
1471 if ((int *)varp == &curbuf->b_p_ar | |
1472 && opt_flags == OPT_LOCAL) | |
1473 value = -1; | |
1474 else | |
1475 value = *(int *)get_varp_scope(&(options[opt_idx]), | |
1476 OPT_GLOBAL); | |
1477 } | |
1478 else | |
1479 { | |
1480 /* | |
1481 * ":set invopt": invert | |
1482 * ":set opt" or ":set noopt": set or reset | |
1483 */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1484 if (nextchar != NUL && !VIM_ISWHITE(afterchar)) |
7 | 1485 { |
1486 errmsg = e_trailing; | |
1487 goto skip; | |
1488 } | |
1489 if (prefix == 2) /* inv */ | |
1490 value = *(int *)(varp) ^ 1; | |
1491 else | |
1492 value = prefix; | |
1493 } | |
1494 | |
1495 errmsg = set_bool_option(opt_idx, varp, (int)value, | |
1496 opt_flags); | |
1497 } | |
1498 else /* numeric or string */ | |
1499 { | |
1500 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL | |
1501 || prefix != 1) | |
1502 { | |
1503 errmsg = e_invarg; | |
1504 goto skip; | |
1505 } | |
1506 | |
1507 if (flags & P_NUM) /* numeric */ | |
1508 { | |
1509 /* | |
1510 * Different ways to set a number option: | |
1511 * & set to default value | |
1512 * < set to global value | |
1513 * <xx> accept special key codes for 'wildchar' | |
1514 * c accept any non-digit for 'wildchar' | |
1515 * [-]0-9 set number | |
1516 * other error | |
1517 */ | |
1518 ++arg; | |
1519 if (nextchar == '&') | |
840 | 1520 value = (long)(long_i)options[opt_idx].def_val[ |
7 | 1521 ((flags & P_VI_DEF) || cp_val) |
1522 ? VI_DEFAULT : VIM_DEFAULT]; | |
1523 else if (nextchar == '<') | |
5446 | 1524 { |
1525 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to | |
1526 * use the global value. */ | |
1527 if ((long *)varp == &curbuf->b_p_ul | |
1528 && opt_flags == OPT_LOCAL) | |
1529 value = NO_LOCAL_UNDOLEVEL; | |
1530 else | |
1531 value = *(long *)get_varp_scope( | |
1532 &(options[opt_idx]), OPT_GLOBAL); | |
1533 } | |
7 | 1534 else if (((long *)varp == &p_wc |
1535 || (long *)varp == &p_wcm) | |
1536 && (*arg == '<' | |
1537 || *arg == '^' | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1538 || (*arg != NUL |
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1539 && (!arg[1] || VIM_ISWHITE(arg[1])) |
7 | 1540 && !VIM_ISDIGIT(*arg)))) |
1541 { | |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1542 value = string_to_key(arg, FALSE); |
7 | 1543 if (value == 0 && (long *)varp != &p_wcm) |
1544 { | |
1545 errmsg = e_invarg; | |
1546 goto skip; | |
1547 } | |
1548 } | |
1549 else if (*arg == '-' || VIM_ISDIGIT(*arg)) | |
1550 { | |
6551 | 1551 /* Allow negative (for 'undolevels'), octal and |
1552 * hex numbers. */ | |
7447
ad432f8f68fb
commit https://github.com/vim/vim/commit/887c1fea4a114e7170091942d0446c8882701b5b
Christian Brabandt <cb@256bit.org>
parents:
7426
diff
changeset
|
1553 vim_str2nr(arg, NULL, &i, STR2NR_ALL, |
16706
77bcb5055fec
patch 8.1.1355: obvious mistakes are accepted as valid expressions
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
1554 &value, NULL, 0, TRUE); |
17039
d726d8cce996
patch 8.1.1519: 'backupskip' may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
16843
diff
changeset
|
1555 if (i == 0 || (arg[i] != NUL |
d726d8cce996
patch 8.1.1519: 'backupskip' may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
16843
diff
changeset
|
1556 && !VIM_ISWHITE(arg[i]))) |
7 | 1557 { |
16706
77bcb5055fec
patch 8.1.1355: obvious mistakes are accepted as valid expressions
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
1558 errmsg = N_("E521: Number required after ="); |
7 | 1559 goto skip; |
1560 } | |
1561 } | |
1562 else | |
1563 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1564 errmsg = N_("E521: Number required after ="); |
7 | 1565 goto skip; |
1566 } | |
1567 | |
1568 if (adding) | |
1569 value = *(long *)varp + value; | |
1570 if (prepending) | |
1571 value = *(long *)varp * value; | |
1572 if (removing) | |
1573 value = *(long *)varp - value; | |
1574 errmsg = set_num_option(opt_idx, varp, value, | |
274 | 1575 errbuf, sizeof(errbuf), opt_flags); |
7 | 1576 } |
1577 else if (opt_idx >= 0) /* string */ | |
1578 { | |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1579 char_u *save_arg = NULL; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1580 char_u *s = NULL; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1581 char_u *oldval = NULL; /* previous value if *varp */ |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1582 char_u *newval; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1583 char_u *origval = NULL; |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1584 char_u *origval_l = NULL; |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1585 char_u *origval_g = NULL; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
1586 #if defined(FEAT_EVAL) |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1587 char_u *saved_origval = NULL; |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1588 char_u *saved_origval_l = NULL; |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1589 char_u *saved_origval_g = NULL; |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1590 char_u *saved_newval = NULL; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1591 #endif |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1592 unsigned newlen; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1593 int comma; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1594 int bs; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1595 int new_value_alloced; /* new string option |
7 | 1596 was allocated */ |
1597 | |
1598 /* When using ":set opt=val" for a global option | |
1599 * with a local value the local value will be | |
1600 * reset, use the global value here. */ | |
1601 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 | |
692 | 1602 && ((int)options[opt_idx].indir & PV_BOTH)) |
7 | 1603 varp = options[opt_idx].var; |
1604 | |
1605 /* The old value is kept until we are sure that the | |
1606 * new value is valid. */ | |
1607 oldval = *(char_u **)varp; | |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1608 |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1609 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1610 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1611 origval_l = *(char_u **)get_varp_scope( |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1612 &(options[opt_idx]), OPT_LOCAL); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1613 origval_g = *(char_u **)get_varp_scope( |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1614 &(options[opt_idx]), OPT_GLOBAL); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1615 |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1616 // A global-local string option might have an empty |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1617 // option as value to indicate that the global |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1618 // value should be used. |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1619 if (((int)options[opt_idx].indir & PV_BOTH) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1620 && origval_l == empty_option) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1621 origval_l = origval_g; |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1622 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1623 |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1624 // When setting the local value of a global |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1625 // option, the old value may be the global value. |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1626 if (((int)options[opt_idx].indir & PV_BOTH) |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1627 && (opt_flags & OPT_LOCAL)) |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1628 origval = *(char_u **)get_varp( |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1629 &options[opt_idx]); |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1630 else |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1631 origval = oldval; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1632 |
7 | 1633 if (nextchar == '&') /* set to default val */ |
1634 { | |
1635 newval = options[opt_idx].def_val[ | |
1636 ((flags & P_VI_DEF) || cp_val) | |
1637 ? VI_DEFAULT : VIM_DEFAULT]; | |
1638 if ((char_u **)varp == &p_bg) | |
1639 { | |
1640 /* guess the value of 'background' */ | |
1641 #ifdef FEAT_GUI | |
1642 if (gui.in_use) | |
1643 newval = gui_bg_default(); | |
1644 else | |
1645 #endif | |
671 | 1646 newval = term_bg_default(); |
7 | 1647 } |
1648 | |
1649 /* expand environment variables and ~ (since the | |
1650 * default value was already expanded, only | |
1651 * required when an environment variable was set | |
1652 * later */ | |
1653 if (newval == NULL) | |
1654 newval = empty_option; | |
1655 else | |
1656 { | |
1657 s = option_expand(opt_idx, newval); | |
1658 if (s == NULL) | |
1659 s = newval; | |
1660 newval = vim_strsave(s); | |
1661 } | |
1662 new_value_alloced = TRUE; | |
1663 } | |
1664 else if (nextchar == '<') /* set to global val */ | |
1665 { | |
1666 newval = vim_strsave(*(char_u **)get_varp_scope( | |
1667 &(options[opt_idx]), OPT_GLOBAL)); | |
1668 new_value_alloced = TRUE; | |
1669 } | |
1670 else | |
1671 { | |
1672 ++arg; /* jump to after the '=' or ':' */ | |
1673 | |
1674 /* | |
1675 * Set 'keywordprg' to ":help" if an empty | |
1676 * value was passed to :set by the user. | |
1677 * Misuse errbuf[] for the resulting string. | |
1678 */ | |
1679 if (varp == (char_u *)&p_kp | |
1680 && (*arg == NUL || *arg == ' ')) | |
1681 { | |
1682 STRCPY(errbuf, ":help"); | |
1683 save_arg = arg; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1684 arg = (char_u *)errbuf; |
7 | 1685 } |
1686 /* | |
3168 | 1687 * Convert 'backspace' number to string, for |
1688 * adding, prepending and removing string. | |
1689 */ | |
1690 else if (varp == (char_u *)&p_bs | |
1691 && VIM_ISDIGIT(**(char_u **)varp)) | |
1692 { | |
1693 i = getdigits((char_u **)varp); | |
1694 switch (i) | |
1695 { | |
1696 case 0: | |
1697 *(char_u **)varp = empty_option; | |
1698 break; | |
1699 case 1: | |
1700 *(char_u **)varp = vim_strsave( | |
1701 (char_u *)"indent,eol"); | |
1702 break; | |
1703 case 2: | |
1704 *(char_u **)varp = vim_strsave( | |
1705 (char_u *)"indent,eol,start"); | |
1706 break; | |
1707 } | |
1708 vim_free(oldval); | |
12190
497b78526358
patch 8.0.0975: using freed memory when setting 'backspace'
Christian Brabandt <cb@256bit.org>
parents:
12188
diff
changeset
|
1709 if (origval == oldval) |
497b78526358
patch 8.0.0975: using freed memory when setting 'backspace'
Christian Brabandt <cb@256bit.org>
parents:
12188
diff
changeset
|
1710 origval = *(char_u **)varp; |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1711 if (origval_l == oldval) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1712 origval_l = *(char_u **)varp; |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1713 if (origval_g == oldval) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1714 origval_g = *(char_u **)varp; |
3168 | 1715 oldval = *(char_u **)varp; |
1716 } | |
1717 /* | |
7 | 1718 * Convert 'whichwrap' number to string, for |
1719 * backwards compatibility with Vim 3.0. | |
1720 * Misuse errbuf[] for the resulting string. | |
1721 */ | |
1722 else if (varp == (char_u *)&p_ww | |
1723 && VIM_ISDIGIT(*arg)) | |
1724 { | |
1725 *errbuf = NUL; | |
1726 i = getdigits(&arg); | |
1727 if (i & 1) | |
1728 STRCAT(errbuf, "b,"); | |
1729 if (i & 2) | |
1730 STRCAT(errbuf, "s,"); | |
1731 if (i & 4) | |
1732 STRCAT(errbuf, "h,l,"); | |
1733 if (i & 8) | |
1734 STRCAT(errbuf, "<,>,"); | |
1735 if (i & 16) | |
1736 STRCAT(errbuf, "[,],"); | |
1737 if (*errbuf != NUL) /* remove trailing , */ | |
1738 errbuf[STRLEN(errbuf) - 1] = NUL; | |
1739 save_arg = arg; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1740 arg = (char_u *)errbuf; |
7 | 1741 } |
1742 /* | |
1743 * Remove '>' before 'dir' and 'bdir', for | |
1744 * backwards compatibility with version 3.0 | |
1745 */ | |
1746 else if ( *arg == '>' | |
1747 && (varp == (char_u *)&p_dir | |
1748 || varp == (char_u *)&p_bdir)) | |
1749 { | |
1750 ++arg; | |
1751 } | |
1752 | |
1753 /* | |
1754 * Copy the new string into allocated memory. | |
1755 * Can't use set_string_option_direct(), because | |
1756 * we need to remove the backslashes. | |
1757 */ | |
1758 /* get a bit too much */ | |
1759 newlen = (unsigned)STRLEN(arg) + 1; | |
1760 if (adding || prepending || removing) | |
1761 newlen += (unsigned)STRLEN(origval) + 1; | |
1762 newval = alloc(newlen); | |
1763 if (newval == NULL) /* out of mem, don't change */ | |
1764 break; | |
1765 s = newval; | |
1766 | |
1767 /* | |
1768 * Copy the string, skip over escaped chars. | |
1769 * For MS-DOS and WIN32 backslashes before normal | |
1770 * file name characters are not removed, and keep | |
1771 * backslash at start, for "\\machine\path", but | |
1772 * do remove it for "\\\\machine\\path". | |
1773 * The reverse is found in ExpandOldSetting(). | |
1774 */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1775 while (*arg && !VIM_ISWHITE(*arg)) |
7 | 1776 { |
1777 if (*arg == '\\' && arg[1] != NUL | |
1778 #ifdef BACKSLASH_IN_FILENAME | |
1779 && !((flags & P_EXPAND) | |
1780 && vim_isfilec(arg[1]) | |
1781 && (arg[1] != '\\' | |
1782 || (s == newval | |
1783 && arg[2] != '\\'))) | |
1784 #endif | |
1785 ) | |
1786 ++arg; /* remove backslash */ | |
1787 if (has_mbyte | |
474 | 1788 && (i = (*mb_ptr2len)(arg)) > 1) |
7 | 1789 { |
1790 /* copy multibyte char */ | |
1791 mch_memmove(s, arg, (size_t)i); | |
1792 arg += i; | |
1793 s += i; | |
1794 } | |
1795 else | |
1796 *s++ = *arg++; | |
1797 } | |
1798 *s = NUL; | |
1799 | |
1800 /* | |
1801 * Expand environment variables and ~. | |
1802 * Don't do it when adding without inserting a | |
1803 * comma. | |
1804 */ | |
1805 if (!(adding || prepending || removing) | |
1806 || (flags & P_COMMA)) | |
1807 { | |
1808 s = option_expand(opt_idx, newval); | |
1809 if (s != NULL) | |
1810 { | |
1811 vim_free(newval); | |
1812 newlen = (unsigned)STRLEN(s) + 1; | |
1813 if (adding || prepending || removing) | |
1814 newlen += (unsigned)STRLEN(origval) + 1; | |
1815 newval = alloc(newlen); | |
1816 if (newval == NULL) | |
1817 break; | |
1818 STRCPY(newval, s); | |
1819 } | |
1820 } | |
1821 | |
1822 /* locate newval[] in origval[] when removing it | |
1823 * and when adding to avoid duplicates */ | |
1824 i = 0; /* init for GCC */ | |
1825 if (removing || (flags & P_NODUP)) | |
1826 { | |
1827 i = (int)STRLEN(newval); | |
1828 bs = 0; | |
1829 for (s = origval; *s; ++s) | |
1830 { | |
1831 if ((!(flags & P_COMMA) | |
1832 || s == origval | |
1833 || (s[-1] == ',' && !(bs & 1))) | |
1834 && STRNCMP(s, newval, i) == 0 | |
1835 && (!(flags & P_COMMA) | |
1836 || s[i] == ',' | |
1837 || s[i] == NUL)) | |
1838 break; | |
2726 | 1839 /* Count backslashes. Only a comma with an |
7426
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1840 * even number of backslashes or a single |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1841 * backslash preceded by a comma before it |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1842 * is recognized as a separator */ |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1843 if ((s > origval + 1 |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1844 && s[-1] == '\\' |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1845 && s[-2] != ',') |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1846 || (s == origval + 1 |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1847 && s[-1] == '\\')) |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1848 |
7 | 1849 ++bs; |
1850 else | |
1851 bs = 0; | |
1852 } | |
1853 | |
1854 /* do not add if already there */ | |
1855 if ((adding || prepending) && *s) | |
1856 { | |
1857 prepending = FALSE; | |
1858 adding = FALSE; | |
1859 STRCPY(newval, origval); | |
1860 } | |
1861 } | |
1862 | |
1863 /* concatenate the two strings; add a ',' if | |
1864 * needed */ | |
1865 if (adding || prepending) | |
1866 { | |
1867 comma = ((flags & P_COMMA) && *origval != NUL | |
1868 && *newval != NUL); | |
1869 if (adding) | |
1870 { | |
1871 i = (int)STRLEN(origval); | |
6841 | 1872 /* strip a trailing comma, would get 2 */ |
7212
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1873 if (comma && i > 1 |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1874 && (flags & P_ONECOMMA) == P_ONECOMMA |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1875 && origval[i - 1] == ',' |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1876 && origval[i - 2] != '\\') |
6841 | 1877 i--; |
7 | 1878 mch_memmove(newval + i + comma, newval, |
1879 STRLEN(newval) + 1); | |
1880 mch_memmove(newval, origval, (size_t)i); | |
1881 } | |
1882 else | |
1883 { | |
1884 i = (int)STRLEN(newval); | |
1622 | 1885 STRMOVE(newval + i + comma, origval); |
7 | 1886 } |
1887 if (comma) | |
1888 newval[i] = ','; | |
1889 } | |
1890 | |
1891 /* Remove newval[] from origval[]. (Note: "i" has | |
1892 * been set above and is used here). */ | |
1893 if (removing) | |
1894 { | |
1895 STRCPY(newval, origval); | |
1896 if (*s) | |
1897 { | |
1898 /* may need to remove a comma */ | |
1899 if (flags & P_COMMA) | |
1900 { | |
1901 if (s == origval) | |
1902 { | |
1903 /* include comma after string */ | |
1904 if (s[i] == ',') | |
1905 ++i; | |
1906 } | |
1907 else | |
1908 { | |
1909 /* include comma before string */ | |
1910 --s; | |
1911 ++i; | |
1912 } | |
1913 } | |
1622 | 1914 STRMOVE(newval + (s - origval), s + i); |
7 | 1915 } |
1916 } | |
1917 | |
1918 if (flags & P_FLAGLIST) | |
1919 { | |
1920 /* Remove flags that appear twice. */ | |
10831
e926c5a7f9bf
patch 8.0.0305: invalid memory access when option has duplicate flag
Christian Brabandt <cb@256bit.org>
parents:
10825
diff
changeset
|
1921 for (s = newval; *s;) |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1922 { |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1923 /* if options have P_FLAGLIST and |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1924 * P_ONECOMMA such as 'whichwrap' */ |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1925 if (flags & P_ONECOMMA) |
7 | 1926 { |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1927 if (*s != ',' && *(s + 1) == ',' |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1928 && vim_strchr(s + 2, *s) != NULL) |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1929 { |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1930 /* Remove the duplicated value and |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1931 * the next comma. */ |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1932 STRMOVE(s, s + 2); |
10831
e926c5a7f9bf
patch 8.0.0305: invalid memory access when option has duplicate flag
Christian Brabandt <cb@256bit.org>
parents:
10825
diff
changeset
|
1933 continue; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1934 } |
7 | 1935 } |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1936 else |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1937 { |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1938 if ((!(flags & P_COMMA) || *s != ',') |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1939 && vim_strchr(s + 1, *s) != NULL) |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1940 { |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1941 STRMOVE(s, s + 1); |
10831
e926c5a7f9bf
patch 8.0.0305: invalid memory access when option has duplicate flag
Christian Brabandt <cb@256bit.org>
parents:
10825
diff
changeset
|
1942 continue; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1943 } |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1944 } |
10831
e926c5a7f9bf
patch 8.0.0305: invalid memory access when option has duplicate flag
Christian Brabandt <cb@256bit.org>
parents:
10825
diff
changeset
|
1945 ++s; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1946 } |
7 | 1947 } |
1948 | |
1949 if (save_arg != NULL) /* number for 'whichwrap' */ | |
1950 arg = save_arg; | |
1951 new_value_alloced = TRUE; | |
1952 } | |
1953 | |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1954 /* |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1955 * Set the new value. |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1956 */ |
7 | 1957 *(char_u **)(varp) = newval; |
1958 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
1959 #if defined(FEAT_EVAL) |
6939 | 1960 if (!starting |
1961 # ifdef FEAT_CRYPT | |
1962 && options[opt_idx].indir != PV_KEY | |
1963 # endif | |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1964 && origval != NULL && newval != NULL) |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1965 { |
6935 | 1966 /* origval may be freed by |
1967 * did_set_string_option(), make a copy. */ | |
1968 saved_origval = vim_strsave(origval); | |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1969 /* newval (and varp) may become invalid if the |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1970 * buffer is closed by autocommands. */ |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1971 saved_newval = vim_strsave(newval); |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1972 if (origval_l != NULL) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1973 saved_origval_l = vim_strsave(origval_l); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1974 if (origval_g != NULL) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1975 saved_origval_g = vim_strsave(origval_g); |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1976 } |
6935 | 1977 #endif |
1978 | |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1979 { |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1980 long_u *p = insecure_flag(opt_idx, opt_flags); |
15207
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
1981 int secure_saved = secure; |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1982 |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1983 // When an option is set in the sandbox, from a |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1984 // modeline or in secure mode, then deal with side |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1985 // effects in secure mode. Also when the value was |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1986 // set with the P_INSECURE flag and is not |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1987 // completely replaced. |
16082
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
1988 if ((opt_flags & OPT_MODELINE) |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1989 #ifdef HAVE_SANDBOX |
16082
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
1990 || sandbox != 0 |
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
1991 #endif |
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
1992 || (!value_is_replaced && (*p & P_INSECURE))) |
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
1993 secure = 1; |
15207
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
1994 |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
1995 // Handle side effects, and set the global value |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
1996 // for ":set" on local options. Note: when setting |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
1997 // 'syntax' or 'filetype' autocommands may be |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
1998 // triggered that can cause havoc. |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
1999 errmsg = did_set_string_option( |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
2000 opt_idx, (char_u **)varp, |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2001 new_value_alloced, oldval, errbuf, |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2002 opt_flags, &value_checked); |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
2003 |
15207
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
2004 secure = secure_saved; |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
2005 } |
7 | 2006 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
2007 #if defined(FEAT_EVAL) |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2008 if (errmsg == NULL) |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2009 trigger_optionsset_string( |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2010 opt_idx, opt_flags, saved_origval, |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2011 saved_origval_l, saved_origval_g, |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2012 saved_newval); |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2013 vim_free(saved_origval); |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2014 vim_free(saved_origval_l); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2015 vim_free(saved_origval_g); |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2016 vim_free(saved_newval); |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2017 #endif |
7 | 2018 /* If error detected, print the error message. */ |
2019 if (errmsg != NULL) | |
2020 goto skip; | |
2021 } | |
2022 else /* key code option */ | |
2023 { | |
2024 char_u *p; | |
2025 | |
2026 if (nextchar == '&') | |
2027 { | |
2028 if (add_termcap_entry(key_name, TRUE) == FAIL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2029 errmsg = N_("E522: Not found in termcap"); |
7 | 2030 } |
2031 else | |
2032 { | |
2033 ++arg; /* jump to after the '=' or ':' */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2034 for (p = arg; *p && !VIM_ISWHITE(*p); ++p) |
7 | 2035 if (*p == '\\' && p[1] != NUL) |
2036 ++p; | |
2037 nextchar = *p; | |
2038 *p = NUL; | |
2039 add_termcode(key_name, arg, FALSE); | |
2040 *p = nextchar; | |
2041 } | |
2042 if (full_screen) | |
2043 ttest(FALSE); | |
2044 redraw_all_later(CLEAR); | |
2045 } | |
2046 } | |
634 | 2047 |
7 | 2048 if (opt_idx >= 0) |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2049 did_set_option( |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2050 opt_idx, opt_flags, value_is_replaced, value_checked); |
7 | 2051 } |
2052 | |
2053 skip: | |
2054 /* | |
2055 * Advance to next argument. | |
2056 * - skip until a blank found, taking care of backslashes | |
2057 * - skip blanks | |
2058 * - skip one "=val" argument (for hidden options ":set gfn =xx") | |
2059 */ | |
2060 for (i = 0; i < 2 ; ++i) | |
2061 { | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2062 while (*arg != NUL && !VIM_ISWHITE(*arg)) |
7 | 2063 if (*arg++ == '\\' && *arg != NUL) |
2064 ++arg; | |
2065 arg = skipwhite(arg); | |
2066 if (*arg != '=') | |
2067 break; | |
2068 } | |
2069 } | |
2070 | |
2071 if (errmsg != NULL) | |
2072 { | |
419 | 2073 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1); |
835 | 2074 i = (int)STRLEN(IObuff) + 2; |
7 | 2075 if (i + (arg - startarg) < IOSIZE) |
2076 { | |
2077 /* append the argument with the error */ | |
2078 STRCAT(IObuff, ": "); | |
2079 mch_memmove(IObuff + i, startarg, (arg - startarg)); | |
2080 IObuff[i + (arg - startarg)] = NUL; | |
2081 } | |
2082 /* make sure all characters are printable */ | |
2083 trans_characters(IObuff, IOSIZE); | |
2084 | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2085 ++no_wait_return; // wait_return done later |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2086 emsg((char *)IObuff); // show error highlighted |
7 | 2087 --no_wait_return; |
2088 | |
2089 return FAIL; | |
2090 } | |
2091 | |
2092 arg = skipwhite(arg); | |
2093 } | |
2094 | |
168 | 2095 theend: |
2096 if (silent_mode && did_show) | |
2097 { | |
2098 /* After displaying option values in silent mode. */ | |
2099 silent_mode = FALSE; | |
2100 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ | |
2101 msg_putchar('\n'); | |
2102 cursor_on(); /* msg_start() switches it off */ | |
2103 out_flush(); | |
2104 silent_mode = TRUE; | |
2105 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */ | |
2106 } | |
2107 | |
7 | 2108 return OK; |
2109 } | |
2110 | |
634 | 2111 /* |
2112 * Call this when an option has been given a new value through a user command. | |
2113 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag. | |
2114 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2115 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2116 did_set_option( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2117 int opt_idx, |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2118 int opt_flags, // possibly with OPT_MODELINE |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2119 int new_value, // value was replaced completely |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2120 int value_checked) // value was checked to be safe, no need to set the |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2121 // P_INSECURE flag. |
634 | 2122 { |
681 | 2123 long_u *p; |
2124 | |
634 | 2125 options[opt_idx].flags |= P_WAS_SET; |
2126 | |
2127 /* When an option is set in the sandbox, from a modeline or in secure mode | |
2128 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the | |
681 | 2129 * flag. */ |
2130 p = insecure_flag(opt_idx, opt_flags); | |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2131 if (!value_checked && (secure |
634 | 2132 #ifdef HAVE_SANDBOX |
2133 || sandbox != 0 | |
2134 #endif | |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2135 || (opt_flags & OPT_MODELINE))) |
681 | 2136 *p = *p | P_INSECURE; |
2137 else if (new_value) | |
2138 *p = *p & ~P_INSECURE; | |
634 | 2139 } |
2140 | |
7 | 2141 /* |
2142 * Convert a key name or string into a key value. | |
2143 * Used for 'wildchar' and 'cedit' options. | |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2144 * When "multi_byte" is TRUE allow for multi-byte characters. |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2145 */ |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2146 int |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2147 string_to_key(char_u *arg, int multi_byte) |
7 | 2148 { |
2149 if (*arg == '<') | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
2150 return find_key_option(arg + 1, TRUE); |
7 | 2151 if (*arg == '^') |
2152 return Ctrl_chr(arg[1]); | |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2153 if (multi_byte) |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2154 return PTR2CHAR(arg); |
7 | 2155 return *arg; |
2156 } | |
2157 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2158 #if defined(FEAT_CMDWIN) || defined(PROTO) |
7 | 2159 /* |
2160 * Check value of 'cedit' and set cedit_key. | |
2161 * Returns NULL if value is OK, error message otherwise. | |
2162 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2163 char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2164 check_cedit(void) |
7 | 2165 { |
2166 int n; | |
2167 | |
2168 if (*p_cedit == NUL) | |
2169 cedit_key = -1; | |
2170 else | |
2171 { | |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2172 n = string_to_key(p_cedit, FALSE); |
7 | 2173 if (vim_isprintc(n)) |
2174 return e_invarg; | |
2175 cedit_key = n; | |
2176 } | |
2177 return NULL; | |
2178 } | |
2179 #endif | |
2180 | |
2181 #ifdef FEAT_TITLE | |
2182 /* | |
2183 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call | |
2184 * maketitle() to create and display it. | |
2185 * When switching the title or icon off, call mch_restore_title() to get | |
2186 * the old value back. | |
2187 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2188 void |
14087
1d25a3e8e03c
patch 8.1.0061: window title is wrong after resetting and setting 'title'
Christian Brabandt <cb@256bit.org>
parents:
14057
diff
changeset
|
2189 did_set_title(void) |
7 | 2190 { |
2191 if (starting != NO_SCREEN | |
2192 #ifdef FEAT_GUI | |
2193 && !gui.starting | |
2194 #endif | |
2195 ) | |
2196 maketitle(); | |
2197 } | |
2198 #endif | |
2199 | |
2200 /* | |
2201 * set_options_bin - called when 'bin' changes value. | |
2202 */ | |
2203 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2204 set_options_bin( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2205 int oldval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2206 int newval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2207 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ |
7 | 2208 { |
2209 /* | |
2210 * The option values that are changed when 'bin' changes are | |
2211 * copied when 'bin is set and restored when 'bin' is reset. | |
2212 */ | |
2213 if (newval) | |
2214 { | |
2215 if (!oldval) /* switched on */ | |
2216 { | |
2217 if (!(opt_flags & OPT_GLOBAL)) | |
2218 { | |
2219 curbuf->b_p_tw_nobin = curbuf->b_p_tw; | |
2220 curbuf->b_p_wm_nobin = curbuf->b_p_wm; | |
2221 curbuf->b_p_ml_nobin = curbuf->b_p_ml; | |
2222 curbuf->b_p_et_nobin = curbuf->b_p_et; | |
2223 } | |
2224 if (!(opt_flags & OPT_LOCAL)) | |
2225 { | |
2226 p_tw_nobin = p_tw; | |
2227 p_wm_nobin = p_wm; | |
2228 p_ml_nobin = p_ml; | |
2229 p_et_nobin = p_et; | |
2230 } | |
2231 } | |
2232 | |
2233 if (!(opt_flags & OPT_GLOBAL)) | |
2234 { | |
2235 curbuf->b_p_tw = 0; /* no automatic line wrap */ | |
2236 curbuf->b_p_wm = 0; /* no automatic line wrap */ | |
2237 curbuf->b_p_ml = 0; /* no modelines */ | |
2238 curbuf->b_p_et = 0; /* no expandtab */ | |
2239 } | |
2240 if (!(opt_flags & OPT_LOCAL)) | |
2241 { | |
2242 p_tw = 0; | |
2243 p_wm = 0; | |
2244 p_ml = FALSE; | |
2245 p_et = FALSE; | |
2246 p_bin = TRUE; /* needed when called for the "-b" argument */ | |
2247 } | |
2248 } | |
2249 else if (oldval) /* switched off */ | |
2250 { | |
2251 if (!(opt_flags & OPT_GLOBAL)) | |
2252 { | |
2253 curbuf->b_p_tw = curbuf->b_p_tw_nobin; | |
2254 curbuf->b_p_wm = curbuf->b_p_wm_nobin; | |
2255 curbuf->b_p_ml = curbuf->b_p_ml_nobin; | |
2256 curbuf->b_p_et = curbuf->b_p_et_nobin; | |
2257 } | |
2258 if (!(opt_flags & OPT_LOCAL)) | |
2259 { | |
2260 p_tw = p_tw_nobin; | |
2261 p_wm = p_wm_nobin; | |
2262 p_ml = p_ml_nobin; | |
2263 p_et = p_et_nobin; | |
2264 } | |
2265 } | |
2266 } | |
2267 | |
2268 /* | |
2269 * Expand environment variables for some string options. | |
2270 * These string options cannot be indirect! | |
2271 * If "val" is NULL expand the current value of the option. | |
2272 * Return pointer to NameBuff, or NULL when not expanded. | |
2273 */ | |
2274 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2275 option_expand(int opt_idx, char_u *val) |
7 | 2276 { |
2277 /* if option doesn't need expansion nothing to do */ | |
2278 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) | |
2279 return NULL; | |
2280 | |
2281 /* If val is longer than MAXPATHL no meaningful expansion can be done, | |
2282 * expand_env() would truncate the string. */ | |
2283 if (val != NULL && STRLEN(val) > MAXPATHL) | |
2284 return NULL; | |
2285 | |
2286 if (val == NULL) | |
2287 val = *(char_u **)options[opt_idx].var; | |
2288 | |
2289 /* | |
2290 * Expanding this with NameBuff, expand_env() must not be passed IObuff. | |
2291 * Escape spaces when expanding 'tags', they are used to separate file | |
2292 * names. | |
374 | 2293 * For 'spellsuggest' expand after "file:". |
7 | 2294 */ |
2295 expand_env_esc(val, NameBuff, MAXPATHL, | |
1408 | 2296 (char_u **)options[opt_idx].var == &p_tags, FALSE, |
744 | 2297 #ifdef FEAT_SPELL |
374 | 2298 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : |
2299 #endif | |
2300 NULL); | |
7 | 2301 if (STRCMP(NameBuff, val) == 0) /* they are the same */ |
2302 return NULL; | |
2303 | |
2304 return NameBuff; | |
2305 } | |
2306 | |
2307 /* | |
2308 * After setting various option values: recompute variables that depend on | |
2309 * option values. | |
2310 */ | |
2311 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2312 didset_options(void) |
7 | 2313 { |
2314 /* initialize the table for 'iskeyword' et.al. */ | |
2315 (void)init_chartab(); | |
2316 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2317 didset_string_options(); |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2318 |
744 | 2319 #ifdef FEAT_SPELL |
484 | 2320 (void)spell_check_msm(); |
374 | 2321 (void)spell_check_sps(); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
2322 (void)compile_cap_prog(curwin->w_s); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2323 (void)did_set_spell_option(TRUE); |
344 | 2324 #endif |
7 | 2325 #ifdef FEAT_CMDWIN |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2326 // set cedit_key |
7 | 2327 (void)check_cedit(); |
2328 #endif | |
5995 | 2329 #ifdef FEAT_LINEBREAK |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2330 /* initialize the table for 'breakat'. */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2331 fill_breakat_flags(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2332 #endif |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2333 after_copy_winopt(curwin); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2334 } |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2335 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2336 /* |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2337 * More side effects of setting options. |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2338 */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2339 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2340 didset_options2(void) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2341 { |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2342 /* Initialize the highlight_attr[] table. */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2343 (void)highlight_changed(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2344 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2345 /* Parse default for 'wildmode' */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2346 check_opt_wim(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2347 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2348 (void)set_chars_option(&p_lcs); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2349 /* Parse default for 'fillchars'. */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2350 (void)set_chars_option(&p_fcs); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2351 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2352 #ifdef FEAT_CLIPBOARD |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2353 /* Parse default for 'clipboard' */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2354 (void)check_clipboard_option(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2355 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2356 #ifdef FEAT_VARTABS |
15858
3a45b89639fb
patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2357 vim_free(curbuf->b_p_vsts_array); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2358 tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array); |
15858
3a45b89639fb
patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2359 vim_free(curbuf->b_p_vts_array); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2360 tabstop_set(curbuf->b_p_vts, &curbuf->b_p_vts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2361 #endif |
7 | 2362 } |
2363 | |
2364 /* | |
2365 * Check for string options that are NULL (normally only termcap options). | |
2366 */ | |
2367 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2368 check_options(void) |
7 | 2369 { |
2370 int opt_idx; | |
2371 | |
2372 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) | |
2373 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL) | |
2374 check_string_option((char_u **)get_varp(&(options[opt_idx]))); | |
2375 } | |
2376 | |
2377 /* | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2378 * Return the option index found by a pointer into term_strings[]. |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2379 * Return -1 if not found. |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2380 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2381 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2382 get_term_opt_idx(char_u **p) |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2383 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2384 int opt_idx; |
7 | 2385 |
2386 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) | |
2387 if (options[opt_idx].var == (char_u *)p) | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2388 return opt_idx; |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2389 return -1; // cannot happen: didn't find it! |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2390 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2391 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2392 /* |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2393 * Mark a terminal option as allocated, found by a pointer into term_strings[]. |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2394 * Return the option index or -1 if not found. |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2395 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2396 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2397 set_term_option_alloced(char_u **p) |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2398 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2399 int opt_idx = get_term_opt_idx(p); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2400 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2401 if (opt_idx >= 0) |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2402 options[opt_idx].flags |= P_ALLOCED; |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2403 return opt_idx; |
7 | 2404 } |
2405 | |
634 | 2406 #if defined(FEAT_EVAL) || defined(PROTO) |
2407 /* | |
2408 * Return TRUE when option "opt" was set from a modeline or in secure mode. | |
2409 * Return FALSE when it wasn't. | |
2410 * Return -1 for an unknown option. | |
2411 */ | |
2412 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2413 was_set_insecurely(char_u *opt, int opt_flags) |
634 | 2414 { |
2415 int idx = findoption(opt); | |
681 | 2416 long_u *flagp; |
634 | 2417 |
2418 if (idx >= 0) | |
681 | 2419 { |
2420 flagp = insecure_flag(idx, opt_flags); | |
2421 return (*flagp & P_INSECURE) != 0; | |
2422 } | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
2423 internal_error("was_set_insecurely()"); |
634 | 2424 return -1; |
2425 } | |
681 | 2426 |
2427 /* | |
2428 * Get a pointer to the flags used for the P_INSECURE flag of option | |
2429 * "opt_idx". For some local options a local flags field is used. | |
2430 */ | |
2431 static long_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2432 insecure_flag(int opt_idx, int opt_flags) |
681 | 2433 { |
2434 if (opt_flags & OPT_LOCAL) | |
2435 switch ((int)options[opt_idx].indir) | |
2436 { | |
2437 #ifdef FEAT_STL_OPT | |
694 | 2438 case PV_STL: return &curwin->w_p_stl_flags; |
681 | 2439 #endif |
2440 #ifdef FEAT_EVAL | |
885 | 2441 # ifdef FEAT_FOLDING |
694 | 2442 case PV_FDE: return &curwin->w_p_fde_flags; |
2443 case PV_FDT: return &curwin->w_p_fdt_flags; | |
885 | 2444 # endif |
790 | 2445 # ifdef FEAT_BEVAL |
2446 case PV_BEXPR: return &curbuf->b_p_bexpr_flags; | |
2447 # endif | |
681 | 2448 # if defined(FEAT_CINDENT) |
694 | 2449 case PV_INDE: return &curbuf->b_p_inde_flags; |
681 | 2450 # endif |
694 | 2451 case PV_FEX: return &curbuf->b_p_fex_flags; |
681 | 2452 # ifdef FEAT_FIND_ID |
694 | 2453 case PV_INEX: return &curbuf->b_p_inex_flags; |
681 | 2454 # endif |
2455 #endif | |
2456 } | |
2457 | |
2458 /* Nothing special, return global flags field. */ | |
2459 return &options[opt_idx].flags; | |
2460 } | |
634 | 2461 #endif |
2462 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2463 #if defined(FEAT_TITLE) || defined(PROTO) |
1805 | 2464 /* |
2465 * Redraw the window title and/or tab page text later. | |
2466 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2467 void redraw_titles(void) |
1805 | 2468 { |
2469 need_maketitle = TRUE; | |
2470 redraw_tabline = TRUE; | |
2471 } | |
2472 #endif | |
2473 | |
7 | 2474 /* |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2475 * Return TRUE if "val" is a valid name: only consists of alphanumeric ASCII |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2476 * characters or characters in "allowed". |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2477 */ |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17845
diff
changeset
|
2478 int |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2479 valid_name(char_u *val, char *allowed) |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2480 { |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2481 char_u *s; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2482 |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2483 for (s = val; *s != NUL; ++s) |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2484 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)allowed, *s) == NULL) |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2485 return FALSE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2486 return TRUE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2487 } |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2488 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2489 #if defined(FEAT_CLIPBOARD) || defined(PROTO) |
7 | 2490 /* |
2491 * Extract the items in the 'clipboard' option and set global values. | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2492 * Return an error message or NULL for success. |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2493 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2494 char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2495 check_clipboard_option(void) |
7 | 2496 { |
2654 | 2497 int new_unnamed = 0; |
3678 | 2498 int new_autoselect_star = FALSE; |
2499 int new_autoselect_plus = FALSE; | |
7 | 2500 int new_autoselectml = FALSE; |
1904 | 2501 int new_html = FALSE; |
7 | 2502 regprog_T *new_exclude_prog = NULL; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2503 char *errmsg = NULL; |
7 | 2504 char_u *p; |
2505 | |
2506 for (p = p_cb; *p != NUL; ) | |
2507 { | |
2508 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL)) | |
2509 { | |
2654 | 2510 new_unnamed |= CLIP_UNNAMED; |
7 | 2511 p += 7; |
2512 } | |
3634 | 2513 else if (STRNCMP(p, "unnamedplus", 11) == 0 |
2654 | 2514 && (p[11] == ',' || p[11] == NUL)) |
2515 { | |
2516 new_unnamed |= CLIP_UNNAMED_PLUS; | |
2517 p += 11; | |
2518 } | |
7 | 2519 else if (STRNCMP(p, "autoselect", 10) == 0 |
3678 | 2520 && (p[10] == ',' || p[10] == NUL)) |
2521 { | |
2522 new_autoselect_star = TRUE; | |
7 | 2523 p += 10; |
2524 } | |
3678 | 2525 else if (STRNCMP(p, "autoselectplus", 14) == 0 |
2526 && (p[14] == ',' || p[14] == NUL)) | |
2527 { | |
2528 new_autoselect_plus = TRUE; | |
2529 p += 14; | |
2530 } | |
7 | 2531 else if (STRNCMP(p, "autoselectml", 12) == 0 |
3678 | 2532 && (p[12] == ',' || p[12] == NUL)) |
7 | 2533 { |
2534 new_autoselectml = TRUE; | |
2535 p += 12; | |
2536 } | |
1904 | 2537 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL)) |
2538 { | |
2539 new_html = TRUE; | |
2540 p += 4; | |
2541 } | |
7 | 2542 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL) |
2543 { | |
2544 p += 8; | |
2545 new_exclude_prog = vim_regcomp(p, RE_MAGIC); | |
2546 if (new_exclude_prog == NULL) | |
2547 errmsg = e_invarg; | |
2548 break; | |
2549 } | |
2550 else | |
2551 { | |
2552 errmsg = e_invarg; | |
2553 break; | |
2554 } | |
2555 if (*p == ',') | |
2556 ++p; | |
2557 } | |
2558 if (errmsg == NULL) | |
2559 { | |
2560 clip_unnamed = new_unnamed; | |
3678 | 2561 clip_autoselect_star = new_autoselect_star; |
2562 clip_autoselect_plus = new_autoselect_plus; | |
7 | 2563 clip_autoselectml = new_autoselectml; |
1904 | 2564 clip_html = new_html; |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4736
diff
changeset
|
2565 vim_regfree(clip_exclude_prog); |
7 | 2566 clip_exclude_prog = new_exclude_prog; |
2248 | 2567 #ifdef FEAT_GUI_GTK |
2183 | 2568 if (gui.in_use) |
2569 { | |
2570 gui_gtk_set_selection_targets(); | |
2571 gui_gtk_set_dnd_targets(); | |
2572 } | |
2573 #endif | |
7 | 2574 } |
2575 else | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4736
diff
changeset
|
2576 vim_regfree(new_exclude_prog); |
7 | 2577 |
2578 return errmsg; | |
2579 } | |
2580 #endif | |
2581 | |
681 | 2582 #if defined(FEAT_EVAL) || defined(PROTO) |
2583 /* | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2584 * Set the script_ctx for an option, taking care of setting the buffer- or |
694 | 2585 * window-local value. |
681 | 2586 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2587 void |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2588 set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx) |
694 | 2589 { |
2590 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; | |
2591 int indir = (int)options[opt_idx].indir; | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2592 sctx_T new_script_ctx = script_ctx; |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2593 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2594 new_script_ctx.sc_lnum += sourcing_lnum; |
694 | 2595 |
2596 /* Remember where the option was set. For local options need to do that | |
2597 * in the buffer or window structure. */ | |
2598 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0) | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2599 options[opt_idx].script_ctx = new_script_ctx; |
694 | 2600 if (both || (opt_flags & OPT_LOCAL)) |
2601 { | |
2602 if (indir & PV_BUF) | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2603 curbuf->b_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
694 | 2604 else if (indir & PV_WIN) |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2605 curwin->w_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
694 | 2606 } |
681 | 2607 } |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2608 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2609 /* |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2610 * Set the script_ctx for a termcap option. |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2611 * "name" must be the two character code, e.g. "RV". |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2612 * When "name" is NULL use "opt_idx". |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2613 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2614 void |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2615 set_term_option_sctx_idx(char *name, int opt_idx) |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2616 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2617 char_u buf[5]; |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2618 int idx; |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2619 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2620 if (name == NULL) |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2621 idx = opt_idx; |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2622 else |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2623 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2624 buf[0] = 't'; |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2625 buf[1] = '_'; |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2626 buf[2] = name[0]; |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2627 buf[3] = name[1]; |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2628 buf[4] = 0; |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2629 idx = findoption(buf); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2630 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2631 if (idx >= 0) |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2632 set_option_sctx_idx(idx, OPT_GLOBAL, current_sctx); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2633 } |
681 | 2634 #endif |
2635 | |
7 | 2636 /* |
2637 * Set the value of a boolean option, and take care of side effects. | |
2638 * Returns NULL for success, or an error message for an error. | |
2639 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2640 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2641 set_bool_option( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2642 int opt_idx, /* index in options[] table */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2643 char_u *varp, /* pointer to the option variable */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2644 int value, /* new value */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2645 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ |
7 | 2646 { |
2647 int old_value = *(int *)varp; | |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
2648 #if defined(FEAT_EVAL) |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2649 int old_global_value = 0; |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
2650 #endif |
7 | 2651 |
2652 /* Disallow changing some options from secure mode */ | |
2653 if ((secure | |
2654 #ifdef HAVE_SANDBOX | |
2655 || sandbox != 0 | |
2656 #endif | |
2657 ) && (options[opt_idx].flags & P_SECURE)) | |
2658 return e_secure; | |
2659 | |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
2660 #if defined(FEAT_EVAL) |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2661 // Save the global value before changing anything. This is needed as for |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2662 // a global-only option setting the "local value" in fact sets the global |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2663 // value (since there is only one value). |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2664 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2665 old_global_value = *(int *)get_varp_scope(&(options[opt_idx]), |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2666 OPT_GLOBAL); |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
2667 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2668 |
7 | 2669 *(int *)varp = value; /* set the new value */ |
2670 #ifdef FEAT_EVAL | |
2671 /* Remember where the option was set. */ | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2672 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 2673 #endif |
2674 | |
634 | 2675 #ifdef FEAT_GUI |
2676 need_mouse_correct = TRUE; | |
2677 #endif | |
2678 | |
7 | 2679 /* May set global value for local option. */ |
2680 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) | |
2681 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; | |
2682 | |
2683 /* | |
2684 * Handle side effects of changing a bool option. | |
2685 */ | |
2686 | |
2687 /* 'compatible' */ | |
2688 if ((int *)varp == &p_cp) | |
2689 compatible_set(); | |
2690 | |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2691 #ifdef FEAT_LANGMAP |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2692 if ((int *)varp == &p_lrm) |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2693 /* 'langremap' -> !'langnoremap' */ |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2694 p_lnr = !p_lrm; |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2695 else if ((int *)varp == &p_lnr) |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2696 /* 'langnoremap' -> !'langremap' */ |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2697 p_lrm = !p_lnr; |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2698 #endif |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2699 |
14846
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2700 #ifdef FEAT_SYN_HL |
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2701 else if ((int *)varp == &curwin->w_p_cul && !value && old_value) |
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2702 reset_cursorline(); |
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2703 #endif |
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2704 |
3246 | 2705 #ifdef FEAT_PERSISTENT_UNDO |
2706 /* 'undofile' */ | |
2707 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) | |
2708 { | |
3894 | 2709 /* Only take action when the option was set. When reset we do not |
2710 * delete the undo file, the option may be set again without making | |
2711 * any changes in between. */ | |
2712 if (curbuf->b_p_udf || p_udf) | |
2713 { | |
2714 char_u hash[UNDO_HASH_SIZE]; | |
2715 buf_T *save_curbuf = curbuf; | |
2716 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
2717 FOR_ALL_BUFFERS(curbuf) |
3894 | 2718 { |
2719 /* When 'undofile' is set globally: for every buffer, otherwise | |
2720 * only for the current buffer: Try to read in the undofile, | |
2721 * if one exists, the buffer wasn't changed and the buffer was | |
2722 * loaded */ | |
2723 if ((curbuf == save_curbuf | |
3246 | 2724 || (opt_flags & OPT_GLOBAL) || opt_flags == 0) |
3894 | 2725 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) |
2726 { | |
2727 u_compute_hash(hash); | |
2728 u_read_undo(NULL, hash, curbuf->b_fname); | |
2729 } | |
2730 } | |
2731 curbuf = save_curbuf; | |
2732 } | |
3246 | 2733 } |
2734 #endif | |
2735 | |
7 | 2736 else if ((int *)varp == &curbuf->b_p_ro) |
2737 { | |
548 | 2738 /* when 'readonly' is reset globally, also reset readonlymode */ |
7 | 2739 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) |
2740 readonlymode = FALSE; | |
548 | 2741 |
2742 /* when 'readonly' is set may give W10 again */ | |
2743 if (curbuf->b_p_ro) | |
2744 curbuf->b_did_warn = FALSE; | |
2745 | |
7 | 2746 #ifdef FEAT_TITLE |
1805 | 2747 redraw_titles(); |
7 | 2748 #endif |
2749 } | |
2750 | |
2362
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2751 #ifdef FEAT_GUI |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2752 else if ((int *)varp == &p_mh) |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2753 { |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2754 if (!p_mh) |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2755 gui_mch_mousehide(FALSE); |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2756 } |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2757 #endif |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2758 |
7 | 2759 /* when 'modifiable' is changed, redraw the window title */ |
2760 else if ((int *)varp == &curbuf->b_p_ma) | |
1805 | 2761 { |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2762 # ifdef FEAT_TERMINAL |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2763 /* Cannot set 'modifiable' when in Terminal mode. */ |
13429
1bb09ac80ef6
patch 8.0.1589: error for setting 'modifiable' when resetting it
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2764 if (curbuf->b_p_ma && (term_in_normal_mode() || (bt_terminal(curbuf) |
1bb09ac80ef6
patch 8.0.1589: error for setting 'modifiable' when resetting it
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
2765 && curbuf->b_term != NULL && !term_is_finished(curbuf)))) |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2766 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2767 curbuf->b_p_ma = FALSE; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2768 return N_("E946: Cannot make a terminal with running job modifiable"); |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2769 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2770 # endif |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2771 # ifdef FEAT_TITLE |
1805 | 2772 redraw_titles(); |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2773 # endif |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2774 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2775 #ifdef FEAT_TITLE |
7 | 2776 /* when 'endofline' is changed, redraw the window title */ |
2777 else if ((int *)varp == &curbuf->b_p_eol) | |
1805 | 2778 { |
2779 redraw_titles(); | |
2780 } | |
6933 | 2781 /* when 'fixeol' is changed, redraw the window title */ |
2782 else if ((int *)varp == &curbuf->b_p_fixeol) | |
2783 { | |
2784 redraw_titles(); | |
2785 } | |
1805 | 2786 /* when 'bomb' is changed, redraw the window title and tab page text */ |
1352 | 2787 else if ((int *)varp == &curbuf->b_p_bomb) |
1805 | 2788 { |
2789 redraw_titles(); | |
2790 } | |
7 | 2791 #endif |
2792 | |
2793 /* when 'bin' is set also set some other options */ | |
2794 else if ((int *)varp == &curbuf->b_p_bin) | |
2795 { | |
2796 set_options_bin(old_value, curbuf->b_p_bin, opt_flags); | |
2797 #ifdef FEAT_TITLE | |
1805 | 2798 redraw_titles(); |
7 | 2799 #endif |
2800 } | |
2801 | |
2802 /* when 'buflisted' changes, trigger autocommands */ | |
2803 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) | |
2804 { | |
2805 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, | |
2806 NULL, NULL, TRUE, curbuf); | |
2807 } | |
2808 | |
2809 /* when 'swf' is set, create swapfile, when reset remove swapfile */ | |
2810 else if ((int *)varp == &curbuf->b_p_swf) | |
2811 { | |
2812 if (curbuf->b_p_swf && p_uc) | |
2813 ml_open_file(curbuf); /* create the swap file */ | |
2814 else | |
1157 | 2815 /* no need to reset curbuf->b_may_swap, ml_open_file() will check |
2816 * buf->b_p_swf */ | |
7 | 2817 mf_close_file(curbuf, TRUE); /* remove the swap file */ |
2818 } | |
2819 | |
2820 /* when 'terse' is set change 'shortmess' */ | |
2821 else if ((int *)varp == &p_terse) | |
2822 { | |
2823 char_u *p; | |
2824 | |
2825 p = vim_strchr(p_shm, SHM_SEARCH); | |
2826 | |
2827 /* insert 's' in p_shm */ | |
2828 if (p_terse && p == NULL) | |
2829 { | |
2830 STRCPY(IObuff, p_shm); | |
2831 STRCAT(IObuff, "s"); | |
694 | 2832 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); |
7 | 2833 } |
2834 /* remove 's' from p_shm */ | |
2835 else if (!p_terse && p != NULL) | |
1622 | 2836 STRMOVE(p, p + 1); |
7 | 2837 } |
2838 | |
2839 /* when 'paste' is set or reset also change other options */ | |
2840 else if ((int *)varp == &p_paste) | |
2841 { | |
2842 paste_option_changed(); | |
2843 } | |
2844 | |
2845 /* when 'insertmode' is set from an autocommand need to do work here */ | |
2846 else if ((int *)varp == &p_im) | |
2847 { | |
2848 if (p_im) | |
2849 { | |
2850 if ((State & INSERT) == 0) | |
2851 need_start_insertmode = TRUE; | |
2852 stop_insert_mode = FALSE; | |
2853 } | |
9359
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
9228
diff
changeset
|
2854 /* only reset if it was set previously */ |
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
9228
diff
changeset
|
2855 else if (old_value) |
7 | 2856 { |
2857 need_start_insertmode = FALSE; | |
2858 stop_insert_mode = TRUE; | |
644 | 2859 if (restart_edit != 0 && mode_displayed) |
7 | 2860 clear_cmdline = TRUE; /* remove "(insert)" */ |
2861 restart_edit = 0; | |
2862 } | |
2863 } | |
2864 | |
2865 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */ | |
2866 else if ((int *)varp == &p_ic && p_hls) | |
2867 { | |
744 | 2868 redraw_all_later(SOME_VALID); |
7 | 2869 } |
2870 | |
2871 #ifdef FEAT_SEARCH_EXTRA | |
2872 /* when 'hlsearch' is set or reset: reset no_hlsearch */ | |
2873 else if ((int *)varp == &p_hls) | |
2874 { | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13774
diff
changeset
|
2875 set_no_hlsearch(FALSE); |
7 | 2876 } |
2877 #endif | |
2878 | |
2879 /* when 'scrollbind' is set: snapshot the current position to avoid a jump | |
2880 * at the end of normal_cmd() */ | |
2881 else if ((int *)varp == &curwin->w_p_scb) | |
2882 { | |
2883 if (curwin->w_p_scb) | |
5157
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2884 { |
7 | 2885 do_check_scrollbind(FALSE); |
5157
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2886 curwin->w_scbind_pos = curwin->w_topline; |
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2887 } |
7 | 2888 } |
2889 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
2890 #if defined(FEAT_QUICKFIX) |
7 | 2891 /* There can be only one window with 'previewwindow' set. */ |
2892 else if ((int *)varp == &curwin->w_p_pvw) | |
2893 { | |
2894 if (curwin->w_p_pvw) | |
2895 { | |
2896 win_T *win; | |
2897 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
2898 FOR_ALL_WINDOWS(win) |
7 | 2899 if (win->w_p_pvw && win != curwin) |
2900 { | |
2901 curwin->w_p_pvw = FALSE; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2902 return N_("E590: A preview window already exists"); |
7 | 2903 } |
2904 } | |
2905 } | |
2906 #endif | |
2907 | |
2908 /* when 'textmode' is set or reset also change 'fileformat' */ | |
2909 else if ((int *)varp == &curbuf->b_p_tx) | |
2910 { | |
2911 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); | |
2912 } | |
2913 | |
2914 /* when 'textauto' is set or reset also change 'fileformats' */ | |
2915 else if ((int *)varp == &p_ta) | |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
16082
diff
changeset
|
2916 { |
7 | 2917 set_string_option_direct((char_u *)"ffs", -1, |
2918 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", | |
694 | 2919 OPT_FREE | opt_flags, 0); |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
16082
diff
changeset
|
2920 } |
7 | 2921 |
2922 /* | |
2923 * When 'lisp' option changes include/exclude '-' in | |
2924 * keyword characters. | |
2925 */ | |
2926 #ifdef FEAT_LISP | |
2927 else if (varp == (char_u *)&(curbuf->b_p_lisp)) | |
2928 { | |
2929 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */ | |
2930 } | |
2931 #endif | |
2932 | |
2933 #ifdef FEAT_TITLE | |
2934 /* when 'title' changed, may need to change the title; same for 'icon' */ | |
14087
1d25a3e8e03c
patch 8.1.0061: window title is wrong after resetting and setting 'title'
Christian Brabandt <cb@256bit.org>
parents:
14057
diff
changeset
|
2935 else if ((int *)varp == &p_title || (int *)varp == &p_icon) |
1d25a3e8e03c
patch 8.1.0061: window title is wrong after resetting and setting 'title'
Christian Brabandt <cb@256bit.org>
parents:
14057
diff
changeset
|
2936 { |
1d25a3e8e03c
patch 8.1.0061: window title is wrong after resetting and setting 'title'
Christian Brabandt <cb@256bit.org>
parents:
14057
diff
changeset
|
2937 did_set_title(); |
7 | 2938 } |
2939 #endif | |
2940 | |
2941 else if ((int *)varp == &curbuf->b_changed) | |
2942 { | |
2943 if (!value) | |
2944 save_file_ff(curbuf); /* Buffer is unchanged */ | |
2945 #ifdef FEAT_TITLE | |
1805 | 2946 redraw_titles(); |
7 | 2947 #endif |
2948 modified_was_set = value; | |
2949 } | |
2950 | |
2951 #ifdef BACKSLASH_IN_FILENAME | |
2952 else if ((int *)varp == &p_ssl) | |
2953 { | |
2954 if (p_ssl) | |
2955 { | |
2956 psepc = '/'; | |
2957 psepcN = '\\'; | |
2958 pseps[0] = '/'; | |
2959 } | |
2960 else | |
2961 { | |
2962 psepc = '\\'; | |
2963 psepcN = '/'; | |
2964 pseps[0] = '\\'; | |
2965 } | |
2966 | |
2967 /* need to adjust the file name arguments and buffer names. */ | |
2968 buflist_slash_adjust(); | |
2969 alist_slash_adjust(); | |
2970 # ifdef FEAT_EVAL | |
2971 scriptnames_slash_adjust(); | |
2972 # endif | |
2973 } | |
2974 #endif | |
2975 | |
2976 /* If 'wrap' is set, set w_leftcol to zero. */ | |
2977 else if ((int *)varp == &curwin->w_p_wrap) | |
2978 { | |
2979 if (curwin->w_p_wrap) | |
2980 curwin->w_leftcol = 0; | |
2981 } | |
2982 | |
2983 else if ((int *)varp == &p_ea) | |
2984 { | |
2985 if (p_ea && !old_value) | |
2986 win_equal(curwin, FALSE, 0); | |
2987 } | |
2988 | |
2989 else if ((int *)varp == &p_wiv) | |
2990 { | |
2991 /* | |
2992 * When 'weirdinvert' changed, set/reset 't_xs'. | |
2993 * Then set 'weirdinvert' according to value of 't_xs'. | |
2994 */ | |
2995 if (p_wiv && !old_value) | |
2996 T_XS = (char_u *)"y"; | |
2997 else if (!p_wiv && old_value) | |
2998 T_XS = empty_option; | |
2999 p_wiv = (*T_XS != NUL); | |
3000 } | |
3001 | |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
3002 #ifdef FEAT_BEVAL_GUI |
7 | 3003 else if ((int *)varp == &p_beval) |
3004 { | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3005 if (!balloonEvalForTerm) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3006 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3007 if (p_beval && !old_value) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3008 gui_mch_enable_beval_area(balloonEval); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3009 else if (!p_beval && old_value) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3010 gui_mch_disable_beval_area(balloonEval); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3011 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3012 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3013 #endif |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
3014 #ifdef FEAT_BEVAL_TERM |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3015 else if ((int *)varp == &p_bevalterm) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3016 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3017 mch_bevalterm_changed(); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3018 } |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
3019 #endif |
820 | 3020 |
3021 #ifdef FEAT_AUTOCHDIR | |
7 | 3022 else if ((int *)varp == &p_acd) |
3023 { | |
961 | 3024 /* Change directories when the 'acd' option is set now. */ |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
3025 DO_AUTOCHDIR; |
7 | 3026 } |
3027 #endif | |
3028 | |
3029 #ifdef FEAT_DIFF | |
3030 /* 'diff' */ | |
3031 else if ((int *)varp == &curwin->w_p_diff) | |
3032 { | |
16 | 3033 /* May add or remove the buffer from the list of diff buffers. */ |
3034 diff_buf_adjust(curwin); | |
3035 # ifdef FEAT_FOLDING | |
7 | 3036 if (foldmethodIsDiff(curwin)) |
3037 foldUpdateAll(curwin); | |
16 | 3038 # endif |
7 | 3039 } |
3040 #endif | |
3041 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3042 #ifdef HAVE_INPUT_METHOD |
7 | 3043 /* 'imdisable' */ |
3044 else if ((int *)varp == &p_imdisable) | |
3045 { | |
3046 /* Only de-activate it here, it will be enabled when changing mode. */ | |
3047 if (p_imdisable) | |
3048 im_set_active(FALSE); | |
3129 | 3049 else if (State & INSERT) |
3050 /* When the option is set from an autocommand, it may need to take | |
3051 * effect right away. */ | |
3052 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); | |
7 | 3053 } |
3054 #endif | |
3055 | |
744 | 3056 #ifdef FEAT_SPELL |
258 | 3057 /* 'spell' */ |
3058 else if ((int *)varp == &curwin->w_p_spell) | |
3059 { | |
3060 if (curwin->w_p_spell) | |
3061 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3062 char *errmsg = did_set_spelllang(curwin); |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3063 |
258 | 3064 if (errmsg != NULL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3065 emsg(_(errmsg)); |
258 | 3066 } |
3067 } | |
3068 #endif | |
3069 | |
7 | 3070 #ifdef FEAT_ARABIC |
3071 if ((int *)varp == &curwin->w_p_arab) | |
3072 { | |
3073 if (curwin->w_p_arab) | |
3074 { | |
3075 /* | |
3076 * 'arabic' is set, handle various sub-settings. | |
3077 */ | |
3078 if (!p_tbidi) | |
3079 { | |
3080 /* set rightleft mode */ | |
3081 if (!curwin->w_p_rl) | |
3082 { | |
3083 curwin->w_p_rl = TRUE; | |
3084 changed_window_setting(); | |
3085 } | |
3086 | |
3087 /* Enable Arabic shaping (major part of what Arabic requires) */ | |
3088 if (!p_arshape) | |
3089 { | |
3090 p_arshape = TRUE; | |
3091 redraw_later_clear(); | |
3092 } | |
3093 } | |
3094 | |
3095 /* Arabic requires a utf-8 encoding, inform the user if its not | |
3096 * set. */ | |
3097 if (STRCMP(p_enc, "utf-8") != 0) | |
16 | 3098 { |
1848 | 3099 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); |
3100 | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
3101 msg_source(HL_ATTR(HLF_W)); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
3102 msg_attr(_(w_arabic), HL_ATTR(HLF_W)); |
1848 | 3103 #ifdef FEAT_EVAL |
3104 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); | |
3105 #endif | |
16 | 3106 } |
7 | 3107 |
3108 /* set 'delcombine' */ | |
3109 p_deco = TRUE; | |
3110 | |
3111 # ifdef FEAT_KEYMAP | |
3112 /* Force-set the necessary keymap for arabic */ | |
3113 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", | |
3114 OPT_LOCAL); | |
3115 # endif | |
3116 } | |
3117 else | |
3118 { | |
3119 /* | |
3120 * 'arabic' is reset, handle various sub-settings. | |
3121 */ | |
3122 if (!p_tbidi) | |
3123 { | |
3124 /* reset rightleft mode */ | |
3125 if (curwin->w_p_rl) | |
3126 { | |
3127 curwin->w_p_rl = FALSE; | |
3128 changed_window_setting(); | |
3129 } | |
3130 | |
3131 /* 'arabicshape' isn't reset, it is a global option and | |
3132 * another window may still need it "on". */ | |
3133 } | |
3134 | |
3135 /* 'delcombine' isn't reset, it is a global option and another | |
3136 * window may still want it "on". */ | |
3137 | |
3138 # ifdef FEAT_KEYMAP | |
3139 /* Revert to the default keymap */ | |
3140 curbuf->b_p_iminsert = B_IMODE_NONE; | |
3141 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; | |
3142 # endif | |
3143 } | |
3443 | 3144 } |
3145 | |
1958 | 3146 #endif |
3147 | |
17827
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3148 #if defined(FEAT_SIGNS) && defined(FEAT_GUI) |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3149 else if (((int *)varp == &curwin->w_p_nu |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3150 || (int *)varp == &curwin->w_p_rnu) |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3151 && gui.in_use |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3152 && (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) == 'u') |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3153 && curbuf->b_signlist != NULL) |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3154 { |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3155 // If the 'number' or 'relativenumber' options are modified and |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3156 // 'signcolumn' is set to 'number', then clear the screen for a full |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3157 // refresh. Otherwise the sign icons are not displayed properly in the |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3158 // number column. If the 'number' option is set and only the |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3159 // 'relativenumber' option is toggled, then don't refresh the screen |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3160 // (optimization). |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3161 if (!(curwin->w_p_nu && ((int *)varp == &curwin->w_p_rnu))) |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3162 redraw_all_later(CLEAR); |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3163 } |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3164 #endif |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3165 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3166 #ifdef FEAT_TERMGUICOLORS |
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3167 /* 'termguicolors' */ |
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3168 else if ((int *)varp == &p_tgc) |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3169 { |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3170 # ifdef FEAT_VTP |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3171 /* Do not turn on 'tgc' when 24-bit colors are not supported. */ |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
3172 if ( |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
3173 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
3174 !gui.in_use && !gui.starting && |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
3175 # endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
3176 !has_vtp_working()) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3177 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3178 p_tgc = 0; |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
3179 return N_("E954: 24-bit colors are not supported on this environment"); |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3180 } |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3181 if (is_term_win32()) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3182 swap_tcap(); |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3183 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3184 # ifdef FEAT_GUI |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3185 if (!gui.in_use && !gui.starting) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3186 # endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3187 highlight_gui_started(); |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3188 # ifdef FEAT_VTP |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3189 /* reset t_Co */ |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3190 if (is_term_win32()) |
14212
2bebc49116fd
patch 8.1.0123: MS-Windows: colors are wrong after setting 'notgc'
Christian Brabandt <cb@256bit.org>
parents:
14194
diff
changeset
|
3191 { |
2bebc49116fd
patch 8.1.0123: MS-Windows: colors are wrong after setting 'notgc'
Christian Brabandt <cb@256bit.org>
parents:
14194
diff
changeset
|
3192 control_console_color_rgb(); |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3193 set_termname(T_NAME); |
14212
2bebc49116fd
patch 8.1.0123: MS-Windows: colors are wrong after setting 'notgc'
Christian Brabandt <cb@256bit.org>
parents:
14194
diff
changeset
|
3194 init_highlight(TRUE, FALSE); |
2bebc49116fd
patch 8.1.0123: MS-Windows: colors are wrong after setting 'notgc'
Christian Brabandt <cb@256bit.org>
parents:
14194
diff
changeset
|
3195 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3196 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3197 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3198 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3199 |
7 | 3200 /* |
3201 * End of handling side effects for bool options. | |
3202 */ | |
3203 | |
6935 | 3204 /* after handling side effects, call autocommand */ |
3205 | |
7 | 3206 options[opt_idx].flags |= P_WAS_SET; |
3207 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3208 #if defined(FEAT_EVAL) |
14804
cca823b02a04
patch 8.1.0414: v:option_old is cleared when using :set in OptionSet autocmd
Christian Brabandt <cb@256bit.org>
parents:
14748
diff
changeset
|
3209 // Don't do this while starting up or recursively. |
cca823b02a04
patch 8.1.0414: v:option_old is cleared when using :set in OptionSet autocmd
Christian Brabandt <cb@256bit.org>
parents:
14748
diff
changeset
|
3210 if (!starting && *get_vim_var_str(VV_OPTION_TYPE) == NUL) |
6935 | 3211 { |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3212 char_u buf_old[2], buf_old_global[2], buf_new[2], buf_type[7]; |
14804
cca823b02a04
patch 8.1.0414: v:option_old is cleared when using :set in OptionSet autocmd
Christian Brabandt <cb@256bit.org>
parents:
14748
diff
changeset
|
3213 |
6937 | 3214 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE); |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3215 vim_snprintf((char *)buf_old_global, 2, "%d", |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3216 old_global_value ? TRUE: FALSE); |
6937 | 3217 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE); |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3218 vim_snprintf((char *)buf_type, 7, "%s", |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3219 (opt_flags & OPT_LOCAL) ? "local" : "global"); |
6935 | 3220 set_vim_var_string(VV_OPTION_NEW, buf_new, -1); |
3221 set_vim_var_string(VV_OPTION_OLD, buf_old, -1); | |
3222 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); | |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3223 if (opt_flags & OPT_LOCAL) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3224 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3225 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3226 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3227 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3228 if (opt_flags & OPT_GLOBAL) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3229 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3230 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3231 set_vim_var_string(VV_OPTION_OLDGLOBAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3232 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3233 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3234 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3235 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3236 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3237 set_vim_var_string(VV_OPTION_OLDGLOBAL, buf_old_global, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3238 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3239 if (opt_flags & OPT_MODELINE) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3240 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3241 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3242 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3243 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3244 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3245 NULL, FALSE, NULL); |
6935 | 3246 reset_v_option_vars(); |
3247 } | |
3248 #endif | |
3249 | |
7 | 3250 comp_col(); /* in case 'ruler' or 'showcmd' changed */ |
3443 | 3251 if (curwin->w_curswant != MAXCOL |
6669 | 3252 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 3253 curwin->w_set_curswant = TRUE; |
7 | 3254 check_redraw(options[opt_idx].flags); |
3255 | |
3256 return NULL; | |
3257 } | |
3258 | |
3259 /* | |
3260 * Set the value of a number option, and take care of side effects. | |
3261 * Returns NULL for success, or an error message for an error. | |
3262 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3263 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3264 set_num_option( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3265 int opt_idx, /* index in options[] table */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3266 char_u *varp, /* pointer to the option variable */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3267 long value, /* new value */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3268 char *errbuf, /* buffer for error messages */ |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3269 size_t errbuflen, /* length of "errbuf" */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3270 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and |
7 | 3271 OPT_MODELINE */ |
3272 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3273 char *errmsg = NULL; |
7 | 3274 long old_value = *(long *)varp; |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3275 #if defined(FEAT_EVAL) |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3276 long old_global_value = 0; // only used when setting a local and |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3277 // global option |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3278 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3279 long old_Rows = Rows; // remember old Rows |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3280 long old_Columns = Columns; // remember old Columns |
7 | 3281 long *pp = (long *)varp; |
3282 | |
634 | 3283 /* Disallow changing some options from secure mode. */ |
3284 if ((secure | |
3285 #ifdef HAVE_SANDBOX | |
3286 || sandbox != 0 | |
3287 #endif | |
3288 ) && (options[opt_idx].flags & P_SECURE)) | |
3289 return e_secure; | |
7 | 3290 |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3291 #if defined(FEAT_EVAL) |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3292 // Save the global value before changing anything. This is needed as for |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3293 // a global-only option setting the "local value" infact sets the global |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3294 // value (since there is only one value). |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3295 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3296 old_global_value = *(long *)get_varp_scope(&(options[opt_idx]), |
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3297 OPT_GLOBAL); |
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3298 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3299 |
7 | 3300 *pp = value; |
3301 #ifdef FEAT_EVAL | |
3302 /* Remember where the option was set. */ | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3303 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 3304 #endif |
634 | 3305 #ifdef FEAT_GUI |
3306 need_mouse_correct = TRUE; | |
3307 #endif | |
7 | 3308 |
3740 | 3309 if (curbuf->b_p_sw < 0) |
7 | 3310 { |
3311 errmsg = e_positive; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3312 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3313 // Use the first 'vartabstop' value, or 'tabstop' if vts isn't in use. |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3314 curbuf->b_p_sw = tabstop_count(curbuf->b_p_vts_array) > 0 |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3315 ? tabstop_first(curbuf->b_p_vts_array) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3316 : curbuf->b_p_ts; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3317 #else |
7 | 3318 curbuf->b_p_sw = curbuf->b_p_ts; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3319 #endif |
7 | 3320 } |
3321 | |
3322 /* | |
3323 * Number options that need some action when changed | |
3324 */ | |
3325 if (pp == &p_wh || pp == &p_hh) | |
3326 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3327 // 'winheight' and 'helpheight' |
7 | 3328 if (p_wh < 1) |
3329 { | |
3330 errmsg = e_positive; | |
3331 p_wh = 1; | |
3332 } | |
3333 if (p_wmh > p_wh) | |
3334 { | |
3335 errmsg = e_winheight; | |
3336 p_wh = p_wmh; | |
3337 } | |
3338 if (p_hh < 0) | |
3339 { | |
3340 errmsg = e_positive; | |
3341 p_hh = 0; | |
3342 } | |
3343 | |
3344 /* Change window height NOW */ | |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10340
diff
changeset
|
3345 if (!ONE_WINDOW) |
7 | 3346 { |
3347 if (pp == &p_wh && curwin->w_height < p_wh) | |
3348 win_setheight((int)p_wh); | |
3349 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) | |
3350 win_setheight((int)p_hh); | |
3351 } | |
3352 } | |
3353 else if (pp == &p_wmh) | |
3354 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3355 // 'winminheight' |
7 | 3356 if (p_wmh < 0) |
3357 { | |
3358 errmsg = e_positive; | |
3359 p_wmh = 0; | |
3360 } | |
3361 if (p_wmh > p_wh) | |
3362 { | |
3363 errmsg = e_winheight; | |
3364 p_wmh = p_wh; | |
3365 } | |
3366 win_setminheight(); | |
3367 } | |
13 | 3368 else if (pp == &p_wiw) |
7 | 3369 { |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3370 // 'winwidth' |
7 | 3371 if (p_wiw < 1) |
3372 { | |
3373 errmsg = e_positive; | |
3374 p_wiw = 1; | |
3375 } | |
3376 if (p_wmw > p_wiw) | |
3377 { | |
3378 errmsg = e_winwidth; | |
3379 p_wiw = p_wmw; | |
3380 } | |
3381 | |
3382 /* Change window width NOW */ | |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10340
diff
changeset
|
3383 if (!ONE_WINDOW && curwin->w_width < p_wiw) |
7 | 3384 win_setwidth((int)p_wiw); |
3385 } | |
3386 else if (pp == &p_wmw) | |
3387 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3388 // 'winminwidth' |
7 | 3389 if (p_wmw < 0) |
3390 { | |
3391 errmsg = e_positive; | |
3392 p_wmw = 0; | |
3393 } | |
3394 if (p_wmw > p_wiw) | |
3395 { | |
3396 errmsg = e_winwidth; | |
3397 p_wmw = p_wiw; | |
3398 } | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3399 win_setminwidth(); |
7 | 3400 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
3401 |
7 | 3402 /* (re)set last window status line */ |
3403 else if (pp == &p_ls) | |
3404 { | |
3405 last_status(FALSE); | |
3406 } | |
670 | 3407 |
3408 /* (re)set tab page line */ | |
677 | 3409 else if (pp == &p_stal) |
670 | 3410 { |
3411 shell_new_rows(); /* recompute window positions and heights */ | |
3412 } | |
7 | 3413 |
3414 #ifdef FEAT_GUI | |
3415 else if (pp == &p_linespace) | |
3416 { | |
444 | 3417 /* Recompute gui.char_height and resize the Vim window to keep the |
3418 * same number of lines. */ | |
3419 if (gui.in_use && gui_mch_adjust_charheight() == OK) | |
813 | 3420 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); |
7 | 3421 } |
3422 #endif | |
3423 | |
3424 #ifdef FEAT_FOLDING | |
3425 /* 'foldlevel' */ | |
3426 else if (pp == &curwin->w_p_fdl) | |
3427 { | |
3428 if (curwin->w_p_fdl < 0) | |
3429 curwin->w_p_fdl = 0; | |
3430 newFoldLevel(); | |
3431 } | |
3432 | |
1805 | 3433 /* 'foldminlines' */ |
7 | 3434 else if (pp == &curwin->w_p_fml) |
3435 { | |
3436 foldUpdateAll(curwin); | |
3437 } | |
3438 | |
3439 /* 'foldnestmax' */ | |
3440 else if (pp == &curwin->w_p_fdn) | |
3441 { | |
3442 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) | |
3443 foldUpdateAll(curwin); | |
3444 } | |
3445 | |
3446 /* 'foldcolumn' */ | |
3447 else if (pp == &curwin->w_p_fdc) | |
3448 { | |
3449 if (curwin->w_p_fdc < 0) | |
3450 { | |
3451 errmsg = e_positive; | |
3452 curwin->w_p_fdc = 0; | |
3453 } | |
3454 else if (curwin->w_p_fdc > 12) | |
3455 { | |
3456 errmsg = e_invarg; | |
3457 curwin->w_p_fdc = 12; | |
3458 } | |
3459 } | |
5438 | 3460 #endif /* FEAT_FOLDING */ |
3461 | |
3462 #if defined(FEAT_FOLDING) || defined(FEAT_CINDENT) | |
7 | 3463 /* 'shiftwidth' or 'tabstop' */ |
3464 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) | |
3465 { | |
5438 | 3466 # ifdef FEAT_FOLDING |
7 | 3467 if (foldmethodIsIndent(curwin)) |
3468 foldUpdateAll(curwin); | |
5438 | 3469 # endif |
3470 # ifdef FEAT_CINDENT | |
3471 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes: | |
3472 * parse 'cinoptions'. */ | |
3473 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) | |
3474 parse_cino(curbuf); | |
3475 # endif | |
3476 } | |
3477 #endif | |
7 | 3478 |
714 | 3479 /* 'maxcombine' */ |
3480 else if (pp == &p_mco) | |
3481 { | |
3482 if (p_mco > MAX_MCO) | |
3483 p_mco = MAX_MCO; | |
3484 else if (p_mco < 0) | |
3485 p_mco = 0; | |
3486 screenclear(); /* will re-allocate the screen */ | |
3487 } | |
3488 | |
7 | 3489 else if (pp == &curbuf->b_p_iminsert) |
3490 { | |
3491 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) | |
3492 { | |
3493 errmsg = e_invarg; | |
3494 curbuf->b_p_iminsert = B_IMODE_NONE; | |
3495 } | |
3496 p_iminsert = curbuf->b_p_iminsert; | |
3497 if (termcap_active) /* don't do this in the alternate screen */ | |
3498 showmode(); | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
3499 #if defined(FEAT_KEYMAP) |
7 | 3500 /* Show/unshow value of 'keymap' in status lines. */ |
3501 status_redraw_curbuf(); | |
3502 #endif | |
3503 } | |
3504 | |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3505 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3506 /* 'imstyle' */ |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3507 else if (pp == &p_imst) |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3508 { |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3509 if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT) |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3510 errmsg = e_invarg; |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3511 } |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3512 #endif |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3513 |
164 | 3514 else if (pp == &p_window) |
3515 { | |
3516 if (p_window < 1) | |
3517 p_window = 1; | |
3518 else if (p_window >= Rows) | |
3519 p_window = Rows - 1; | |
3520 } | |
3521 | |
7 | 3522 else if (pp == &curbuf->b_p_imsearch) |
3523 { | |
3524 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) | |
3525 { | |
3526 errmsg = e_invarg; | |
3527 curbuf->b_p_imsearch = B_IMODE_NONE; | |
3528 } | |
3529 p_imsearch = curbuf->b_p_imsearch; | |
3530 } | |
3531 | |
3532 #ifdef FEAT_TITLE | |
3533 /* if 'titlelen' has changed, redraw the title */ | |
3534 else if (pp == &p_titlelen) | |
3535 { | |
3536 if (p_titlelen < 0) | |
3537 { | |
3538 errmsg = e_positive; | |
3539 p_titlelen = 85; | |
3540 } | |
3541 if (starting != NO_SCREEN && old_value != p_titlelen) | |
3542 need_maketitle = TRUE; | |
3543 } | |
3544 #endif | |
3545 | |
3546 /* if p_ch changed value, change the command line height */ | |
3547 else if (pp == &p_ch) | |
3548 { | |
3549 if (p_ch < 1) | |
3550 { | |
3551 errmsg = e_positive; | |
3552 p_ch = 1; | |
3553 } | |
1404 | 3554 if (p_ch > Rows - min_rows() + 1) |
3555 p_ch = Rows - min_rows() + 1; | |
7 | 3556 |
3557 /* Only compute the new window layout when startup has been | |
3558 * completed. Otherwise the frame sizes may be wrong. */ | |
3559 if (p_ch != old_value && full_screen | |
3560 #ifdef FEAT_GUI | |
3561 && !gui.starting | |
3562 #endif | |
3563 ) | |
824 | 3564 command_height(); |
7 | 3565 } |
3566 | |
3567 /* when 'updatecount' changes from zero to non-zero, open swap files */ | |
3568 else if (pp == &p_uc) | |
3569 { | |
3570 if (p_uc < 0) | |
3571 { | |
3572 errmsg = e_positive; | |
3573 p_uc = 100; | |
3574 } | |
3575 if (p_uc && !old_value) | |
3576 ml_open_files(); | |
3577 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3578 #ifdef FEAT_CONCEAL |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3579 else if (pp == &curwin->w_p_cole) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3580 { |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3581 if (curwin->w_p_cole < 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3582 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3583 errmsg = e_positive; |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3584 curwin->w_p_cole = 0; |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3585 } |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3586 else if (curwin->w_p_cole > 3) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3587 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3588 errmsg = e_invarg; |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3589 curwin->w_p_cole = 3; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3590 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3591 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3592 #endif |
16 | 3593 #ifdef MZSCHEME_GUI_THREADS |
14 | 3594 else if (pp == &p_mzq) |
3595 mzvim_reset_timer(); | |
3596 #endif | |
7 | 3597 |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3598 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3599 /* 'pyxversion' */ |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3600 else if (pp == &p_pyx) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3601 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3602 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3603 errmsg = e_invarg; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3604 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3605 #endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3606 |
7 | 3607 /* sync undo before 'undolevels' changes */ |
3608 else if (pp == &p_ul) | |
3609 { | |
3610 /* use the old value, otherwise u_sync() may not work properly */ | |
3611 p_ul = old_value; | |
825 | 3612 u_sync(TRUE); |
7 | 3613 p_ul = value; |
3614 } | |
5446 | 3615 else if (pp == &curbuf->b_p_ul) |
3616 { | |
3617 /* use the old value, otherwise u_sync() may not work properly */ | |
3618 curbuf->b_p_ul = old_value; | |
3619 u_sync(TRUE); | |
3620 curbuf->b_p_ul = value; | |
3621 } | |
7 | 3622 |
13 | 3623 #ifdef FEAT_LINEBREAK |
3624 /* 'numberwidth' must be positive */ | |
3625 else if (pp == &curwin->w_p_nuw) | |
3626 { | |
3627 if (curwin->w_p_nuw < 1) | |
3628 { | |
3629 errmsg = e_positive; | |
3630 curwin->w_p_nuw = 1; | |
3631 } | |
17229
f1c7b7a4d9e4
patch 8.1.1614: 'numberwidth' can only go up to 10
Bram Moolenaar <Bram@vim.org>
parents:
17176
diff
changeset
|
3632 if (curwin->w_p_nuw > 20) |
13 | 3633 { |
3634 errmsg = e_invarg; | |
17229
f1c7b7a4d9e4
patch 8.1.1614: 'numberwidth' can only go up to 10
Bram Moolenaar <Bram@vim.org>
parents:
17176
diff
changeset
|
3635 curwin->w_p_nuw = 20; |
13 | 3636 } |
6727 | 3637 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */ |
13 | 3638 } |
3639 #endif | |
3640 | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3641 else if (pp == &curbuf->b_p_tw) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3642 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3643 if (curbuf->b_p_tw < 0) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3644 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3645 errmsg = e_positive; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3646 curbuf->b_p_tw = 0; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3647 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3648 #ifdef FEAT_SYN_HL |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3649 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3650 win_T *wp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3651 tabpage_T *tp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3652 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3653 FOR_ALL_TAB_WINDOWS(tp, wp) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3654 check_colorcolumn(wp); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3655 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3656 #endif |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3657 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3658 |
7 | 3659 /* |
3660 * Check the bounds for numeric options here | |
3661 */ | |
3662 if (Rows < min_rows() && full_screen) | |
3663 { | |
3664 if (errbuf != NULL) | |
3665 { | |
274 | 3666 vim_snprintf((char *)errbuf, errbuflen, |
3667 _("E593: Need at least %d lines"), min_rows()); | |
7 | 3668 errmsg = errbuf; |
3669 } | |
3670 Rows = min_rows(); | |
3671 } | |
3672 if (Columns < MIN_COLUMNS && full_screen) | |
3673 { | |
3674 if (errbuf != NULL) | |
3675 { | |
274 | 3676 vim_snprintf((char *)errbuf, errbuflen, |
3677 _("E594: Need at least %d columns"), MIN_COLUMNS); | |
7 | 3678 errmsg = errbuf; |
3679 } | |
3680 Columns = MIN_COLUMNS; | |
3681 } | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
5039
diff
changeset
|
3682 limit_screen_size(); |
7 | 3683 |
3684 /* | |
3685 * If the screen (shell) height has been changed, assume it is the | |
3686 * physical screenheight. | |
3687 */ | |
3688 if (old_Rows != Rows || old_Columns != Columns) | |
3689 { | |
3690 /* Changing the screen size is not allowed while updating the screen. */ | |
3691 if (updating_screen) | |
3692 *pp = old_value; | |
3693 else if (full_screen | |
3694 #ifdef FEAT_GUI | |
3695 && !gui.starting | |
3696 #endif | |
3697 ) | |
3698 set_shellsize((int)Columns, (int)Rows, TRUE); | |
3699 else | |
3700 { | |
3701 /* Postpone the resizing; check the size and cmdline position for | |
3702 * messages. */ | |
3703 check_shellsize(); | |
3704 if (cmdline_row > Rows - p_ch && Rows > p_ch) | |
3705 cmdline_row = Rows - p_ch; | |
3706 } | |
857 | 3707 if (p_window >= Rows || !option_was_set((char_u *)"window")) |
164 | 3708 p_window = Rows - 1; |
7 | 3709 } |
3710 | |
3711 if (curbuf->b_p_ts <= 0) | |
3712 { | |
3713 errmsg = e_positive; | |
3714 curbuf->b_p_ts = 8; | |
3715 } | |
3716 if (p_tm < 0) | |
3717 { | |
3718 errmsg = e_positive; | |
3719 p_tm = 0; | |
3720 } | |
3721 if ((curwin->w_p_scr <= 0 | |
3722 || (curwin->w_p_scr > curwin->w_height | |
3723 && curwin->w_height > 0)) | |
3724 && full_screen) | |
3725 { | |
3726 if (pp == &(curwin->w_p_scr)) | |
3727 { | |
3728 if (curwin->w_p_scr != 0) | |
3729 errmsg = e_scroll; | |
3730 win_comp_scroll(curwin); | |
3731 } | |
3732 /* If 'scroll' became invalid because of a side effect silently adjust | |
3733 * it. */ | |
3734 else if (curwin->w_p_scr <= 0) | |
3735 curwin->w_p_scr = 1; | |
3736 else /* curwin->w_p_scr > curwin->w_height */ | |
3737 curwin->w_p_scr = curwin->w_height; | |
3738 } | |
1726 | 3739 if (p_hi < 0) |
3740 { | |
3741 errmsg = e_positive; | |
3742 p_hi = 0; | |
3743 } | |
5991 | 3744 else if (p_hi > 10000) |
3745 { | |
3746 errmsg = e_invarg; | |
3747 p_hi = 10000; | |
3748 } | |
4444 | 3749 if (p_re < 0 || p_re > 2) |
3750 { | |
3751 errmsg = e_invarg; | |
3752 p_re = 0; | |
3753 } | |
7 | 3754 if (p_report < 0) |
3755 { | |
3756 errmsg = e_positive; | |
3757 p_report = 1; | |
3758 } | |
532 | 3759 if ((p_sj < -100 || p_sj >= Rows) && full_screen) |
7 | 3760 { |
3761 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */ | |
3762 p_sj = Rows / 2; | |
3763 else | |
3764 { | |
3765 errmsg = e_scroll; | |
3766 p_sj = 1; | |
3767 } | |
3768 } | |
3769 if (p_so < 0 && full_screen) | |
3770 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
3771 errmsg = e_positive; |
7 | 3772 p_so = 0; |
3773 } | |
3774 if (p_siso < 0 && full_screen) | |
3775 { | |
3776 errmsg = e_positive; | |
3777 p_siso = 0; | |
3778 } | |
3779 #ifdef FEAT_CMDWIN | |
3780 if (p_cwh < 1) | |
3781 { | |
3782 errmsg = e_positive; | |
3783 p_cwh = 1; | |
3784 } | |
3785 #endif | |
3786 if (p_ut < 0) | |
3787 { | |
3788 errmsg = e_positive; | |
3789 p_ut = 2000; | |
3790 } | |
3791 if (p_ss < 0) | |
3792 { | |
3793 errmsg = e_positive; | |
3794 p_ss = 0; | |
3795 } | |
3796 | |
3797 /* May set global value for local option. */ | |
3798 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) | |
3799 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; | |
3800 | |
3801 options[opt_idx].flags |= P_WAS_SET; | |
3802 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3803 #if defined(FEAT_EVAL) |
14804
cca823b02a04
patch 8.1.0414: v:option_old is cleared when using :set in OptionSet autocmd
Christian Brabandt <cb@256bit.org>
parents:
14748
diff
changeset
|
3804 // Don't do this while starting up, failure or recursively. |
cca823b02a04
patch 8.1.0414: v:option_old is cleared when using :set in OptionSet autocmd
Christian Brabandt <cb@256bit.org>
parents:
14748
diff
changeset
|
3805 if (!starting && errmsg == NULL && *get_vim_var_str(VV_OPTION_TYPE) == NUL) |
6935 | 3806 { |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3807 char_u buf_old[11], buf_old_global[11], buf_new[11], buf_type[7]; |
6937 | 3808 vim_snprintf((char *)buf_old, 10, "%ld", old_value); |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3809 vim_snprintf((char *)buf_old_global, 10, "%ld", old_global_value); |
6937 | 3810 vim_snprintf((char *)buf_new, 10, "%ld", value); |
3811 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); | |
6935 | 3812 set_vim_var_string(VV_OPTION_NEW, buf_new, -1); |
3813 set_vim_var_string(VV_OPTION_OLD, buf_old, -1); | |
3814 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); | |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3815 if (opt_flags & OPT_LOCAL) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3816 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3817 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3818 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3819 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3820 if (opt_flags & OPT_GLOBAL) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3821 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3822 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3823 set_vim_var_string(VV_OPTION_OLDGLOBAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3824 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3825 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3826 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3827 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3828 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3829 set_vim_var_string(VV_OPTION_OLDGLOBAL, buf_old_global, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3830 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3831 if (opt_flags & OPT_MODELINE) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3832 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3833 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3834 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3835 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3836 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3837 NULL, FALSE, NULL); |
6935 | 3838 reset_v_option_vars(); |
3839 } | |
3840 #endif | |
3841 | |
7 | 3842 comp_col(); /* in case 'columns' or 'ls' changed */ |
3443 | 3843 if (curwin->w_curswant != MAXCOL |
6669 | 3844 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 3845 curwin->w_set_curswant = TRUE; |
7 | 3846 check_redraw(options[opt_idx].flags); |
3847 | |
3848 return errmsg; | |
3849 } | |
3850 | |
3851 /* | |
3852 * Called after an option changed: check if something needs to be redrawn. | |
3853 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
3854 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3855 check_redraw(long_u flags) |
7 | 3856 { |
3857 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */ | |
3263 | 3858 int doclear = (flags & P_RCLR) == P_RCLR; |
3859 int all = ((flags & P_RALL) == P_RALL || doclear); | |
7 | 3860 |
3861 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */ | |
3862 status_redraw_all(); | |
3863 | |
3864 if ((flags & P_RBUF) || (flags & P_RWIN) || all) | |
3865 changed_window_setting(); | |
3866 if (flags & P_RBUF) | |
3867 redraw_curbuf_later(NOT_VALID); | |
10456
536a7d49249c
commit https://github.com/vim/vim/commit/a2477fd3490c1166522631eee53c57d34321086a
Christian Brabandt <cb@256bit.org>
parents:
10424
diff
changeset
|
3868 if (flags & P_RWINONLY) |
536a7d49249c
commit https://github.com/vim/vim/commit/a2477fd3490c1166522631eee53c57d34321086a
Christian Brabandt <cb@256bit.org>
parents:
10424
diff
changeset
|
3869 redraw_later(NOT_VALID); |
3263 | 3870 if (doclear) |
7 | 3871 redraw_all_later(CLEAR); |
3872 else if (all) | |
3873 redraw_all_later(NOT_VALID); | |
3874 } | |
3875 | |
3876 /* | |
3877 * Find index for option 'arg'. | |
3878 * Return -1 if not found. | |
3879 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
3880 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3881 findoption(char_u *arg) |
7 | 3882 { |
3883 int opt_idx; | |
3884 char *s, *p; | |
3885 static short quick_tab[27] = {0, 0}; /* quick access table */ | |
3886 int is_term_opt; | |
3887 | |
3888 /* | |
3889 * For first call: Initialize the quick-access table. | |
3890 * It contains the index for the first option that starts with a certain | |
3891 * letter. There are 26 letters, plus the first "t_" option. | |
3892 */ | |
3893 if (quick_tab[1] == 0) | |
3894 { | |
3895 p = options[0].fullname; | |
3896 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
3897 { | |
3898 if (s[0] != p[0]) | |
3899 { | |
3900 if (s[0] == 't' && s[1] == '_') | |
3901 quick_tab[26] = opt_idx; | |
3902 else | |
3903 quick_tab[CharOrdLow(s[0])] = opt_idx; | |
3904 } | |
3905 p = s; | |
3906 } | |
3907 } | |
3908 | |
3909 /* | |
3910 * Check for name starting with an illegal character. | |
3911 */ | |
3912 #ifdef EBCDIC | |
3913 if (!islower(arg[0])) | |
3914 #else | |
3915 if (arg[0] < 'a' || arg[0] > 'z') | |
3916 #endif | |
3917 return -1; | |
3918 | |
3919 is_term_opt = (arg[0] == 't' && arg[1] == '_'); | |
3920 if (is_term_opt) | |
3921 opt_idx = quick_tab[26]; | |
3922 else | |
3923 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
3924 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
3925 { | |
3926 if (STRCMP(arg, s) == 0) /* match full name */ | |
3927 break; | |
3928 } | |
3929 if (s == NULL && !is_term_opt) | |
3930 { | |
3931 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
3932 for ( ; options[opt_idx].fullname != NULL; opt_idx++) | |
3933 { | |
3934 s = options[opt_idx].shortname; | |
3935 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */ | |
3936 break; | |
3937 s = NULL; | |
3938 } | |
3939 } | |
3940 if (s == NULL) | |
3941 opt_idx = -1; | |
3942 return opt_idx; | |
3943 } | |
3944 | |
14 | 3945 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME) |
7 | 3946 /* |
3947 * Get the value for an option. | |
3948 * | |
3949 * Returns: | |
3950 * Number or Toggle option: 1, *numval gets value. | |
3951 * String option: 0, *stringval gets allocated string. | |
3952 * Hidden Number or Toggle option: -1. | |
3953 * hidden String option: -2. | |
3954 * unknown option: -3. | |
3955 */ | |
3956 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3957 get_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3958 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3959 long *numval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3960 char_u **stringval, /* NULL when only checking existence */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3961 int opt_flags) |
7 | 3962 { |
3963 int opt_idx; | |
3964 char_u *varp; | |
3965 | |
3966 opt_idx = findoption(name); | |
3967 if (opt_idx < 0) /* unknown option */ | |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3968 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3969 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3970 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3971 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_' |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
3972 && (key = find_key_option(name, FALSE)) != 0) |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3973 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3974 char_u key_name[2]; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3975 char_u *p; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3976 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3977 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3978 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3979 key_name[0] = KEY2TERMCAP0(key); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3980 key_name[1] = KEY2TERMCAP1(key); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3981 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3982 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3983 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3984 key_name[0] = KS_KEY; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3985 key_name[1] = (key & 0xff); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3986 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3987 p = find_termcode(key_name); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3988 if (p != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3989 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3990 if (stringval != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3991 *stringval = vim_strsave(p); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3992 return 0; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3993 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3994 } |
7 | 3995 return -3; |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3996 } |
7 | 3997 |
3998 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | |
3999 | |
4000 if (options[opt_idx].flags & P_STRING) | |
4001 { | |
4002 if (varp == NULL) /* hidden option */ | |
4003 return -2; | |
4004 if (stringval != NULL) | |
4005 { | |
4006 #ifdef FEAT_CRYPT | |
4007 /* never return the value of the crypt key */ | |
1622 | 4008 if ((char_u **)varp == &curbuf->b_p_key |
4009 && **(char_u **)(varp) != NUL) | |
7 | 4010 *stringval = vim_strsave((char_u *)"*****"); |
4011 else | |
4012 #endif | |
4013 *stringval = vim_strsave(*(char_u **)(varp)); | |
4014 } | |
4015 return 0; | |
4016 } | |
4017 | |
4018 if (varp == NULL) /* hidden option */ | |
4019 return -1; | |
4020 if (options[opt_idx].flags & P_NUM) | |
4021 *numval = *(long *)varp; | |
4022 else | |
4023 { | |
4024 /* Special case: 'modified' is b_changed, but we also want to consider | |
4025 * it set when 'ff' or 'fenc' changed. */ | |
4026 if ((int *)varp == &curbuf->b_changed) | |
4027 *numval = curbufIsChanged(); | |
4028 else | |
9395
beab399e3883
commit https://github.com/vim/vim/commit/2acfbed9dbea990f129535de7ff3df360365130b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4029 *numval = (long) *(int *)varp; |
7 | 4030 } |
4031 return 1; | |
4032 } | |
4033 #endif | |
4034 | |
5610 | 4035 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
4350 | 4036 /* |
4037 * Returns the option attributes and its value. Unlike the above function it | |
4038 * will return either global value or local value of the option depending on | |
4039 * what was requested, but it will never return global value if it was | |
4040 * requested to return local one and vice versa. Neither it will return | |
4041 * buffer-local value if it was requested to return window-local one. | |
4042 * | |
4043 * Pretends that option is absent if it is not present in the requested scope | |
4044 * (i.e. has no global, window-local or buffer-local value depending on | |
4045 * opt_type). Uses | |
4046 * | |
4047 * Returned flags: | |
5867 | 4048 * 0 hidden or unknown option, also option that does not have requested |
4049 * type (see SREQ_* in vim.h) | |
4350 | 4050 * see SOPT_* in vim.h for other flags |
4051 * | |
4052 * Possible opt_type values: see SREQ_* in vim.h | |
4053 */ | |
4054 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4055 get_option_value_strict( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4056 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4057 long *numval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4058 char_u **stringval, /* NULL when only obtaining attributes */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4059 int opt_type, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4060 void *from) |
4350 | 4061 { |
4062 int opt_idx; | |
4367 | 4063 char_u *varp = NULL; |
4350 | 4064 struct vimoption *p; |
4065 int r = 0; | |
4066 | |
4067 opt_idx = findoption(name); | |
4068 if (opt_idx < 0) | |
4069 return 0; | |
4070 | |
4071 p = &(options[opt_idx]); | |
4072 | |
4073 /* Hidden option */ | |
4074 if (p->var == NULL) | |
4075 return 0; | |
4076 | |
4077 if (p->flags & P_BOOL) | |
4078 r |= SOPT_BOOL; | |
4079 else if (p->flags & P_NUM) | |
4080 r |= SOPT_NUM; | |
4081 else if (p->flags & P_STRING) | |
4082 r |= SOPT_STRING; | |
4083 | |
4084 if (p->indir == PV_NONE) | |
4085 { | |
4086 if (opt_type == SREQ_GLOBAL) | |
4087 r |= SOPT_GLOBAL; | |
4088 else | |
4089 return 0; /* Did not request global-only option */ | |
4090 } | |
4091 else | |
4092 { | |
4093 if (p->indir & PV_BOTH) | |
4094 r |= SOPT_GLOBAL; | |
4095 else if (opt_type == SREQ_GLOBAL) | |
4096 return 0; /* Requested global option */ | |
4097 | |
4098 if (p->indir & PV_WIN) | |
4099 { | |
4100 if (opt_type == SREQ_BUF) | |
4101 return 0; /* Did not request window-local option */ | |
4102 else | |
4103 r |= SOPT_WIN; | |
4104 } | |
4105 else if (p->indir & PV_BUF) | |
4106 { | |
4107 if (opt_type == SREQ_WIN) | |
4108 return 0; /* Did not request buffer-local option */ | |
4109 else | |
4110 r |= SOPT_BUF; | |
4111 } | |
4112 } | |
4113 | |
4114 if (stringval == NULL) | |
4115 return r; | |
4116 | |
4117 if (opt_type == SREQ_GLOBAL) | |
4118 varp = p->var; | |
4119 else | |
4120 { | |
4121 if (opt_type == SREQ_BUF) | |
4122 { | |
4123 /* Special case: 'modified' is b_changed, but we also want to | |
4124 * consider it set when 'ff' or 'fenc' changed. */ | |
4125 if (p->indir == PV_MOD) | |
4126 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4127 *numval = bufIsChanged((buf_T *)from); |
4350 | 4128 varp = NULL; |
4129 } | |
4130 #ifdef FEAT_CRYPT | |
4131 else if (p->indir == PV_KEY) | |
4132 { | |
4133 /* never return the value of the crypt key */ | |
4134 *stringval = NULL; | |
4135 varp = NULL; | |
4136 } | |
4137 #endif | |
4138 else | |
4139 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4140 buf_T *save_curbuf = curbuf; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4141 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4142 // only getting a pointer, no need to use aucmd_prepbuf() |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4143 curbuf = (buf_T *)from; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4144 curwin->w_buffer = curbuf; |
4350 | 4145 varp = get_varp(p); |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4146 curbuf = save_curbuf; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4147 curwin->w_buffer = curbuf; |
4350 | 4148 } |
4149 } | |
4150 else if (opt_type == SREQ_WIN) | |
4151 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4152 win_T *save_curwin = curwin; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4153 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4154 curwin = (win_T *)from; |
4350 | 4155 curbuf = curwin->w_buffer; |
4156 varp = get_varp(p); | |
4157 curwin = save_curwin; | |
4158 curbuf = curwin->w_buffer; | |
4159 } | |
4160 if (varp == p->var) | |
4161 return (r | SOPT_UNSET); | |
4162 } | |
4163 | |
4164 if (varp != NULL) | |
4165 { | |
4166 if (p->flags & P_STRING) | |
4167 *stringval = vim_strsave(*(char_u **)(varp)); | |
4168 else if (p->flags & P_NUM) | |
4169 *numval = *(long *) varp; | |
4170 else | |
4171 *numval = *(int *)varp; | |
4172 } | |
4173 | |
4174 return r; | |
4175 } | |
5610 | 4176 |
4177 /* | |
6243 | 4178 * Iterate over options. First argument is a pointer to a pointer to a |
4179 * structure inside options[] array, second is option type like in the above | |
4180 * function. | |
5610 | 4181 * |
6243 | 4182 * If first argument points to NULL it is assumed that iteration just started |
5610 | 4183 * and caller needs the very first value. |
6243 | 4184 * If first argument points to the end marker function returns NULL and sets |
5610 | 4185 * first argument to NULL. |
4186 * | |
4187 * Returns full option name for current option on each call. | |
4188 */ | |
4189 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4190 option_iter_next(void **option, int opt_type) |
5610 | 4191 { |
4192 struct vimoption *ret = NULL; | |
4193 do | |
4194 { | |
4195 if (*option == NULL) | |
4196 *option = (void *) options; | |
4197 else if (((struct vimoption *) (*option))->fullname == NULL) | |
4198 { | |
4199 *option = NULL; | |
4200 return NULL; | |
4201 } | |
4202 else | |
4203 *option = (void *) (((struct vimoption *) (*option)) + 1); | |
4204 | |
4205 ret = ((struct vimoption *) (*option)); | |
4206 | |
4207 /* Hidden option */ | |
4208 if (ret->var == NULL) | |
4209 { | |
4210 ret = NULL; | |
4211 continue; | |
4212 } | |
4213 | |
4214 switch (opt_type) | |
4215 { | |
4216 case SREQ_GLOBAL: | |
4217 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH)) | |
4218 ret = NULL; | |
4219 break; | |
4220 case SREQ_BUF: | |
4221 if (!(ret->indir & PV_BUF)) | |
4222 ret = NULL; | |
4223 break; | |
4224 case SREQ_WIN: | |
4225 if (!(ret->indir & PV_WIN)) | |
4226 ret = NULL; | |
4227 break; | |
4228 default: | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
4229 internal_error("option_iter_next()"); |
5610 | 4230 return NULL; |
4231 } | |
4232 } | |
4233 while (ret == NULL); | |
4234 | |
4235 return (char_u *)ret->fullname; | |
4236 } | |
4350 | 4237 #endif |
4238 | |
7 | 4239 /* |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4240 * Return the flags for the option at 'opt_idx'. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4241 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4242 long_u |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4243 get_option_flags(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4244 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4245 return options[opt_idx].flags; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4246 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4247 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4248 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4249 * Set a flag for the option at 'opt_idx'. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4250 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4251 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4252 set_option_flag(int opt_idx, long_u flag) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4253 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4254 options[opt_idx].flags |= flag; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4255 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4256 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4257 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4258 * Clear a flag for the option at 'opt_idx'. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4259 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4260 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4261 clear_option_flag(int opt_idx, long_u flag) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4262 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4263 options[opt_idx].flags &= ~flag; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4264 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4265 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4266 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4267 * Returns TRUE if the option at 'opt_idx' is a global option |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4268 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4269 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4270 is_global_option(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4271 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4272 return options[opt_idx].indir == PV_NONE; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4273 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4274 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4275 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4276 * Returns TRUE if the option at 'opt_idx' is a global option which also has a |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4277 * local value. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4278 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4279 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4280 is_global_local_option(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4281 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4282 return options[opt_idx].indir & PV_BOTH; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4283 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4284 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4285 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4286 * Returns TRUE if the option at 'opt_idx' is a window-local option |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4287 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4288 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4289 is_window_local_option(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4290 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4291 return options[opt_idx].var == VAR_WIN; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4292 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4293 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4294 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4295 * Returns TRUE if the option at 'opt_idx' is a hidden option |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4296 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4297 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4298 is_hidden_option(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4299 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4300 return options[opt_idx].var == NULL; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4301 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4302 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4303 #if defined(FEAT_CRYPT) || defined(PROTO) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4304 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4305 * Returns TRUE if the option at 'opt_idx' is a crypt key option |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4306 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4307 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4308 is_crypt_key_option(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4309 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4310 return options[opt_idx].indir == PV_KEY; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4311 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4312 #endif |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4313 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4314 /* |
7 | 4315 * Set the value of option "name". |
4316 * Use "string" for string options, use "number" for other options. | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4317 * |
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4318 * Returns NULL on success or error message on error. |
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4319 */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4320 char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4321 set_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4322 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4323 long number, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4324 char_u *string, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4325 int opt_flags) /* OPT_LOCAL or 0 (both) */ |
7 | 4326 { |
4327 int opt_idx; | |
4328 char_u *varp; | |
835 | 4329 long_u flags; |
7 | 4330 |
4331 opt_idx = findoption(name); | |
838 | 4332 if (opt_idx < 0) |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4333 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4334 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4335 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4336 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_' |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4337 && (key = find_key_option(name, FALSE)) != 0) |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4338 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4339 char_u key_name[2]; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4340 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4341 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4342 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4343 key_name[0] = KEY2TERMCAP0(key); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4344 key_name[1] = KEY2TERMCAP1(key); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4345 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4346 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4347 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4348 key_name[0] = KS_KEY; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4349 key_name[1] = (key & 0xff); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4350 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4351 add_termcode(key_name, string, FALSE); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4352 if (full_screen) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4353 ttest(FALSE); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4354 redraw_all_later(CLEAR); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4355 return NULL; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4356 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4357 |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4358 semsg(_("E355: Unknown option: %s"), name); |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4359 } |
7 | 4360 else |
4361 { | |
4362 flags = options[opt_idx].flags; | |
4363 #ifdef HAVE_SANDBOX | |
4364 /* Disallow changing some options in the sandbox */ | |
4365 if (sandbox > 0 && (flags & P_SECURE)) | |
634 | 4366 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4367 emsg(_(e_sandbox)); |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4368 return NULL; |
634 | 4369 } |
4370 #endif | |
4371 if (flags & P_STRING) | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4372 return set_string_option(opt_idx, string, opt_flags); |
7 | 4373 else |
4374 { | |
1667 | 4375 varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
7 | 4376 if (varp != NULL) /* hidden option is not changed */ |
4377 { | |
1298 | 4378 if (number == 0 && string != NULL) |
4379 { | |
1757 | 4380 int idx; |
1298 | 4381 |
4382 /* Either we are given a string or we are setting option | |
4383 * to zero. */ | |
1757 | 4384 for (idx = 0; string[idx] == '0'; ++idx) |
1298 | 4385 ; |
1757 | 4386 if (string[idx] != NUL || idx == 0) |
1298 | 4387 { |
4388 /* There's another character after zeros or the string | |
4389 * is empty. In both cases, we are trying to set a | |
4390 * num option using a string. */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4391 semsg(_("E521: Number required: &%s = '%s'"), |
1298 | 4392 name, string); |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4393 return NULL; /* do nothing as we hit an error */ |
1298 | 4394 |
4395 } | |
4396 } | |
7 | 4397 if (flags & P_NUM) |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4398 return set_num_option(opt_idx, varp, number, |
274 | 4399 NULL, 0, opt_flags); |
7 | 4400 else |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4401 return set_bool_option(opt_idx, varp, (int)number, |
634 | 4402 opt_flags); |
7 | 4403 } |
4404 } | |
4405 } | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4406 return NULL; |
7 | 4407 } |
4408 | |
4409 /* | |
4410 * Get the terminal code for a terminal option. | |
4411 * Returns NULL when not found. | |
4412 */ | |
4413 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4414 get_term_code(char_u *tname) |
7 | 4415 { |
4416 int opt_idx; | |
4417 char_u *varp; | |
4418 | |
4419 if (tname[0] != 't' || tname[1] != '_' || | |
4420 tname[2] == NUL || tname[3] == NUL) | |
4421 return NULL; | |
4422 if ((opt_idx = findoption(tname)) >= 0) | |
4423 { | |
4424 varp = get_varp(&(options[opt_idx])); | |
4425 if (varp != NULL) | |
4426 varp = *(char_u **)(varp); | |
4427 return varp; | |
4428 } | |
4429 return find_termcode(tname + 2); | |
4430 } | |
4431 | |
4432 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4433 get_highlight_default(void) |
7 | 4434 { |
4435 int i; | |
4436 | |
4437 i = findoption((char_u *)"hl"); | |
4438 if (i >= 0) | |
4439 return options[i].def_val[VI_DEFAULT]; | |
4440 return (char_u *)NULL; | |
4441 } | |
4442 | |
39 | 4443 char_u * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4444 get_encoding_default(void) |
39 | 4445 { |
4446 int i; | |
4447 | |
4448 i = findoption((char_u *)"enc"); | |
4449 if (i >= 0) | |
4450 return options[i].def_val[VI_DEFAULT]; | |
4451 return (char_u *)NULL; | |
4452 } | |
4453 | |
7 | 4454 /* |
4455 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number. | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4456 * When "has_lt" is true there is a '<' before "*arg_arg". |
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4457 * Returns 0 when the key is not recognized. |
7 | 4458 */ |
4459 static int | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4460 find_key_option(char_u *arg_arg, int has_lt) |
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4461 { |
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4462 int key = 0; |
7 | 4463 int modifiers; |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4464 char_u *arg = arg_arg; |
7 | 4465 |
4466 /* | |
4467 * Don't use get_special_key_code() for t_xx, we don't want it to call | |
4468 * add_termcap_entry(). | |
4469 */ | |
4470 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
4471 key = TERMCAP2KEY(arg[2], arg[3]); | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4472 else if (has_lt) |
7 | 4473 { |
4474 --arg; /* put arg at the '<' */ | |
4475 modifiers = 0; | |
9869
989d44d35a66
commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
4476 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE); |
7 | 4477 if (modifiers) /* can't handle modifiers here */ |
4478 key = 0; | |
4479 } | |
4480 return key; | |
4481 } | |
4482 | |
4483 /* | |
4484 * if 'all' == 0: show changed options | |
4485 * if 'all' == 1: show all normal options | |
4486 * if 'all' == 2: show all terminal options | |
4487 */ | |
4488 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4489 showoptions( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4490 int all, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4491 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ |
7 | 4492 { |
4493 struct vimoption *p; | |
4494 int col; | |
4495 int isterm; | |
4496 char_u *varp; | |
4497 struct vimoption **items; | |
4498 int item_count; | |
4499 int run; | |
4500 int row, rows; | |
4501 int cols; | |
4502 int i; | |
4503 int len; | |
4504 | |
4505 #define INC 20 | |
4506 #define GAP 3 | |
4507 | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16806
diff
changeset
|
4508 items = ALLOC_MULT(struct vimoption *, PARAM_COUNT); |
7 | 4509 if (items == NULL) |
4510 return; | |
4511 | |
4512 /* Highlight title */ | |
4513 if (all == 2) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4514 msg_puts_title(_("\n--- Terminal codes ---")); |
7 | 4515 else if (opt_flags & OPT_GLOBAL) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4516 msg_puts_title(_("\n--- Global option values ---")); |
7 | 4517 else if (opt_flags & OPT_LOCAL) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4518 msg_puts_title(_("\n--- Local option values ---")); |
7 | 4519 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4520 msg_puts_title(_("\n--- Options ---")); |
7 | 4521 |
4522 /* | |
4523 * do the loop two times: | |
4524 * 1. display the short items | |
4525 * 2. display the long items (only strings and numbers) | |
4526 */ | |
4527 for (run = 1; run <= 2 && !got_int; ++run) | |
4528 { | |
4529 /* | |
4530 * collect the items in items[] | |
4531 */ | |
4532 item_count = 0; | |
4533 for (p = &options[0]; p->fullname != NULL; p++) | |
4534 { | |
14968
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4535 // apply :filter /pat/ |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4536 if (message_filtered((char_u *) p->fullname)) |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4537 continue; |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4538 |
7 | 4539 varp = NULL; |
4540 isterm = istermoption(p); | |
4541 if (opt_flags != 0) | |
4542 { | |
4543 if (p->indir != PV_NONE && !isterm) | |
4544 varp = get_varp_scope(p, opt_flags); | |
4545 } | |
4546 else | |
4547 varp = get_varp(p); | |
4548 if (varp != NULL | |
4549 && ((all == 2 && isterm) | |
4550 || (all == 1 && !isterm) | |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4551 || (all == 0 && !optval_default(p, varp, p_cp)))) |
7 | 4552 { |
4553 if (p->flags & P_BOOL) | |
4554 len = 1; /* a toggle option fits always */ | |
4555 else | |
4556 { | |
4557 option_value2string(p, opt_flags); | |
4558 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; | |
4559 } | |
4560 if ((len <= INC - GAP && run == 1) || | |
4561 (len > INC - GAP && run == 2)) | |
4562 items[item_count++] = p; | |
4563 } | |
4564 } | |
4565 | |
4566 /* | |
4567 * display the items | |
4568 */ | |
4569 if (run == 1) | |
4570 { | |
4571 cols = (Columns + GAP - 3) / INC; | |
4572 if (cols == 0) | |
4573 cols = 1; | |
4574 rows = (item_count + cols - 1) / cols; | |
4575 } | |
4576 else /* run == 2 */ | |
4577 rows = item_count; | |
4578 for (row = 0; row < rows && !got_int; ++row) | |
4579 { | |
4580 msg_putchar('\n'); /* go to next line */ | |
4581 if (got_int) /* 'q' typed in more */ | |
4582 break; | |
4583 col = 0; | |
4584 for (i = row; i < item_count; i += rows) | |
4585 { | |
4586 msg_col = col; /* make columns */ | |
4587 showoneopt(items[i], opt_flags); | |
4588 col += INC; | |
4589 } | |
4590 out_flush(); | |
4591 ui_breakcheck(); | |
4592 } | |
4593 } | |
4594 vim_free(items); | |
4595 } | |
4596 | |
4597 /* | |
4598 * Return TRUE if option "p" has its default value. | |
4599 */ | |
4600 static int | |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4601 optval_default(struct vimoption *p, char_u *varp, int compatible) |
7 | 4602 { |
4603 int dvi; | |
4604 | |
4605 if (varp == NULL) | |
4606 return TRUE; /* hidden option is always at default */ | |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4607 dvi = ((p->flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; |
7 | 4608 if (p->flags & P_NUM) |
840 | 4609 return (*(long *)varp == (long)(long_i)p->def_val[dvi]); |
7 | 4610 if (p->flags & P_BOOL) |
840 | 4611 /* the cast to long is required for Manx C, long_i is |
4612 * needed for MSVC */ | |
4613 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]); | |
7 | 4614 /* P_STRING */ |
4615 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); | |
4616 } | |
4617 | |
4618 /* | |
4619 * showoneopt: show the value of one option | |
4620 * must not be called with a hidden option! | |
4621 */ | |
4622 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4623 showoneopt( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4624 struct vimoption *p, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4625 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */ |
7 | 4626 { |
168 | 4627 char_u *varp; |
4628 int save_silent = silent_mode; | |
4629 | |
4630 silent_mode = FALSE; | |
4631 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ | |
7 | 4632 |
4633 varp = get_varp_scope(p, opt_flags); | |
4634 | |
4635 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */ | |
4636 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed | |
4637 ? !curbufIsChanged() : !*(int *)varp)) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4638 msg_puts("no"); |
7 | 4639 else if ((p->flags & P_BOOL) && *(int *)varp < 0) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4640 msg_puts("--"); |
7 | 4641 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4642 msg_puts(" "); |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4643 msg_puts(p->fullname); |
7 | 4644 if (!(p->flags & P_BOOL)) |
4645 { | |
4646 msg_putchar('='); | |
4647 /* put value string in NameBuff */ | |
4648 option_value2string(p, opt_flags); | |
4649 msg_outtrans(NameBuff); | |
4650 } | |
168 | 4651 |
4652 silent_mode = save_silent; | |
4653 info_message = FALSE; | |
7 | 4654 } |
4655 | |
4656 /* | |
4657 * Write modified options as ":set" commands to a file. | |
4658 * | |
4659 * There are three values for "opt_flags": | |
4660 * OPT_GLOBAL: Write global option values and fresh values of | |
4661 * buffer-local options (used for start of a session | |
4662 * file). | |
4663 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for | |
4664 * curwin (used for a vimrc file). | |
4665 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh | |
4666 * and local values for window-local options of | |
4667 * curwin. Local values are also written when at the | |
4668 * default value, because a modeline or autocommand | |
4669 * may have set them when doing ":edit file" and the | |
4670 * user has set them back at the default or fresh | |
4671 * value. | |
4672 * When "local_only" is TRUE, don't write fresh | |
4673 * values, only local values (for ":mkview"). | |
4674 * (fresh value = value used for a new buffer or window for a local option). | |
4675 * | |
4676 * Return FAIL on error, OK otherwise. | |
4677 */ | |
4678 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4679 makeset(FILE *fd, int opt_flags, int local_only) |
7 | 4680 { |
4681 struct vimoption *p; | |
4682 char_u *varp; /* currently used value */ | |
4683 char_u *varp_fresh; /* local value */ | |
4684 char_u *varp_local = NULL; /* fresh value */ | |
4685 char *cmd; | |
4686 int round; | |
1384 | 4687 int pri; |
7 | 4688 |
4689 /* | |
4690 * The options that don't have a default (terminal name, columns, lines) | |
4691 * are never written. Terminal options are also not written. | |
1384 | 4692 * Do the loop over "options[]" twice: once for options with the |
4693 * P_PRI_MKRC flag and once without. | |
7 | 4694 */ |
1384 | 4695 for (pri = 1; pri >= 0; --pri) |
4696 { | |
4697 for (p = &options[0]; !istermoption(p); p++) | |
4698 if (!(p->flags & P_NO_MKRC) | |
4699 && !istermoption(p) | |
4700 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) | |
7 | 4701 { |
4702 /* skip global option when only doing locals */ | |
4703 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) | |
4704 continue; | |
4705 | |
4706 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc | |
4707 * file, they are always buffer-specific. */ | |
4708 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) | |
4709 continue; | |
4710 | |
4711 /* Global values are only written when not at the default value. */ | |
4712 varp = get_varp_scope(p, opt_flags); | |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4713 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp, p_cp)) |
7 | 4714 continue; |
4715 | |
4716 round = 2; | |
4717 if (p->indir != PV_NONE) | |
4718 { | |
4719 if (p->var == VAR_WIN) | |
4720 { | |
4721 /* skip window-local option when only doing globals */ | |
4722 if (!(opt_flags & OPT_LOCAL)) | |
4723 continue; | |
4724 /* When fresh value of window-local option is not at the | |
4725 * default, need to write it too. */ | |
4726 if (!(opt_flags & OPT_GLOBAL) && !local_only) | |
4727 { | |
4728 varp_fresh = get_varp_scope(p, OPT_GLOBAL); | |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4729 if (!optval_default(p, varp_fresh, p_cp)) |
7 | 4730 { |
4731 round = 1; | |
4732 varp_local = varp; | |
4733 varp = varp_fresh; | |
4734 } | |
4735 } | |
4736 } | |
4737 } | |
4738 | |
4739 /* Round 1: fresh value for window-local options. | |
4740 * Round 2: other values */ | |
4741 for ( ; round <= 2; varp = varp_local, ++round) | |
4742 { | |
4743 if (round == 1 || (opt_flags & OPT_GLOBAL)) | |
4744 cmd = "set"; | |
4745 else | |
4746 cmd = "setlocal"; | |
4747 | |
4748 if (p->flags & P_BOOL) | |
4749 { | |
4750 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) | |
4751 return FAIL; | |
4752 } | |
4753 else if (p->flags & P_NUM) | |
4754 { | |
4755 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) | |
4756 return FAIL; | |
4757 } | |
4758 else /* P_STRING */ | |
4759 { | |
694 | 4760 int do_endif = FALSE; |
4761 | |
7 | 4762 /* Don't set 'syntax' and 'filetype' again if the value is |
4763 * already right, avoids reloading the syntax file. */ | |
694 | 4764 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4765 #if defined(FEAT_SYN_HL) |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4766 p->indir == PV_SYN || |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4767 #endif |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4768 p->indir == PV_FT) |
7 | 4769 { |
4770 if (fprintf(fd, "if &%s != '%s'", p->fullname, | |
4771 *(char_u **)(varp)) < 0 | |
4772 || put_eol(fd) < 0) | |
4773 return FAIL; | |
694 | 4774 do_endif = TRUE; |
7 | 4775 } |
4776 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp, | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4777 p->flags) == FAIL) |
7 | 4778 return FAIL; |
694 | 4779 if (do_endif) |
7 | 4780 { |
4781 if (put_line(fd, "endif") == FAIL) | |
4782 return FAIL; | |
4783 } | |
4784 } | |
4785 } | |
4786 } | |
1384 | 4787 } |
7 | 4788 return OK; |
4789 } | |
4790 | |
4791 #if defined(FEAT_FOLDING) || defined(PROTO) | |
4792 /* | |
4793 * Generate set commands for the local fold options only. Used when | |
4794 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options". | |
4795 */ | |
4796 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4797 makefoldset(FILE *fd) |
7 | 4798 { |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4799 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, 0) == FAIL |
7 | 4800 # ifdef FEAT_EVAL |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4801 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, 0) |
7 | 4802 == FAIL |
4803 # endif | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4804 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, 0) |
7 | 4805 == FAIL |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4806 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, 0) |
7 | 4807 == FAIL |
4808 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL | |
4809 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL | |
4810 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL | |
4811 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL | |
4812 ) | |
4813 return FAIL; | |
4814 | |
4815 return OK; | |
4816 } | |
4817 #endif | |
4818 | |
4819 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4820 put_setstring( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4821 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4822 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4823 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4824 char_u **valuep, |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4825 long_u flags) |
7 | 4826 { |
4827 char_u *s; | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4828 char_u *buf = NULL; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4829 char_u *part = NULL; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4830 char_u *p; |
7 | 4831 |
4832 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
4833 return FAIL; | |
4834 if (*valuep != NULL) | |
4835 { | |
4836 /* Output 'pastetoggle' as key names. For other | |
4837 * options some characters have to be escaped with | |
4838 * CTRL-V or backslash */ | |
4839 if (valuep == &p_pt) | |
4840 { | |
4841 s = *valuep; | |
4842 while (*s != NUL) | |
1601 | 4843 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL) |
7 | 4844 return FAIL; |
4845 } | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4846 // expand the option value, replace $HOME by ~ |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4847 else if ((flags & P_EXPAND) != 0) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4848 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4849 int size = (int)STRLEN(*valuep) + 1; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4850 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4851 // replace home directory in the whole option value into "buf" |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4852 buf = alloc(size); |
2780 | 4853 if (buf == NULL) |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4854 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4855 home_replace(NULL, *valuep, buf, size, FALSE); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4856 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4857 // If the option value is longer than MAXPATHL, we need to append |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4858 // earch comma separated part of the option separately, so that it |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4859 // can be expanded when read back. |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4860 if (size >= MAXPATHL && (flags & P_COMMA) != 0 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4861 && vim_strchr(*valuep, ',') != NULL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4862 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4863 part = alloc(size); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4864 if (part == NULL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4865 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4866 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4867 // write line break to clear the option, e.g. ':set rtp=' |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4868 if (put_eol(fd) == FAIL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4869 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4870 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4871 p = buf; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4872 while (*p != NUL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4873 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4874 // for each comma separated option part, append value to |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4875 // the option, :set rtp+=value |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4876 if (fprintf(fd, "%s %s+=", cmd, name) < 0) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4877 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4878 (void)copy_option_part(&p, part, size, ","); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4879 if (put_escstr(fd, part, 2) == FAIL || put_eol(fd) == FAIL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4880 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4881 } |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4882 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4883 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4884 return OK; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4885 } |
7 | 4886 if (put_escstr(fd, buf, 2) == FAIL) |
2780 | 4887 { |
4888 vim_free(buf); | |
7 | 4889 return FAIL; |
2780 | 4890 } |
4891 vim_free(buf); | |
7 | 4892 } |
4893 else if (put_escstr(fd, *valuep, 2) == FAIL) | |
4894 return FAIL; | |
4895 } | |
4896 if (put_eol(fd) < 0) | |
4897 return FAIL; | |
4898 return OK; | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4899 fail: |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4900 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4901 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4902 return FAIL; |
7 | 4903 } |
4904 | |
4905 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4906 put_setnum( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4907 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4908 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4909 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4910 long *valuep) |
7 | 4911 { |
4912 long wc; | |
4913 | |
4914 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
4915 return FAIL; | |
4916 if (wc_use_keyname((char_u *)valuep, &wc)) | |
4917 { | |
4918 /* print 'wildchar' and 'wildcharm' as a key name */ | |
4919 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) | |
4920 return FAIL; | |
4921 } | |
4922 else if (fprintf(fd, "%ld", *valuep) < 0) | |
4923 return FAIL; | |
4924 if (put_eol(fd) < 0) | |
4925 return FAIL; | |
4926 return OK; | |
4927 } | |
4928 | |
4929 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4930 put_setbool( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4931 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4932 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4933 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4934 int value) |
7 | 4935 { |
1416 | 4936 if (value < 0) /* global/local option using global value */ |
4937 return OK; | |
7 | 4938 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 |
4939 || put_eol(fd) < 0) | |
4940 return FAIL; | |
4941 return OK; | |
4942 } | |
4943 | |
4944 /* | |
4945 * Clear all the terminal options. | |
4946 * If the option has been allocated, free the memory. | |
4947 * Terminal options are never hidden or indirect. | |
4948 */ | |
4949 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4950 clear_termoptions(void) |
7 | 4951 { |
4952 /* | |
4953 * Reset a few things before clearing the old options. This may cause | |
4954 * outputting a few things that the terminal doesn't understand, but the | |
4955 * screen will be cleared later, so this is OK. | |
4956 */ | |
4957 #ifdef FEAT_MOUSE_TTY | |
4958 mch_setmouse(FALSE); /* switch mouse off */ | |
4959 #endif | |
4960 #ifdef FEAT_TITLE | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14381
diff
changeset
|
4961 mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */ |
7 | 4962 #endif |
4963 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI) | |
4964 /* When starting the GUI close the display opened for the clipboard. | |
4965 * After restoring the title, because that will need the display. */ | |
4966 if (gui.starting) | |
4967 clear_xterm_clip(); | |
4968 #endif | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10205
diff
changeset
|
4969 stoptermcap(); /* stop termcap mode */ |
7 | 4970 |
359 | 4971 free_termoptions(); |
4972 } | |
4973 | |
4974 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4975 free_termoptions(void) |
359 | 4976 { |
4977 struct vimoption *p; | |
4978 | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4979 for (p = options; p->fullname != NULL; p++) |
7 | 4980 if (istermoption(p)) |
4981 { | |
4982 if (p->flags & P_ALLOCED) | |
4983 free_string_option(*(char_u **)(p->var)); | |
4984 if (p->flags & P_DEF_ALLOCED) | |
4985 free_string_option(p->def_val[VI_DEFAULT]); | |
4986 *(char_u **)(p->var) = empty_option; | |
4987 p->def_val[VI_DEFAULT] = empty_option; | |
4988 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED); | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4989 #ifdef FEAT_EVAL |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4990 // remember where the option was cleared |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4991 set_option_sctx_idx((int)(p - options), OPT_GLOBAL, current_sctx); |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4992 #endif |
7 | 4993 } |
4994 clear_termcodes(); | |
4995 } | |
4996 | |
4997 /* | |
1941 | 4998 * Free the string for one term option, if it was allocated. |
4999 * Set the string to empty_option and clear allocated flag. | |
5000 * "var" points to the option value. | |
5001 */ | |
5002 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5003 free_one_termoption(char_u *var) |
1941 | 5004 { |
5005 struct vimoption *p; | |
5006 | |
5007 for (p = &options[0]; p->fullname != NULL; p++) | |
5008 if (p->var == var) | |
5009 { | |
5010 if (p->flags & P_ALLOCED) | |
5011 free_string_option(*(char_u **)(p->var)); | |
5012 *(char_u **)(p->var) = empty_option; | |
5013 p->flags &= ~P_ALLOCED; | |
5014 break; | |
5015 } | |
5016 } | |
5017 | |
5018 /* | |
7 | 5019 * Set the terminal option defaults to the current value. |
5020 * Used after setting the terminal name. | |
5021 */ | |
5022 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5023 set_term_defaults(void) |
7 | 5024 { |
5025 struct vimoption *p; | |
5026 | |
5027 for (p = &options[0]; p->fullname != NULL; p++) | |
5028 { | |
5029 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) | |
5030 { | |
5031 if (p->flags & P_DEF_ALLOCED) | |
5032 { | |
5033 free_string_option(p->def_val[VI_DEFAULT]); | |
5034 p->flags &= ~P_DEF_ALLOCED; | |
5035 } | |
5036 p->def_val[VI_DEFAULT] = *(char_u **)(p->var); | |
5037 if (p->flags & P_ALLOCED) | |
5038 { | |
5039 p->flags |= P_DEF_ALLOCED; | |
5040 p->flags &= ~P_ALLOCED; /* don't free the value now */ | |
5041 } | |
5042 } | |
5043 } | |
5044 } | |
5045 | |
5046 /* | |
5047 * return TRUE if 'p' starts with 't_' | |
5048 */ | |
5049 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5050 istermoption(struct vimoption *p) |
7 | 5051 { |
5052 return (p->fullname[0] == 't' && p->fullname[1] == '_'); | |
5053 } | |
5054 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5055 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5056 * Returns TRUE if the option at 'opt_idx' starts with 't_' |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5057 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5058 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5059 istermoption_idx(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5060 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5061 return istermoption(&options[opt_idx]); |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5062 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5063 |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
5064 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
7 | 5065 /* |
4350 | 5066 * Unset local option value, similar to ":set opt<". |
5067 */ | |
5068 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5069 unset_global_local_option(char_u *name, void *from) |
4350 | 5070 { |
5071 struct vimoption *p; | |
5072 int opt_idx; | |
4361 | 5073 buf_T *buf = (buf_T *)from; |
4350 | 5074 |
5075 opt_idx = findoption(name); | |
7007 | 5076 if (opt_idx < 0) |
5077 return; | |
4350 | 5078 p = &(options[opt_idx]); |
5079 | |
5080 switch ((int)p->indir) | |
5081 { | |
5082 /* global option with local value: use local value if it's been set */ | |
5083 case PV_EP: | |
4361 | 5084 clear_string_option(&buf->b_p_ep); |
4350 | 5085 break; |
5086 case PV_KP: | |
4361 | 5087 clear_string_option(&buf->b_p_kp); |
4350 | 5088 break; |
5089 case PV_PATH: | |
4361 | 5090 clear_string_option(&buf->b_p_path); |
4350 | 5091 break; |
5092 case PV_AR: | |
5093 buf->b_p_ar = -1; | |
5094 break; | |
6243 | 5095 case PV_BKC: |
5096 clear_string_option(&buf->b_p_bkc); | |
5097 buf->b_bkc_flags = 0; | |
5098 break; | |
4350 | 5099 case PV_TAGS: |
4361 | 5100 clear_string_option(&buf->b_p_tags); |
4350 | 5101 break; |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5102 case PV_TC: |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5103 clear_string_option(&buf->b_p_tc); |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5104 buf->b_tc_flags = 0; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5105 break; |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5106 case PV_SISO: |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5107 curwin->w_p_siso = -1; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5108 break; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5109 case PV_SO: |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5110 curwin->w_p_so = -1; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5111 break; |
4350 | 5112 #ifdef FEAT_FIND_ID |
5113 case PV_DEF: | |
4361 | 5114 clear_string_option(&buf->b_p_def); |
4350 | 5115 break; |
5116 case PV_INC: | |
4361 | 5117 clear_string_option(&buf->b_p_inc); |
4350 | 5118 break; |
5119 #endif | |
5120 case PV_DICT: | |
4361 | 5121 clear_string_option(&buf->b_p_dict); |
4350 | 5122 break; |
5123 case PV_TSR: | |
4361 | 5124 clear_string_option(&buf->b_p_tsr); |
4350 | 5125 break; |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5126 case PV_FP: |
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5127 clear_string_option(&buf->b_p_fp); |
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5128 break; |
4350 | 5129 #ifdef FEAT_QUICKFIX |
5130 case PV_EFM: | |
4361 | 5131 clear_string_option(&buf->b_p_efm); |
4350 | 5132 break; |
5133 case PV_GP: | |
4361 | 5134 clear_string_option(&buf->b_p_gp); |
4350 | 5135 break; |
5136 case PV_MP: | |
4361 | 5137 clear_string_option(&buf->b_p_mp); |
4350 | 5138 break; |
5139 #endif | |
5140 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) | |
5141 case PV_BEXPR: | |
4361 | 5142 clear_string_option(&buf->b_p_bexpr); |
4350 | 5143 break; |
5144 #endif | |
5145 #if defined(FEAT_CRYPT) | |
5146 case PV_CM: | |
4361 | 5147 clear_string_option(&buf->b_p_cm); |
4350 | 5148 break; |
5149 #endif | |
5150 #ifdef FEAT_STL_OPT | |
5151 case PV_STL: | |
4361 | 5152 clear_string_option(&((win_T *)from)->w_p_stl); |
4350 | 5153 break; |
5154 #endif | |
5446 | 5155 case PV_UL: |
5156 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; | |
5157 break; | |
5712 | 5158 #ifdef FEAT_LISP |
5159 case PV_LW: | |
5160 clear_string_option(&buf->b_p_lw); | |
5161 break; | |
5162 #endif | |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
5163 case PV_MENC: |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
5164 clear_string_option(&buf->b_p_menc); |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
5165 break; |
4350 | 5166 } |
5167 } | |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
5168 #endif |
4350 | 5169 |
5170 /* | |
7 | 5171 * Get pointer to option variable, depending on local or global scope. |
5172 */ | |
5173 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5174 get_varp_scope(struct vimoption *p, int opt_flags) |
7 | 5175 { |
5176 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE) | |
5177 { | |
5178 if (p->var == VAR_WIN) | |
5179 return (char_u *)GLOBAL_WO(get_varp(p)); | |
5180 return p->var; | |
5181 } | |
692 | 5182 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) |
7 | 5183 { |
5184 switch ((int)p->indir) | |
5185 { | |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5186 case PV_FP: return (char_u *)&(curbuf->b_p_fp); |
7 | 5187 #ifdef FEAT_QUICKFIX |
694 | 5188 case PV_EFM: return (char_u *)&(curbuf->b_p_efm); |
5189 case PV_GP: return (char_u *)&(curbuf->b_p_gp); | |
5190 case PV_MP: return (char_u *)&(curbuf->b_p_mp); | |
5191 #endif | |
5192 case PV_EP: return (char_u *)&(curbuf->b_p_ep); | |
5193 case PV_KP: return (char_u *)&(curbuf->b_p_kp); | |
5194 case PV_PATH: return (char_u *)&(curbuf->b_p_path); | |
692 | 5195 case PV_AR: return (char_u *)&(curbuf->b_p_ar); |
694 | 5196 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags); |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5197 case PV_TC: return (char_u *)&(curbuf->b_p_tc); |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5198 case PV_SISO: return (char_u *)&(curwin->w_p_siso); |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5199 case PV_SO: return (char_u *)&(curwin->w_p_so); |
7 | 5200 #ifdef FEAT_FIND_ID |
694 | 5201 case PV_DEF: return (char_u *)&(curbuf->b_p_def); |
5202 case PV_INC: return (char_u *)&(curbuf->b_p_inc); | |
7 | 5203 #endif |
694 | 5204 case PV_DICT: return (char_u *)&(curbuf->b_p_dict); |
5205 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr); | |
790 | 5206 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5207 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr); | |
5208 #endif | |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5209 #if defined(FEAT_CRYPT) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5210 case PV_CM: return (char_u *)&(curbuf->b_p_cm); |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5211 #endif |
40 | 5212 #ifdef FEAT_STL_OPT |
694 | 5213 case PV_STL: return (char_u *)&(curwin->w_p_stl); |
40 | 5214 #endif |
5446 | 5215 case PV_UL: return (char_u *)&(curbuf->b_p_ul); |
5712 | 5216 #ifdef FEAT_LISP |
5217 case PV_LW: return (char_u *)&(curbuf->b_p_lw); | |
5218 #endif | |
6243 | 5219 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc); |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
5220 case PV_MENC: return (char_u *)&(curbuf->b_p_menc); |
7 | 5221 } |
5222 return NULL; /* "cannot happen" */ | |
5223 } | |
5224 return get_varp(p); | |
5225 } | |
5226 | |
5227 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5228 * Get pointer to option variable at 'opt_idx', depending on local or global |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5229 * scope. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5230 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5231 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5232 get_option_varp_scope(int opt_idx, int opt_flags) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5233 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5234 return get_varp_scope(&(options[opt_idx]), opt_flags); |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5235 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5236 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5237 /* |
7 | 5238 * Get pointer to option variable. |
5239 */ | |
5240 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5241 get_varp(struct vimoption *p) |
7 | 5242 { |
5243 /* hidden option, always return NULL */ | |
5244 if (p->var == NULL) | |
5245 return NULL; | |
5246 | |
5247 switch ((int)p->indir) | |
5248 { | |
5249 case PV_NONE: return p->var; | |
5250 | |
5251 /* global option with local value: use local value if it's been set */ | |
694 | 5252 case PV_EP: return *curbuf->b_p_ep != NUL |
7 | 5253 ? (char_u *)&curbuf->b_p_ep : p->var; |
694 | 5254 case PV_KP: return *curbuf->b_p_kp != NUL |
7 | 5255 ? (char_u *)&curbuf->b_p_kp : p->var; |
694 | 5256 case PV_PATH: return *curbuf->b_p_path != NUL |
7 | 5257 ? (char_u *)&(curbuf->b_p_path) : p->var; |
692 | 5258 case PV_AR: return curbuf->b_p_ar >= 0 |
7 | 5259 ? (char_u *)&(curbuf->b_p_ar) : p->var; |
694 | 5260 case PV_TAGS: return *curbuf->b_p_tags != NUL |
7 | 5261 ? (char_u *)&(curbuf->b_p_tags) : p->var; |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5262 case PV_TC: return *curbuf->b_p_tc != NUL |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5263 ? (char_u *)&(curbuf->b_p_tc) : p->var; |
6243 | 5264 case PV_BKC: return *curbuf->b_p_bkc != NUL |
5265 ? (char_u *)&(curbuf->b_p_bkc) : p->var; | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5266 case PV_SISO: return curwin->w_p_siso >= 0 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5267 ? (char_u *)&(curwin->w_p_siso) : p->var; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5268 case PV_SO: return curwin->w_p_so >= 0 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5269 ? (char_u *)&(curwin->w_p_so) : p->var; |
7 | 5270 #ifdef FEAT_FIND_ID |
694 | 5271 case PV_DEF: return *curbuf->b_p_def != NUL |
7 | 5272 ? (char_u *)&(curbuf->b_p_def) : p->var; |
694 | 5273 case PV_INC: return *curbuf->b_p_inc != NUL |
7 | 5274 ? (char_u *)&(curbuf->b_p_inc) : p->var; |
5275 #endif | |
694 | 5276 case PV_DICT: return *curbuf->b_p_dict != NUL |
7 | 5277 ? (char_u *)&(curbuf->b_p_dict) : p->var; |
694 | 5278 case PV_TSR: return *curbuf->b_p_tsr != NUL |
7 | 5279 ? (char_u *)&(curbuf->b_p_tsr) : p->var; |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5280 case PV_FP: return *curbuf->b_p_fp != NUL |
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5281 ? (char_u *)&(curbuf->b_p_fp) : p->var; |
7 | 5282 #ifdef FEAT_QUICKFIX |
694 | 5283 case PV_EFM: return *curbuf->b_p_efm != NUL |
5284 ? (char_u *)&(curbuf->b_p_efm) : p->var; | |
5285 case PV_GP: return *curbuf->b_p_gp != NUL | |
7 | 5286 ? (char_u *)&(curbuf->b_p_gp) : p->var; |
694 | 5287 case PV_MP: return *curbuf->b_p_mp != NUL |
7 | 5288 ? (char_u *)&(curbuf->b_p_mp) : p->var; |
5289 #endif | |
790 | 5290 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5291 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL | |
5292 ? (char_u *)&(curbuf->b_p_bexpr) : p->var; | |
5293 #endif | |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5294 #if defined(FEAT_CRYPT) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5295 case PV_CM: return *curbuf->b_p_cm != NUL |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5296 ? (char_u *)&(curbuf->b_p_cm) : p->var; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5297 #endif |
40 | 5298 #ifdef FEAT_STL_OPT |
694 | 5299 case PV_STL: return *curwin->w_p_stl != NUL |
40 | 5300 ? (char_u *)&(curwin->w_p_stl) : p->var; |
5301 #endif | |
5446 | 5302 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL |
5303 ? (char_u *)&(curbuf->b_p_ul) : p->var; | |
5712 | 5304 #ifdef FEAT_LISP |
5305 case PV_LW: return *curbuf->b_p_lw != NUL | |
5306 ? (char_u *)&(curbuf->b_p_lw) : p->var; | |
5307 #endif | |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
5308 case PV_MENC: return *curbuf->b_p_menc != NUL |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
5309 ? (char_u *)&(curbuf->b_p_menc) : p->var; |
7 | 5310 #ifdef FEAT_ARABIC |
5311 case PV_ARAB: return (char_u *)&(curwin->w_p_arab); | |
5312 #endif | |
5313 case PV_LIST: return (char_u *)&(curwin->w_p_list); | |
744 | 5314 #ifdef FEAT_SPELL |
5315 case PV_SPELL: return (char_u *)&(curwin->w_p_spell); | |
5316 #endif | |
221 | 5317 #ifdef FEAT_SYN_HL |
744 | 5318 case PV_CUC: return (char_u *)&(curwin->w_p_cuc); |
5319 case PV_CUL: return (char_u *)&(curwin->w_p_cul); | |
18047
6650e3dff8d4
patch 8.1.2019: 'cursorline' always highlights the whole line
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
5320 case PV_CULOPT: return (char_u *)&(curwin->w_p_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5321 case PV_CC: return (char_u *)&(curwin->w_p_cc); |
221 | 5322 #endif |
7 | 5323 #ifdef FEAT_DIFF |
5324 case PV_DIFF: return (char_u *)&(curwin->w_p_diff); | |
5325 #endif | |
5326 #ifdef FEAT_FOLDING | |
5327 case PV_FDC: return (char_u *)&(curwin->w_p_fdc); | |
5328 case PV_FEN: return (char_u *)&(curwin->w_p_fen); | |
5329 case PV_FDI: return (char_u *)&(curwin->w_p_fdi); | |
5330 case PV_FDL: return (char_u *)&(curwin->w_p_fdl); | |
5331 case PV_FDM: return (char_u *)&(curwin->w_p_fdm); | |
5332 case PV_FML: return (char_u *)&(curwin->w_p_fml); | |
5333 case PV_FDN: return (char_u *)&(curwin->w_p_fdn); | |
5334 # ifdef FEAT_EVAL | |
5335 case PV_FDE: return (char_u *)&(curwin->w_p_fde); | |
5336 case PV_FDT: return (char_u *)&(curwin->w_p_fdt); | |
5337 # endif | |
5338 case PV_FMR: return (char_u *)&(curwin->w_p_fmr); | |
5339 #endif | |
5340 case PV_NU: return (char_u *)&(curwin->w_p_nu); | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
5341 case PV_RNU: return (char_u *)&(curwin->w_p_rnu); |
13 | 5342 #ifdef FEAT_LINEBREAK |
5343 case PV_NUW: return (char_u *)&(curwin->w_p_nuw); | |
5344 #endif | |
7 | 5345 case PV_WFH: return (char_u *)&(curwin->w_p_wfh); |
782 | 5346 case PV_WFW: return (char_u *)&(curwin->w_p_wfw); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
5347 #if defined(FEAT_QUICKFIX) |
7 | 5348 case PV_PVW: return (char_u *)&(curwin->w_p_pvw); |
5349 #endif | |
5350 #ifdef FEAT_RIGHTLEFT | |
5351 case PV_RL: return (char_u *)&(curwin->w_p_rl); | |
5352 case PV_RLC: return (char_u *)&(curwin->w_p_rlc); | |
5353 #endif | |
5354 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr); | |
5355 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); | |
5356 #ifdef FEAT_LINEBREAK | |
5357 case PV_LBR: return (char_u *)&(curwin->w_p_lbr); | |
5995 | 5358 case PV_BRI: return (char_u *)&(curwin->w_p_bri); |
5359 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt); | |
7 | 5360 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5361 case PV_WCR: return (char_u *)&(curwin->w_p_wcr); |
7 | 5362 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5363 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5364 #ifdef FEAT_CONCEAL |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5365 case PV_COCU: return (char_u *)&(curwin->w_p_cocu); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5366 case PV_COLE: return (char_u *)&(curwin->w_p_cole); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5367 #endif |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5368 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5369 case PV_TWK: return (char_u *)&(curwin->w_p_twk); |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5370 case PV_TWS: return (char_u *)&(curwin->w_p_tws); |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5371 case PV_TWSL: return (char_u *)&(curbuf->b_p_twsl); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5372 #endif |
7 | 5373 |
5374 case PV_AI: return (char_u *)&(curbuf->b_p_ai); | |
5375 case PV_BIN: return (char_u *)&(curbuf->b_p_bin); | |
5376 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); | |
5377 case PV_BH: return (char_u *)&(curbuf->b_p_bh); | |
5378 case PV_BT: return (char_u *)&(curbuf->b_p_bt); | |
5379 case PV_BL: return (char_u *)&(curbuf->b_p_bl); | |
5380 case PV_CI: return (char_u *)&(curbuf->b_p_ci); | |
5381 #ifdef FEAT_CINDENT | |
5382 case PV_CIN: return (char_u *)&(curbuf->b_p_cin); | |
5383 case PV_CINK: return (char_u *)&(curbuf->b_p_cink); | |
5384 case PV_CINO: return (char_u *)&(curbuf->b_p_cino); | |
5385 #endif | |
5386 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) | |
5387 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); | |
5388 #endif | |
5389 #ifdef FEAT_COMMENTS | |
5390 case PV_COM: return (char_u *)&(curbuf->b_p_com); | |
5391 #endif | |
5392 #ifdef FEAT_FOLDING | |
5393 case PV_CMS: return (char_u *)&(curbuf->b_p_cms); | |
5394 #endif | |
5395 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt); | |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17791
diff
changeset
|
5396 #ifdef BACKSLASH_IN_FILENAME |
17543
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
17476
diff
changeset
|
5397 case PV_CSL: return (char_u *)&(curbuf->b_p_csl); |
7 | 5398 #endif |
12 | 5399 #ifdef FEAT_COMPL_FUNC |
5400 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); | |
502 | 5401 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); |
12 | 5402 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5403 #ifdef FEAT_EVAL |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5404 case PV_TFU: return (char_u *)&(curbuf->b_p_tfu); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5405 #endif |
7 | 5406 case PV_EOL: return (char_u *)&(curbuf->b_p_eol); |
6933 | 5407 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol); |
7 | 5408 case PV_ET: return (char_u *)&(curbuf->b_p_et); |
5409 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); | |
5410 case PV_FF: return (char_u *)&(curbuf->b_p_ff); | |
5411 case PV_FT: return (char_u *)&(curbuf->b_p_ft); | |
5412 case PV_FO: return (char_u *)&(curbuf->b_p_fo); | |
41 | 5413 case PV_FLP: return (char_u *)&(curbuf->b_p_flp); |
7 | 5414 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); |
5415 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); | |
5416 case PV_INF: return (char_u *)&(curbuf->b_p_inf); | |
5417 case PV_ISK: return (char_u *)&(curbuf->b_p_isk); | |
5418 #ifdef FEAT_FIND_ID | |
5419 # ifdef FEAT_EVAL | |
5420 case PV_INEX: return (char_u *)&(curbuf->b_p_inex); | |
5421 # endif | |
5422 #endif | |
5423 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
5424 case PV_INDE: return (char_u *)&(curbuf->b_p_inde); | |
5425 case PV_INDK: return (char_u *)&(curbuf->b_p_indk); | |
5426 #endif | |
694 | 5427 #ifdef FEAT_EVAL |
667 | 5428 case PV_FEX: return (char_u *)&(curbuf->b_p_fex); |
5429 #endif | |
7 | 5430 #ifdef FEAT_CRYPT |
5431 case PV_KEY: return (char_u *)&(curbuf->b_p_key); | |
5432 #endif | |
5433 #ifdef FEAT_LISP | |
5434 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp); | |
5435 #endif | |
5436 case PV_ML: return (char_u *)&(curbuf->b_p_ml); | |
5437 case PV_MPS: return (char_u *)&(curbuf->b_p_mps); | |
5438 case PV_MA: return (char_u *)&(curbuf->b_p_ma); | |
5439 case PV_MOD: return (char_u *)&(curbuf->b_changed); | |
5440 case PV_NF: return (char_u *)&(curbuf->b_p_nf); | |
5441 case PV_PI: return (char_u *)&(curbuf->b_p_pi); | |
12 | 5442 #ifdef FEAT_TEXTOBJ |
5443 case PV_QE: return (char_u *)&(curbuf->b_p_qe); | |
5444 #endif | |
7 | 5445 case PV_RO: return (char_u *)&(curbuf->b_p_ro); |
5446 #ifdef FEAT_SMARTINDENT | |
5447 case PV_SI: return (char_u *)&(curbuf->b_p_si); | |
5448 #endif | |
5449 case PV_SN: return (char_u *)&(curbuf->b_p_sn); | |
5450 case PV_STS: return (char_u *)&(curbuf->b_p_sts); | |
5451 #ifdef FEAT_SEARCHPATH | |
5452 case PV_SUA: return (char_u *)&(curbuf->b_p_sua); | |
5453 #endif | |
5454 case PV_SWF: return (char_u *)&(curbuf->b_p_swf); | |
5455 #ifdef FEAT_SYN_HL | |
410 | 5456 case PV_SMC: return (char_u *)&(curbuf->b_p_smc); |
744 | 5457 case PV_SYN: return (char_u *)&(curbuf->b_p_syn); |
5458 #endif | |
5459 #ifdef FEAT_SPELL | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5460 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5461 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5462 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl); |
7 | 5463 #endif |
5464 case PV_SW: return (char_u *)&(curbuf->b_p_sw); | |
5465 case PV_TS: return (char_u *)&(curbuf->b_p_ts); | |
5466 case PV_TW: return (char_u *)&(curbuf->b_p_tw); | |
5467 case PV_TX: return (char_u *)&(curbuf->b_p_tx); | |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
5468 #ifdef FEAT_PERSISTENT_UNDO |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
5469 case PV_UDF: return (char_u *)&(curbuf->b_p_udf); |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
5470 #endif |
7 | 5471 case PV_WM: return (char_u *)&(curbuf->b_p_wm); |
5472 #ifdef FEAT_KEYMAP | |
5473 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); | |
5474 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5475 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5476 case PV_SCL: return (char_u *)&(curwin->w_p_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5477 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5478 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5479 case PV_VSTS: return (char_u *)&(curbuf->b_p_vsts); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5480 case PV_VTS: return (char_u *)&(curbuf->b_p_vts); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5481 #endif |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
5482 default: iemsg(_("E356: get_varp ERROR")); |
7 | 5483 } |
5484 /* always return a valid pointer to avoid a crash! */ | |
5485 return (char_u *)&(curbuf->b_p_wm); | |
5486 } | |
5487 | |
5488 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5489 * Return a pointer to the variable for option at 'opt_idx' |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5490 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5491 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5492 get_option_var(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5493 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5494 return options[opt_idx].var; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5495 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5496 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5497 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5498 * Return the full name of the option at 'opt_idx' |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5499 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5500 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5501 get_option_fullname(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5502 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5503 return (char_u *)options[opt_idx].fullname; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5504 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5505 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5506 /* |
7 | 5507 * Get the value of 'equalprg', either the buffer-local one or the global one. |
5508 */ | |
5509 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5510 get_equalprg(void) |
7 | 5511 { |
5512 if (*curbuf->b_p_ep == NUL) | |
5513 return p_ep; | |
5514 return curbuf->b_p_ep; | |
5515 } | |
5516 | |
5517 /* | |
5518 * Copy options from one window to another. | |
5519 * Used when splitting a window. | |
5520 */ | |
5521 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5522 win_copy_options(win_T *wp_from, win_T *wp_to) |
7 | 5523 { |
5524 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); | |
5525 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt); | |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5526 after_copy_winopt(wp_to); |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5527 } |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5528 |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5529 /* |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5530 * After copying window options: update variables depending on options. |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5531 */ |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5532 void |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5533 after_copy_winopt(win_T *wp) |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5534 { |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5535 #ifdef FEAT_LINEBREAK |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5536 briopt_check(wp); |
6162 | 5537 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
5538 #ifdef FEAT_SYN_HL |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5539 fill_culopt_flags(NULL, wp); |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5540 check_colorcolumn(wp); |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
5541 #endif |
7 | 5542 } |
5543 | |
5544 /* | |
5545 * Copy the options from one winopt_T to another. | |
5546 * Doesn't free the old option values in "to", use clear_winopt() for that. | |
5547 * The 'scroll' option is not copied, because it depends on the window height. | |
5548 * The 'previewwindow' option is reset, there can be only one preview window. | |
5549 */ | |
5550 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5551 copy_winopt(winopt_T *from, winopt_T *to) |
7 | 5552 { |
5553 #ifdef FEAT_ARABIC | |
5554 to->wo_arab = from->wo_arab; | |
5555 #endif | |
5556 to->wo_list = from->wo_list; | |
5557 to->wo_nu = from->wo_nu; | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
5558 to->wo_rnu = from->wo_rnu; |
13 | 5559 #ifdef FEAT_LINEBREAK |
5560 to->wo_nuw = from->wo_nuw; | |
5561 #endif | |
7 | 5562 #ifdef FEAT_RIGHTLEFT |
5563 to->wo_rl = from->wo_rl; | |
5564 to->wo_rlc = vim_strsave(from->wo_rlc); | |
5565 #endif | |
40 | 5566 #ifdef FEAT_STL_OPT |
5567 to->wo_stl = vim_strsave(from->wo_stl); | |
5568 #endif | |
7 | 5569 to->wo_wrap = from->wo_wrap; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5570 #ifdef FEAT_DIFF |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5571 to->wo_wrap_save = from->wo_wrap_save; |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5572 #endif |
7 | 5573 #ifdef FEAT_LINEBREAK |
5574 to->wo_lbr = from->wo_lbr; | |
5995 | 5575 to->wo_bri = from->wo_bri; |
5576 to->wo_briopt = vim_strsave(from->wo_briopt); | |
7 | 5577 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5578 to->wo_wcr = vim_strsave(from->wo_wcr); |
7 | 5579 to->wo_scb = from->wo_scb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5580 to->wo_scb_save = from->wo_scb_save; |
2651 | 5581 to->wo_crb = from->wo_crb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5582 to->wo_crb_save = from->wo_crb_save; |
744 | 5583 #ifdef FEAT_SPELL |
5584 to->wo_spell = from->wo_spell; | |
5585 #endif | |
221 | 5586 #ifdef FEAT_SYN_HL |
744 | 5587 to->wo_cuc = from->wo_cuc; |
5588 to->wo_cul = from->wo_cul; | |
18047
6650e3dff8d4
patch 8.1.2019: 'cursorline' always highlights the whole line
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
5589 to->wo_culopt = vim_strsave(from->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5590 to->wo_cc = vim_strsave(from->wo_cc); |
221 | 5591 #endif |
7 | 5592 #ifdef FEAT_DIFF |
5593 to->wo_diff = from->wo_diff; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5594 to->wo_diff_saved = from->wo_diff_saved; |
7 | 5595 #endif |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
5596 #ifdef FEAT_CONCEAL |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
5597 to->wo_cocu = vim_strsave(from->wo_cocu); |
2379
b67b0b5a93d3
Window split didn't copy the value of 'conceallevel'.
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
5598 to->wo_cole = from->wo_cole; |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
5599 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5600 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5601 to->wo_twk = vim_strsave(from->wo_twk); |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5602 to->wo_tws = vim_strsave(from->wo_tws); |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5603 #endif |
7 | 5604 #ifdef FEAT_FOLDING |
5605 to->wo_fdc = from->wo_fdc; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5606 to->wo_fdc_save = from->wo_fdc_save; |
7 | 5607 to->wo_fen = from->wo_fen; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5608 to->wo_fen_save = from->wo_fen_save; |
7 | 5609 to->wo_fdi = vim_strsave(from->wo_fdi); |
5610 to->wo_fml = from->wo_fml; | |
5611 to->wo_fdl = from->wo_fdl; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5612 to->wo_fdl_save = from->wo_fdl_save; |
7 | 5613 to->wo_fdm = vim_strsave(from->wo_fdm); |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5614 to->wo_fdm_save = from->wo_diff_saved |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5615 ? vim_strsave(from->wo_fdm_save) : empty_option; |
7 | 5616 to->wo_fdn = from->wo_fdn; |
5617 # ifdef FEAT_EVAL | |
5618 to->wo_fde = vim_strsave(from->wo_fde); | |
5619 to->wo_fdt = vim_strsave(from->wo_fdt); | |
5620 # endif | |
5621 to->wo_fmr = vim_strsave(from->wo_fmr); | |
5622 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5623 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5624 to->wo_scl = vim_strsave(from->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5625 #endif |
7 | 5626 check_winopt(to); /* don't want NULL pointers */ |
5627 } | |
5628 | |
5629 /* | |
5630 * Check string options in a window for a NULL value. | |
5631 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
5632 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5633 check_win_options(win_T *win) |
7 | 5634 { |
5635 check_winopt(&win->w_onebuf_opt); | |
5636 check_winopt(&win->w_allbuf_opt); | |
5637 } | |
5638 | |
5639 /* | |
5640 * Check for NULL pointers in a winopt_T and replace them with empty_option. | |
5641 */ | |
5997 | 5642 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5643 check_winopt(winopt_T *wop UNUSED) |
7 | 5644 { |
5645 #ifdef FEAT_FOLDING | |
5646 check_string_option(&wop->wo_fdi); | |
5647 check_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5648 check_string_option(&wop->wo_fdm_save); |
7 | 5649 # ifdef FEAT_EVAL |
5650 check_string_option(&wop->wo_fde); | |
5651 check_string_option(&wop->wo_fdt); | |
5652 # endif | |
5653 check_string_option(&wop->wo_fmr); | |
5654 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5655 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5656 check_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5657 #endif |
7 | 5658 #ifdef FEAT_RIGHTLEFT |
5659 check_string_option(&wop->wo_rlc); | |
5660 #endif | |
40 | 5661 #ifdef FEAT_STL_OPT |
5662 check_string_option(&wop->wo_stl); | |
5663 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5664 #ifdef FEAT_SYN_HL |
18047
6650e3dff8d4
patch 8.1.2019: 'cursorline' always highlights the whole line
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
5665 check_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5666 check_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5667 #endif |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
5668 #ifdef FEAT_CONCEAL |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
5669 check_string_option(&wop->wo_cocu); |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
5670 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5671 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5672 check_string_option(&wop->wo_twk); |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5673 check_string_option(&wop->wo_tws); |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5674 #endif |
5995 | 5675 #ifdef FEAT_LINEBREAK |
5676 check_string_option(&wop->wo_briopt); | |
5677 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5678 check_string_option(&wop->wo_wcr); |
7 | 5679 } |
5680 | |
5681 /* | |
5682 * Free the allocated memory inside a winopt_T. | |
5683 */ | |
5684 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5685 clear_winopt(winopt_T *wop UNUSED) |
7 | 5686 { |
5687 #ifdef FEAT_FOLDING | |
5688 clear_string_option(&wop->wo_fdi); | |
5689 clear_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5690 clear_string_option(&wop->wo_fdm_save); |
7 | 5691 # ifdef FEAT_EVAL |
5692 clear_string_option(&wop->wo_fde); | |
5693 clear_string_option(&wop->wo_fdt); | |
5694 # endif | |
5695 clear_string_option(&wop->wo_fmr); | |
5696 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5697 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5698 clear_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5699 #endif |
5995 | 5700 #ifdef FEAT_LINEBREAK |
5701 clear_string_option(&wop->wo_briopt); | |
5702 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5703 clear_string_option(&wop->wo_wcr); |
7 | 5704 #ifdef FEAT_RIGHTLEFT |
5705 clear_string_option(&wop->wo_rlc); | |
5706 #endif | |
40 | 5707 #ifdef FEAT_STL_OPT |
5708 clear_string_option(&wop->wo_stl); | |
5709 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5710 #ifdef FEAT_SYN_HL |
18047
6650e3dff8d4
patch 8.1.2019: 'cursorline' always highlights the whole line
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
5711 clear_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5712 clear_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5713 #endif |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
5714 #ifdef FEAT_CONCEAL |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
5715 clear_string_option(&wop->wo_cocu); |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
5716 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5717 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5718 clear_string_option(&wop->wo_twk); |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5719 clear_string_option(&wop->wo_tws); |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5720 #endif |
7 | 5721 } |
5722 | |
5723 /* | |
5724 * Copy global option values to local options for one buffer. | |
5725 * Used when creating a new buffer and sometimes when entering a buffer. | |
5726 * flags: | |
5727 * BCO_ENTER We will enter the buf buffer. | |
5728 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when | |
5729 * appropriate. | |
5730 * BCO_NOHELP Don't copy the values to a help buffer. | |
5731 */ | |
5732 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5733 buf_copy_options(buf_T *buf, int flags) |
7 | 5734 { |
5735 int should_copy = TRUE; | |
5736 char_u *save_p_isk = NULL; /* init for GCC */ | |
5737 int dont_do_help; | |
5738 int did_isk = FALSE; | |
5739 | |
5740 /* | |
5741 * Skip this when the option defaults have not been set yet. Happens when | |
5742 * main() allocates the first buffer. | |
5743 */ | |
5744 if (p_cpo != NULL) | |
5745 { | |
5746 /* | |
5747 * Always copy when entering and 'cpo' contains 'S'. | |
5748 * Don't copy when already initialized. | |
5749 * Don't copy when 'cpo' contains 's' and not entering. | |
5750 * 'S' BCO_ENTER initialized 's' should_copy | |
5751 * yes yes X X TRUE | |
5752 * yes no yes X FALSE | |
5753 * no X yes X FALSE | |
5754 * X no no yes FALSE | |
5755 * X no no no TRUE | |
5756 * no yes no X TRUE | |
5757 */ | |
5758 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) | |
5759 && (buf->b_p_initialized | |
5760 || (!(flags & BCO_ENTER) | |
5761 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
5762 should_copy = FALSE; | |
5763 | |
5764 if (should_copy || (flags & BCO_ALWAYS)) | |
5765 { | |
5766 /* Don't copy the options specific to a help buffer when | |
5767 * BCO_NOHELP is given or the options were initialized already | |
5768 * (jumping back to a help file with CTRL-T or CTRL-O) */ | |
5769 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) | |
5770 || buf->b_p_initialized; | |
5771 if (dont_do_help) /* don't free b_p_isk */ | |
5772 { | |
5773 save_p_isk = buf->b_p_isk; | |
5774 buf->b_p_isk = NULL; | |
5775 } | |
5776 /* | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14381
diff
changeset
|
5777 * Always free the allocated strings. If not already initialized, |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14381
diff
changeset
|
5778 * reset 'readonly' and copy 'fileformat'. |
7 | 5779 */ |
5780 if (!buf->b_p_initialized) | |
5781 { | |
5782 free_buf_options(buf, TRUE); | |
5783 buf->b_p_ro = FALSE; /* don't copy readonly */ | |
5784 buf->b_p_tx = p_tx; | |
5785 buf->b_p_fenc = vim_strsave(p_fenc); | |
10268
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5786 switch (*p_ffs) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5787 { |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5788 case 'm': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5789 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break; |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5790 case 'd': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5791 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break; |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5792 case 'u': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5793 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break; |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5794 default: |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5795 buf->b_p_ff = vim_strsave(p_ff); |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5796 } |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5797 if (buf->b_p_ff != NULL) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5798 buf->b_start_ffc = *buf->b_p_ff; |
7 | 5799 buf->b_p_bh = empty_option; |
5800 buf->b_p_bt = empty_option; | |
5801 } | |
5802 else | |
5803 free_buf_options(buf, FALSE); | |
5804 | |
5805 buf->b_p_ai = p_ai; | |
5806 buf->b_p_ai_nopaste = p_ai_nopaste; | |
5807 buf->b_p_sw = p_sw; | |
5808 buf->b_p_tw = p_tw; | |
5809 buf->b_p_tw_nopaste = p_tw_nopaste; | |
5810 buf->b_p_tw_nobin = p_tw_nobin; | |
5811 buf->b_p_wm = p_wm; | |
5812 buf->b_p_wm_nopaste = p_wm_nopaste; | |
5813 buf->b_p_wm_nobin = p_wm_nobin; | |
5814 buf->b_p_bin = p_bin; | |
402 | 5815 buf->b_p_bomb = p_bomb; |
6954 | 5816 buf->b_p_fixeol = p_fixeol; |
7 | 5817 buf->b_p_et = p_et; |
5818 buf->b_p_et_nobin = p_et_nobin; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
5819 buf->b_p_et_nopaste = p_et_nopaste; |
7 | 5820 buf->b_p_ml = p_ml; |
5821 buf->b_p_ml_nobin = p_ml_nobin; | |
5822 buf->b_p_inf = p_inf; | |
11321
f57dce6b934b
patch 8.0.0546: swap file exists briefly when opening the command window
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
5823 buf->b_p_swf = cmdmod.noswapfile ? FALSE : p_swf; |
7 | 5824 buf->b_p_cpt = vim_strsave(p_cpt); |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17791
diff
changeset
|
5825 #ifdef BACKSLASH_IN_FILENAME |
17543
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
17476
diff
changeset
|
5826 buf->b_p_csl = vim_strsave(p_csl); |
7 | 5827 #endif |
12 | 5828 #ifdef FEAT_COMPL_FUNC |
5829 buf->b_p_cfu = vim_strsave(p_cfu); | |
502 | 5830 buf->b_p_ofu = vim_strsave(p_ofu); |
12 | 5831 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5832 #ifdef FEAT_EVAL |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5833 buf->b_p_tfu = vim_strsave(p_tfu); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5834 #endif |
7 | 5835 buf->b_p_sts = p_sts; |
5836 buf->b_p_sts_nopaste = p_sts_nopaste; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5837 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5838 buf->b_p_vsts = vim_strsave(p_vsts); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5839 if (p_vsts && p_vsts != empty_option) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5840 tabstop_set(p_vsts, &buf->b_p_vsts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5841 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5842 buf->b_p_vsts_array = 0; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5843 buf->b_p_vsts_nopaste = p_vsts_nopaste |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5844 ? vim_strsave(p_vsts_nopaste) : NULL; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5845 #endif |
7 | 5846 buf->b_p_sn = p_sn; |
5847 #ifdef FEAT_COMMENTS | |
5848 buf->b_p_com = vim_strsave(p_com); | |
5849 #endif | |
5850 #ifdef FEAT_FOLDING | |
5851 buf->b_p_cms = vim_strsave(p_cms); | |
5852 #endif | |
5853 buf->b_p_fo = vim_strsave(p_fo); | |
41 | 5854 buf->b_p_flp = vim_strsave(p_flp); |
7 | 5855 buf->b_p_nf = vim_strsave(p_nf); |
5856 buf->b_p_mps = vim_strsave(p_mps); | |
5857 #ifdef FEAT_SMARTINDENT | |
5858 buf->b_p_si = p_si; | |
5859 #endif | |
5860 buf->b_p_ci = p_ci; | |
5861 #ifdef FEAT_CINDENT | |
5862 buf->b_p_cin = p_cin; | |
5863 buf->b_p_cink = vim_strsave(p_cink); | |
5864 buf->b_p_cino = vim_strsave(p_cino); | |
5865 #endif | |
5866 /* Don't copy 'filetype', it must be detected */ | |
5867 buf->b_p_ft = empty_option; | |
5868 buf->b_p_pi = p_pi; | |
5869 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) | |
5870 buf->b_p_cinw = vim_strsave(p_cinw); | |
5871 #endif | |
5872 #ifdef FEAT_LISP | |
5873 buf->b_p_lisp = p_lisp; | |
5874 #endif | |
5875 #ifdef FEAT_SYN_HL | |
5876 /* Don't copy 'syntax', it must be set */ | |
5877 buf->b_p_syn = empty_option; | |
410 | 5878 buf->b_p_smc = p_smc; |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7538
diff
changeset
|
5879 buf->b_s.b_syn_isk = empty_option; |
744 | 5880 #endif |
5881 #ifdef FEAT_SPELL | |
2599 | 5882 buf->b_s.b_p_spc = vim_strsave(p_spc); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5883 (void)compile_cap_prog(&buf->b_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5884 buf->b_s.b_p_spf = vim_strsave(p_spf); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5885 buf->b_s.b_p_spl = vim_strsave(p_spl); |
7 | 5886 #endif |
5887 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
5888 buf->b_p_inde = vim_strsave(p_inde); | |
5889 buf->b_p_indk = vim_strsave(p_indk); | |
5890 #endif | |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5891 buf->b_p_fp = empty_option; |
667 | 5892 #if defined(FEAT_EVAL) |
5893 buf->b_p_fex = vim_strsave(p_fex); | |
5894 #endif | |
7 | 5895 #ifdef FEAT_CRYPT |
5896 buf->b_p_key = vim_strsave(p_key); | |
5897 #endif | |
5898 #ifdef FEAT_SEARCHPATH | |
5899 buf->b_p_sua = vim_strsave(p_sua); | |
5900 #endif | |
5901 #ifdef FEAT_KEYMAP | |
5902 buf->b_p_keymap = vim_strsave(p_keymap); | |
5903 buf->b_kmap_state |= KEYMAP_INIT; | |
5904 #endif | |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5905 #ifdef FEAT_TERMINAL |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5906 buf->b_p_twsl = p_twsl; |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5907 #endif |
7 | 5908 /* This isn't really an option, but copying the langmap and IME |
5909 * state from the current buffer is better than resetting it. */ | |
5910 buf->b_p_iminsert = p_iminsert; | |
5911 buf->b_p_imsearch = p_imsearch; | |
5912 | |
5913 /* options that are normally global but also have a local value | |
5914 * are not copied, start using the global value */ | |
5915 buf->b_p_ar = -1; | |
5446 | 5916 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
6243 | 5917 buf->b_p_bkc = empty_option; |
5918 buf->b_bkc_flags = 0; | |
7 | 5919 #ifdef FEAT_QUICKFIX |
5920 buf->b_p_gp = empty_option; | |
5921 buf->b_p_mp = empty_option; | |
5922 buf->b_p_efm = empty_option; | |
5923 #endif | |
5924 buf->b_p_ep = empty_option; | |
5925 buf->b_p_kp = empty_option; | |
5926 buf->b_p_path = empty_option; | |
5927 buf->b_p_tags = empty_option; | |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5928 buf->b_p_tc = empty_option; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5929 buf->b_tc_flags = 0; |
7 | 5930 #ifdef FEAT_FIND_ID |
5931 buf->b_p_def = empty_option; | |
5932 buf->b_p_inc = empty_option; | |
5933 # ifdef FEAT_EVAL | |
5934 buf->b_p_inex = vim_strsave(p_inex); | |
5935 # endif | |
5936 #endif | |
5937 buf->b_p_dict = empty_option; | |
5938 buf->b_p_tsr = empty_option; | |
12 | 5939 #ifdef FEAT_TEXTOBJ |
5940 buf->b_p_qe = vim_strsave(p_qe); | |
5941 #endif | |
790 | 5942 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5943 buf->b_p_bexpr = empty_option; | |
5944 #endif | |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5945 #if defined(FEAT_CRYPT) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5946 buf->b_p_cm = empty_option; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5947 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
5948 #ifdef FEAT_PERSISTENT_UNDO |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
5949 buf->b_p_udf = p_udf; |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
5950 #endif |
5712 | 5951 #ifdef FEAT_LISP |
5952 buf->b_p_lw = empty_option; | |
5953 #endif | |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
5954 buf->b_p_menc = empty_option; |
7 | 5955 |
5956 /* | |
5957 * Don't copy the options set by ex_help(), use the saved values, | |
5958 * when going from a help buffer to a non-help buffer. | |
5959 * Don't touch these at all when BCO_NOHELP is used and going from | |
5960 * or to a help buffer. | |
5961 */ | |
5962 if (dont_do_help) | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5963 { |
7 | 5964 buf->b_p_isk = save_p_isk; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5965 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5966 if (p_vts && p_vts != empty_option && !buf->b_p_vts_array) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5967 tabstop_set(p_vts, &buf->b_p_vts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5968 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5969 buf->b_p_vts_array = NULL; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5970 #endif |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5971 } |
7 | 5972 else |
5973 { | |
5974 buf->b_p_isk = vim_strsave(p_isk); | |
5975 did_isk = TRUE; | |
5976 buf->b_p_ts = p_ts; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5977 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5978 buf->b_p_vts = vim_strsave(p_vts); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5979 if (p_vts && p_vts != empty_option && !buf->b_p_vts_array) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5980 tabstop_set(p_vts, &buf->b_p_vts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5981 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5982 buf->b_p_vts_array = NULL; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5983 #endif |
7 | 5984 buf->b_help = FALSE; |
5985 if (buf->b_p_bt[0] == 'h') | |
5986 clear_string_option(&buf->b_p_bt); | |
5987 buf->b_p_ma = p_ma; | |
5988 } | |
5989 } | |
5990 | |
5991 /* | |
5992 * When the options should be copied (ignoring BCO_ALWAYS), set the | |
5993 * flag that indicates that the options have been initialized. | |
5994 */ | |
5995 if (should_copy) | |
5996 buf->b_p_initialized = TRUE; | |
5997 } | |
5998 | |
5999 check_buf_options(buf); /* make sure we don't have NULLs */ | |
6000 if (did_isk) | |
6001 (void)buf_init_chartab(buf, FALSE); | |
6002 } | |
6003 | |
6004 /* | |
6005 * Reset the 'modifiable' option and its default value. | |
6006 */ | |
6007 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6008 reset_modifiable(void) |
7 | 6009 { |
6010 int opt_idx; | |
6011 | |
6012 curbuf->b_p_ma = FALSE; | |
6013 p_ma = FALSE; | |
6014 opt_idx = findoption((char_u *)"ma"); | |
838 | 6015 if (opt_idx >= 0) |
6016 options[opt_idx].def_val[VI_DEFAULT] = FALSE; | |
7 | 6017 } |
6018 | |
6019 /* | |
6020 * Set the global value for 'iminsert' to the local value. | |
6021 */ | |
6022 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6023 set_iminsert_global(void) |
7 | 6024 { |
6025 p_iminsert = curbuf->b_p_iminsert; | |
6026 } | |
6027 | |
6028 /* | |
6029 * Set the global value for 'imsearch' to the local value. | |
6030 */ | |
6031 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6032 set_imsearch_global(void) |
7 | 6033 { |
6034 p_imsearch = curbuf->b_p_imsearch; | |
6035 } | |
6036 | |
6037 static int expand_option_idx = -1; | |
6038 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; | |
6039 static int expand_option_flags = 0; | |
6040 | |
6041 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6042 set_context_in_set_cmd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6043 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6044 char_u *arg, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6045 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */ |
7 | 6046 { |
6047 int nextchar; | |
6048 long_u flags = 0; /* init for GCC */ | |
6049 int opt_idx = 0; /* init for GCC */ | |
6050 char_u *p; | |
6051 char_u *s; | |
6052 int is_term_option = FALSE; | |
6053 int key; | |
6054 | |
6055 expand_option_flags = opt_flags; | |
6056 | |
6057 xp->xp_context = EXPAND_SETTINGS; | |
6058 if (*arg == NUL) | |
6059 { | |
6060 xp->xp_pattern = arg; | |
6061 return; | |
6062 } | |
6063 p = arg + STRLEN(arg) - 1; | |
6064 if (*p == ' ' && *(p - 1) != '\\') | |
6065 { | |
6066 xp->xp_pattern = p + 1; | |
6067 return; | |
6068 } | |
6069 while (p > arg) | |
6070 { | |
6071 s = p; | |
6072 /* count number of backslashes before ' ' or ',' */ | |
6073 if (*p == ' ' || *p == ',') | |
6074 { | |
6075 while (s > arg && *(s - 1) == '\\') | |
6076 --s; | |
6077 } | |
6078 /* break at a space with an even number of backslashes */ | |
6079 if (*p == ' ' && ((p - s) & 1) == 0) | |
6080 { | |
6081 ++p; | |
6082 break; | |
6083 } | |
6084 --p; | |
6085 } | |
1911 | 6086 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0) |
7 | 6087 { |
6088 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
6089 p += 2; | |
6090 } | |
6091 if (STRNCMP(p, "inv", 3) == 0) | |
6092 { | |
6093 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
6094 p += 3; | |
6095 } | |
6096 xp->xp_pattern = arg = p; | |
6097 if (*arg == '<') | |
6098 { | |
6099 while (*p != '>') | |
6100 if (*p++ == NUL) /* expand terminal option name */ | |
6101 return; | |
6102 key = get_special_key_code(arg + 1); | |
6103 if (key == 0) /* unknown name */ | |
6104 { | |
6105 xp->xp_context = EXPAND_NOTHING; | |
6106 return; | |
6107 } | |
6108 nextchar = *++p; | |
6109 is_term_option = TRUE; | |
6110 expand_option_name[2] = KEY2TERMCAP0(key); | |
6111 expand_option_name[3] = KEY2TERMCAP1(key); | |
6112 } | |
6113 else | |
6114 { | |
6115 if (p[0] == 't' && p[1] == '_') | |
6116 { | |
6117 p += 2; | |
6118 if (*p != NUL) | |
6119 ++p; | |
6120 if (*p == NUL) | |
6121 return; /* expand option name */ | |
6122 nextchar = *++p; | |
6123 is_term_option = TRUE; | |
6124 expand_option_name[2] = p[-2]; | |
6125 expand_option_name[3] = p[-1]; | |
6126 } | |
6127 else | |
6128 { | |
6129 /* Allow * wildcard */ | |
6130 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') | |
6131 p++; | |
6132 if (*p == NUL) | |
6133 return; | |
6134 nextchar = *p; | |
6135 *p = NUL; | |
6136 opt_idx = findoption(arg); | |
6137 *p = nextchar; | |
6138 if (opt_idx == -1 || options[opt_idx].var == NULL) | |
6139 { | |
6140 xp->xp_context = EXPAND_NOTHING; | |
6141 return; | |
6142 } | |
6143 flags = options[opt_idx].flags; | |
6144 if (flags & P_BOOL) | |
6145 { | |
6146 xp->xp_context = EXPAND_NOTHING; | |
6147 return; | |
6148 } | |
6149 } | |
6150 } | |
6151 /* handle "-=" and "+=" */ | |
6152 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') | |
6153 { | |
6154 ++p; | |
6155 nextchar = '='; | |
6156 } | |
6157 if ((nextchar != '=' && nextchar != ':') | |
6158 || xp->xp_context == EXPAND_BOOL_SETTINGS) | |
6159 { | |
6160 xp->xp_context = EXPAND_UNSUCCESSFUL; | |
6161 return; | |
6162 } | |
6163 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) | |
6164 { | |
6165 xp->xp_context = EXPAND_OLD_SETTING; | |
6166 if (is_term_option) | |
6167 expand_option_idx = -1; | |
6168 else | |
6169 expand_option_idx = opt_idx; | |
6170 xp->xp_pattern = p + 1; | |
6171 return; | |
6172 } | |
6173 xp->xp_context = EXPAND_NOTHING; | |
6174 if (is_term_option || (flags & P_NUM)) | |
6175 return; | |
6176 | |
6177 xp->xp_pattern = p + 1; | |
6178 | |
6179 if (flags & P_EXPAND) | |
6180 { | |
6181 p = options[opt_idx].var; | |
6182 if (p == (char_u *)&p_bdir | |
6183 || p == (char_u *)&p_dir | |
6184 || p == (char_u *)&p_path | |
8182
95d59081580f
commit https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
6185 || p == (char_u *)&p_pp |
7 | 6186 || p == (char_u *)&p_rtp |
6187 #ifdef FEAT_SEARCHPATH | |
6188 || p == (char_u *)&p_cdpath | |
6189 #endif | |
6190 #ifdef FEAT_SESSION | |
6191 || p == (char_u *)&p_vdir | |
6192 #endif | |
6193 ) | |
6194 { | |
6195 xp->xp_context = EXPAND_DIRECTORIES; | |
6196 if (p == (char_u *)&p_path | |
6197 #ifdef FEAT_SEARCHPATH | |
6198 || p == (char_u *)&p_cdpath | |
6199 #endif | |
6200 ) | |
6201 xp->xp_backslash = XP_BS_THREE; | |
6202 else | |
6203 xp->xp_backslash = XP_BS_ONE; | |
6204 } | |
6205 else | |
6206 { | |
6207 xp->xp_context = EXPAND_FILES; | |
6208 /* for 'tags' need three backslashes for a space */ | |
6209 if (p == (char_u *)&p_tags) | |
6210 xp->xp_backslash = XP_BS_THREE; | |
6211 else | |
6212 xp->xp_backslash = XP_BS_ONE; | |
6213 } | |
6214 } | |
6215 | |
6216 /* For an option that is a list of file names, find the start of the | |
6217 * last file name. */ | |
6218 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) | |
6219 { | |
6220 /* count number of backslashes before ' ' or ',' */ | |
6221 if (*p == ' ' || *p == ',') | |
6222 { | |
6223 s = p; | |
6224 while (s > xp->xp_pattern && *(s - 1) == '\\') | |
6225 --s; | |
6226 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) | |
6227 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) | |
6228 { | |
6229 xp->xp_pattern = p + 1; | |
6230 break; | |
6231 } | |
6232 } | |
374 | 6233 |
744 | 6234 #ifdef FEAT_SPELL |
374 | 6235 /* for 'spellsuggest' start at "file:" */ |
6236 if (options[opt_idx].var == (char_u *)&p_sps | |
6237 && STRNCMP(p, "file:", 5) == 0) | |
6238 { | |
6239 xp->xp_pattern = p + 5; | |
6240 break; | |
6241 } | |
6242 #endif | |
7 | 6243 } |
6244 | |
6245 return; | |
6246 } | |
6247 | |
6248 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6249 ExpandSettings( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6250 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6251 regmatch_T *regmatch, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6252 int *num_file, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6253 char_u ***file) |
7 | 6254 { |
6255 int num_normal = 0; /* Nr of matching non-term-code settings */ | |
6256 int num_term = 0; /* Nr of matching terminal code settings */ | |
6257 int opt_idx; | |
6258 int match; | |
6259 int count = 0; | |
6260 char_u *str; | |
6261 int loop; | |
6262 int is_term_opt; | |
6263 char_u name_buf[MAX_KEY_NAME_LEN]; | |
6264 static char *(names[]) = {"all", "termcap"}; | |
6265 int ic = regmatch->rm_ic; /* remember the ignore-case flag */ | |
6266 | |
6267 /* do this loop twice: | |
6268 * loop == 0: count the number of matching options | |
6269 * loop == 1: copy the matching options into allocated memory | |
6270 */ | |
6271 for (loop = 0; loop <= 1; ++loop) | |
6272 { | |
6273 regmatch->rm_ic = ic; | |
6274 if (xp->xp_context != EXPAND_BOOL_SETTINGS) | |
6275 { | |
1883 | 6276 for (match = 0; match < (int)(sizeof(names) / sizeof(char *)); |
6277 ++match) | |
7 | 6278 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0)) |
6279 { | |
6280 if (loop == 0) | |
6281 num_normal++; | |
6282 else | |
6283 (*file)[count++] = vim_strsave((char_u *)names[match]); | |
6284 } | |
6285 } | |
6286 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; | |
6287 opt_idx++) | |
6288 { | |
6289 if (options[opt_idx].var == NULL) | |
6290 continue; | |
6291 if (xp->xp_context == EXPAND_BOOL_SETTINGS | |
6292 && !(options[opt_idx].flags & P_BOOL)) | |
6293 continue; | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6294 is_term_opt = istermoption_idx(opt_idx); |
7 | 6295 if (is_term_opt && num_normal > 0) |
6296 continue; | |
6297 match = FALSE; | |
6298 if (vim_regexec(regmatch, str, (colnr_T)0) | |
6299 || (options[opt_idx].shortname != NULL | |
6300 && vim_regexec(regmatch, | |
6301 (char_u *)options[opt_idx].shortname, (colnr_T)0))) | |
6302 match = TRUE; | |
6303 else if (is_term_opt) | |
6304 { | |
6305 name_buf[0] = '<'; | |
6306 name_buf[1] = 't'; | |
6307 name_buf[2] = '_'; | |
6308 name_buf[3] = str[2]; | |
6309 name_buf[4] = str[3]; | |
6310 name_buf[5] = '>'; | |
6311 name_buf[6] = NUL; | |
6312 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6313 { | |
6314 match = TRUE; | |
6315 str = name_buf; | |
6316 } | |
6317 } | |
6318 if (match) | |
6319 { | |
6320 if (loop == 0) | |
6321 { | |
6322 if (is_term_opt) | |
6323 num_term++; | |
6324 else | |
6325 num_normal++; | |
6326 } | |
6327 else | |
6328 (*file)[count++] = vim_strsave(str); | |
6329 } | |
6330 } | |
6331 /* | |
6332 * Check terminal key codes, these are not in the option table | |
6333 */ | |
6334 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) | |
6335 { | |
6336 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) | |
6337 { | |
6338 if (!isprint(str[0]) || !isprint(str[1])) | |
6339 continue; | |
6340 | |
6341 name_buf[0] = 't'; | |
6342 name_buf[1] = '_'; | |
6343 name_buf[2] = str[0]; | |
6344 name_buf[3] = str[1]; | |
6345 name_buf[4] = NUL; | |
6346 | |
6347 match = FALSE; | |
6348 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6349 match = TRUE; | |
6350 else | |
6351 { | |
6352 name_buf[0] = '<'; | |
6353 name_buf[1] = 't'; | |
6354 name_buf[2] = '_'; | |
6355 name_buf[3] = str[0]; | |
6356 name_buf[4] = str[1]; | |
6357 name_buf[5] = '>'; | |
6358 name_buf[6] = NUL; | |
6359 | |
6360 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6361 match = TRUE; | |
6362 } | |
6363 if (match) | |
6364 { | |
6365 if (loop == 0) | |
6366 num_term++; | |
6367 else | |
6368 (*file)[count++] = vim_strsave(name_buf); | |
6369 } | |
6370 } | |
6371 | |
6372 /* | |
6373 * Check special key names. | |
6374 */ | |
6375 regmatch->rm_ic = TRUE; /* ignore case here */ | |
6376 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) | |
6377 { | |
6378 name_buf[0] = '<'; | |
6379 STRCPY(name_buf + 1, str); | |
6380 STRCAT(name_buf, ">"); | |
6381 | |
6382 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6383 { | |
6384 if (loop == 0) | |
6385 num_term++; | |
6386 else | |
6387 (*file)[count++] = vim_strsave(name_buf); | |
6388 } | |
6389 } | |
6390 } | |
6391 if (loop == 0) | |
6392 { | |
6393 if (num_normal > 0) | |
6394 *num_file = num_normal; | |
6395 else if (num_term > 0) | |
6396 *num_file = num_term; | |
6397 else | |
6398 return OK; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16806
diff
changeset
|
6399 *file = ALLOC_MULT(char_u *, *num_file); |
7 | 6400 if (*file == NULL) |
6401 { | |
6402 *file = (char_u **)""; | |
6403 return FAIL; | |
6404 } | |
6405 } | |
6406 } | |
6407 return OK; | |
6408 } | |
6409 | |
6410 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6411 ExpandOldSetting(int *num_file, char_u ***file) |
7 | 6412 { |
6413 char_u *var = NULL; /* init for GCC */ | |
6414 char_u *buf; | |
6415 | |
6416 *num_file = 0; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16806
diff
changeset
|
6417 *file = ALLOC_ONE(char_u *); |
7 | 6418 if (*file == NULL) |
6419 return FAIL; | |
6420 | |
6421 /* | |
6422 * For a terminal key code expand_option_idx is < 0. | |
6423 */ | |
6424 if (expand_option_idx < 0) | |
6425 { | |
6426 var = find_termcode(expand_option_name + 2); | |
6427 if (var == NULL) | |
6428 expand_option_idx = findoption(expand_option_name); | |
6429 } | |
6430 | |
6431 if (expand_option_idx >= 0) | |
6432 { | |
6433 /* put string of option value in NameBuff */ | |
6434 option_value2string(&options[expand_option_idx], expand_option_flags); | |
6435 var = NameBuff; | |
6436 } | |
6437 else if (var == NULL) | |
6438 var = (char_u *)""; | |
6439 | |
6440 /* A backslash is required before some characters. This is the reverse of | |
6441 * what happens in do_set(). */ | |
6442 buf = vim_strsave_escaped(var, escape_chars); | |
6443 | |
6444 if (buf == NULL) | |
6445 { | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13242
diff
changeset
|
6446 VIM_CLEAR(*file); |
7 | 6447 return FAIL; |
6448 } | |
6449 | |
6450 #ifdef BACKSLASH_IN_FILENAME | |
6451 /* For MS-Windows et al. we don't double backslashes at the start and | |
6452 * before a file name character. */ | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
6453 for (var = buf; *var != NUL; MB_PTR_ADV(var)) |
7 | 6454 if (var[0] == '\\' && var[1] == '\\' |
6455 && expand_option_idx >= 0 | |
6456 && (options[expand_option_idx].flags & P_EXPAND) | |
6457 && vim_isfilec(var[2]) | |
6458 && (var[2] != '\\' || (var == buf && var[4] != '\\'))) | |
1622 | 6459 STRMOVE(var, var + 1); |
7 | 6460 #endif |
6461 | |
6462 *file[0] = buf; | |
6463 *num_file = 1; | |
6464 return OK; | |
6465 } | |
6466 | |
6467 /* | |
6468 * Get the value for the numeric or string option *opp in a nice format into | |
6469 * NameBuff[]. Must not be called with a hidden option! | |
6470 */ | |
6471 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6472 option_value2string( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6473 struct vimoption *opp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6474 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */ |
7 | 6475 { |
6476 char_u *varp; | |
6477 | |
6478 varp = get_varp_scope(opp, opt_flags); | |
6479 | |
6480 if (opp->flags & P_NUM) | |
6481 { | |
6482 long wc = 0; | |
6483 | |
6484 if (wc_use_keyname(varp, &wc)) | |
6485 STRCPY(NameBuff, get_special_key_name((int)wc, 0)); | |
6486 else if (wc != 0) | |
6487 STRCPY(NameBuff, transchar((int)wc)); | |
6488 else | |
6489 sprintf((char *)NameBuff, "%ld", *(long *)varp); | |
6490 } | |
6491 else /* P_STRING */ | |
6492 { | |
6493 varp = *(char_u **)(varp); | |
6494 if (varp == NULL) /* just in case */ | |
6495 NameBuff[0] = NUL; | |
6496 #ifdef FEAT_CRYPT | |
6497 /* don't show the actual value of 'key', only that it's set */ | |
840 | 6498 else if (opp->var == (char_u *)&p_key && *varp) |
7 | 6499 STRCPY(NameBuff, "*****"); |
6500 #endif | |
6501 else if (opp->flags & P_EXPAND) | |
6502 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE); | |
6503 /* Translate 'pastetoggle' into special key names */ | |
6504 else if ((char_u **)opp->var == &p_pt) | |
6505 str2specialbuf(p_pt, NameBuff, MAXPATHL); | |
6506 else | |
419 | 6507 vim_strncpy(NameBuff, varp, MAXPATHL - 1); |
7 | 6508 } |
6509 } | |
6510 | |
6511 /* | |
6512 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be | |
6513 * printed as a keyname. | |
6514 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. | |
6515 */ | |
6516 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6517 wc_use_keyname(char_u *varp, long *wcp) |
7 | 6518 { |
6519 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) | |
6520 { | |
6521 *wcp = *(long *)varp; | |
6522 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0) | |
6523 return TRUE; | |
6524 } | |
6525 return FALSE; | |
6526 } | |
6527 | |
6528 /* | |
6529 * Return TRUE if format option 'x' is in effect. | |
6530 * Take care of no formatting when 'paste' is set. | |
6531 */ | |
6532 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6533 has_format_option(int x) |
7 | 6534 { |
6535 if (p_paste) | |
6536 return FALSE; | |
6537 return (vim_strchr(curbuf->b_p_fo, x) != NULL); | |
6538 } | |
6539 | |
6540 /* | |
6541 * Return TRUE if "x" is present in 'shortmess' option, or | |
6542 * 'shortmess' contains 'a' and "x" is present in SHM_A. | |
6543 */ | |
6544 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6545 shortmess(int x) |
7 | 6546 { |
3384 | 6547 return p_shm != NULL && |
6548 ( vim_strchr(p_shm, x) != NULL | |
7 | 6549 || (vim_strchr(p_shm, 'a') != NULL |
6550 && vim_strchr((char_u *)SHM_A, x) != NULL)); | |
6551 } | |
6552 | |
6553 /* | |
6554 * paste_option_changed() - Called after p_paste was set or reset. | |
6555 */ | |
6556 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6557 paste_option_changed(void) |
7 | 6558 { |
6559 static int old_p_paste = FALSE; | |
6560 static int save_sm = 0; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6561 static int save_sta = 0; |
7 | 6562 #ifdef FEAT_CMDL_INFO |
6563 static int save_ru = 0; | |
6564 #endif | |
6565 #ifdef FEAT_RIGHTLEFT | |
6566 static int save_ri = 0; | |
6567 static int save_hkmap = 0; | |
6568 #endif | |
6569 buf_T *buf; | |
6570 | |
6571 if (p_paste) | |
6572 { | |
6573 /* | |
6574 * Paste switched from off to on. | |
6575 * Save the current values, so they can be restored later. | |
6576 */ | |
6577 if (!old_p_paste) | |
6578 { | |
6579 /* save options for each buffer */ | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6580 FOR_ALL_BUFFERS(buf) |
7 | 6581 { |
6582 buf->b_p_tw_nopaste = buf->b_p_tw; | |
6583 buf->b_p_wm_nopaste = buf->b_p_wm; | |
6584 buf->b_p_sts_nopaste = buf->b_p_sts; | |
6585 buf->b_p_ai_nopaste = buf->b_p_ai; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6586 buf->b_p_et_nopaste = buf->b_p_et; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6587 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6588 if (buf->b_p_vsts_nopaste) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6589 vim_free(buf->b_p_vsts_nopaste); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6590 buf->b_p_vsts_nopaste = buf->b_p_vsts && buf->b_p_vsts != empty_option |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6591 ? vim_strsave(buf->b_p_vsts) : NULL; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6592 #endif |
7 | 6593 } |
6594 | |
6595 /* save global options */ | |
6596 save_sm = p_sm; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6597 save_sta = p_sta; |
7 | 6598 #ifdef FEAT_CMDL_INFO |
6599 save_ru = p_ru; | |
6600 #endif | |
6601 #ifdef FEAT_RIGHTLEFT | |
6602 save_ri = p_ri; | |
6603 save_hkmap = p_hkmap; | |
6604 #endif | |
6605 /* save global values for local buffer options */ | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6606 p_ai_nopaste = p_ai; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6607 p_et_nopaste = p_et; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6608 p_sts_nopaste = p_sts; |
7 | 6609 p_tw_nopaste = p_tw; |
6610 p_wm_nopaste = p_wm; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6611 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6612 if (p_vsts_nopaste) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6613 vim_free(p_vsts_nopaste); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6614 p_vsts_nopaste = p_vsts && p_vsts != empty_option ? vim_strsave(p_vsts) : NULL; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6615 #endif |
7 | 6616 } |
6617 | |
6618 /* | |
6619 * Always set the option values, also when 'paste' is set when it is | |
6620 * already on. | |
6621 */ | |
6622 /* set options for each buffer */ | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6623 FOR_ALL_BUFFERS(buf) |
7 | 6624 { |
6625 buf->b_p_tw = 0; /* textwidth is 0 */ | |
6626 buf->b_p_wm = 0; /* wrapmargin is 0 */ | |
6627 buf->b_p_sts = 0; /* softtabstop is 0 */ | |
6628 buf->b_p_ai = 0; /* no auto-indent */ | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6629 buf->b_p_et = 0; /* no expandtab */ |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6630 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6631 if (buf->b_p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6632 free_string_option(buf->b_p_vsts); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6633 buf->b_p_vsts = empty_option; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6634 if (buf->b_p_vsts_array) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6635 vim_free(buf->b_p_vsts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6636 buf->b_p_vsts_array = 0; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6637 #endif |
7 | 6638 } |
6639 | |
6640 /* set global options */ | |
6641 p_sm = 0; /* no showmatch */ | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6642 p_sta = 0; /* no smarttab */ |
7 | 6643 #ifdef FEAT_CMDL_INFO |
6644 if (p_ru) | |
6645 status_redraw_all(); /* redraw to remove the ruler */ | |
6646 p_ru = 0; /* no ruler */ | |
6647 #endif | |
6648 #ifdef FEAT_RIGHTLEFT | |
6649 p_ri = 0; /* no reverse insert */ | |
6650 p_hkmap = 0; /* no Hebrew keyboard */ | |
6651 #endif | |
6652 /* set global values for local buffer options */ | |
6653 p_tw = 0; | |
6654 p_wm = 0; | |
6655 p_sts = 0; | |
6656 p_ai = 0; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6657 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6658 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6659 free_string_option(p_vsts); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6660 p_vsts = empty_option; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6661 #endif |
7 | 6662 } |
6663 | |
6664 /* | |
6665 * Paste switched from on to off: Restore saved values. | |
6666 */ | |
6667 else if (old_p_paste) | |
6668 { | |
6669 /* restore options for each buffer */ | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6670 FOR_ALL_BUFFERS(buf) |
7 | 6671 { |
6672 buf->b_p_tw = buf->b_p_tw_nopaste; | |
6673 buf->b_p_wm = buf->b_p_wm_nopaste; | |
6674 buf->b_p_sts = buf->b_p_sts_nopaste; | |
6675 buf->b_p_ai = buf->b_p_ai_nopaste; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6676 buf->b_p_et = buf->b_p_et_nopaste; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6677 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6678 if (buf->b_p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6679 free_string_option(buf->b_p_vsts); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6680 buf->b_p_vsts = buf->b_p_vsts_nopaste |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6681 ? vim_strsave(buf->b_p_vsts_nopaste) : empty_option; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6682 if (buf->b_p_vsts_array) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6683 vim_free(buf->b_p_vsts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6684 if (buf->b_p_vsts && buf->b_p_vsts != empty_option) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6685 tabstop_set(buf->b_p_vsts, &buf->b_p_vsts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6686 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6687 buf->b_p_vsts_array = 0; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6688 #endif |
7 | 6689 } |
6690 | |
6691 /* restore global options */ | |
6692 p_sm = save_sm; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6693 p_sta = save_sta; |
7 | 6694 #ifdef FEAT_CMDL_INFO |
6695 if (p_ru != save_ru) | |
6696 status_redraw_all(); /* redraw to draw the ruler */ | |
6697 p_ru = save_ru; | |
6698 #endif | |
6699 #ifdef FEAT_RIGHTLEFT | |
6700 p_ri = save_ri; | |
6701 p_hkmap = save_hkmap; | |
6702 #endif | |
6703 /* set global values for local buffer options */ | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6704 p_ai = p_ai_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6705 p_et = p_et_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6706 p_sts = p_sts_nopaste; |
7 | 6707 p_tw = p_tw_nopaste; |
6708 p_wm = p_wm_nopaste; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6709 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6710 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6711 free_string_option(p_vsts); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6712 p_vsts = p_vsts_nopaste ? vim_strsave(p_vsts_nopaste) : empty_option; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6713 #endif |
7 | 6714 } |
6715 | |
6716 old_p_paste = p_paste; | |
6717 } | |
6718 | |
6719 /* | |
6720 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found. | |
6721 * | |
6722 * Reset 'compatible' and set the values for options that didn't get set yet | |
6723 * to the Vim defaults. | |
6724 * Don't do this if the 'compatible' option has been set or reset before. | |
819 | 6725 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet. |
7 | 6726 */ |
6727 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6728 vimrc_found(char_u *fname, char_u *envname) |
819 | 6729 { |
6730 int opt_idx; | |
826 | 6731 int dofree = FALSE; |
819 | 6732 char_u *p; |
7 | 6733 |
6734 if (!option_was_set((char_u *)"cp")) | |
6735 { | |
6736 p_cp = FALSE; | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6737 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 6738 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF))) |
6739 set_option_default(opt_idx, OPT_FREE, FALSE); | |
6740 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
6741 didset_options2(); |
7 | 6742 } |
819 | 6743 |
6744 if (fname != NULL) | |
6745 { | |
6746 p = vim_getenv(envname, &dofree); | |
6747 if (p == NULL) | |
6748 { | |
6749 /* Set $MYVIMRC to the first vimrc file found. */ | |
6750 p = FullName_save(fname, FALSE); | |
6751 if (p != NULL) | |
6752 { | |
6753 vim_setenv(envname, p); | |
6754 vim_free(p); | |
6755 } | |
6756 } | |
6757 else if (dofree) | |
6758 vim_free(p); | |
6759 } | |
7 | 6760 } |
6761 | |
6762 /* | |
6763 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg. | |
6764 */ | |
6765 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6766 change_compatible(int on) |
7 | 6767 { |
838 | 6768 int opt_idx; |
6769 | |
7 | 6770 if (p_cp != on) |
6771 { | |
6772 p_cp = on; | |
6773 compatible_set(); | |
6774 } | |
838 | 6775 opt_idx = findoption((char_u *)"cp"); |
6776 if (opt_idx >= 0) | |
6777 options[opt_idx].flags |= P_WAS_SET; | |
7 | 6778 } |
6779 | |
6780 /* | |
6781 * Return TRUE when option "name" has been set. | |
5245
8c6615a30951
updated for version 7.4a.047
Bram Moolenaar <bram@vim.org>
parents:
5157
diff
changeset
|
6782 * Only works correctly for global options. |
7 | 6783 */ |
6784 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6785 option_was_set(char_u *name) |
7 | 6786 { |
6787 int idx; | |
6788 | |
6789 idx = findoption(name); | |
6790 if (idx < 0) /* unknown option */ | |
6791 return FALSE; | |
6792 if (options[idx].flags & P_WAS_SET) | |
6793 return TRUE; | |
6794 return FALSE; | |
6795 } | |
6796 | |
6797 /* | |
3980 | 6798 * Reset the flag indicating option "name" was set. |
6799 */ | |
14748
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6800 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6801 reset_option_was_set(char_u *name) |
3980 | 6802 { |
6803 int idx = findoption(name); | |
6804 | |
6805 if (idx >= 0) | |
14748
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6806 { |
3980 | 6807 options[idx].flags &= ~P_WAS_SET; |
14748
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6808 return OK; |
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6809 } |
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6810 return FAIL; |
3980 | 6811 } |
6812 | |
6813 /* | |
7 | 6814 * compatible_set() - Called when 'compatible' has been set or unset. |
6815 * | |
6816 * When 'compatible' set: Set all relevant options (those that have the P_VIM) | |
6817 * flag) to a Vi compatible value. | |
6818 * When 'compatible' is unset: Set all options that have a different default | |
6819 * for Vim (without the P_VI_DEF flag) to that default. | |
6820 */ | |
6821 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6822 compatible_set(void) |
7 | 6823 { |
6824 int opt_idx; | |
6825 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6826 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 6827 if ( ((options[opt_idx].flags & P_VIM) && p_cp) |
6828 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp)) | |
6829 set_option_default(opt_idx, OPT_FREE, p_cp); | |
6830 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
6831 didset_options2(); |
7 | 6832 } |
6833 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6834 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
7 | 6835 |
6836 /* | |
6837 * fill_breakat_flags() -- called when 'breakat' changes value. | |
6838 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6839 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6840 fill_breakat_flags(void) |
7 | 6841 { |
500 | 6842 char_u *p; |
7 | 6843 int i; |
6844 | |
6845 for (i = 0; i < 256; i++) | |
6846 breakat_flags[i] = FALSE; | |
6847 | |
6848 if (p_breakat != NULL) | |
500 | 6849 for (p = p_breakat; *p; p++) |
6850 breakat_flags[*p] = TRUE; | |
7 | 6851 } |
6852 #endif | |
6853 | |
6854 /* | |
6855 * Read the 'wildmode' option, fill wim_flags[]. | |
6856 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6857 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6858 check_opt_wim(void) |
7 | 6859 { |
6860 char_u new_wim_flags[4]; | |
6861 char_u *p; | |
6862 int i; | |
6863 int idx = 0; | |
6864 | |
6865 for (i = 0; i < 4; ++i) | |
6866 new_wim_flags[i] = 0; | |
6867 | |
6868 for (p = p_wim; *p; ++p) | |
6869 { | |
6870 for (i = 0; ASCII_ISALPHA(p[i]); ++i) | |
6871 ; | |
6872 if (p[i] != NUL && p[i] != ',' && p[i] != ':') | |
6873 return FAIL; | |
6874 if (i == 7 && STRNCMP(p, "longest", 7) == 0) | |
6875 new_wim_flags[idx] |= WIM_LONGEST; | |
6876 else if (i == 4 && STRNCMP(p, "full", 4) == 0) | |
6877 new_wim_flags[idx] |= WIM_FULL; | |
6878 else if (i == 4 && STRNCMP(p, "list", 4) == 0) | |
6879 new_wim_flags[idx] |= WIM_LIST; | |
6880 else | |
6881 return FAIL; | |
6882 p += i; | |
6883 if (*p == NUL) | |
6884 break; | |
6885 if (*p == ',') | |
6886 { | |
6887 if (idx == 3) | |
6888 return FAIL; | |
6889 ++idx; | |
6890 } | |
6891 } | |
6892 | |
6893 /* fill remaining entries with last flag */ | |
6894 while (idx < 3) | |
6895 { | |
6896 new_wim_flags[idx + 1] = new_wim_flags[idx]; | |
6897 ++idx; | |
6898 } | |
6899 | |
6900 /* only when there are no errors, wim_flags[] is changed */ | |
6901 for (i = 0; i < 4; ++i) | |
6902 wim_flags[i] = new_wim_flags[i]; | |
6903 return OK; | |
6904 } | |
6905 | |
6906 /* | |
6907 * Check if backspacing over something is allowed. | |
6908 */ | |
6909 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6910 can_bs( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6911 int what) /* BS_INDENT, BS_EOL or BS_START */ |
7 | 6912 { |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
6913 #ifdef FEAT_JOB_CHANNEL |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
6914 if (what == BS_START && bt_prompt(curbuf)) |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
6915 return FALSE; |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
6916 #endif |
7 | 6917 switch (*p_bs) |
6918 { | |
6919 case '2': return TRUE; | |
6920 case '1': return (what != BS_START); | |
6921 case '0': return FALSE; | |
6922 } | |
6923 return vim_strchr(p_bs, what) != NULL; | |
6924 } | |
6925 | |
6926 /* | |
6927 * Save the current values of 'fileformat' and 'fileencoding', so that we know | |
6928 * the file must be considered changed when the value is different. | |
6929 */ | |
6930 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6931 save_file_ff(buf_T *buf) |
7 | 6932 { |
6933 buf->b_start_ffc = *buf->b_p_ff; | |
6934 buf->b_start_eol = buf->b_p_eol; | |
1352 | 6935 buf->b_start_bomb = buf->b_p_bomb; |
6936 | |
7 | 6937 /* Only use free/alloc when necessary, they take time. */ |
6938 if (buf->b_start_fenc == NULL | |
6939 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0) | |
6940 { | |
6941 vim_free(buf->b_start_fenc); | |
6942 buf->b_start_fenc = vim_strsave(buf->b_p_fenc); | |
6943 } | |
6944 } | |
6945 | |
6946 /* | |
6947 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value | |
6948 * from when editing started (save_file_ff() called). | |
1352 | 6949 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was |
6950 * changed and 'binary' is not set. | |
6933 | 6951 * Also when 'endofline' was changed and 'fixeol' is not set. |
2685 | 6952 * When "ignore_empty" is true don't consider a new, empty buffer to be |
6953 * changed. | |
7 | 6954 */ |
6955 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6956 file_ff_differs(buf_T *buf, int ignore_empty) |
7 | 6957 { |
1319 | 6958 /* In a buffer that was never loaded the options are not valid. */ |
6959 if (buf->b_flags & BF_NEVERLOADED) | |
6960 return FALSE; | |
2685 | 6961 if (ignore_empty |
6962 && (buf->b_flags & BF_NEW) | |
7 | 6963 && buf->b_ml.ml_line_count == 1 |
6964 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL) | |
6965 return FALSE; | |
6966 if (buf->b_start_ffc != *buf->b_p_ff) | |
6967 return TRUE; | |
6933 | 6968 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol) |
7 | 6969 return TRUE; |
1352 | 6970 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb) |
6971 return TRUE; | |
7 | 6972 if (buf->b_start_fenc == NULL) |
6973 return (*buf->b_p_fenc != NUL); | |
6974 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0); | |
6975 } | |
6976 | |
6977 /* | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6978 * Return the effective 'scrolloff' value for the current window, using the |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6979 * global value when appropriate. |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6980 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6981 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6982 get_scrolloff_value(void) |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6983 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6984 return curwin->w_p_so < 0 ? p_so : curwin->w_p_so; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6985 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6986 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6987 /* |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6988 * Return the effective 'sidescrolloff' value for the current window, using the |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6989 * global value when appropriate. |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6990 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6991 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6992 get_sidescrolloff_value(void) |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6993 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6994 return curwin->w_p_siso < 0 ? p_siso : curwin->w_p_siso; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6995 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6996 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6997 /* |
4029 | 6998 * Check matchpairs option for "*initc". |
6999 * If there is a match set "*initc" to the matching character and "*findc" to | |
7000 * the opposite character. Set "*backwards" to the direction. | |
7001 * When "switchit" is TRUE swap the direction. | |
7002 */ | |
7003 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7004 find_mps_values( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7005 int *initc, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7006 int *findc, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7007 int *backwards, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7008 int switchit) |
4029 | 7009 { |
7010 char_u *ptr; | |
7011 | |
7012 ptr = curbuf->b_p_mps; | |
7013 while (*ptr != NUL) | |
7014 { | |
7015 if (has_mbyte) | |
7016 { | |
7017 char_u *prev; | |
7018 | |
7019 if (mb_ptr2char(ptr) == *initc) | |
7020 { | |
7021 if (switchit) | |
7022 { | |
7023 *findc = *initc; | |
7024 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); | |
7025 *backwards = TRUE; | |
7026 } | |
7027 else | |
7028 { | |
7029 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); | |
7030 *backwards = FALSE; | |
7031 } | |
7032 return; | |
7033 } | |
7034 prev = ptr; | |
7035 ptr += mb_ptr2len(ptr) + 1; | |
7036 if (mb_ptr2char(ptr) == *initc) | |
7037 { | |
7038 if (switchit) | |
7039 { | |
7040 *findc = *initc; | |
7041 *initc = mb_ptr2char(prev); | |
7042 *backwards = FALSE; | |
7043 } | |
7044 else | |
7045 { | |
7046 *findc = mb_ptr2char(prev); | |
7047 *backwards = TRUE; | |
7048 } | |
7049 return; | |
7050 } | |
7051 ptr += mb_ptr2len(ptr); | |
7052 } | |
7053 else | |
7054 { | |
7055 if (*ptr == *initc) | |
7056 { | |
7057 if (switchit) | |
7058 { | |
7059 *backwards = TRUE; | |
7060 *findc = *initc; | |
7061 *initc = ptr[2]; | |
7062 } | |
7063 else | |
7064 { | |
7065 *backwards = FALSE; | |
7066 *findc = ptr[2]; | |
7067 } | |
7068 return; | |
7069 } | |
7070 ptr += 2; | |
7071 if (*ptr == *initc) | |
7072 { | |
7073 if (switchit) | |
7074 { | |
7075 *backwards = FALSE; | |
7076 *findc = *initc; | |
7077 *initc = ptr[-2]; | |
7078 } | |
7079 else | |
7080 { | |
7081 *backwards = TRUE; | |
7082 *findc = ptr[-2]; | |
7083 } | |
7084 return; | |
7085 } | |
7086 ++ptr; | |
7087 } | |
7088 if (*ptr == ',') | |
7089 ++ptr; | |
7090 } | |
7091 } | |
5995 | 7092 |
7093 #if defined(FEAT_LINEBREAK) || defined(PROTO) | |
7094 /* | |
7095 * This is called when 'breakindentopt' is changed and when a window is | |
7096 * initialized. | |
7097 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7098 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7099 briopt_check(win_T *wp) |
5995 | 7100 { |
7101 char_u *p; | |
7102 int bri_shift = 0; | |
7103 long bri_min = 20; | |
7104 int bri_sbr = FALSE; | |
7105 | |
6162 | 7106 p = wp->w_p_briopt; |
5995 | 7107 while (*p != NUL) |
7108 { | |
7109 if (STRNCMP(p, "shift:", 6) == 0 | |
7110 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6]))) | |
7111 { | |
7112 p += 6; | |
7113 bri_shift = getdigits(&p); | |
7114 } | |
7115 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4])) | |
7116 { | |
7117 p += 4; | |
7118 bri_min = getdigits(&p); | |
7119 } | |
7120 else if (STRNCMP(p, "sbr", 3) == 0) | |
7121 { | |
7122 p += 3; | |
7123 bri_sbr = TRUE; | |
7124 } | |
7125 if (*p != ',' && *p != NUL) | |
7126 return FAIL; | |
7127 if (*p == ',') | |
7128 ++p; | |
7129 } | |
7130 | |
6162 | 7131 wp->w_p_brishift = bri_shift; |
7132 wp->w_p_brimin = bri_min; | |
7133 wp->w_p_brisbr = bri_sbr; | |
5995 | 7134 |
7135 return OK; | |
7136 } | |
7137 #endif | |
6243 | 7138 |
7139 /* | |
7140 * Get the local or global value of 'backupcopy'. | |
7141 */ | |
7142 unsigned int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7143 get_bkc_value(buf_T *buf) |
6243 | 7144 { |
7145 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags; | |
7146 } | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7147 |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7148 #if defined(FEAT_SIGNS) || defined(PROTO) |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7149 /* |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7150 * Return TRUE when window "wp" has a column to draw signs in. |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7151 */ |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7152 int |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7153 signcolumn_on(win_T *wp) |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7154 { |
17129
4fb68abc770f
patch 8.1.1564: sign column takes up space
Bram Moolenaar <Bram@vim.org>
parents:
17115
diff
changeset
|
7155 // If 'signcolumn' is set to 'number', signs are displayed in the 'number' |
4fb68abc770f
patch 8.1.1564: sign column takes up space
Bram Moolenaar <Bram@vim.org>
parents:
17115
diff
changeset
|
7156 // column (if present). Otherwise signs are to be displayed in the sign |
4fb68abc770f
patch 8.1.1564: sign column takes up space
Bram Moolenaar <Bram@vim.org>
parents:
17115
diff
changeset
|
7157 // column. |
4fb68abc770f
patch 8.1.1564: sign column takes up space
Bram Moolenaar <Bram@vim.org>
parents:
17115
diff
changeset
|
7158 if (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u') |
4fb68abc770f
patch 8.1.1564: sign column takes up space
Bram Moolenaar <Bram@vim.org>
parents:
17115
diff
changeset
|
7159 return wp->w_buffer->b_signlist != NULL && !wp->w_p_nu && !wp->w_p_rnu; |
4fb68abc770f
patch 8.1.1564: sign column takes up space
Bram Moolenaar <Bram@vim.org>
parents:
17115
diff
changeset
|
7160 |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7161 if (*wp->w_p_scl == 'n') |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7162 return FALSE; |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7163 if (*wp->w_p_scl == 'y') |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7164 return TRUE; |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7165 return (wp->w_buffer->b_signlist != NULL |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7166 # ifdef FEAT_NETBEANS_INTG |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7167 || wp->w_buffer->b_has_sign_column |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7168 # endif |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7169 ); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7170 } |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7171 #endif |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7172 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7173 #if defined(FEAT_EVAL) || defined(PROTO) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7174 /* |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7175 * Get window or buffer local options. |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7176 */ |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7177 dict_T * |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7178 get_winbuf_options(int bufopt) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7179 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7180 dict_T *d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7181 int opt_idx; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7182 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7183 d = dict_alloc(); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7184 if (d == NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7185 return NULL; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7186 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7187 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7188 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7189 struct vimoption *opt = &options[opt_idx]; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7190 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7191 if ((bufopt && (opt->indir & PV_BUF)) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7192 || (!bufopt && (opt->indir & PV_WIN))) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7193 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7194 char_u *varp = get_varp(opt); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7195 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7196 if (varp != NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7197 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7198 if (opt->flags & P_STRING) |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14243
diff
changeset
|
7199 dict_add_string(d, opt->fullname, *(char_u **)varp); |
10205
22e97a250277
commit https://github.com/vim/vim/commit/789a5c0e3d27f09456678f0cfb6c1bd2d8ab4a35
Christian Brabandt <cb@256bit.org>
parents:
10070
diff
changeset
|
7200 else if (opt->flags & P_NUM) |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14243
diff
changeset
|
7201 dict_add_number(d, opt->fullname, *(long *)varp); |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7202 else |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14243
diff
changeset
|
7203 dict_add_number(d, opt->fullname, *(int *)varp); |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7204 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7205 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7206 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7207 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7208 return d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7209 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7210 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7211 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7212 #if defined(FEAT_SYN_HL) || defined(PROTO) |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7213 /* |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7214 * This is called when 'culopt' is changed |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7215 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7216 int |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7217 fill_culopt_flags(char_u *val, win_T *wp) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7218 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7219 char_u *p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7220 char_u culopt_flags_new = 0; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7221 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7222 if (val == NULL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7223 p = wp->w_p_culopt; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7224 else |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7225 p = val; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7226 while (*p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7227 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7228 if (STRNCMP(p, "line", 4) == 0) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7229 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7230 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7231 culopt_flags_new |= CULOPT_LINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7232 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7233 else if (STRNCMP(p, "both", 4) == 0) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7234 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7235 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7236 culopt_flags_new |= CULOPT_LINE | CULOPT_NBR; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7237 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7238 else if (STRNCMP(p, "number", 6) == 0) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7239 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7240 p += 6; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7241 culopt_flags_new |= CULOPT_NBR; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7242 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7243 else if (STRNCMP(p, "screenline", 10) == 0) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7244 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7245 p += 10; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7246 culopt_flags_new |= CULOPT_SCRLINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7247 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7248 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7249 if (*p != ',' && *p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7250 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7251 if (*p == ',') |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7252 ++p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7253 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7254 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7255 // Can't have both "line" and "screenline". |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7256 if ((culopt_flags_new & CULOPT_LINE) && (culopt_flags_new & CULOPT_SCRLINE)) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7257 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7258 wp->w_p_culopt_flags = culopt_flags_new; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7259 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7260 return OK; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7261 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7262 #endif |