Mercurial > vim
annotate src/option.c @ 18068:1101eacc1444 v8.1.2029
patch 8.1.2029: cannot control 'cursorline' highlighting well
Commit: https://github.com/vim/vim/commit/017ba07fa2cdc578245618717229444fd50c470d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 14 21:01:23 2019 +0200
patch 8.1.2029: cannot control 'cursorline' highlighting well
Problem: Cannot control 'cursorline' highlighting well.
Solution: Add "screenline". (Christian Brabandt, closes https://github.com/vim/vim/issues/4933)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 14 Sep 2019 21:15:04 +0200 |
parents | 88b5c2b4e3d2 |
children | df5778d73320 |
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); |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
41 static void did_set_option(int opt_idx, int opt_flags, int new_value, int value_checked); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
42 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
|
43 static void didset_options(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
44 static void didset_options2(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
45 static void check_string_option(char_u **pp); |
681 | 46 #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
|
47 static long_u *insecure_flag(int opt_idx, int opt_flags); |
681 | 48 #else |
49 # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags) | |
50 #endif | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
51 static void set_string_option_global(int opt_idx, char_u **varp); |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
52 static char *did_set_string_option(int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char *errbuf, int opt_flags, int *value_checked); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
53 #ifdef FEAT_STL_OPT |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
54 static char *check_stl_option(char_u *s); |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
55 #endif |
7 | 56 #ifdef FEAT_CLIPBOARD |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
57 static char *check_clipboard_option(void); |
7 | 58 #endif |
694 | 59 #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
|
60 static void set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
61 #endif |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
62 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
|
63 static char *set_num_option(int opt_idx, char_u *varp, long value, char *errbuf, size_t errbuflen, int opt_flags); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
64 static void check_redraw(long_u flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
65 static int findoption(char_u *); |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 static int put_setbool(FILE *fd, char *cmd, char *name, int value); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
73 static int istermoption(struct vimoption *); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
74 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
|
75 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 static void paste_option_changed(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
81 static void compatible_set(void); |
7 | 82 #ifdef FEAT_LINEBREAK |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
83 static void fill_breakat_flags(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
84 #endif |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
85 static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
86 static int check_opt_strings(char_u *val, char **values, int); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
87 static int check_opt_wim(void); |
6162 | 88 #ifdef FEAT_LINEBREAK |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
89 static int briopt_check(win_T *wp); |
6162 | 90 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
91 #ifdef FEAT_SYN_HL |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
92 static int 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
|
93 #endif |
7 | 94 |
95 /* | |
96 * Initialize the options, first part. | |
97 * | |
98 * 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
|
99 * If "clean_arg" is TRUE Vim was started with --clean. |
7 | 100 */ |
101 void | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
102 set_init_1(int clean_arg) |
7 | 103 { |
104 char_u *p; | |
105 int opt_idx; | |
835 | 106 long_u n; |
7 | 107 |
108 #ifdef FEAT_LANGMAP | |
109 langmap_init(); | |
110 #endif | |
111 | |
112 /* Be Vi compatible by default */ | |
113 p_cp = TRUE; | |
114 | |
164 | 115 /* Use POSIX compatibility when $VIM_POSIX is set. */ |
116 if (mch_getenv((char_u *)"VIM_POSIX") != NULL) | |
168 | 117 { |
164 | 118 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
|
119 set_string_default("shm", (char_u *)SHM_POSIX); |
168 | 120 } |
164 | 121 |
7 | 122 /* |
123 * Find default value for 'shell' option. | |
161 | 124 * Don't use it if it is empty. |
7 | 125 */ |
161 | 126 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
|
127 #if defined(MSWIN) |
161 | 128 || ((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
|
129 || ((p = (char_u *)default_shell()) != NULL && *p != NUL) |
7 | 130 #endif |
161 | 131 ) |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
132 set_string_default_esc("sh", p, TRUE); |
7 | 133 |
134 #ifdef FEAT_WILDIGN | |
135 /* | |
136 * Set the default for 'backupskip' to include environment variables for | |
137 * temp files. | |
138 */ | |
139 { | |
140 # ifdef UNIX | |
141 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"}; | |
142 # else | |
143 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"}; | |
144 # endif | |
170 | 145 int len; |
146 garray_T ga; | |
147 int mustfree; | |
7 | 148 |
149 ga_init2(&ga, 1, 100); | |
150 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n) | |
151 { | |
170 | 152 mustfree = FALSE; |
7 | 153 # ifdef UNIX |
154 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
|
155 # ifdef MACOS_X |
f64c5e636c9f
patch 8.0.1704: 'backupskip' default doesn't work for Mac
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
156 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
|
157 # else |
7 | 158 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
|
159 # endif |
7 | 160 else |
161 # endif | |
170 | 162 p = vim_getenv((char_u *)names[n], &mustfree); |
7 | 163 if (p != NULL && *p != NUL) |
164 { | |
165 /* First time count the NUL, otherwise count the ','. */ | |
835 | 166 len = (int)STRLEN(p) + 3; |
7 | 167 if (ga_grow(&ga, len) == OK) |
168 { | |
169 if (ga.ga_len > 0) | |
170 STRCAT(ga.ga_data, ","); | |
171 STRCAT(ga.ga_data, p); | |
172 add_pathsep(ga.ga_data); | |
173 STRCAT(ga.ga_data, "*"); | |
174 ga.ga_len += len; | |
175 } | |
176 } | |
170 | 177 if (mustfree) |
178 vim_free(p); | |
7 | 179 } |
180 if (ga.ga_data != NULL) | |
181 { | |
182 set_string_default("bsk", ga.ga_data); | |
183 vim_free(ga.ga_data); | |
184 } | |
185 } | |
186 #endif | |
187 | |
188 /* | |
189 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory | |
190 */ | |
191 opt_idx = findoption((char_u *)"maxmemtot"); | |
838 | 192 if (opt_idx >= 0) |
193 { | |
7 | 194 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
838 | 195 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) |
196 #endif | |
197 { | |
7 | 198 #ifdef HAVE_AVAIL_MEM |
838 | 199 /* Use amount of memory available at this moment. */ |
3634 | 200 n = (mch_avail_mem(FALSE) >> 1); |
7 | 201 #else |
202 # ifdef HAVE_TOTAL_MEM | |
838 | 203 /* Use amount of memory available to Vim. */ |
1110 | 204 n = (mch_total_mem(FALSE) >> 1); |
7 | 205 # else |
838 | 206 n = (0x7fffffff >> 11); |
7 | 207 # endif |
208 #endif | |
209 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; | |
838 | 210 opt_idx = findoption((char_u *)"maxmem"); |
211 if (opt_idx >= 0) | |
212 { | |
213 #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
|
214 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
|
215 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L) |
838 | 216 #endif |
217 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; | |
218 } | |
219 } | |
7 | 220 } |
221 | |
222 #ifdef FEAT_SEARCHPATH | |
223 { | |
224 char_u *cdpath; | |
225 char_u *buf; | |
226 int i; | |
227 int j; | |
170 | 228 int mustfree = FALSE; |
7 | 229 |
230 /* Initialize the 'cdpath' option's default value. */ | |
170 | 231 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree); |
7 | 232 if (cdpath != NULL) |
233 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16730
diff
changeset
|
234 buf = alloc((STRLEN(cdpath) << 1) + 2); |
7 | 235 if (buf != NULL) |
236 { | |
237 buf[0] = ','; /* start with ",", current dir first */ | |
238 j = 1; | |
239 for (i = 0; cdpath[i] != NUL; ++i) | |
240 { | |
241 if (vim_ispathlistsep(cdpath[i])) | |
242 buf[j++] = ','; | |
243 else | |
244 { | |
245 if (cdpath[i] == ' ' || cdpath[i] == ',') | |
246 buf[j++] = '\\'; | |
247 buf[j++] = cdpath[i]; | |
248 } | |
249 } | |
250 buf[j] = NUL; | |
251 opt_idx = findoption((char_u *)"cdpath"); | |
838 | 252 if (opt_idx >= 0) |
253 { | |
254 options[opt_idx].def_val[VI_DEFAULT] = buf; | |
255 options[opt_idx].flags |= P_DEF_ALLOCED; | |
256 } | |
2445
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
257 else |
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
258 vim_free(buf); /* cannot happen */ |
7 | 259 } |
170 | 260 if (mustfree) |
261 vim_free(cdpath); | |
7 | 262 } |
263 } | |
264 #endif | |
265 | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
266 #if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux)) |
7 | 267 /* Set print encoding on platforms that don't default to latin1 */ |
268 set_string_default("penc", | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
269 # if defined(MSWIN) |
7 | 270 (char_u *)"cp1252" |
271 # else | |
272 # ifdef VMS | |
273 (char_u *)"dec-mcs" | |
274 # else | |
275 # ifdef EBCDIC | |
276 (char_u *)"ebcdic-uk" | |
277 # else | |
278 # ifdef MAC | |
279 (char_u *)"mac-roman" | |
280 # else /* HPUX */ | |
281 (char_u *)"hp-roman8" | |
282 # endif | |
283 # endif | |
284 # endif | |
285 # endif | |
286 ); | |
287 #endif | |
288 | |
289 #ifdef FEAT_POSTSCRIPT | |
290 /* 'printexpr' must be allocated to be able to evaluate it. */ | |
291 set_string_default("pexpr", | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
292 # if defined(MSWIN) |
8 | 293 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)" |
7 | 294 # else |
295 # ifdef VMS | |
296 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)" | |
297 | |
298 # else | |
299 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error" | |
300 # endif | |
301 # endif | |
302 ); | |
303 #endif | |
304 | |
305 /* | |
306 * Set all the options (except the terminal options) to their default | |
307 * value. Also set the global value for local options. | |
308 */ | |
309 set_options_default(0); | |
310 | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
311 #ifdef CLEAN_RUNTIMEPATH |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
312 if (clean_arg) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
313 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
314 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
|
315 if (opt_idx >= 0) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
316 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
317 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
|
318 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
|
319 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
320 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
|
321 if (opt_idx >= 0) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
322 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
323 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
|
324 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
|
325 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
326 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
327 #endif |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
328 |
7 | 329 #ifdef FEAT_GUI |
330 if (found_reverse_arg) | |
331 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0); | |
332 #endif | |
333 | |
334 curbuf->b_p_initialized = TRUE; | |
335 curbuf->b_p_ar = -1; /* no local 'autoread' value */ | |
5446 | 336 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
7 | 337 check_buf_options(curbuf); |
338 check_win_options(curwin); | |
339 check_options(); | |
340 | |
341 /* Must be before option_expand(), because that one needs vim_isIDc() */ | |
342 didset_options(); | |
343 | |
744 | 344 #ifdef FEAT_SPELL |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
345 /* 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
|
346 * didset_options() because it only depends on 'encoding'. */ |
227 | 347 init_spell_chartab(); |
348 #endif | |
349 | |
7 | 350 /* |
351 * Expand environment variables and things like "~" for the defaults. | |
352 * If option_expand() returns non-NULL the variable is expanded. This can | |
353 * only happen for non-indirect options. | |
354 * Also set the default to the expanded value, so ":set" does not list | |
355 * them. | |
356 * Don't set the P_ALLOCED flag, because we don't want to free the | |
357 * default. | |
358 */ | |
359 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) | |
360 { | |
361 if ((options[opt_idx].flags & P_GETTEXT) | |
362 && options[opt_idx].var != NULL) | |
363 p = (char_u *)_(*(char **)options[opt_idx].var); | |
364 else | |
365 p = option_expand(opt_idx, NULL); | |
366 if (p != NULL && (p = vim_strsave(p)) != NULL) | |
367 { | |
368 *(char_u **)options[opt_idx].var = p; | |
369 /* VIMEXP | |
370 * Defaults for all expanded options are currently the same for Vi | |
371 * and Vim. When this changes, add some code here! Also need to | |
372 * split P_DEF_ALLOCED in two. | |
373 */ | |
374 if (options[opt_idx].flags & P_DEF_ALLOCED) | |
375 vim_free(options[opt_idx].def_val[VI_DEFAULT]); | |
376 options[opt_idx].def_val[VI_DEFAULT] = p; | |
377 options[opt_idx].flags |= P_DEF_ALLOCED; | |
378 } | |
379 } | |
380 | |
381 save_file_ff(curbuf); /* Buffer is unchanged */ | |
382 | |
383 #if defined(FEAT_ARABIC) | |
384 /* Detect use of mlterm. | |
385 * Mlterm is a terminal emulator akin to xterm that has some special | |
386 * abilities (bidi namely). | |
387 * NOTE: mlterm's author is being asked to 'set' a variable | |
388 * instead of an environment variable due to inheritance. | |
389 */ | |
390 if (mch_getenv((char_u *)"MLTERM") != NULL) | |
391 set_option_value((char_u *)"tbidi", 1L, NULL, 0); | |
392 #endif | |
393 | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
394 didset_options2(); |
7 | 395 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
396 # if defined(MSWIN) && defined(FEAT_GETTEXT) |
7 | 397 /* |
398 * If $LANG isn't set, try to get a good value for it. This makes the | |
399 * right language be used automatically. Don't do this for English. | |
400 */ | |
401 if (mch_getenv((char_u *)"LANG") == NULL) | |
402 { | |
403 char buf[20]; | |
404 | |
405 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95. | |
406 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use | |
407 * only the first two. */ | |
408 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, | |
409 (LPTSTR)buf, 20); | |
410 if (n >= 2 && STRNICMP(buf, "en", 2) != 0) | |
411 { | |
412 /* There are a few exceptions (probably more) */ | |
413 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0) | |
414 STRCPY(buf, "zh_TW"); | |
415 else if (STRNICMP(buf, "chs", 3) == 0 | |
416 || STRNICMP(buf, "zhc", 3) == 0) | |
417 STRCPY(buf, "zh_CN"); | |
418 else if (STRNICMP(buf, "jp", 2) == 0) | |
419 STRCPY(buf, "ja"); | |
420 else | |
421 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
|
422 vim_setenv((char_u *)"LANG", (char_u *)buf); |
7 | 423 } |
424 } | |
168 | 425 # else |
767 | 426 # ifdef MACOS_CONVERT |
1622 | 427 /* Moved to os_mac_conv.c to avoid dependency problems. */ |
428 mac_lang_init(); | |
168 | 429 # endif |
7 | 430 # endif |
431 | |
432 /* enc_locale() will try to find the encoding of the current locale. */ | |
433 p = enc_locale(); | |
434 if (p != NULL) | |
435 { | |
436 char_u *save_enc; | |
437 | |
438 /* Try setting 'encoding' and check if the value is valid. | |
439 * If not, go back to the default "latin1". */ | |
440 save_enc = p_enc; | |
441 p_enc = p; | |
1080 | 442 if (STRCMP(p_enc, "gb18030") == 0) |
443 { | |
444 /* We don't support "gb18030", but "cp936" is a good substitute | |
445 * for practical purposes, thus use that. It's not an alias to | |
446 * still support conversion between gb18030 and utf-8. */ | |
447 p_enc = vim_strsave((char_u *)"cp936"); | |
448 vim_free(p); | |
449 } | |
7 | 450 if (mb_init() == NULL) |
451 { | |
452 opt_idx = findoption((char_u *)"encoding"); | |
838 | 453 if (opt_idx >= 0) |
454 { | |
455 options[opt_idx].def_val[VI_DEFAULT] = p_enc; | |
456 options[opt_idx].flags |= P_DEF_ALLOCED; | |
457 } | |
7 | 458 |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12636
diff
changeset
|
459 #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
|
460 if (STRCMP(p_enc, "latin1") == 0 || enc_utf8) |
24 | 461 { |
714 | 462 /* Adjust the default for 'isprint' and 'iskeyword' to match |
463 * latin1. Also set the defaults for when 'nocompatible' is | |
464 * set. */ | |
24 | 465 set_string_option_direct((char_u *)"isp", -1, |
719 | 466 ISP_LATIN1, OPT_FREE, SID_NONE); |
714 | 467 set_string_option_direct((char_u *)"isk", -1, |
468 ISK_LATIN1, OPT_FREE, SID_NONE); | |
469 opt_idx = findoption((char_u *)"isp"); | |
838 | 470 if (opt_idx >= 0) |
471 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1; | |
714 | 472 opt_idx = findoption((char_u *)"isk"); |
838 | 473 if (opt_idx >= 0) |
474 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1; | |
24 | 475 (void)init_chartab(); |
476 } | |
477 #endif | |
478 | |
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
|
479 #if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
7 | 480 /* Win32 console: When GetACP() returns a different value from |
481 * 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
|
482 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
|
483 # 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
|
484 (!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
|
485 # 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
|
486 GetACP() != GetConsoleCP()) |
7 | 487 { |
488 char buf[50]; | |
489 | |
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
|
490 /* 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
|
491 * 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
|
492 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
|
493 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
|
494 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
|
495 sprintf(buf, "cp%ld", (long)GetConsoleCP()); |
7 | 496 p_tenc = vim_strsave((char_u *)buf); |
497 if (p_tenc != NULL) | |
498 { | |
499 opt_idx = findoption((char_u *)"termencoding"); | |
838 | 500 if (opt_idx >= 0) |
501 { | |
502 options[opt_idx].def_val[VI_DEFAULT] = p_tenc; | |
503 options[opt_idx].flags |= P_DEF_ALLOCED; | |
504 } | |
7 | 505 convert_setup(&input_conv, p_tenc, p_enc); |
506 convert_setup(&output_conv, p_enc, p_tenc); | |
507 } | |
508 else | |
509 p_tenc = empty_option; | |
510 } | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
511 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
512 #if defined(MSWIN) |
170 | 513 /* $HOME may have characters in active code page. */ |
514 init_homedir(); | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
515 #endif |
7 | 516 } |
517 else | |
518 { | |
519 vim_free(p_enc); | |
520 p_enc = save_enc; | |
521 } | |
522 } | |
523 | |
524 #ifdef FEAT_MULTI_LANG | |
525 /* Set the default for 'helplang'. */ | |
526 set_helplang_default(get_mess_lang()); | |
527 #endif | |
528 } | |
529 | |
530 /* | |
531 * Set an option to its default value. | |
532 * This does not take care of side effects! | |
533 */ | |
534 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
535 set_option_default( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
536 int opt_idx, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
537 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
|
538 int compatible) /* use Vi default value */ |
7 | 539 { |
540 char_u *varp; /* pointer to variable for current option */ | |
541 int dvi; /* index in def_val[] */ | |
542 long_u flags; | |
681 | 543 long_u *flagsp; |
7 | 544 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
545 | |
546 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); | |
547 flags = options[opt_idx].flags; | |
320 | 548 if (varp != NULL) /* skip hidden option, nothing to do for it */ |
7 | 549 { |
550 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; | |
551 if (flags & P_STRING) | |
552 { | |
13845
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
553 /* 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
|
554 * freeing and allocating the value. */ |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
555 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
|
556 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
|
557 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
|
558 else |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
559 { |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
560 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
|
561 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
|
562 *(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
|
563 options[opt_idx].flags &= ~P_ALLOCED; |
7 | 564 } |
565 } | |
566 else if (flags & P_NUM) | |
567 { | |
1017 | 568 if (options[opt_idx].indir == PV_SCROLL) |
7 | 569 win_comp_scroll(curwin); |
570 else | |
571 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
572 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
|
573 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
574 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
|
575 || (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
|
576 // '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
|
577 // 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
|
578 *(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
|
579 else |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
580 *(long *)varp = def_val; |
7 | 581 /* May also set global value for local option. */ |
582 if (both) | |
583 *(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
|
584 def_val; |
7 | 585 } |
586 } | |
587 else /* P_BOOL */ | |
588 { | |
840 | 589 /* the cast to long is required for Manx C, long_i is needed for |
590 * MSVC */ | |
591 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; | |
1111 | 592 #ifdef UNIX |
593 /* 'modeline' defaults to off for root */ | |
594 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) | |
595 *(int *)varp = FALSE; | |
596 #endif | |
7 | 597 /* May also set global value for local option. */ |
598 if (both) | |
599 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | |
600 *(int *)varp; | |
601 } | |
634 | 602 |
681 | 603 /* The default value is not insecure. */ |
604 flagsp = insecure_flag(opt_idx, opt_flags); | |
605 *flagsp = *flagsp & ~P_INSECURE; | |
7 | 606 } |
607 | |
608 #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
|
609 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 610 #endif |
611 } | |
612 | |
613 /* | |
614 * 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
|
615 * When "opt_flags" is non-zero skip 'encoding'. |
7 | 616 */ |
617 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
618 set_options_default( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
619 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ |
7 | 620 { |
621 int i; | |
622 win_T *wp; | |
671 | 623 tabpage_T *tp; |
7 | 624 |
625 for (i = 0; !istermoption(&options[i]); i++) | |
7034
e668b160ac68
commit https://github.com/vim/vim/commit/b341dda575899458f7075614dcedf0a80ee9d080
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
626 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
|
627 && (opt_flags == 0 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
628 || (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
|
629 # if defined(FEAT_CRYPT) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
630 && 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
|
631 && 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
|
632 # endif |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
633 ))) |
7 | 634 set_option_default(i, opt_flags, p_cp); |
635 | |
636 /* The 'scroll' option must be computed for all windows. */ | |
671 | 637 FOR_ALL_TAB_WINDOWS(tp, wp) |
7 | 638 win_comp_scroll(wp); |
6205 | 639 #ifdef FEAT_CINDENT |
640 parse_cino(curbuf); | |
641 #endif | |
7 | 642 } |
643 | |
644 /* | |
645 * Set the Vi-default value of a string option. | |
646 * 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
|
647 * 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
|
648 */ |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
649 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
|
650 set_string_default_esc(char *name, char_u *val, int escape) |
7 | 651 { |
652 char_u *p; | |
653 int opt_idx; | |
654 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
655 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
|
656 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
|
657 else |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
658 p = vim_strsave(val); |
7 | 659 if (p != NULL) /* we don't want a NULL */ |
660 { | |
661 opt_idx = findoption((char_u *)name); | |
838 | 662 if (opt_idx >= 0) |
663 { | |
664 if (options[opt_idx].flags & P_DEF_ALLOCED) | |
665 vim_free(options[opt_idx].def_val[VI_DEFAULT]); | |
666 options[opt_idx].def_val[VI_DEFAULT] = p; | |
667 options[opt_idx].flags |= P_DEF_ALLOCED; | |
668 } | |
7 | 669 } |
670 } | |
671 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
672 void |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
673 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
|
674 { |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
675 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
|
676 } |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
677 |
7 | 678 /* |
679 * Set the Vi-default value of a number option. | |
680 * Used for 'lines' and 'columns'. | |
681 */ | |
682 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
683 set_number_default(char *name, long val) |
7 | 684 { |
838 | 685 int opt_idx; |
686 | |
687 opt_idx = findoption((char_u *)name); | |
688 if (opt_idx >= 0) | |
840 | 689 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 690 } |
691 | |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
692 /* |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
693 * 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
|
694 * 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
|
695 * 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
|
696 */ |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
697 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
|
698 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
|
699 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
700 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
|
701 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
|
702 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
703 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
|
704 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
|
705 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
|
706 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
707 for (i = 0; !istermoption(&options[i]); i++) |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
708 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
709 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
|
710 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
|
711 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
712 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
|
713 && (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
|
714 && !(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
|
715 && !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
|
716 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
|
717 } |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
718 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
719 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
|
720 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
|
721 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
|
722 } |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
723 |
359 | 724 #if defined(EXITFREE) || defined(PROTO) |
725 /* | |
726 * Free all options. | |
727 */ | |
728 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
729 free_all_options(void) |
359 | 730 { |
731 int i; | |
732 | |
733 for (i = 0; !istermoption(&options[i]); i++) | |
734 { | |
735 if (options[i].indir == PV_NONE) | |
736 { | |
737 /* 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
|
738 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL) |
359 | 739 free_string_option(*(char_u **)options[i].var); |
740 if (options[i].flags & P_DEF_ALLOCED) | |
741 free_string_option(options[i].def_val[VI_DEFAULT]); | |
742 } | |
743 else if (options[i].var != VAR_WIN | |
744 && (options[i].flags & P_STRING)) | |
745 /* buffer-local option: free global value */ | |
746 free_string_option(*(char_u **)options[i].var); | |
747 } | |
748 } | |
749 #endif | |
750 | |
751 | |
7 | 752 /* |
753 * Initialize the options, part two: After getting Rows and Columns and | |
754 * setting 'term'. | |
755 */ | |
756 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
757 set_init_2(void) |
7 | 758 { |
164 | 759 int idx; |
760 | |
7 | 761 /* |
12718
f8f505ffc0a6
patch 8.0.1237: ":set scroll&" often gives an error
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
762 * '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
|
763 * which results in the actual value computed from the window height. |
7 | 764 */ |
168 | 765 idx = findoption((char_u *)"scroll"); |
838 | 766 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
168 | 767 set_option_default(idx, OPT_LOCAL, p_cp); |
7 | 768 comp_col(); |
769 | |
164 | 770 /* |
771 * 'window' is only for backwards compatibility with Vi. | |
772 * Default is Rows - 1. | |
773 */ | |
857 | 774 if (!option_was_set((char_u *)"window")) |
164 | 775 p_window = Rows - 1; |
776 set_number_default("window", Rows - 1); | |
777 | |
671 | 778 /* 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
|
779 #if !((defined(MSWIN)) && !defined(FEAT_GUI)) |
671 | 780 /* |
781 * If 'background' wasn't set by the user, try guessing the value, | |
782 * depending on the terminal name. Only need to check for terminals | |
783 * with a dark background, that can handle color. | |
784 */ | |
785 idx = findoption((char_u *)"bg"); | |
838 | 786 if (idx >= 0 && !(options[idx].flags & P_WAS_SET) |
787 && *term_bg_default() == 'd') | |
671 | 788 { |
694 | 789 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0); |
671 | 790 /* don't mark it as set, when starting the GUI it may be |
791 * changed again */ | |
792 options[idx].flags &= ~P_WAS_SET; | |
7 | 793 } |
794 #endif | |
440 | 795 |
796 #ifdef CURSOR_SHAPE | |
797 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */ | |
798 #endif | |
799 #ifdef FEAT_MOUSESHAPE | |
800 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */ | |
801 #endif | |
802 #ifdef FEAT_PRINTER | |
803 (void)parse_printoptions(); /* parse 'printoptions' default value */ | |
804 #endif | |
7 | 805 } |
806 | |
807 /* | |
671 | 808 * Return "dark" or "light" depending on the kind of terminal. |
809 * This is just guessing! Recognized are: | |
810 * "linux" Linux console | |
811 * "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
|
812 * "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
|
813 * "putty.*" Putty program |
671 | 814 * We also check the COLORFGBG environment variable, which is set by |
815 * rxvt and derivatives. This variable contains either two or three | |
816 * values separated by semicolons; we want the last value in either | |
817 * case. If this value is 0-6 or 8, our background is dark. | |
818 */ | |
819 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
820 term_bg_default(void) |
671 | 821 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
822 #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
|
823 /* DOS console is nearly always black */ |
671 | 824 return (char_u *)"dark"; |
825 #else | |
677 | 826 char_u *p; |
827 | |
671 | 828 if (STRCMP(T_NAME, "linux") == 0 |
829 || 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
|
830 || 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
|
831 || STRNCMP(T_NAME, "putty", 5) == 0 |
671 | 832 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL |
833 && (p = vim_strrchr(p, ';')) != NULL | |
834 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8') | |
835 && p[2] == NUL)) | |
836 return (char_u *)"dark"; | |
837 return (char_u *)"light"; | |
838 #endif | |
839 } | |
840 | |
841 /* | |
7 | 842 * Initialize the options, part three: After reading the .vimrc |
843 */ | |
844 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
845 set_init_3(void) |
7 | 846 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
847 #if defined(UNIX) || defined(MSWIN) |
7 | 848 /* |
849 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. | |
850 * This is done after other initializations, where 'shell' might have been | |
851 * set, but only if they have not been set before. | |
852 */ | |
853 char_u *p; | |
854 int idx_srr; | |
855 int do_srr; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
856 # ifdef FEAT_QUICKFIX |
7 | 857 int idx_sp; |
858 int do_sp; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
859 # endif |
7 | 860 |
861 idx_srr = findoption((char_u *)"srr"); | |
838 | 862 if (idx_srr < 0) |
863 do_srr = FALSE; | |
864 else | |
865 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
|
866 # ifdef FEAT_QUICKFIX |
7 | 867 idx_sp = findoption((char_u *)"sp"); |
838 | 868 if (idx_sp < 0) |
869 do_sp = FALSE; | |
870 else | |
871 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
|
872 # endif |
5867 | 873 p = get_isolated_shell_name(); |
7 | 874 if (p != NULL) |
875 { | |
876 /* | |
877 * Default for p_sp is "| tee", for p_srr is ">". | |
878 * For known shells it is changed here to include stderr. | |
879 */ | |
880 if ( fnamecmp(p, "csh") == 0 | |
881 || 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
|
882 # if defined(MSWIN) // also check with .exe extension |
7 | 883 || fnamecmp(p, "csh.exe") == 0 |
884 || fnamecmp(p, "tcsh.exe") == 0 | |
885 # endif | |
886 ) | |
887 { | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
888 # if defined(FEAT_QUICKFIX) |
7 | 889 if (do_sp) |
890 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
891 # ifdef MSWIN |
7 | 892 p_sp = (char_u *)">&"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
893 # else |
7 | 894 p_sp = (char_u *)"|& tee"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
895 # endif |
7 | 896 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
897 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
898 # endif |
7 | 899 if (do_srr) |
900 { | |
901 p_srr = (char_u *)">&"; | |
902 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
903 } | |
904 } | |
905 else | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
906 /* Always use bourne shell style redirection if we reach this */ |
7 | 907 if ( fnamecmp(p, "sh") == 0 |
908 || fnamecmp(p, "ksh") == 0 | |
2774 | 909 || fnamecmp(p, "mksh") == 0 |
910 || fnamecmp(p, "pdksh") == 0 | |
7 | 911 || fnamecmp(p, "zsh") == 0 |
836 | 912 || fnamecmp(p, "zsh-beta") == 0 |
7 | 913 || fnamecmp(p, "bash") == 0 |
5867 | 914 || 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
|
915 # ifdef MSWIN |
7 | 916 || fnamecmp(p, "cmd") == 0 |
917 || fnamecmp(p, "sh.exe") == 0 | |
918 || fnamecmp(p, "ksh.exe") == 0 | |
2774 | 919 || fnamecmp(p, "mksh.exe") == 0 |
920 || fnamecmp(p, "pdksh.exe") == 0 | |
7 | 921 || fnamecmp(p, "zsh.exe") == 0 |
836 | 922 || fnamecmp(p, "zsh-beta.exe") == 0 |
7 | 923 || fnamecmp(p, "bash.exe") == 0 |
924 || fnamecmp(p, "cmd.exe") == 0 | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
925 # endif |
7 | 926 ) |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
927 { |
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
928 # if defined(FEAT_QUICKFIX) |
7 | 929 if (do_sp) |
930 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
931 # ifdef MSWIN |
7 | 932 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
|
933 # else |
7 | 934 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
|
935 # endif |
7 | 936 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
937 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
938 # endif |
7 | 939 if (do_srr) |
940 { | |
941 p_srr = (char_u *)">%s 2>&1"; | |
942 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
943 } | |
944 } | |
945 vim_free(p); | |
946 } | |
947 #endif | |
948 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
949 #if defined(MSWIN) |
7 | 950 /* |
3352 | 951 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the |
952 * 'shell' option. | |
7 | 953 * This is done after other initializations, where 'shell' might have been |
954 * set, but only if they have not been set before. Default for p_shcf is | |
955 * "/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
|
956 * "-c" and "\"". And for Win32 we need to set p_sxq instead. |
7 | 957 */ |
10 | 958 if (strstr((char *)gettail(p_sh), "sh") != NULL) |
7 | 959 { |
960 int idx3; | |
961 | |
962 idx3 = findoption((char_u *)"shcf"); | |
838 | 963 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 964 { |
965 p_shcf = (char_u *)"-c"; | |
966 options[idx3].def_val[VI_DEFAULT] = p_shcf; | |
967 } | |
968 | |
969 /* Somehow Win32 requires the quotes around the redirection too */ | |
970 idx3 = findoption((char_u *)"sxq"); | |
838 | 971 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 972 { |
973 p_sxq = (char_u *)"\""; | |
974 options[idx3].def_val[VI_DEFAULT] = p_sxq; | |
975 } | |
976 } | |
3352 | 977 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL) |
978 { | |
979 int idx3; | |
980 | |
981 /* | |
982 * cmd.exe on Windows will strip the first and last double quote given | |
983 * on the command line, e.g. most of the time things like: | |
984 * cmd /c "my path/to/echo" "my args to echo" | |
985 * become: | |
986 * my path/to/echo" "my args to echo | |
987 * when executed. | |
988 * | |
3357 | 989 * To avoid this, set shellxquote to surround the command in |
990 * parenthesis. This appears to make most commands work, without | |
991 * breaking commands that worked previously, such as | |
992 * '"path with spaces/cmd" "a&b"'. | |
3352 | 993 */ |
994 idx3 = findoption((char_u *)"sxq"); | |
995 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
996 { | |
3357 | 997 p_sxq = (char_u *)"("; |
3352 | 998 options[idx3].def_val[VI_DEFAULT] = p_sxq; |
999 } | |
1000 | |
1001 idx3 = findoption((char_u *)"shcf"); | |
1002 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
1003 { | |
3357 | 1004 p_shcf = (char_u *)"/c"; |
3352 | 1005 options[idx3].def_val[VI_DEFAULT] = p_shcf; |
1006 } | |
1007 } | |
7 | 1008 #endif |
1009 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11107
diff
changeset
|
1010 if (BUFEMPTY()) |
8659
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1011 { |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1012 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
|
1013 |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1014 /* 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
|
1015 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
|
1016 set_fileformat(default_fileformat(), OPT_LOCAL); |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1017 } |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1018 |
7 | 1019 #ifdef FEAT_TITLE |
1020 set_title_defaults(); | |
1021 #endif | |
1022 } | |
1023 | |
1024 #if defined(FEAT_MULTI_LANG) || defined(PROTO) | |
1025 /* | |
1026 * When 'helplang' is still at its default value, set it to "lang". | |
1027 * Only the first two characters of "lang" are used. | |
1028 */ | |
1029 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1030 set_helplang_default(char_u *lang) |
7 | 1031 { |
1032 int idx; | |
1033 | |
1034 if (lang == NULL || STRLEN(lang) < 2) /* safety check */ | |
1035 return; | |
1036 idx = findoption((char_u *)"hlg"); | |
838 | 1037 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
7 | 1038 { |
1039 if (options[idx].flags & P_ALLOCED) | |
1040 free_string_option(p_hlg); | |
1041 p_hlg = vim_strsave(lang); | |
1042 if (p_hlg == NULL) | |
1043 p_hlg = empty_option; | |
1044 else | |
18 | 1045 { |
14997
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1046 // zh_CN becomes "cn", zh_TW becomes "tw" |
18 | 1047 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) |
1048 { | |
1049 p_hlg[0] = TOLOWER_ASC(p_hlg[3]); | |
1050 p_hlg[1] = TOLOWER_ASC(p_hlg[4]); | |
1051 } | |
14997
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1052 // 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
|
1053 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
|
1054 { |
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1055 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
|
1056 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
|
1057 } |
7 | 1058 p_hlg[2] = NUL; |
18 | 1059 } |
7 | 1060 options[idx].flags |= P_ALLOCED; |
1061 } | |
1062 } | |
1063 #endif | |
1064 | |
1065 #ifdef FEAT_GUI | |
1066 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1067 gui_bg_default(void) |
7 | 1068 { |
1069 if (gui_get_lightness(gui.back_pixel) < 127) | |
1070 return (char_u *)"dark"; | |
1071 return (char_u *)"light"; | |
1072 } | |
1073 | |
1074 /* | |
1075 * Option initializations that can only be done after opening the GUI window. | |
1076 */ | |
1077 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1078 init_gui_options(void) |
7 | 1079 { |
1080 /* Set the 'background' option according to the lightness of the | |
1081 * background color, unless the user has set it already. */ | |
1082 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0) | |
1083 { | |
1084 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0); | |
1085 highlight_changed(); | |
1086 } | |
1087 } | |
1088 #endif | |
1089 | |
1090 #ifdef FEAT_TITLE | |
1091 /* | |
1092 * 'title' and 'icon' only default to true if they have not been set or reset | |
1093 * in .vimrc and we can read the old value. | |
1094 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if | |
1095 * they can be reset. This reduces startup time when using X on a remote | |
1096 * machine. | |
1097 */ | |
1098 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1099 set_title_defaults(void) |
7 | 1100 { |
1101 int idx1; | |
1102 long val; | |
1103 | |
1104 /* | |
1105 * If GUI is (going to be) used, we can always set the window title and | |
1106 * icon name. Saves a bit of time, because the X11 display server does | |
1107 * not need to be contacted. | |
1108 */ | |
1109 idx1 = findoption((char_u *)"title"); | |
838 | 1110 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 1111 { |
1112 #ifdef FEAT_GUI | |
1113 if (gui.starting || gui.in_use) | |
1114 val = TRUE; | |
1115 else | |
1116 #endif | |
1117 val = mch_can_restore_title(); | |
840 | 1118 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 1119 p_title = val; |
1120 } | |
1121 idx1 = findoption((char_u *)"icon"); | |
838 | 1122 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 1123 { |
1124 #ifdef FEAT_GUI | |
1125 if (gui.starting || gui.in_use) | |
1126 val = TRUE; | |
1127 else | |
1128 #endif | |
1129 val = mch_can_restore_icon(); | |
840 | 1130 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 1131 p_icon = val; |
1132 } | |
1133 } | |
1134 #endif | |
1135 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
1136 #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
|
1137 /* |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1138 * Trigger the OptionSet autocommand. |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1139 * "opt_idx" is the index of the option being set. |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1140 * "opt_flags" can be OPT_LOCAL etc. |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1141 * "oldval" the old value |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1142 * "oldval_l" the old local value (only non-NULL if global and local value |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1143 * are set) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1144 * "oldval_g" the old global value (only non-NULL if global and local value |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1145 * are set) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1146 * "newval" the new value |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1147 */ |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1148 static void |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1149 trigger_optionsset_string( |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1150 int opt_idx, |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1151 int opt_flags, |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1152 char_u *oldval, |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1153 char_u *oldval_l, |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1154 char_u *oldval_g, |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1155 char_u *newval) |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1156 { |
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
|
1157 // Don't do this 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
|
1158 if (oldval != NULL && newval != NULL |
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
|
1159 && *get_vim_var_str(VV_OPTION_TYPE) == NUL) |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1160 { |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1161 char_u buf_type[7]; |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1162 |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1163 sprintf((char *)buf_type, "%s", |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1164 (opt_flags & OPT_LOCAL) ? "local" : "global"); |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1165 set_vim_var_string(VV_OPTION_OLD, oldval, -1); |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1166 set_vim_var_string(VV_OPTION_NEW, newval, -1); |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1167 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
|
1168 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
|
1169 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1170 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
|
1171 set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1172 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1173 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
|
1174 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1175 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
|
1176 set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1177 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1178 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
|
1179 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1180 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
|
1181 set_vim_var_string(VV_OPTION_OLDLOCAL, oldval_l, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1182 set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval_g, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1183 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1184 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
|
1185 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1186 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
|
1187 set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1188 } |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1189 apply_autocmds(EVENT_OPTIONSET, |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1190 (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL); |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1191 reset_v_option_vars(); |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1192 } |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1193 } |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1194 #endif |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1195 |
7 | 1196 /* |
1197 * Parse 'arg' for option settings. | |
1198 * | |
1199 * 'arg' may be IObuff, but only when no errors can be present and option | |
1200 * does not need to be expanded with option_expand(). | |
1201 * "opt_flags": | |
1202 * 0 for ":set" | |
717 | 1203 * OPT_GLOBAL for ":setglobal" |
1204 * OPT_LOCAL for ":setlocal" and a modeline | |
7 | 1205 * OPT_MODELINE for a modeline |
717 | 1206 * OPT_WINONLY to only set window-local options |
1207 * OPT_NOWIN to skip setting window-local options | |
7 | 1208 * |
1209 * returns FAIL if an error is detected, OK otherwise | |
1210 */ | |
1211 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1212 do_set( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1213 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
|
1214 int opt_flags) |
7 | 1215 { |
1216 int opt_idx; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1217 char *errmsg; |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1218 char errbuf[80]; |
7 | 1219 char_u *startarg; |
1220 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */ | |
1221 int nextchar; /* next non-white char after option name */ | |
1222 int afterchar; /* character just after option name */ | |
1223 int len; | |
1224 int i; | |
9389
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
1225 varnumber_T value; |
7 | 1226 int key; |
1227 long_u flags; /* flags for current option */ | |
1228 char_u *varp = NULL; /* pointer to variable for current option */ | |
1229 int did_show = FALSE; /* already showed one value */ | |
1230 int adding; /* "opt+=arg" */ | |
1231 int prepending; /* "opt^=arg" */ | |
1232 int removing; /* "opt-=arg" */ | |
1233 int cp_val = 0; | |
1234 char_u key_name[2]; | |
1235 | |
1236 if (*arg == NUL) | |
1237 { | |
1238 showoptions(0, opt_flags); | |
168 | 1239 did_show = TRUE; |
1240 goto theend; | |
7 | 1241 } |
1242 | |
1243 while (*arg != NUL) /* loop to process all options */ | |
1244 { | |
1245 errmsg = NULL; | |
1246 startarg = arg; /* remember for error message */ | |
1247 | |
36 | 1248 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3]) |
1249 && !(opt_flags & OPT_MODELINE)) | |
7 | 1250 { |
1251 /* | |
1252 * ":set all" show all options. | |
1253 * ":set all&" set all options to their default value. | |
1254 */ | |
1255 arg += 3; | |
1256 if (*arg == '&') | |
1257 { | |
1258 ++arg; | |
1259 /* Only for :set command set global value of local options. */ | |
1260 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
|
1261 didset_options(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
1262 didset_options2(); |
7034
e668b160ac68
commit https://github.com/vim/vim/commit/b341dda575899458f7075614dcedf0a80ee9d080
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
1263 redraw_all_later(CLEAR); |
7 | 1264 } |
1265 else | |
168 | 1266 { |
7 | 1267 showoptions(1, opt_flags); |
168 | 1268 did_show = TRUE; |
1269 } | |
7 | 1270 } |
36 | 1271 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) |
7 | 1272 { |
1273 showoptions(2, opt_flags); | |
1274 show_termcodes(); | |
168 | 1275 did_show = TRUE; |
7 | 1276 arg += 7; |
1277 } | |
1278 else | |
1279 { | |
1280 prefix = 1; | |
1911 | 1281 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0) |
7 | 1282 { |
1283 prefix = 0; | |
1284 arg += 2; | |
1285 } | |
1286 else if (STRNCMP(arg, "inv", 3) == 0) | |
1287 { | |
1288 prefix = 2; | |
1289 arg += 3; | |
1290 } | |
1291 | |
1292 /* find end of name */ | |
1293 key = 0; | |
1294 if (*arg == '<') | |
1295 { | |
1296 opt_idx = -1; | |
1297 /* look out for <t_>;> */ | |
1298 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) | |
1299 len = 5; | |
1300 else | |
1301 { | |
1302 len = 1; | |
1303 while (arg[len] != NUL && arg[len] != '>') | |
1304 ++len; | |
1305 } | |
1306 if (arg[len] != '>') | |
1307 { | |
1308 errmsg = e_invarg; | |
1309 goto skip; | |
1310 } | |
1311 arg[len] = NUL; /* put NUL after name */ | |
1312 if (arg[1] == 't' && arg[2] == '_') /* could be term code */ | |
1313 opt_idx = findoption(arg + 1); | |
1314 arg[len++] = '>'; /* restore '>' */ | |
1315 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
|
1316 key = find_key_option(arg + 1, TRUE); |
7 | 1317 } |
1318 else | |
1319 { | |
1320 len = 0; | |
1321 /* | |
1322 * The two characters after "t_" may not be alphanumeric. | |
1323 */ | |
1324 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
1325 len = 4; | |
1326 else | |
1327 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') | |
1328 ++len; | |
1329 nextchar = arg[len]; | |
1330 arg[len] = NUL; /* put NUL after name */ | |
1331 opt_idx = findoption(arg); | |
1332 arg[len] = nextchar; /* restore nextchar */ | |
1333 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
|
1334 key = find_key_option(arg, FALSE); |
7 | 1335 } |
1336 | |
1337 /* remember character after option name */ | |
1338 afterchar = arg[len]; | |
1339 | |
1340 /* 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
|
1341 while (VIM_ISWHITE(arg[len])) |
7 | 1342 ++len; |
1343 | |
1344 adding = FALSE; | |
1345 prepending = FALSE; | |
1346 removing = FALSE; | |
1347 if (arg[len] != NUL && arg[len + 1] == '=') | |
1348 { | |
1349 if (arg[len] == '+') | |
1350 { | |
1351 adding = TRUE; /* "+=" */ | |
1352 ++len; | |
1353 } | |
1354 else if (arg[len] == '^') | |
1355 { | |
1356 prepending = TRUE; /* "^=" */ | |
1357 ++len; | |
1358 } | |
1359 else if (arg[len] == '-') | |
1360 { | |
1361 removing = TRUE; /* "-=" */ | |
1362 ++len; | |
1363 } | |
1364 } | |
1365 nextchar = arg[len]; | |
1366 | |
1367 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */ | |
1368 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1369 errmsg = N_("E518: Unknown option"); |
7 | 1370 goto skip; |
1371 } | |
1372 | |
1373 if (opt_idx >= 0) | |
1374 { | |
1375 if (options[opt_idx].var == NULL) /* hidden option: skip */ | |
1376 { | |
1377 /* Only give an error message when requesting the value of | |
1378 * a hidden option, ignore setting it. */ | |
1379 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL | |
1380 && (!(options[opt_idx].flags & P_BOOL) | |
1381 || nextchar == '?')) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1382 errmsg = N_("E519: Option not supported"); |
7 | 1383 goto skip; |
1384 } | |
1385 | |
1386 flags = options[opt_idx].flags; | |
1387 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | |
1388 } | |
1389 else | |
1390 { | |
1391 flags = P_STRING; | |
1392 if (key < 0) | |
1393 { | |
1394 key_name[0] = KEY2TERMCAP0(key); | |
1395 key_name[1] = KEY2TERMCAP1(key); | |
1396 } | |
1397 else | |
1398 { | |
1399 key_name[0] = KS_KEY; | |
1400 key_name[1] = (key & 0xff); | |
1401 } | |
1402 } | |
1403 | |
634 | 1404 /* Skip all options that are not window-local (used when showing |
1405 * an already loaded buffer in a window). */ | |
1406 if ((opt_flags & OPT_WINONLY) | |
1407 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) | |
1408 goto skip; | |
1409 | |
717 | 1410 /* Skip all options that are window-local (used for :vimgrep). */ |
1411 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0 | |
1412 && options[opt_idx].var == VAR_WIN) | |
1413 goto skip; | |
1414 | |
1807 | 1415 /* Disallow changing some options from modelines. */ |
1416 if (opt_flags & OPT_MODELINE) | |
7 | 1417 { |
2317
2b2cd34569eb
Disallow setting 'enc' in a modeline. (Patrick Texier)
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
1418 if (flags & (P_SECURE | P_NO_ML)) |
1807 | 1419 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1420 errmsg = _("E520: Not allowed in a modeline"); |
1807 | 1421 goto skip; |
1422 } | |
16728
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1423 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
|
1424 { |
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1425 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
|
1426 goto skip; |
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1427 } |
1810 | 1428 #ifdef FEAT_DIFF |
1807 | 1429 /* In diff mode some options are overruled. This avoids that |
1430 * 'foldmethod' becomes "marker" instead of "diff" and that | |
1431 * "wrap" gets set. */ | |
1432 if (curwin->w_p_diff | |
2445
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
1433 && 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
|
1434 && ( |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1435 #ifdef FEAT_FOLDING |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1436 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
|
1437 #endif |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1438 options[opt_idx].indir == PV_WRAP)) |
1807 | 1439 goto skip; |
1810 | 1440 #endif |
7 | 1441 } |
1442 | |
1443 #ifdef HAVE_SANDBOX | |
1444 /* Disallow changing some options in the sandbox */ | |
634 | 1445 if (sandbox != 0 && (flags & P_SECURE)) |
7 | 1446 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1447 errmsg = _(e_sandbox); |
7 | 1448 goto skip; |
1449 } | |
1450 #endif | |
1451 | |
1452 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) | |
1453 { | |
1454 arg += len; | |
1455 cp_val = p_cp; | |
1456 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') | |
1457 { | |
1458 if (arg[3] == 'm') /* "opt&vim": set to Vim default */ | |
1459 { | |
1460 cp_val = FALSE; | |
1461 arg += 3; | |
1462 } | |
1463 else /* "opt&vi": set to Vi default */ | |
1464 { | |
1465 cp_val = TRUE; | |
1466 arg += 2; | |
1467 } | |
1468 } | |
1469 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
|
1470 && arg[1] != NUL && !VIM_ISWHITE(arg[1])) |
7 | 1471 { |
1472 errmsg = e_trailing; | |
1473 goto skip; | |
1474 } | |
1475 } | |
1476 | |
1477 /* | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
1478 * 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
|
1479 * allows only one '=' character per "set" command line. grrr. (jw) |
7 | 1480 */ |
1481 if (nextchar == '?' | |
1482 || (prefix == 1 | |
1483 && vim_strchr((char_u *)"=:&<", nextchar) == NULL | |
1484 && !(flags & P_BOOL))) | |
1485 { | |
1486 /* | |
1487 * print value | |
1488 */ | |
1489 if (did_show) | |
1490 msg_putchar('\n'); /* cursor below last one */ | |
1491 else | |
1492 { | |
1493 gotocmdline(TRUE); /* cursor at status line */ | |
1494 did_show = TRUE; /* remember that we did a line */ | |
1495 } | |
1496 if (opt_idx >= 0) | |
1497 { | |
1498 showoneopt(&options[opt_idx], opt_flags); | |
1499 #ifdef FEAT_EVAL | |
1500 if (p_verbose > 0) | |
694 | 1501 { |
1502 /* Mention where the option was last set. */ | |
1503 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
|
1504 last_set_msg(options[opt_idx].script_ctx); |
694 | 1505 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
|
1506 last_set_msg(curwin->w_p_script_ctx[ |
694 | 1507 (int)options[opt_idx].indir & PV_MASK]); |
1508 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
|
1509 last_set_msg(curbuf->b_p_script_ctx[ |
694 | 1510 (int)options[opt_idx].indir & PV_MASK]); |
1511 } | |
7 | 1512 #endif |
1513 } | |
1514 else | |
1515 { | |
1516 char_u *p; | |
1517 | |
1518 p = find_termcode(key_name); | |
1519 if (p == NULL) | |
1520 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1521 errmsg = N_("E846: Key code not set"); |
7 | 1522 goto skip; |
1523 } | |
1524 else | |
1525 (void)show_one_termcode(key_name, p, TRUE); | |
1526 } | |
1527 if (nextchar != '?' | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1528 && nextchar != NUL && !VIM_ISWHITE(afterchar)) |
7 | 1529 errmsg = e_trailing; |
1530 } | |
1531 else | |
1532 { | |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1533 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
|
1534 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
|
1535 |
7 | 1536 if (flags & P_BOOL) /* boolean */ |
1537 { | |
1538 if (nextchar == '=' || nextchar == ':') | |
1539 { | |
1540 errmsg = e_invarg; | |
1541 goto skip; | |
1542 } | |
1543 | |
1544 /* | |
1545 * ":set opt!": invert | |
1546 * ":set opt&": reset to default value | |
1547 * ":set opt<": reset to global value | |
1548 */ | |
1549 if (nextchar == '!') | |
1550 value = *(int *)(varp) ^ 1; | |
1551 else if (nextchar == '&') | |
840 | 1552 value = (int)(long)(long_i)options[opt_idx].def_val[ |
7 | 1553 ((flags & P_VI_DEF) || cp_val) |
1554 ? VI_DEFAULT : VIM_DEFAULT]; | |
1555 else if (nextchar == '<') | |
1556 { | |
1557 /* For 'autoread' -1 means to use global value. */ | |
1558 if ((int *)varp == &curbuf->b_p_ar | |
1559 && opt_flags == OPT_LOCAL) | |
1560 value = -1; | |
1561 else | |
1562 value = *(int *)get_varp_scope(&(options[opt_idx]), | |
1563 OPT_GLOBAL); | |
1564 } | |
1565 else | |
1566 { | |
1567 /* | |
1568 * ":set invopt": invert | |
1569 * ":set opt" or ":set noopt": set or reset | |
1570 */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1571 if (nextchar != NUL && !VIM_ISWHITE(afterchar)) |
7 | 1572 { |
1573 errmsg = e_trailing; | |
1574 goto skip; | |
1575 } | |
1576 if (prefix == 2) /* inv */ | |
1577 value = *(int *)(varp) ^ 1; | |
1578 else | |
1579 value = prefix; | |
1580 } | |
1581 | |
1582 errmsg = set_bool_option(opt_idx, varp, (int)value, | |
1583 opt_flags); | |
1584 } | |
1585 else /* numeric or string */ | |
1586 { | |
1587 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL | |
1588 || prefix != 1) | |
1589 { | |
1590 errmsg = e_invarg; | |
1591 goto skip; | |
1592 } | |
1593 | |
1594 if (flags & P_NUM) /* numeric */ | |
1595 { | |
1596 /* | |
1597 * Different ways to set a number option: | |
1598 * & set to default value | |
1599 * < set to global value | |
1600 * <xx> accept special key codes for 'wildchar' | |
1601 * c accept any non-digit for 'wildchar' | |
1602 * [-]0-9 set number | |
1603 * other error | |
1604 */ | |
1605 ++arg; | |
1606 if (nextchar == '&') | |
840 | 1607 value = (long)(long_i)options[opt_idx].def_val[ |
7 | 1608 ((flags & P_VI_DEF) || cp_val) |
1609 ? VI_DEFAULT : VIM_DEFAULT]; | |
1610 else if (nextchar == '<') | |
5446 | 1611 { |
1612 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to | |
1613 * use the global value. */ | |
1614 if ((long *)varp == &curbuf->b_p_ul | |
1615 && opt_flags == OPT_LOCAL) | |
1616 value = NO_LOCAL_UNDOLEVEL; | |
1617 else | |
1618 value = *(long *)get_varp_scope( | |
1619 &(options[opt_idx]), OPT_GLOBAL); | |
1620 } | |
7 | 1621 else if (((long *)varp == &p_wc |
1622 || (long *)varp == &p_wcm) | |
1623 && (*arg == '<' | |
1624 || *arg == '^' | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1625 || (*arg != NUL |
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1626 && (!arg[1] || VIM_ISWHITE(arg[1])) |
7 | 1627 && !VIM_ISDIGIT(*arg)))) |
1628 { | |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1629 value = string_to_key(arg, FALSE); |
7 | 1630 if (value == 0 && (long *)varp != &p_wcm) |
1631 { | |
1632 errmsg = e_invarg; | |
1633 goto skip; | |
1634 } | |
1635 } | |
1636 else if (*arg == '-' || VIM_ISDIGIT(*arg)) | |
1637 { | |
6551 | 1638 /* Allow negative (for 'undolevels'), octal and |
1639 * hex numbers. */ | |
7447
ad432f8f68fb
commit https://github.com/vim/vim/commit/887c1fea4a114e7170091942d0446c8882701b5b
Christian Brabandt <cb@256bit.org>
parents:
7426
diff
changeset
|
1640 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
|
1641 &value, NULL, 0, TRUE); |
17039
d726d8cce996
patch 8.1.1519: 'backupskip' may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
16843
diff
changeset
|
1642 if (i == 0 || (arg[i] != NUL |
d726d8cce996
patch 8.1.1519: 'backupskip' may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
16843
diff
changeset
|
1643 && !VIM_ISWHITE(arg[i]))) |
7 | 1644 { |
16706
77bcb5055fec
patch 8.1.1355: obvious mistakes are accepted as valid expressions
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
1645 errmsg = N_("E521: Number required after ="); |
7 | 1646 goto skip; |
1647 } | |
1648 } | |
1649 else | |
1650 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1651 errmsg = N_("E521: Number required after ="); |
7 | 1652 goto skip; |
1653 } | |
1654 | |
1655 if (adding) | |
1656 value = *(long *)varp + value; | |
1657 if (prepending) | |
1658 value = *(long *)varp * value; | |
1659 if (removing) | |
1660 value = *(long *)varp - value; | |
1661 errmsg = set_num_option(opt_idx, varp, value, | |
274 | 1662 errbuf, sizeof(errbuf), opt_flags); |
7 | 1663 } |
1664 else if (opt_idx >= 0) /* string */ | |
1665 { | |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1666 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
|
1667 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
|
1668 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
|
1669 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
|
1670 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
|
1671 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
|
1672 char_u *origval_g = NULL; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
1673 #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
|
1674 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
|
1675 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
|
1676 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
|
1677 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
|
1678 #endif |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1679 unsigned newlen; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1680 int comma; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1681 int bs; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1682 int new_value_alloced; /* new string option |
7 | 1683 was allocated */ |
1684 | |
1685 /* When using ":set opt=val" for a global option | |
1686 * with a local value the local value will be | |
1687 * reset, use the global value here. */ | |
1688 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 | |
692 | 1689 && ((int)options[opt_idx].indir & PV_BOTH)) |
7 | 1690 varp = options[opt_idx].var; |
1691 | |
1692 /* The old value is kept until we are sure that the | |
1693 * new value is valid. */ | |
1694 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
|
1695 |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1696 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
|
1697 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1698 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
|
1699 &(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
|
1700 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
|
1701 &(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
|
1702 |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1703 // 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
|
1704 // 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
|
1705 // 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
|
1706 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
|
1707 && 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
|
1708 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
|
1709 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1710 |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1711 // 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
|
1712 // 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
|
1713 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
|
1714 && (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
|
1715 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
|
1716 &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
|
1717 else |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1718 origval = oldval; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1719 |
7 | 1720 if (nextchar == '&') /* set to default val */ |
1721 { | |
1722 newval = options[opt_idx].def_val[ | |
1723 ((flags & P_VI_DEF) || cp_val) | |
1724 ? VI_DEFAULT : VIM_DEFAULT]; | |
1725 if ((char_u **)varp == &p_bg) | |
1726 { | |
1727 /* guess the value of 'background' */ | |
1728 #ifdef FEAT_GUI | |
1729 if (gui.in_use) | |
1730 newval = gui_bg_default(); | |
1731 else | |
1732 #endif | |
671 | 1733 newval = term_bg_default(); |
7 | 1734 } |
1735 | |
1736 /* expand environment variables and ~ (since the | |
1737 * default value was already expanded, only | |
1738 * required when an environment variable was set | |
1739 * later */ | |
1740 if (newval == NULL) | |
1741 newval = empty_option; | |
1742 else | |
1743 { | |
1744 s = option_expand(opt_idx, newval); | |
1745 if (s == NULL) | |
1746 s = newval; | |
1747 newval = vim_strsave(s); | |
1748 } | |
1749 new_value_alloced = TRUE; | |
1750 } | |
1751 else if (nextchar == '<') /* set to global val */ | |
1752 { | |
1753 newval = vim_strsave(*(char_u **)get_varp_scope( | |
1754 &(options[opt_idx]), OPT_GLOBAL)); | |
1755 new_value_alloced = TRUE; | |
1756 } | |
1757 else | |
1758 { | |
1759 ++arg; /* jump to after the '=' or ':' */ | |
1760 | |
1761 /* | |
1762 * Set 'keywordprg' to ":help" if an empty | |
1763 * value was passed to :set by the user. | |
1764 * Misuse errbuf[] for the resulting string. | |
1765 */ | |
1766 if (varp == (char_u *)&p_kp | |
1767 && (*arg == NUL || *arg == ' ')) | |
1768 { | |
1769 STRCPY(errbuf, ":help"); | |
1770 save_arg = arg; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1771 arg = (char_u *)errbuf; |
7 | 1772 } |
1773 /* | |
3168 | 1774 * Convert 'backspace' number to string, for |
1775 * adding, prepending and removing string. | |
1776 */ | |
1777 else if (varp == (char_u *)&p_bs | |
1778 && VIM_ISDIGIT(**(char_u **)varp)) | |
1779 { | |
1780 i = getdigits((char_u **)varp); | |
1781 switch (i) | |
1782 { | |
1783 case 0: | |
1784 *(char_u **)varp = empty_option; | |
1785 break; | |
1786 case 1: | |
1787 *(char_u **)varp = vim_strsave( | |
1788 (char_u *)"indent,eol"); | |
1789 break; | |
1790 case 2: | |
1791 *(char_u **)varp = vim_strsave( | |
1792 (char_u *)"indent,eol,start"); | |
1793 break; | |
1794 } | |
1795 vim_free(oldval); | |
12190
497b78526358
patch 8.0.0975: using freed memory when setting 'backspace'
Christian Brabandt <cb@256bit.org>
parents:
12188
diff
changeset
|
1796 if (origval == oldval) |
497b78526358
patch 8.0.0975: using freed memory when setting 'backspace'
Christian Brabandt <cb@256bit.org>
parents:
12188
diff
changeset
|
1797 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
|
1798 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
|
1799 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
|
1800 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
|
1801 origval_g = *(char_u **)varp; |
3168 | 1802 oldval = *(char_u **)varp; |
1803 } | |
1804 /* | |
7 | 1805 * Convert 'whichwrap' number to string, for |
1806 * backwards compatibility with Vim 3.0. | |
1807 * Misuse errbuf[] for the resulting string. | |
1808 */ | |
1809 else if (varp == (char_u *)&p_ww | |
1810 && VIM_ISDIGIT(*arg)) | |
1811 { | |
1812 *errbuf = NUL; | |
1813 i = getdigits(&arg); | |
1814 if (i & 1) | |
1815 STRCAT(errbuf, "b,"); | |
1816 if (i & 2) | |
1817 STRCAT(errbuf, "s,"); | |
1818 if (i & 4) | |
1819 STRCAT(errbuf, "h,l,"); | |
1820 if (i & 8) | |
1821 STRCAT(errbuf, "<,>,"); | |
1822 if (i & 16) | |
1823 STRCAT(errbuf, "[,],"); | |
1824 if (*errbuf != NUL) /* remove trailing , */ | |
1825 errbuf[STRLEN(errbuf) - 1] = NUL; | |
1826 save_arg = arg; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1827 arg = (char_u *)errbuf; |
7 | 1828 } |
1829 /* | |
1830 * Remove '>' before 'dir' and 'bdir', for | |
1831 * backwards compatibility with version 3.0 | |
1832 */ | |
1833 else if ( *arg == '>' | |
1834 && (varp == (char_u *)&p_dir | |
1835 || varp == (char_u *)&p_bdir)) | |
1836 { | |
1837 ++arg; | |
1838 } | |
1839 | |
1840 /* | |
1841 * Copy the new string into allocated memory. | |
1842 * Can't use set_string_option_direct(), because | |
1843 * we need to remove the backslashes. | |
1844 */ | |
1845 /* get a bit too much */ | |
1846 newlen = (unsigned)STRLEN(arg) + 1; | |
1847 if (adding || prepending || removing) | |
1848 newlen += (unsigned)STRLEN(origval) + 1; | |
1849 newval = alloc(newlen); | |
1850 if (newval == NULL) /* out of mem, don't change */ | |
1851 break; | |
1852 s = newval; | |
1853 | |
1854 /* | |
1855 * Copy the string, skip over escaped chars. | |
1856 * For MS-DOS and WIN32 backslashes before normal | |
1857 * file name characters are not removed, and keep | |
1858 * backslash at start, for "\\machine\path", but | |
1859 * do remove it for "\\\\machine\\path". | |
1860 * The reverse is found in ExpandOldSetting(). | |
1861 */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1862 while (*arg && !VIM_ISWHITE(*arg)) |
7 | 1863 { |
1864 if (*arg == '\\' && arg[1] != NUL | |
1865 #ifdef BACKSLASH_IN_FILENAME | |
1866 && !((flags & P_EXPAND) | |
1867 && vim_isfilec(arg[1]) | |
1868 && (arg[1] != '\\' | |
1869 || (s == newval | |
1870 && arg[2] != '\\'))) | |
1871 #endif | |
1872 ) | |
1873 ++arg; /* remove backslash */ | |
1874 if (has_mbyte | |
474 | 1875 && (i = (*mb_ptr2len)(arg)) > 1) |
7 | 1876 { |
1877 /* copy multibyte char */ | |
1878 mch_memmove(s, arg, (size_t)i); | |
1879 arg += i; | |
1880 s += i; | |
1881 } | |
1882 else | |
1883 *s++ = *arg++; | |
1884 } | |
1885 *s = NUL; | |
1886 | |
1887 /* | |
1888 * Expand environment variables and ~. | |
1889 * Don't do it when adding without inserting a | |
1890 * comma. | |
1891 */ | |
1892 if (!(adding || prepending || removing) | |
1893 || (flags & P_COMMA)) | |
1894 { | |
1895 s = option_expand(opt_idx, newval); | |
1896 if (s != NULL) | |
1897 { | |
1898 vim_free(newval); | |
1899 newlen = (unsigned)STRLEN(s) + 1; | |
1900 if (adding || prepending || removing) | |
1901 newlen += (unsigned)STRLEN(origval) + 1; | |
1902 newval = alloc(newlen); | |
1903 if (newval == NULL) | |
1904 break; | |
1905 STRCPY(newval, s); | |
1906 } | |
1907 } | |
1908 | |
1909 /* locate newval[] in origval[] when removing it | |
1910 * and when adding to avoid duplicates */ | |
1911 i = 0; /* init for GCC */ | |
1912 if (removing || (flags & P_NODUP)) | |
1913 { | |
1914 i = (int)STRLEN(newval); | |
1915 bs = 0; | |
1916 for (s = origval; *s; ++s) | |
1917 { | |
1918 if ((!(flags & P_COMMA) | |
1919 || s == origval | |
1920 || (s[-1] == ',' && !(bs & 1))) | |
1921 && STRNCMP(s, newval, i) == 0 | |
1922 && (!(flags & P_COMMA) | |
1923 || s[i] == ',' | |
1924 || s[i] == NUL)) | |
1925 break; | |
2726 | 1926 /* 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
|
1927 * 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
|
1928 * 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
|
1929 * is recognized as a separator */ |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1930 if ((s > origval + 1 |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1931 && s[-1] == '\\' |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1932 && s[-2] != ',') |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1933 || (s == origval + 1 |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1934 && s[-1] == '\\')) |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1935 |
7 | 1936 ++bs; |
1937 else | |
1938 bs = 0; | |
1939 } | |
1940 | |
1941 /* do not add if already there */ | |
1942 if ((adding || prepending) && *s) | |
1943 { | |
1944 prepending = FALSE; | |
1945 adding = FALSE; | |
1946 STRCPY(newval, origval); | |
1947 } | |
1948 } | |
1949 | |
1950 /* concatenate the two strings; add a ',' if | |
1951 * needed */ | |
1952 if (adding || prepending) | |
1953 { | |
1954 comma = ((flags & P_COMMA) && *origval != NUL | |
1955 && *newval != NUL); | |
1956 if (adding) | |
1957 { | |
1958 i = (int)STRLEN(origval); | |
6841 | 1959 /* 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
|
1960 if (comma && i > 1 |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1961 && (flags & P_ONECOMMA) == P_ONECOMMA |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1962 && origval[i - 1] == ',' |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1963 && origval[i - 2] != '\\') |
6841 | 1964 i--; |
7 | 1965 mch_memmove(newval + i + comma, newval, |
1966 STRLEN(newval) + 1); | |
1967 mch_memmove(newval, origval, (size_t)i); | |
1968 } | |
1969 else | |
1970 { | |
1971 i = (int)STRLEN(newval); | |
1622 | 1972 STRMOVE(newval + i + comma, origval); |
7 | 1973 } |
1974 if (comma) | |
1975 newval[i] = ','; | |
1976 } | |
1977 | |
1978 /* Remove newval[] from origval[]. (Note: "i" has | |
1979 * been set above and is used here). */ | |
1980 if (removing) | |
1981 { | |
1982 STRCPY(newval, origval); | |
1983 if (*s) | |
1984 { | |
1985 /* may need to remove a comma */ | |
1986 if (flags & P_COMMA) | |
1987 { | |
1988 if (s == origval) | |
1989 { | |
1990 /* include comma after string */ | |
1991 if (s[i] == ',') | |
1992 ++i; | |
1993 } | |
1994 else | |
1995 { | |
1996 /* include comma before string */ | |
1997 --s; | |
1998 ++i; | |
1999 } | |
2000 } | |
1622 | 2001 STRMOVE(newval + (s - origval), s + i); |
7 | 2002 } |
2003 } | |
2004 | |
2005 if (flags & P_FLAGLIST) | |
2006 { | |
2007 /* 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
|
2008 for (s = newval; *s;) |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2009 { |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2010 /* if options have P_FLAGLIST and |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2011 * P_ONECOMMA such as 'whichwrap' */ |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2012 if (flags & P_ONECOMMA) |
7 | 2013 { |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2014 if (*s != ',' && *(s + 1) == ',' |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2015 && vim_strchr(s + 2, *s) != NULL) |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2016 { |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2017 /* Remove the duplicated value and |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2018 * the next comma. */ |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2019 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
|
2020 continue; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2021 } |
7 | 2022 } |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2023 else |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2024 { |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2025 if ((!(flags & P_COMMA) || *s != ',') |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2026 && vim_strchr(s + 1, *s) != NULL) |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2027 { |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2028 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
|
2029 continue; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2030 } |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2031 } |
10831
e926c5a7f9bf
patch 8.0.0305: invalid memory access when option has duplicate flag
Christian Brabandt <cb@256bit.org>
parents:
10825
diff
changeset
|
2032 ++s; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2033 } |
7 | 2034 } |
2035 | |
2036 if (save_arg != NULL) /* number for 'whichwrap' */ | |
2037 arg = save_arg; | |
2038 new_value_alloced = TRUE; | |
2039 } | |
2040 | |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2041 /* |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2042 * 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
|
2043 */ |
7 | 2044 *(char_u **)(varp) = newval; |
2045 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
2046 #if defined(FEAT_EVAL) |
6939 | 2047 if (!starting |
2048 # ifdef FEAT_CRYPT | |
2049 && options[opt_idx].indir != PV_KEY | |
2050 # endif | |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
2051 && 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
|
2052 { |
6935 | 2053 /* origval may be freed by |
2054 * did_set_string_option(), make a copy. */ | |
2055 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
|
2056 /* 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
|
2057 * 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
|
2058 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
|
2059 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
|
2060 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
|
2061 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
|
2062 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
|
2063 } |
6935 | 2064 #endif |
2065 | |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
2066 { |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
2067 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
|
2068 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
|
2069 |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
2070 // 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
|
2071 // 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
|
2072 // 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
|
2073 // 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
|
2074 // completely replaced. |
16082
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
2075 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
|
2076 #ifdef HAVE_SANDBOX |
16082
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
2077 || sandbox != 0 |
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
2078 #endif |
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
2079 || (!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
|
2080 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
|
2081 |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
2082 // 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
|
2083 // 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
|
2084 // '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
|
2085 // 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
|
2086 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
|
2087 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
|
2088 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
|
2089 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
|
2090 |
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
|
2091 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
|
2092 } |
7 | 2093 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
2094 #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
|
2095 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
|
2096 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
|
2097 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
|
2098 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
|
2099 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
|
2100 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
|
2101 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
|
2102 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
|
2103 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
|
2104 #endif |
7 | 2105 /* If error detected, print the error message. */ |
2106 if (errmsg != NULL) | |
2107 goto skip; | |
2108 } | |
2109 else /* key code option */ | |
2110 { | |
2111 char_u *p; | |
2112 | |
2113 if (nextchar == '&') | |
2114 { | |
2115 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
|
2116 errmsg = N_("E522: Not found in termcap"); |
7 | 2117 } |
2118 else | |
2119 { | |
2120 ++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
|
2121 for (p = arg; *p && !VIM_ISWHITE(*p); ++p) |
7 | 2122 if (*p == '\\' && p[1] != NUL) |
2123 ++p; | |
2124 nextchar = *p; | |
2125 *p = NUL; | |
2126 add_termcode(key_name, arg, FALSE); | |
2127 *p = nextchar; | |
2128 } | |
2129 if (full_screen) | |
2130 ttest(FALSE); | |
2131 redraw_all_later(CLEAR); | |
2132 } | |
2133 } | |
634 | 2134 |
7 | 2135 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
|
2136 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
|
2137 opt_idx, opt_flags, value_is_replaced, value_checked); |
7 | 2138 } |
2139 | |
2140 skip: | |
2141 /* | |
2142 * Advance to next argument. | |
2143 * - skip until a blank found, taking care of backslashes | |
2144 * - skip blanks | |
2145 * - skip one "=val" argument (for hidden options ":set gfn =xx") | |
2146 */ | |
2147 for (i = 0; i < 2 ; ++i) | |
2148 { | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2149 while (*arg != NUL && !VIM_ISWHITE(*arg)) |
7 | 2150 if (*arg++ == '\\' && *arg != NUL) |
2151 ++arg; | |
2152 arg = skipwhite(arg); | |
2153 if (*arg != '=') | |
2154 break; | |
2155 } | |
2156 } | |
2157 | |
2158 if (errmsg != NULL) | |
2159 { | |
419 | 2160 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1); |
835 | 2161 i = (int)STRLEN(IObuff) + 2; |
7 | 2162 if (i + (arg - startarg) < IOSIZE) |
2163 { | |
2164 /* append the argument with the error */ | |
2165 STRCAT(IObuff, ": "); | |
2166 mch_memmove(IObuff + i, startarg, (arg - startarg)); | |
2167 IObuff[i + (arg - startarg)] = NUL; | |
2168 } | |
2169 /* make sure all characters are printable */ | |
2170 trans_characters(IObuff, IOSIZE); | |
2171 | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2172 ++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
|
2173 emsg((char *)IObuff); // show error highlighted |
7 | 2174 --no_wait_return; |
2175 | |
2176 return FAIL; | |
2177 } | |
2178 | |
2179 arg = skipwhite(arg); | |
2180 } | |
2181 | |
168 | 2182 theend: |
2183 if (silent_mode && did_show) | |
2184 { | |
2185 /* After displaying option values in silent mode. */ | |
2186 silent_mode = FALSE; | |
2187 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ | |
2188 msg_putchar('\n'); | |
2189 cursor_on(); /* msg_start() switches it off */ | |
2190 out_flush(); | |
2191 silent_mode = TRUE; | |
2192 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */ | |
2193 } | |
2194 | |
7 | 2195 return OK; |
2196 } | |
2197 | |
634 | 2198 /* |
2199 * Call this when an option has been given a new value through a user command. | |
2200 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag. | |
2201 */ | |
2202 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2203 did_set_option( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2204 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
|
2205 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
|
2206 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
|
2207 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
|
2208 // P_INSECURE flag. |
634 | 2209 { |
681 | 2210 long_u *p; |
2211 | |
634 | 2212 options[opt_idx].flags |= P_WAS_SET; |
2213 | |
2214 /* When an option is set in the sandbox, from a modeline or in secure mode | |
2215 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the | |
681 | 2216 * flag. */ |
2217 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
|
2218 if (!value_checked && (secure |
634 | 2219 #ifdef HAVE_SANDBOX |
2220 || sandbox != 0 | |
2221 #endif | |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2222 || (opt_flags & OPT_MODELINE))) |
681 | 2223 *p = *p | P_INSECURE; |
2224 else if (new_value) | |
2225 *p = *p & ~P_INSECURE; | |
634 | 2226 } |
2227 | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2228 static char * |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2229 illegal_char(char *errbuf, int c) |
7 | 2230 { |
2231 if (errbuf == NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2232 return ""; |
7 | 2233 sprintf((char *)errbuf, _("E539: Illegal character <%s>"), |
274 | 2234 (char *)transchar(c)); |
7 | 2235 return errbuf; |
2236 } | |
2237 | |
2238 /* | |
2239 * Convert a key name or string into a key value. | |
2240 * 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
|
2241 * 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
|
2242 */ |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2243 int |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2244 string_to_key(char_u *arg, int multi_byte) |
7 | 2245 { |
2246 if (*arg == '<') | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
2247 return find_key_option(arg + 1, TRUE); |
7 | 2248 if (*arg == '^') |
2249 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
|
2250 if (multi_byte) |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2251 return PTR2CHAR(arg); |
7 | 2252 return *arg; |
2253 } | |
2254 | |
2255 #ifdef FEAT_CMDWIN | |
2256 /* | |
2257 * Check value of 'cedit' and set cedit_key. | |
2258 * Returns NULL if value is OK, error message otherwise. | |
2259 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2260 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2261 check_cedit(void) |
7 | 2262 { |
2263 int n; | |
2264 | |
2265 if (*p_cedit == NUL) | |
2266 cedit_key = -1; | |
2267 else | |
2268 { | |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2269 n = string_to_key(p_cedit, FALSE); |
7 | 2270 if (vim_isprintc(n)) |
2271 return e_invarg; | |
2272 cedit_key = n; | |
2273 } | |
2274 return NULL; | |
2275 } | |
2276 #endif | |
2277 | |
2278 #ifdef FEAT_TITLE | |
2279 /* | |
2280 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call | |
2281 * maketitle() to create and display it. | |
2282 * When switching the title or icon off, call mch_restore_title() to get | |
2283 * the old value back. | |
2284 */ | |
2285 static 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
|
2286 did_set_title(void) |
7 | 2287 { |
2288 if (starting != NO_SCREEN | |
2289 #ifdef FEAT_GUI | |
2290 && !gui.starting | |
2291 #endif | |
2292 ) | |
2293 maketitle(); | |
2294 } | |
2295 #endif | |
2296 | |
2297 /* | |
2298 * set_options_bin - called when 'bin' changes value. | |
2299 */ | |
2300 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2301 set_options_bin( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2302 int oldval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2303 int newval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2304 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ |
7 | 2305 { |
2306 /* | |
2307 * The option values that are changed when 'bin' changes are | |
2308 * copied when 'bin is set and restored when 'bin' is reset. | |
2309 */ | |
2310 if (newval) | |
2311 { | |
2312 if (!oldval) /* switched on */ | |
2313 { | |
2314 if (!(opt_flags & OPT_GLOBAL)) | |
2315 { | |
2316 curbuf->b_p_tw_nobin = curbuf->b_p_tw; | |
2317 curbuf->b_p_wm_nobin = curbuf->b_p_wm; | |
2318 curbuf->b_p_ml_nobin = curbuf->b_p_ml; | |
2319 curbuf->b_p_et_nobin = curbuf->b_p_et; | |
2320 } | |
2321 if (!(opt_flags & OPT_LOCAL)) | |
2322 { | |
2323 p_tw_nobin = p_tw; | |
2324 p_wm_nobin = p_wm; | |
2325 p_ml_nobin = p_ml; | |
2326 p_et_nobin = p_et; | |
2327 } | |
2328 } | |
2329 | |
2330 if (!(opt_flags & OPT_GLOBAL)) | |
2331 { | |
2332 curbuf->b_p_tw = 0; /* no automatic line wrap */ | |
2333 curbuf->b_p_wm = 0; /* no automatic line wrap */ | |
2334 curbuf->b_p_ml = 0; /* no modelines */ | |
2335 curbuf->b_p_et = 0; /* no expandtab */ | |
2336 } | |
2337 if (!(opt_flags & OPT_LOCAL)) | |
2338 { | |
2339 p_tw = 0; | |
2340 p_wm = 0; | |
2341 p_ml = FALSE; | |
2342 p_et = FALSE; | |
2343 p_bin = TRUE; /* needed when called for the "-b" argument */ | |
2344 } | |
2345 } | |
2346 else if (oldval) /* switched off */ | |
2347 { | |
2348 if (!(opt_flags & OPT_GLOBAL)) | |
2349 { | |
2350 curbuf->b_p_tw = curbuf->b_p_tw_nobin; | |
2351 curbuf->b_p_wm = curbuf->b_p_wm_nobin; | |
2352 curbuf->b_p_ml = curbuf->b_p_ml_nobin; | |
2353 curbuf->b_p_et = curbuf->b_p_et_nobin; | |
2354 } | |
2355 if (!(opt_flags & OPT_LOCAL)) | |
2356 { | |
2357 p_tw = p_tw_nobin; | |
2358 p_wm = p_wm_nobin; | |
2359 p_ml = p_ml_nobin; | |
2360 p_et = p_et_nobin; | |
2361 } | |
2362 } | |
2363 } | |
2364 | |
2365 /* | |
2366 * Expand environment variables for some string options. | |
2367 * These string options cannot be indirect! | |
2368 * If "val" is NULL expand the current value of the option. | |
2369 * Return pointer to NameBuff, or NULL when not expanded. | |
2370 */ | |
2371 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2372 option_expand(int opt_idx, char_u *val) |
7 | 2373 { |
2374 /* if option doesn't need expansion nothing to do */ | |
2375 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) | |
2376 return NULL; | |
2377 | |
2378 /* If val is longer than MAXPATHL no meaningful expansion can be done, | |
2379 * expand_env() would truncate the string. */ | |
2380 if (val != NULL && STRLEN(val) > MAXPATHL) | |
2381 return NULL; | |
2382 | |
2383 if (val == NULL) | |
2384 val = *(char_u **)options[opt_idx].var; | |
2385 | |
2386 /* | |
2387 * Expanding this with NameBuff, expand_env() must not be passed IObuff. | |
2388 * Escape spaces when expanding 'tags', they are used to separate file | |
2389 * names. | |
374 | 2390 * For 'spellsuggest' expand after "file:". |
7 | 2391 */ |
2392 expand_env_esc(val, NameBuff, MAXPATHL, | |
1408 | 2393 (char_u **)options[opt_idx].var == &p_tags, FALSE, |
744 | 2394 #ifdef FEAT_SPELL |
374 | 2395 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : |
2396 #endif | |
2397 NULL); | |
7 | 2398 if (STRCMP(NameBuff, val) == 0) /* they are the same */ |
2399 return NULL; | |
2400 | |
2401 return NameBuff; | |
2402 } | |
2403 | |
2404 /* | |
2405 * After setting various option values: recompute variables that depend on | |
2406 * option values. | |
2407 */ | |
2408 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2409 didset_options(void) |
7 | 2410 { |
2411 /* initialize the table for 'iskeyword' et.al. */ | |
2412 (void)init_chartab(); | |
2413 | |
2414 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE); | |
2415 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE); | |
6949 | 2416 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE); |
7 | 2417 #ifdef FEAT_SESSION |
2418 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE); | |
2419 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE); | |
2420 #endif | |
2421 #ifdef FEAT_FOLDING | |
2422 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE); | |
2423 #endif | |
2424 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE); | |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
2425 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE); |
7 | 2426 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE); |
2427 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) | |
2428 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE); | |
2429 #endif | |
744 | 2430 #ifdef FEAT_SPELL |
484 | 2431 (void)spell_check_msm(); |
374 | 2432 (void)spell_check_sps(); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
2433 (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
|
2434 (void)did_set_spell_option(TRUE); |
344 | 2435 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
2436 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) |
7 | 2437 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE); |
2438 #endif | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2271
diff
changeset
|
2439 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) |
7 | 2440 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE); |
2441 #endif | |
2442 #ifdef FEAT_CMDWIN | |
2443 /* set cedit_key */ | |
2444 (void)check_cedit(); | |
2445 #endif | |
5995 | 2446 #ifdef FEAT_LINEBREAK |
6162 | 2447 briopt_check(curwin); |
5995 | 2448 #endif |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2449 #ifdef FEAT_LINEBREAK |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2450 /* initialize the table for 'breakat'. */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2451 fill_breakat_flags(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2452 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
2453 #ifdef FEAT_SYN_HL |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
2454 fill_culopt_flags(NULL, curwin); |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
2455 #endif |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2456 } |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2457 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2458 /* |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2459 * More side effects of setting options. |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2460 */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2461 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2462 didset_options2(void) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2463 { |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2464 /* Initialize the highlight_attr[] table. */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2465 (void)highlight_changed(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2466 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2467 /* Parse default for 'wildmode' */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2468 check_opt_wim(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2469 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2470 (void)set_chars_option(&p_lcs); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2471 /* Parse default for 'fillchars'. */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2472 (void)set_chars_option(&p_fcs); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2473 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2474 #ifdef FEAT_CLIPBOARD |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2475 /* Parse default for 'clipboard' */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2476 (void)check_clipboard_option(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2477 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2478 #ifdef FEAT_VARTABS |
15858
3a45b89639fb
patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2479 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
|
2480 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
|
2481 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
|
2482 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
|
2483 #endif |
7 | 2484 } |
2485 | |
2486 /* | |
2487 * Check for string options that are NULL (normally only termcap options). | |
2488 */ | |
2489 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2490 check_options(void) |
7 | 2491 { |
2492 int opt_idx; | |
2493 | |
2494 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) | |
2495 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL) | |
2496 check_string_option((char_u **)get_varp(&(options[opt_idx]))); | |
2497 } | |
2498 | |
2499 /* | |
2500 * Check string options in a buffer for NULL value. | |
2501 */ | |
2502 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2503 check_buf_options(buf_T *buf) |
7 | 2504 { |
2505 check_string_option(&buf->b_p_bh); | |
2506 check_string_option(&buf->b_p_bt); | |
2507 check_string_option(&buf->b_p_fenc); | |
2508 check_string_option(&buf->b_p_ff); | |
2509 #ifdef FEAT_FIND_ID | |
2510 check_string_option(&buf->b_p_def); | |
2511 check_string_option(&buf->b_p_inc); | |
2512 # ifdef FEAT_EVAL | |
2513 check_string_option(&buf->b_p_inex); | |
2514 # endif | |
2515 #endif | |
2516 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
2517 check_string_option(&buf->b_p_inde); | |
2518 check_string_option(&buf->b_p_indk); | |
2519 #endif | |
790 | 2520 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
2521 check_string_option(&buf->b_p_bexpr); | |
2522 #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
|
2523 #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
|
2524 check_string_option(&buf->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
|
2525 #endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
2526 check_string_option(&buf->b_p_fp); |
667 | 2527 #if defined(FEAT_EVAL) |
2528 check_string_option(&buf->b_p_fex); | |
2529 #endif | |
7 | 2530 #ifdef FEAT_CRYPT |
2531 check_string_option(&buf->b_p_key); | |
2532 #endif | |
2533 check_string_option(&buf->b_p_kp); | |
2534 check_string_option(&buf->b_p_mps); | |
2535 check_string_option(&buf->b_p_fo); | |
41 | 2536 check_string_option(&buf->b_p_flp); |
7 | 2537 check_string_option(&buf->b_p_isk); |
2538 #ifdef FEAT_COMMENTS | |
2539 check_string_option(&buf->b_p_com); | |
2540 #endif | |
2541 #ifdef FEAT_FOLDING | |
2542 check_string_option(&buf->b_p_cms); | |
2543 #endif | |
2544 check_string_option(&buf->b_p_nf); | |
12 | 2545 #ifdef FEAT_TEXTOBJ |
2546 check_string_option(&buf->b_p_qe); | |
2547 #endif | |
7 | 2548 #ifdef FEAT_SYN_HL |
2549 check_string_option(&buf->b_p_syn); | |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7538
diff
changeset
|
2550 check_string_option(&buf->b_s.b_syn_isk); |
744 | 2551 #endif |
2552 #ifdef FEAT_SPELL | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
2553 check_string_option(&buf->b_s.b_p_spc); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
2554 check_string_option(&buf->b_s.b_p_spf); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
2555 check_string_option(&buf->b_s.b_p_spl); |
7 | 2556 #endif |
2557 #ifdef FEAT_SEARCHPATH | |
2558 check_string_option(&buf->b_p_sua); | |
2559 #endif | |
2560 #ifdef FEAT_CINDENT | |
2561 check_string_option(&buf->b_p_cink); | |
2562 check_string_option(&buf->b_p_cino); | |
5438 | 2563 parse_cino(buf); |
7 | 2564 #endif |
2565 check_string_option(&buf->b_p_ft); | |
2566 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) | |
2567 check_string_option(&buf->b_p_cinw); | |
2568 #endif | |
2569 check_string_option(&buf->b_p_cpt); | |
12 | 2570 #ifdef FEAT_COMPL_FUNC |
2571 check_string_option(&buf->b_p_cfu); | |
502 | 2572 check_string_option(&buf->b_p_ofu); |
12 | 2573 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
2574 #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
|
2575 check_string_option(&buf->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
|
2576 #endif |
7 | 2577 #ifdef FEAT_KEYMAP |
2578 check_string_option(&buf->b_p_keymap); | |
2579 #endif | |
2580 #ifdef FEAT_QUICKFIX | |
2581 check_string_option(&buf->b_p_gp); | |
2582 check_string_option(&buf->b_p_mp); | |
2583 check_string_option(&buf->b_p_efm); | |
2584 #endif | |
2585 check_string_option(&buf->b_p_ep); | |
2586 check_string_option(&buf->b_p_path); | |
2587 check_string_option(&buf->b_p_tags); | |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
2588 check_string_option(&buf->b_p_tc); |
7 | 2589 check_string_option(&buf->b_p_dict); |
2590 check_string_option(&buf->b_p_tsr); | |
5712 | 2591 #ifdef FEAT_LISP |
2592 check_string_option(&buf->b_p_lw); | |
2593 #endif | |
6243 | 2594 check_string_option(&buf->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
|
2595 check_string_option(&buf->b_p_menc); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2596 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2597 check_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
|
2598 check_string_option(&buf->b_p_vts); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2599 #endif |
7 | 2600 } |
2601 | |
2602 /* | |
2603 * Free the string allocated for an option. | |
2604 * Checks for the string being empty_option. This may happen if we're out of | |
2605 * memory, vim_strsave() returned NULL, which was replaced by empty_option by | |
2606 * check_options(). | |
2607 * Does NOT check for P_ALLOCED flag! | |
2608 */ | |
2609 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2610 free_string_option(char_u *p) |
7 | 2611 { |
2612 if (p != empty_option) | |
2613 vim_free(p); | |
2614 } | |
2615 | |
2616 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2617 clear_string_option(char_u **pp) |
7 | 2618 { |
2619 if (*pp != empty_option) | |
2620 vim_free(*pp); | |
2621 *pp = empty_option; | |
2622 } | |
2623 | |
2624 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2625 check_string_option(char_u **pp) |
7 | 2626 { |
2627 if (*pp == NULL) | |
2628 *pp = empty_option; | |
2629 } | |
2630 | |
2631 /* | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2632 * 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
|
2633 * 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
|
2634 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2635 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2636 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
|
2637 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2638 int opt_idx; |
7 | 2639 |
2640 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) | |
2641 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
|
2642 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
|
2643 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
|
2644 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2645 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2646 /* |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2647 * 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
|
2648 * 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
|
2649 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2650 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2651 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
|
2652 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2653 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
|
2654 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2655 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
|
2656 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
|
2657 return opt_idx; |
7 | 2658 } |
2659 | |
634 | 2660 #if defined(FEAT_EVAL) || defined(PROTO) |
2661 /* | |
2662 * Return TRUE when option "opt" was set from a modeline or in secure mode. | |
2663 * Return FALSE when it wasn't. | |
2664 * Return -1 for an unknown option. | |
2665 */ | |
2666 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2667 was_set_insecurely(char_u *opt, int opt_flags) |
634 | 2668 { |
2669 int idx = findoption(opt); | |
681 | 2670 long_u *flagp; |
634 | 2671 |
2672 if (idx >= 0) | |
681 | 2673 { |
2674 flagp = insecure_flag(idx, opt_flags); | |
2675 return (*flagp & P_INSECURE) != 0; | |
2676 } | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
2677 internal_error("was_set_insecurely()"); |
634 | 2678 return -1; |
2679 } | |
681 | 2680 |
2681 /* | |
2682 * Get a pointer to the flags used for the P_INSECURE flag of option | |
2683 * "opt_idx". For some local options a local flags field is used. | |
2684 */ | |
2685 static long_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2686 insecure_flag(int opt_idx, int opt_flags) |
681 | 2687 { |
2688 if (opt_flags & OPT_LOCAL) | |
2689 switch ((int)options[opt_idx].indir) | |
2690 { | |
2691 #ifdef FEAT_STL_OPT | |
694 | 2692 case PV_STL: return &curwin->w_p_stl_flags; |
681 | 2693 #endif |
2694 #ifdef FEAT_EVAL | |
885 | 2695 # ifdef FEAT_FOLDING |
694 | 2696 case PV_FDE: return &curwin->w_p_fde_flags; |
2697 case PV_FDT: return &curwin->w_p_fdt_flags; | |
885 | 2698 # endif |
790 | 2699 # ifdef FEAT_BEVAL |
2700 case PV_BEXPR: return &curbuf->b_p_bexpr_flags; | |
2701 # endif | |
681 | 2702 # if defined(FEAT_CINDENT) |
694 | 2703 case PV_INDE: return &curbuf->b_p_inde_flags; |
681 | 2704 # endif |
694 | 2705 case PV_FEX: return &curbuf->b_p_fex_flags; |
681 | 2706 # ifdef FEAT_FIND_ID |
694 | 2707 case PV_INEX: return &curbuf->b_p_inex_flags; |
681 | 2708 # endif |
2709 #endif | |
2710 } | |
2711 | |
2712 /* Nothing special, return global flags field. */ | |
2713 return &options[opt_idx].flags; | |
2714 } | |
634 | 2715 #endif |
2716 | |
1805 | 2717 #ifdef FEAT_TITLE |
2718 /* | |
2719 * Redraw the window title and/or tab page text later. | |
2720 */ | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2721 static void redraw_titles(void) |
1805 | 2722 { |
2723 need_maketitle = TRUE; | |
2724 redraw_tabline = TRUE; | |
2725 } | |
2726 #endif | |
2727 | |
7 | 2728 /* |
2729 * Set a string option to a new value (without checking the effect). | |
2730 * The string is copied into allocated memory. | |
2731 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used. | |
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
|
2732 * When "set_sid" is zero set the scriptID to current_sctx.sc_sid. When |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2733 * "set_sid" is SID_NONE don't set the scriptID. Otherwise set the scriptID to |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2734 * "set_sid". |
7 | 2735 */ |
2736 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2737 set_string_option_direct( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2738 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2739 int opt_idx, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2740 char_u *val, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2741 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
|
2742 int set_sid UNUSED) |
7 | 2743 { |
2744 char_u *s; | |
2745 char_u **varp; | |
2746 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; | |
944 | 2747 int idx = opt_idx; |
2748 | |
2749 if (idx == -1) /* use name */ | |
2750 { | |
2751 idx = findoption(name); | |
2752 if (idx < 0) /* not found (should not happen) */ | |
694 | 2753 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2754 semsg(_(e_intern2), "set_string_option_direct()"); |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2755 siemsg(_("For option %s"), name); |
7 | 2756 return; |
694 | 2757 } |
7 | 2758 } |
2759 | |
944 | 2760 if (options[idx].var == NULL) /* can't set hidden option */ |
7 | 2761 return; |
2762 | |
2763 s = vim_strsave(val); | |
2764 if (s != NULL) | |
2765 { | |
944 | 2766 varp = (char_u **)get_varp_scope(&(options[idx]), |
7 | 2767 both ? OPT_LOCAL : opt_flags); |
944 | 2768 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED)) |
7 | 2769 free_string_option(*varp); |
2770 *varp = s; | |
2771 | |
2772 /* For buffer/window local option may also set the global value. */ | |
2773 if (both) | |
944 | 2774 set_string_option_global(idx, varp); |
2775 | |
2776 options[idx].flags |= P_ALLOCED; | |
7 | 2777 |
2778 /* When setting both values of a global option with a local value, | |
2779 * make the local value empty, so that the global value is used. */ | |
944 | 2780 if (((int)options[idx].indir & PV_BOTH) && both) |
7 | 2781 { |
2782 free_string_option(*varp); | |
2783 *varp = empty_option; | |
2784 } | |
694 | 2785 # ifdef FEAT_EVAL |
2786 if (set_sid != SID_NONE) | |
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
|
2787 { |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2788 sctx_T 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
|
2789 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2790 if (set_sid == 0) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2791 script_ctx = current_sctx; |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2792 else |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2793 { |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2794 script_ctx.sc_sid = set_sid; |
15008
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
14997
diff
changeset
|
2795 script_ctx.sc_seq = 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
|
2796 script_ctx.sc_lnum = 0; |
16223
abb67309c1ca
patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
2797 script_ctx.sc_version = 1; |
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
|
2798 } |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2799 set_option_sctx_idx(idx, opt_flags, 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
|
2800 } |
694 | 2801 # endif |
7 | 2802 } |
2803 } | |
2804 | |
2805 /* | |
16806
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2806 * Like set_string_option_direct(), but for a window-local option in "wp". |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2807 * Blocks autocommands to avoid the old curwin becoming invalid. |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2808 */ |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2809 void |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2810 set_string_option_direct_in_win( |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2811 win_T *wp, |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2812 char_u *name, |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2813 int opt_idx, |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2814 char_u *val, |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2815 int opt_flags, |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2816 int set_sid) |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2817 { |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2818 win_T *save_curwin = curwin; |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2819 |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2820 block_autocmds(); |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2821 curwin = wp; |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2822 curbuf = curwin->w_buffer; |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2823 set_string_option_direct(name, opt_idx, val, opt_flags, set_sid); |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2824 curwin = save_curwin; |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2825 curbuf = curwin->w_buffer; |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2826 unblock_autocmds(); |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2827 } |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2828 |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2829 /* |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2830 * Like set_string_option_direct(), but for a buffer-local option in "buf". |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2831 * Blocks autocommands to avoid the old curbuf becoming invalid. |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2832 */ |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2833 void |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2834 set_string_option_direct_in_buf( |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2835 buf_T *buf, |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2836 char_u *name, |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2837 int opt_idx, |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2838 char_u *val, |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2839 int opt_flags, |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2840 int set_sid) |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2841 { |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2842 buf_T *save_curbuf = curbuf; |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2843 |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2844 block_autocmds(); |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2845 curbuf = buf; |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2846 curwin->w_buffer = curbuf; |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2847 set_string_option_direct(name, opt_idx, val, opt_flags, set_sid); |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2848 curbuf = save_curbuf; |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2849 curwin->w_buffer = curbuf; |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2850 unblock_autocmds(); |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2851 } |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2852 |
306766ed0f70
patch 8.1.1405: "highlight" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
2853 /* |
7 | 2854 * Set global value for string option when it's a local option. |
2855 */ | |
2856 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2857 set_string_option_global( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2858 int opt_idx, /* option index */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2859 char_u **varp) /* pointer to option variable */ |
7 | 2860 { |
2861 char_u **p, *s; | |
2862 | |
2863 /* the global value is always allocated */ | |
2864 if (options[opt_idx].var == VAR_WIN) | |
2865 p = (char_u **)GLOBAL_WO(varp); | |
2866 else | |
2867 p = (char_u **)options[opt_idx].var; | |
2868 if (options[opt_idx].indir != PV_NONE | |
2869 && p != varp | |
2870 && (s = vim_strsave(*varp)) != NULL) | |
2871 { | |
2872 free_string_option(*p); | |
2873 *p = s; | |
2874 } | |
2875 } | |
2876 | |
2877 /* | |
2878 * Set a string option to a new value, and handle the effects. | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
2879 * |
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
2880 * 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
|
2881 */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2882 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2883 set_string_option( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2884 int opt_idx, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2885 char_u *value, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2886 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ |
7 | 2887 { |
2888 char_u *s; | |
2889 char_u **varp; | |
2890 char_u *oldval; | |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
2891 #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
|
2892 char_u *oldval_l = NULL; |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2893 char_u *oldval_g = NULL; |
6935 | 2894 char_u *saved_oldval = NULL; |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2895 char_u *saved_oldval_l = NULL; |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2896 char_u *saved_oldval_g = NULL; |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
2897 char_u *saved_newval = NULL; |
6935 | 2898 #endif |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2899 char *r = NULL; |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2900 int value_checked = FALSE; |
7 | 2901 |
2902 if (options[opt_idx].var == NULL) /* don't set hidden option */ | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
2903 return NULL; |
7 | 2904 |
2905 s = vim_strsave(value); | |
2906 if (s != NULL) | |
2907 { | |
2908 varp = (char_u **)get_varp_scope(&(options[opt_idx]), | |
2909 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 | |
692 | 2910 ? (((int)options[opt_idx].indir & PV_BOTH) |
7 | 2911 ? OPT_GLOBAL : OPT_LOCAL) |
2912 : opt_flags); | |
2913 oldval = *varp; | |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
2914 #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
|
2915 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
|
2916 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2917 oldval_l = *(char_u **)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
|
2918 OPT_LOCAL); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2919 oldval_g = *(char_u **)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
|
2920 OPT_GLOBAL); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2921 } |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
2922 #endif |
7 | 2923 *varp = s; |
6935 | 2924 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
2925 #if defined(FEAT_EVAL) |
6939 | 2926 if (!starting |
2927 # ifdef FEAT_CRYPT | |
2928 && options[opt_idx].indir != PV_KEY | |
2929 # endif | |
2930 ) | |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
2931 { |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2932 if (oldval_l != NULL) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2933 saved_oldval_l = vim_strsave(oldval_l); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2934 if (oldval_g != NULL) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2935 saved_oldval_g = vim_strsave(oldval_g); |
6935 | 2936 saved_oldval = vim_strsave(oldval); |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
2937 saved_newval = vim_strsave(s); |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
2938 } |
6935 | 2939 #endif |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
2940 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL, |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2941 opt_flags, &value_checked)) == NULL) |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2942 did_set_option(opt_idx, opt_flags, TRUE, value_checked); |
6935 | 2943 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
2944 #if defined(FEAT_EVAL) |
10962
6da4287fd735
patch 8.0.0370: invalid memory access when setting wildchar empty
Christian Brabandt <cb@256bit.org>
parents:
10960
diff
changeset
|
2945 /* call autocommand after handling side effects */ |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2946 if (r == NULL) |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2947 trigger_optionsset_string(opt_idx, opt_flags, |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2948 saved_oldval, saved_oldval_l, |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2949 saved_oldval_g, 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
|
2950 vim_free(saved_oldval); |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2951 vim_free(saved_oldval_l); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2952 vim_free(saved_oldval_g); |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2953 vim_free(saved_newval); |
6935 | 2954 #endif |
7 | 2955 } |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
2956 return r; |
7 | 2957 } |
2958 | |
2959 /* | |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2960 * 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
|
2961 * 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
|
2962 */ |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17845
diff
changeset
|
2963 int |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2964 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
|
2965 { |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2966 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
|
2967 |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2968 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
|
2969 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
|
2970 return FALSE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2971 return TRUE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2972 } |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2973 |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2974 /* |
10322
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
2975 * Return TRUE if "val" is a valid 'filetype' name. |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
2976 * Also used for 'syntax' and 'keymap'. |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
2977 */ |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
2978 static int |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
2979 valid_filetype(char_u *val) |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
2980 { |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2981 return valid_name(val, ".-_"); |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2982 } |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2983 |
16279
36d97f2a4c2b
patch 8.1.1144: too strict checking of the 'spellfile' option
Bram Moolenaar <Bram@vim.org>
parents:
16277
diff
changeset
|
2984 /* |
7 | 2985 * Handle string options that need some action to perform when changed. |
2986 * Returns NULL for success, or an error message for an error. | |
2987 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2988 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2989 did_set_string_option( |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2990 int opt_idx, // index in options[] table |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2991 char_u **varp, // pointer to the option variable |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2992 int new_value_alloced, // new value was allocated |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2993 char_u *oldval, // previous value of the option |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2994 char *errbuf, // buffer for errors, or NULL |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2995 int opt_flags, // OPT_LOCAL and/or OPT_GLOBAL |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2996 int *value_checked) // value was checked to be save, no |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2997 // need to set P_INSECURE |
7 | 2998 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2999 char *errmsg = NULL; |
7 | 3000 char_u *s, *p; |
3001 int did_chartab = FALSE; | |
3002 char_u **gvarp; | |
835 | 3003 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED); |
1801 | 3004 #ifdef FEAT_GUI |
3005 /* set when changing an option that only requires a redraw in the GUI */ | |
3006 int redraw_gui_only = FALSE; | |
3007 #endif | |
14097
db44cd9f8068
patch 8.1.0066: nasty autocommand causes using freed memory
Christian Brabandt <cb@256bit.org>
parents:
14087
diff
changeset
|
3008 int value_changed = FALSE; |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3009 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3010 int did_swaptcap = FALSE; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3011 #endif |
7 | 3012 |
3013 /* Get the global option to compare with, otherwise we would have to check | |
3014 * two values for all local options. */ | |
3015 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL); | |
3016 | |
3017 /* Disallow changing some options from secure mode */ | |
3018 if ((secure | |
3019 #ifdef HAVE_SANDBOX | |
3020 || sandbox != 0 | |
3021 #endif | |
3022 ) && (options[opt_idx].flags & P_SECURE)) | |
3023 errmsg = e_secure; | |
3024 | |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3025 // Check for a "normal" directory or file name in some options. Disallow a |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3026 // path separator (slash and/or backslash), wildcards and characters that |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3027 // are often illegal in a file name. Be more permissive if "secure" is off. |
10416
ef5474130b0e
commit https://github.com/vim/vim/commit/7554da4033498c4da0af3cde542c3e87e9097b73
Christian Brabandt <cb@256bit.org>
parents:
10414
diff
changeset
|
3028 else if (((options[opt_idx].flags & P_NFNAME) |
10424
bc97f64c21c2
commit https://github.com/vim/vim/commit/0945eaface83e78138fbd40f95cc590bab0e8c86
Christian Brabandt <cb@256bit.org>
parents:
10420
diff
changeset
|
3029 && vim_strpbrk(*varp, (char_u *)(secure |
bc97f64c21c2
commit https://github.com/vim/vim/commit/0945eaface83e78138fbd40f95cc590bab0e8c86
Christian Brabandt <cb@256bit.org>
parents:
10420
diff
changeset
|
3030 ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL) |
10416
ef5474130b0e
commit https://github.com/vim/vim/commit/7554da4033498c4da0af3cde542c3e87e9097b73
Christian Brabandt <cb@256bit.org>
parents:
10414
diff
changeset
|
3031 || ((options[opt_idx].flags & P_NDNAME) |
ef5474130b0e
commit https://github.com/vim/vim/commit/7554da4033498c4da0af3cde542c3e87e9097b73
Christian Brabandt <cb@256bit.org>
parents:
10414
diff
changeset
|
3032 && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL)) |
36 | 3033 errmsg = e_invarg; |
3034 | |
7 | 3035 /* 'term' */ |
3036 else if (varp == &T_NAME) | |
3037 { | |
3038 if (T_NAME[0] == NUL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3039 errmsg = N_("E529: Cannot set 'term' to empty string"); |
7 | 3040 #ifdef FEAT_GUI |
3041 if (gui.in_use) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3042 errmsg = N_("E530: Cannot change term in GUI"); |
7 | 3043 else if (term_is_gui(T_NAME)) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3044 errmsg = N_("E531: Use \":gui\" to start the GUI"); |
7 | 3045 #endif |
3046 else if (set_termname(T_NAME) == FAIL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3047 errmsg = N_("E522: Not found in termcap"); |
7 | 3048 else |
10906
7fc1df5536c9
patch 8.0.0342: double free with EXITFREE and setting 'ttytype'
Christian Brabandt <cb@256bit.org>
parents:
10887
diff
changeset
|
3049 { |
7 | 3050 /* Screen colors may have changed. */ |
3051 redraw_later_clear(); | |
10906
7fc1df5536c9
patch 8.0.0342: double free with EXITFREE and setting 'ttytype'
Christian Brabandt <cb@256bit.org>
parents:
10887
diff
changeset
|
3052 |
7fc1df5536c9
patch 8.0.0342: double free with EXITFREE and setting 'ttytype'
Christian Brabandt <cb@256bit.org>
parents:
10887
diff
changeset
|
3053 /* Both 'term' and 'ttytype' point to T_NAME, only set the |
7fc1df5536c9
patch 8.0.0342: double free with EXITFREE and setting 'ttytype'
Christian Brabandt <cb@256bit.org>
parents:
10887
diff
changeset
|
3054 * P_ALLOCED flag on 'term'. */ |
7fc1df5536c9
patch 8.0.0342: double free with EXITFREE and setting 'ttytype'
Christian Brabandt <cb@256bit.org>
parents:
10887
diff
changeset
|
3055 opt_idx = findoption((char_u *)"term"); |
10934
32b299ae6752
patch 8.0.0356: leaking memory when setting 'ttytype'
Christian Brabandt <cb@256bit.org>
parents:
10906
diff
changeset
|
3056 free_oldval = (options[opt_idx].flags & P_ALLOCED); |
10906
7fc1df5536c9
patch 8.0.0342: double free with EXITFREE and setting 'ttytype'
Christian Brabandt <cb@256bit.org>
parents:
10887
diff
changeset
|
3057 } |
7 | 3058 } |
3059 | |
3060 /* 'backupcopy' */ | |
6243 | 3061 else if (gvarp == &p_bkc) |
3062 { | |
3063 char_u *bkc = p_bkc; | |
3064 unsigned int *flags = &bkc_flags; | |
3065 | |
3066 if (opt_flags & OPT_LOCAL) | |
3067 { | |
3068 bkc = curbuf->b_p_bkc; | |
3069 flags = &curbuf->b_bkc_flags; | |
3070 } | |
3071 | |
6255 | 3072 if ((opt_flags & OPT_LOCAL) && *bkc == NUL) |
3073 /* make the local value empty: use the global value */ | |
3074 *flags = 0; | |
3075 else | |
3076 { | |
3077 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK) | |
3078 errmsg = e_invarg; | |
3079 if ((((int)*flags & BKC_AUTO) != 0) | |
3080 + (((int)*flags & BKC_YES) != 0) | |
3081 + (((int)*flags & BKC_NO) != 0) != 1) | |
3082 { | |
3083 /* Must have exactly one of "auto", "yes" and "no". */ | |
3084 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE); | |
3085 errmsg = e_invarg; | |
3086 } | |
7 | 3087 } |
3088 } | |
3089 | |
3090 /* 'backupext' and 'patchmode' */ | |
3091 else if (varp == &p_bex || varp == &p_pm) | |
3092 { | |
3093 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex, | |
3094 *p_pm == '.' ? p_pm + 1 : p_pm) == 0) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3095 errmsg = N_("E589: 'backupext' and 'patchmode' are equal"); |
7 | 3096 } |
5995 | 3097 #ifdef FEAT_LINEBREAK |
3098 /* 'breakindentopt' */ | |
3099 else if (varp == &curwin->w_p_briopt) | |
3100 { | |
6162 | 3101 if (briopt_check(curwin) == FAIL) |
5995 | 3102 errmsg = e_invarg; |
3103 } | |
3104 #endif | |
7 | 3105 |
3106 /* | |
7697
f04e2b6feea2
commit https://github.com/vim/vim/commit/88e8f9f14434a7cd538d0c159dc432bea869a5bd
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
3107 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[] |
7 | 3108 * If the new option is invalid, use old value. 'lisp' option: refill |
7697
f04e2b6feea2
commit https://github.com/vim/vim/commit/88e8f9f14434a7cd538d0c159dc432bea869a5bd
Christian Brabandt <cb@256bit.org>
parents:
7687
diff
changeset
|
3109 * g_chartab[] for '-' char |
7 | 3110 */ |
3111 else if ( varp == &p_isi | |
3112 || varp == &(curbuf->b_p_isk) | |
3113 || varp == &p_isp | |
3114 || varp == &p_isf) | |
3115 { | |
3116 if (init_chartab() == FAIL) | |
3117 { | |
3118 did_chartab = TRUE; /* need to restore it below */ | |
3119 errmsg = e_invarg; /* error in value */ | |
3120 } | |
3121 } | |
3122 | |
3123 /* 'helpfile' */ | |
3124 else if (varp == &p_hf) | |
3125 { | |
3126 /* May compute new values for $VIM and $VIMRUNTIME */ | |
3127 if (didset_vim) | |
3128 { | |
3129 vim_setenv((char_u *)"VIM", (char_u *)""); | |
3130 didset_vim = FALSE; | |
3131 } | |
3132 if (didset_vimruntime) | |
3133 { | |
3134 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)""); | |
3135 didset_vimruntime = FALSE; | |
3136 } | |
3137 } | |
3138 | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3139 #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
|
3140 /* 'cursorlineopt' */ |
6650e3dff8d4
patch 8.1.2019: 'cursorline' always highlights the whole line
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
3141 else if (varp == &curwin->w_p_culopt |
6650e3dff8d4
patch 8.1.2019: 'cursorline' always highlights the whole line
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
3142 || gvarp == &curwin->w_allbuf_opt.wo_culopt) |
6650e3dff8d4
patch 8.1.2019: 'cursorline' always highlights the whole line
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
3143 { |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
3144 if (**varp == NUL || fill_culopt_flags(*varp, curwin) != OK) |
18047
6650e3dff8d4
patch 8.1.2019: 'cursorline' always highlights the whole line
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
3145 errmsg = e_invarg; |
6650e3dff8d4
patch 8.1.2019: 'cursorline' always highlights the whole line
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
3146 } |
6650e3dff8d4
patch 8.1.2019: 'cursorline' always highlights the whole line
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
3147 |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3148 /* 'colorcolumn' */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3149 else if (varp == &curwin->w_p_cc) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3150 errmsg = check_colorcolumn(curwin); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3151 #endif |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3152 |
7 | 3153 #ifdef FEAT_MULTI_LANG |
3154 /* 'helplang' */ | |
3155 else if (varp == &p_hlg) | |
3156 { | |
3157 /* Check for "", "ab", "ab,cd", etc. */ | |
3158 for (s = p_hlg; *s != NUL; s += 3) | |
3159 { | |
3160 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) | |
3161 { | |
3162 errmsg = e_invarg; | |
3163 break; | |
3164 } | |
3165 if (s[2] == NUL) | |
3166 break; | |
3167 } | |
3168 } | |
3169 #endif | |
3170 | |
3171 /* 'highlight' */ | |
3172 else if (varp == &p_hl) | |
3173 { | |
3174 if (highlight_changed() == FAIL) | |
3175 errmsg = e_invarg; /* invalid flags */ | |
3176 } | |
3177 | |
3178 /* 'nrformats' */ | |
3179 else if (gvarp == &p_nf) | |
3180 { | |
3181 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK) | |
3182 errmsg = e_invarg; | |
3183 } | |
3184 | |
3185 #ifdef FEAT_SESSION | |
3186 /* 'sessionoptions' */ | |
3187 else if (varp == &p_ssop) | |
3188 { | |
3189 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK) | |
3190 errmsg = e_invarg; | |
3191 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR)) | |
3192 { | |
3193 /* Don't allow both "sesdir" and "curdir". */ | |
3194 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE); | |
3195 errmsg = e_invarg; | |
3196 } | |
3197 } | |
3198 /* 'viewoptions' */ | |
3199 else if (varp == &p_vop) | |
3200 { | |
3201 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK) | |
3202 errmsg = e_invarg; | |
3203 } | |
3204 #endif | |
3205 | |
3206 /* 'scrollopt' */ | |
3207 else if (varp == &p_sbo) | |
3208 { | |
3209 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK) | |
3210 errmsg = e_invarg; | |
3211 } | |
3212 | |
3213 /* 'ambiwidth' */ | |
8629
54ac275e3fc4
commit https://github.com/vim/vim/commit/3848e00e0177abdb31bc600234967863ec487233
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
3214 else if (varp == &p_ambw || varp == &p_emoji) |
7 | 3215 { |
3216 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK) | |
3217 errmsg = e_invarg; | |
2492
c945fdb34ce3
Disallow setting 'ambiwidth' to "double" when 'listchars' or 'fillchars'
Bram Moolenaar <bram@vim.org>
parents:
2452
diff
changeset
|
3218 else if (set_chars_option(&p_lcs) != NULL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3219 errmsg = _("E834: Conflicts with value of 'listchars'"); |
2492
c945fdb34ce3
Disallow setting 'ambiwidth' to "double" when 'listchars' or 'fillchars'
Bram Moolenaar <bram@vim.org>
parents:
2452
diff
changeset
|
3220 else if (set_chars_option(&p_fcs) != NULL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3221 errmsg = _("E835: Conflicts with value of 'fillchars'"); |
7 | 3222 } |
3223 | |
3224 /* 'background' */ | |
3225 else if (varp == &p_bg) | |
3226 { | |
3227 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK) | |
3228 { | |
3229 #ifdef FEAT_EVAL | |
3230 int dark = (*p_bg == 'd'); | |
3231 #endif | |
3232 | |
3233 init_highlight(FALSE, FALSE); | |
3234 | |
3235 #ifdef FEAT_EVAL | |
3236 if (dark != (*p_bg == 'd') | |
3237 && get_var_value((char_u *)"g:colors_name") != NULL) | |
3238 { | |
3239 /* The color scheme must have set 'background' back to another | |
3240 * value, that's not what we want here. Disable the color | |
3241 * scheme and set the colors again. */ | |
148 | 3242 do_unlet((char_u *)"g:colors_name", TRUE); |
7 | 3243 free_string_option(p_bg); |
3244 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light")); | |
3245 check_string_option(&p_bg); | |
3246 init_highlight(FALSE, FALSE); | |
3247 } | |
3248 #endif | |
3249 } | |
3250 else | |
3251 errmsg = e_invarg; | |
3252 } | |
3253 | |
3254 /* 'wildmode' */ | |
3255 else if (varp == &p_wim) | |
3256 { | |
3257 if (check_opt_wim() == FAIL) | |
3258 errmsg = e_invarg; | |
3259 } | |
3260 | |
40 | 3261 /* 'wildoptions' */ |
3262 else if (varp == &p_wop) | |
3263 { | |
3264 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK) | |
3265 errmsg = e_invarg; | |
3266 } | |
3267 | |
7 | 3268 #ifdef FEAT_WAK |
3269 /* 'winaltkeys' */ | |
3270 else if (varp == &p_wak) | |
3271 { | |
3272 if (*p_wak == NUL | |
3273 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK) | |
3274 errmsg = e_invarg; | |
3275 # ifdef FEAT_MENU | |
3276 # ifdef FEAT_GUI_MOTIF | |
3277 else if (gui.in_use) | |
3278 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm'); | |
3279 # else | |
3280 # ifdef FEAT_GUI_GTK | |
3281 else if (gui.in_use) | |
3282 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm'); | |
3283 # endif | |
3284 # endif | |
3285 # endif | |
3286 } | |
3287 #endif | |
3288 | |
3289 /* 'eventignore' */ | |
3290 else if (varp == &p_ei) | |
3291 { | |
3292 if (check_ei() == FAIL) | |
3293 errmsg = e_invarg; | |
3294 } | |
3295 | |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
3296 /* 'encoding', 'fileencoding', 'termencoding' and 'makeencoding' */ |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
3297 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
3298 || gvarp == &p_menc) |
7 | 3299 { |
3300 if (gvarp == &p_fenc) | |
3301 { | |
1535 | 3302 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL) |
7 | 3303 errmsg = e_modifiable; |
3304 else if (vim_strchr(*varp, ',') != NULL) | |
3305 /* No comma allowed in 'fileencoding'; catches confusing it | |
3306 * with 'fileencodings'. */ | |
3307 errmsg = e_invarg; | |
39 | 3308 else |
3309 { | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3310 #ifdef FEAT_TITLE |
7 | 3311 /* May show a "+" in the title now. */ |
1805 | 3312 redraw_titles(); |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3313 #endif |
39 | 3314 /* Add 'fileencoding' to the swap file. */ |
3315 ml_setflags(curbuf); | |
3316 } | |
7 | 3317 } |
3318 if (errmsg == NULL) | |
3319 { | |
3320 /* canonize the value, so that STRCMP() can be used on it */ | |
3321 p = enc_canonize(*varp); | |
3322 if (p != NULL) | |
3323 { | |
3324 vim_free(*varp); | |
3325 *varp = p; | |
3326 } | |
3327 if (varp == &p_enc) | |
3328 { | |
3329 errmsg = mb_init(); | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3330 #ifdef FEAT_TITLE |
1805 | 3331 redraw_titles(); |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3332 #endif |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3333 } |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3334 } |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3335 |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3336 #if defined(FEAT_GUI_GTK) |
7 | 3337 if (errmsg == NULL && varp == &p_tenc && gui.in_use) |
3338 { | |
3339 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */ | |
3340 if (STRCMP(p_tenc, "utf-8") != 0) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3341 errmsg = N_("E617: Cannot be changed in the GTK+ 2 GUI"); |
7 | 3342 } |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3343 #endif |
7 | 3344 |
3345 if (errmsg == NULL) | |
3346 { | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3347 #ifdef FEAT_KEYMAP |
7 | 3348 /* When 'keymap' is used and 'encoding' changes, reload the keymap |
3349 * (with another encoding). */ | |
3350 if (varp == &p_enc && *curbuf->b_p_keymap != NUL) | |
3351 (void)keymap_init(); | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3352 #endif |
7 | 3353 |
3354 /* When 'termencoding' is not empty and 'encoding' changes or when | |
3355 * 'termencoding' changes, need to setup for keyboard input and | |
3356 * display output conversion. */ | |
3357 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc)) | |
3358 { | |
12946
eae40b455a72
patch 8.0.1349: options test fails when using Motif or GTK GUI
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
3359 if (convert_setup(&input_conv, p_tenc, p_enc) == FAIL |
eae40b455a72
patch 8.0.1349: options test fails when using Motif or GTK GUI
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
3360 || convert_setup(&output_conv, p_enc, p_tenc) == FAIL) |
eae40b455a72
patch 8.0.1349: options test fails when using Motif or GTK GUI
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
3361 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3362 semsg(_("E950: Cannot convert between %s and %s"), |
12946
eae40b455a72
patch 8.0.1349: options test fails when using Motif or GTK GUI
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
3363 p_tenc, p_enc); |
eae40b455a72
patch 8.0.1349: options test fails when using Motif or GTK GUI
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
3364 errmsg = e_invarg; |
eae40b455a72
patch 8.0.1349: options test fails when using Motif or GTK GUI
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
3365 } |
7 | 3366 } |
170 | 3367 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
3368 #if defined(MSWIN) |
170 | 3369 /* $HOME may have characters in active code page. */ |
3370 if (varp == &p_enc) | |
3371 init_homedir(); | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3372 #endif |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3373 } |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3374 } |
7 | 3375 |
3376 #if defined(FEAT_POSTSCRIPT) | |
3377 else if (varp == &p_penc) | |
3378 { | |
3379 /* Canonize printencoding if VIM standard one */ | |
3380 p = enc_canonize(p_penc); | |
3381 if (p != NULL) | |
3382 { | |
3383 vim_free(p_penc); | |
3384 p_penc = p; | |
3385 } | |
3386 else | |
3387 { | |
3388 /* Ensure lower case and '-' for '_' */ | |
3389 for (s = p_penc; *s != NUL; s++) | |
3390 { | |
3391 if (*s == '_') | |
3392 *s = '-'; | |
3393 else | |
3394 *s = TOLOWER_ASC(*s); | |
3395 } | |
3396 } | |
3397 } | |
3398 #endif | |
3399 | |
574 | 3400 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
7 | 3401 else if (varp == &p_imak) |
3402 { | |
11401
fc1939947789
patch 8.0.0585: test_options fails when run in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11356
diff
changeset
|
3403 if (!im_xim_isvalid_imactivate()) |
7 | 3404 errmsg = e_invarg; |
3405 } | |
3406 #endif | |
3407 | |
3408 #ifdef FEAT_KEYMAP | |
3409 else if (varp == &curbuf->b_p_keymap) | |
3410 { | |
10322
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
3411 if (!valid_filetype(*varp)) |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
3412 errmsg = e_invarg; |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
3413 else |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3414 { |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3415 int secure_save = secure; |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3416 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3417 // Reset the secure flag, since the value of 'keymap' has |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3418 // been checked to be safe. |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3419 secure = 0; |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3420 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3421 // load or unload key mapping tables |
10322
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
3422 errmsg = keymap_init(); |
7 | 3423 |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3424 secure = secure_save; |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3425 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3426 // Since we check the value, there is no need to set P_INSECURE, |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3427 // even when the value comes from a modeline. |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3428 *value_checked = TRUE; |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3429 } |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
3430 |
1833 | 3431 if (errmsg == NULL) |
3432 { | |
3433 if (*curbuf->b_p_keymap != NUL) | |
3434 { | |
3435 /* Installed a new keymap, switch on using it. */ | |
3436 curbuf->b_p_iminsert = B_IMODE_LMAP; | |
3437 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT) | |
3438 curbuf->b_p_imsearch = B_IMODE_LMAP; | |
3439 } | |
3440 else | |
3441 { | |
3442 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */ | |
3443 if (curbuf->b_p_iminsert == B_IMODE_LMAP) | |
3444 curbuf->b_p_iminsert = B_IMODE_NONE; | |
3445 if (curbuf->b_p_imsearch == B_IMODE_LMAP) | |
3446 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; | |
3447 } | |
3448 if ((opt_flags & OPT_LOCAL) == 0) | |
3449 { | |
3450 set_iminsert_global(); | |
3451 set_imsearch_global(); | |
3452 } | |
7 | 3453 status_redraw_curbuf(); |
3454 } | |
3455 } | |
3456 #endif | |
3457 | |
3458 /* 'fileformat' */ | |
3459 else if (gvarp == &p_ff) | |
3460 { | |
3461 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL)) | |
3462 errmsg = e_modifiable; | |
3463 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK) | |
3464 errmsg = e_invarg; | |
3465 else | |
3466 { | |
3467 /* may also change 'textmode' */ | |
3468 if (get_fileformat(curbuf) == EOL_DOS) | |
3469 curbuf->b_p_tx = TRUE; | |
3470 else | |
3471 curbuf->b_p_tx = FALSE; | |
3472 #ifdef FEAT_TITLE | |
1805 | 3473 redraw_titles(); |
7 | 3474 #endif |
39 | 3475 /* update flag in swap file */ |
3476 ml_setflags(curbuf); | |
2073
5bedef935ce3
updated for version 7.2.357
Bram Moolenaar <bram@zimbu.org>
parents:
2060
diff
changeset
|
3477 /* Redraw needed when switching to/from "mac": a CR in the text |
5bedef935ce3
updated for version 7.2.357
Bram Moolenaar <bram@zimbu.org>
parents:
2060
diff
changeset
|
3478 * will be displayed differently. */ |
5bedef935ce3
updated for version 7.2.357
Bram Moolenaar <bram@zimbu.org>
parents:
2060
diff
changeset
|
3479 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm') |
5bedef935ce3
updated for version 7.2.357
Bram Moolenaar <bram@zimbu.org>
parents:
2060
diff
changeset
|
3480 redraw_curbuf_later(NOT_VALID); |
7 | 3481 } |
3482 } | |
3483 | |
3484 /* 'fileformats' */ | |
3485 else if (varp == &p_ffs) | |
3486 { | |
3487 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK) | |
3488 errmsg = e_invarg; | |
3489 else | |
3490 { | |
3491 /* also change 'textauto' */ | |
3492 if (*p_ffs == NUL) | |
3493 p_ta = FALSE; | |
3494 else | |
3495 p_ta = TRUE; | |
3496 } | |
3497 } | |
3498 | |
2267 | 3499 #if defined(FEAT_CRYPT) |
7 | 3500 /* 'cryptkey' */ |
3501 else if (gvarp == &p_key) | |
3502 { | |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17596
diff
changeset
|
3503 // Make sure the ":set" command doesn't show the new value in the |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17596
diff
changeset
|
3504 // history. |
7 | 3505 remove_key_from_history(); |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17596
diff
changeset
|
3506 |
2267 | 3507 if (STRCMP(curbuf->b_p_key, oldval) != 0) |
3508 /* Need to update the swapfile. */ | |
6817 | 3509 ml_set_crypt_key(curbuf, oldval, |
3510 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm); | |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3511 } |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3512 |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3513 else if (gvarp == &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
|
3514 { |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3515 if (opt_flags & OPT_LOCAL) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3516 p = 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
|
3517 else |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3518 p = 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
|
3519 if (check_opt_strings(p, p_cm_values, TRUE) != OK) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3520 errmsg = e_invarg; |
6122 | 3521 else if (crypt_self_test() == FAIL) |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3522 errmsg = e_invarg; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3523 else |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3524 { |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3525 /* When setting the global value to empty, make it "zip". */ |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3526 if (*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
|
3527 { |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3528 if (new_value_alloced) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3529 free_string_option(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
|
3530 p_cm = vim_strsave((char_u *)"zip"); |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3531 new_value_alloced = TRUE; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3532 } |
6130 | 3533 /* When using ":set cm=name" the local value is going to be empty. |
3534 * Do that here, otherwise the crypt functions will still use the | |
3535 * local value. */ | |
3536 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) | |
3537 { | |
3538 free_string_option(curbuf->b_p_cm); | |
3539 curbuf->b_p_cm = empty_option; | |
3540 } | |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3541 |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3542 /* Need to update the swapfile when the effective method changed. |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3543 * Set "s" to the effective old value, "p" to the effective new |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3544 * method and compare. */ |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3545 if ((opt_flags & OPT_LOCAL) && *oldval == NUL) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3546 s = p_cm; /* was previously using the global value */ |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3547 else |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3548 s = oldval; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3549 if (*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
|
3550 p = p_cm; /* is now using the global value */ |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3551 else |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3552 p = 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
|
3553 if (STRCMP(s, p) != 0) |
6817 | 3554 ml_set_crypt_key(curbuf, curbuf->b_p_key, s); |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3555 |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3556 /* If the global value changes need to update the swapfile for all |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3557 * buffers using that value. */ |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3558 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3559 { |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3560 buf_T *buf; |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3561 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
3562 FOR_ALL_BUFFERS(buf) |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3563 if (buf != curbuf && *buf->b_p_cm == NUL) |
6817 | 3564 ml_set_crypt_key(buf, buf->b_p_key, oldval); |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3565 } |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
3566 } |
7 | 3567 } |
3568 #endif | |
3569 | |
3570 /* 'matchpairs' */ | |
3571 else if (gvarp == &p_mps) | |
3572 { | |
4029 | 3573 if (has_mbyte) |
3574 { | |
3575 for (p = *varp; *p != NUL; ++p) | |
3576 { | |
4033 | 3577 int x2 = -1; |
3578 int x3 = -1; | |
4029 | 3579 |
3580 if (*p != NUL) | |
3581 p += mb_ptr2len(p); | |
3582 if (*p != NUL) | |
3583 x2 = *p++; | |
3584 if (*p != NUL) | |
3585 { | |
3586 x3 = mb_ptr2char(p); | |
3587 p += mb_ptr2len(p); | |
3588 } | |
4033 | 3589 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ',')) |
4029 | 3590 { |
3591 errmsg = e_invarg; | |
3592 break; | |
3593 } | |
3594 if (*p == NUL) | |
3595 break; | |
3596 } | |
3597 } | |
3598 else | |
3599 { | |
3600 /* Check for "x:y,x:y" */ | |
3601 for (p = *varp; *p != NUL; p += 4) | |
3602 { | |
3603 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ',')) | |
3604 { | |
3605 errmsg = e_invarg; | |
3606 break; | |
3607 } | |
3608 if (p[3] == NUL) | |
3609 break; | |
3610 } | |
7 | 3611 } |
3612 } | |
3613 | |
3614 #ifdef FEAT_COMMENTS | |
3615 /* 'comments' */ | |
3616 else if (gvarp == &p_com) | |
3617 { | |
3618 for (s = *varp; *s; ) | |
3619 { | |
3620 while (*s && *s != ':') | |
3621 { | |
3622 if (vim_strchr((char_u *)COM_ALL, *s) == NULL | |
3623 && !VIM_ISDIGIT(*s) && *s != '-') | |
3624 { | |
3625 errmsg = illegal_char(errbuf, *s); | |
3626 break; | |
3627 } | |
3628 ++s; | |
3629 } | |
3630 if (*s++ == NUL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3631 errmsg = N_("E524: Missing colon"); |
7 | 3632 else if (*s == ',' || *s == NUL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3633 errmsg = N_("E525: Zero length string"); |
7 | 3634 if (errmsg != NULL) |
3635 break; | |
3636 while (*s && *s != ',') | |
3637 { | |
3638 if (*s == '\\' && s[1] != NUL) | |
3639 ++s; | |
3640 ++s; | |
3641 } | |
3642 s = skip_to_option_part(s); | |
3643 } | |
3644 } | |
3645 #endif | |
3646 | |
3647 /* 'listchars' */ | |
3648 else if (varp == &p_lcs) | |
3649 { | |
3650 errmsg = set_chars_option(varp); | |
3651 } | |
3652 | |
3653 /* 'fillchars' */ | |
3654 else if (varp == &p_fcs) | |
3655 { | |
3656 errmsg = set_chars_option(varp); | |
3657 } | |
3658 | |
3659 #ifdef FEAT_CMDWIN | |
3660 /* 'cedit' */ | |
3661 else if (varp == &p_cedit) | |
3662 { | |
3663 errmsg = check_cedit(); | |
3664 } | |
3665 #endif | |
3666 | |
294 | 3667 /* 'verbosefile' */ |
3668 else if (varp == &p_vfile) | |
3669 { | |
3670 verbose_stop(); | |
3671 if (*p_vfile != NUL && verbose_open() == FAIL) | |
3672 errmsg = e_invarg; | |
3673 } | |
3674 | |
7 | 3675 #ifdef FEAT_VIMINFO |
3676 /* 'viminfo' */ | |
3677 else if (varp == &p_viminfo) | |
3678 { | |
3679 for (s = p_viminfo; *s;) | |
3680 { | |
3681 /* Check it's a valid character */ | |
3682 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) | |
3683 { | |
3684 errmsg = illegal_char(errbuf, *s); | |
3685 break; | |
3686 } | |
3687 if (*s == 'n') /* name is always last one */ | |
3688 break; | |
3689 else if (*s == 'r') /* skip until next ',' */ | |
3690 { | |
3691 while (*++s && *s != ',') | |
3692 ; | |
3693 } | |
23 | 3694 else if (*s == '%') |
3695 { | |
3696 /* optional number */ | |
3697 while (vim_isdigit(*++s)) | |
3698 ; | |
3699 } | |
3700 else if (*s == '!' || *s == 'h' || *s == 'c') | |
7 | 3701 ++s; /* no extra chars */ |
3702 else /* must have a number */ | |
3703 { | |
3704 while (vim_isdigit(*++s)) | |
3705 ; | |
3706 | |
3707 if (!VIM_ISDIGIT(*(s - 1))) | |
3708 { | |
3709 if (errbuf != NULL) | |
3710 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3711 sprintf(errbuf, _("E526: Missing number after <%s>"), |
7 | 3712 transchar_byte(*(s - 1))); |
3713 errmsg = errbuf; | |
3714 } | |
3715 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3716 errmsg = ""; |
7 | 3717 break; |
3718 } | |
3719 } | |
3720 if (*s == ',') | |
3721 ++s; | |
3722 else if (*s) | |
3723 { | |
3724 if (errbuf != NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3725 errmsg = N_("E527: Missing comma"); |
7 | 3726 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3727 errmsg = ""; |
7 | 3728 break; |
3729 } | |
3730 } | |
3731 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3732 errmsg = N_("E528: Must specify a ' value"); |
7 | 3733 } |
3734 #endif /* FEAT_VIMINFO */ | |
3735 | |
3736 /* terminal options */ | |
3737 else if (istermoption(&options[opt_idx]) && full_screen) | |
3738 { | |
3739 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */ | |
3740 if (varp == &T_CCO) | |
3741 { | |
1846 | 3742 int colors = atoi((char *)T_CCO); |
3743 | |
3744 /* Only reinitialize colors if t_Co value has really changed to | |
3745 * avoid expensive reload of colorscheme if t_Co is set to the | |
3746 * same value multiple times. */ | |
3747 if (colors != t_colors) | |
3748 { | |
3749 t_colors = colors; | |
3750 if (t_colors <= 1) | |
3751 { | |
3752 if (new_value_alloced) | |
3753 vim_free(T_CCO); | |
3754 T_CCO = empty_option; | |
3755 } | |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3756 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3757 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
|
3758 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3759 swap_tcap(); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3760 did_swaptcap = TRUE; |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3761 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3762 #endif |
1846 | 3763 /* We now have a different color setup, initialize it again. */ |
3764 init_highlight(TRUE, FALSE); | |
3765 } | |
7 | 3766 } |
3767 ttest(FALSE); | |
3768 if (varp == &T_ME) | |
3769 { | |
3770 out_str(T_ME); | |
3771 redraw_later(CLEAR); | |
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
|
3772 #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) |
7 | 3773 /* Since t_me has been set, this probably means that the user |
3774 * wants to use this as default colors. Need to reset default | |
3775 * background/foreground colors. */ | |
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
|
3776 # 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
|
3777 if (!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
|
3778 # 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
|
3779 mch_set_normal_colors(); |
7 | 3780 #endif |
3781 } | |
10708
4940a195bd1f
patch 8.0.0244: making t_BE empty only has an effect before startup
Christian Brabandt <cb@256bit.org>
parents:
10640
diff
changeset
|
3782 if (varp == &T_BE && termcap_active) |
4940a195bd1f
patch 8.0.0244: making t_BE empty only has an effect before startup
Christian Brabandt <cb@256bit.org>
parents:
10640
diff
changeset
|
3783 { |
4940a195bd1f
patch 8.0.0244: making t_BE empty only has an effect before startup
Christian Brabandt <cb@256bit.org>
parents:
10640
diff
changeset
|
3784 if (*T_BE == NUL) |
4940a195bd1f
patch 8.0.0244: making t_BE empty only has an effect before startup
Christian Brabandt <cb@256bit.org>
parents:
10640
diff
changeset
|
3785 /* When clearing t_BE we assume the user no longer wants |
4940a195bd1f
patch 8.0.0244: making t_BE empty only has an effect before startup
Christian Brabandt <cb@256bit.org>
parents:
10640
diff
changeset
|
3786 * bracketed paste, thus disable it by writing t_BD. */ |
4940a195bd1f
patch 8.0.0244: making t_BE empty only has an effect before startup
Christian Brabandt <cb@256bit.org>
parents:
10640
diff
changeset
|
3787 out_str(T_BD); |
4940a195bd1f
patch 8.0.0244: making t_BE empty only has an effect before startup
Christian Brabandt <cb@256bit.org>
parents:
10640
diff
changeset
|
3788 else |
4940a195bd1f
patch 8.0.0244: making t_BE empty only has an effect before startup
Christian Brabandt <cb@256bit.org>
parents:
10640
diff
changeset
|
3789 out_str(T_BE); |
4940a195bd1f
patch 8.0.0244: making t_BE empty only has an effect before startup
Christian Brabandt <cb@256bit.org>
parents:
10640
diff
changeset
|
3790 } |
7 | 3791 } |
3792 | |
3793 #ifdef FEAT_LINEBREAK | |
3794 /* 'showbreak' */ | |
3795 else if (varp == &p_sbr) | |
3796 { | |
3797 for (s = p_sbr; *s; ) | |
3798 { | |
3799 if (ptr2cells(s) != 1) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3800 errmsg = N_("E595: contains unprintable or wide character"); |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
3801 MB_PTR_ADV(s); |
7 | 3802 } |
3803 } | |
3804 #endif | |
3805 | |
3806 #ifdef FEAT_GUI | |
3807 /* 'guifont' */ | |
3808 else if (varp == &p_guifont) | |
3809 { | |
3810 if (gui.in_use) | |
3811 { | |
3812 p = p_guifont; | |
574 | 3813 # if defined(FEAT_GUI_GTK) |
7 | 3814 /* |
3815 * Put up a font dialog and let the user select a new value. | |
3816 * If this is cancelled go back to the old value but don't | |
3817 * give an error message. | |
3818 */ | |
3819 if (STRCMP(p, "*") == 0) | |
3820 { | |
3821 p = gui_mch_font_dialog(oldval); | |
3822 | |
3823 if (new_value_alloced) | |
3824 free_string_option(p_guifont); | |
3825 | |
3826 p_guifont = (p != NULL) ? p : vim_strsave(oldval); | |
3827 new_value_alloced = TRUE; | |
3828 } | |
3829 # endif | |
3830 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK) | |
3831 { | |
3832 # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON) | |
3833 if (STRCMP(p_guifont, "*") == 0) | |
3834 { | |
3835 /* Dialog was cancelled: Keep the old value without giving | |
3836 * an error message. */ | |
3837 if (new_value_alloced) | |
3838 free_string_option(p_guifont); | |
3839 p_guifont = vim_strsave(oldval); | |
3840 new_value_alloced = TRUE; | |
3841 } | |
3842 else | |
3843 # endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3844 errmsg = N_("E596: Invalid font(s)"); |
7 | 3845 } |
3846 } | |
1801 | 3847 redraw_gui_only = TRUE; |
7 | 3848 } |
3849 # ifdef FEAT_XFONTSET | |
3850 else if (varp == &p_guifontset) | |
3851 { | |
3852 if (STRCMP(p_guifontset, "*") == 0) | |
15472
0fcc1315c061
patch 8.1.0744: compiler warnings for signed/unsigned strings
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3853 errmsg = N_("E597: can't select fontset"); |
7 | 3854 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK) |
15472
0fcc1315c061
patch 8.1.0744: compiler warnings for signed/unsigned strings
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3855 errmsg = N_("E598: Invalid fontset"); |
1801 | 3856 redraw_gui_only = TRUE; |
7 | 3857 } |
3858 # endif | |
3859 else if (varp == &p_guifontwide) | |
3860 { | |
3861 if (STRCMP(p_guifontwide, "*") == 0) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3862 errmsg = N_("E533: can't select wide font"); |
7 | 3863 else if (gui_get_wide_font() == FAIL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3864 errmsg = N_("E534: Invalid wide font"); |
1801 | 3865 redraw_gui_only = TRUE; |
7 | 3866 } |
3867 #endif | |
3868 | |
3869 #ifdef CURSOR_SHAPE | |
3870 /* 'guicursor' */ | |
3871 else if (varp == &p_guicursor) | |
3872 errmsg = parse_shape_opt(SHAPE_CURSOR); | |
3873 #endif | |
3874 | |
3875 #ifdef FEAT_MOUSESHAPE | |
3876 /* 'mouseshape' */ | |
3877 else if (varp == &p_mouseshape) | |
3878 { | |
3879 errmsg = parse_shape_opt(SHAPE_MOUSE); | |
3880 update_mouseshape(-1); | |
3881 } | |
3882 #endif | |
3883 | |
3884 #ifdef FEAT_PRINTER | |
3885 else if (varp == &p_popt) | |
440 | 3886 errmsg = parse_printoptions(); |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3887 # if defined(FEAT_POSTSCRIPT) |
15 | 3888 else if (varp == &p_pmfn) |
440 | 3889 errmsg = parse_printmbfont(); |
15 | 3890 # endif |
7 | 3891 #endif |
3892 | |
3893 #ifdef FEAT_LANGMAP | |
3894 /* 'langmap' */ | |
3895 else if (varp == &p_langmap) | |
3896 langmap_set(); | |
3897 #endif | |
3898 | |
3899 #ifdef FEAT_LINEBREAK | |
3900 /* 'breakat' */ | |
3901 else if (varp == &p_breakat) | |
3902 fill_breakat_flags(); | |
3903 #endif | |
3904 | |
3905 #ifdef FEAT_TITLE | |
3906 /* 'titlestring' and 'iconstring' */ | |
3907 else if (varp == &p_titlestring || varp == &p_iconstring) | |
3908 { | |
3909 # ifdef FEAT_STL_OPT | |
3910 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON; | |
3911 | |
3912 /* NULL => statusline syntax */ | |
3913 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL) | |
3914 stl_syntax |= flagval; | |
3915 else | |
3916 stl_syntax &= ~flagval; | |
3917 # endif | |
14087
1d25a3e8e03c
patch 8.1.0061: window title is wrong after resetting and setting 'title'
Christian Brabandt <cb@256bit.org>
parents:
14057
diff
changeset
|
3918 did_set_title(); |
7 | 3919 } |
3920 #endif | |
3921 | |
3922 #ifdef FEAT_GUI | |
3923 /* 'guioptions' */ | |
3924 else if (varp == &p_go) | |
1801 | 3925 { |
7 | 3926 gui_init_which_components(oldval); |
1801 | 3927 redraw_gui_only = TRUE; |
3928 } | |
7 | 3929 #endif |
3930 | |
688 | 3931 #if defined(FEAT_GUI_TABLINE) |
3932 /* 'guitablabel' */ | |
3933 else if (varp == &p_gtl) | |
1801 | 3934 { |
827 | 3935 redraw_tabline = TRUE; |
1801 | 3936 redraw_gui_only = TRUE; |
3937 } | |
3938 /* 'guitabtooltip' */ | |
3939 else if (varp == &p_gtt) | |
3940 { | |
3941 redraw_gui_only = TRUE; | |
3942 } | |
688 | 3943 #endif |
3944 | |
7 | 3945 #if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS)) |
3946 /* 'ttymouse' */ | |
3947 else if (varp == &p_ttym) | |
3948 { | |
190 | 3949 /* Switch the mouse off before changing the escape sequences used for |
3950 * that. */ | |
3951 mch_setmouse(FALSE); | |
7 | 3952 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK) |
3953 errmsg = e_invarg; | |
3954 else | |
3955 check_mouse_termcode(); | |
227 | 3956 if (termcap_active) |
3957 setmouse(); /* may switch it on again */ | |
7 | 3958 } |
3959 #endif | |
3960 | |
3961 /* 'selection' */ | |
3962 else if (varp == &p_sel) | |
3963 { | |
3964 if (*p_sel == NUL | |
3965 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK) | |
3966 errmsg = e_invarg; | |
3967 } | |
3968 | |
3969 /* 'selectmode' */ | |
3970 else if (varp == &p_slm) | |
3971 { | |
3972 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK) | |
3973 errmsg = e_invarg; | |
3974 } | |
3975 | |
3976 #ifdef FEAT_BROWSE | |
3977 /* 'browsedir' */ | |
3978 else if (varp == &p_bsdir) | |
3979 { | |
3980 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK | |
3981 && !mch_isdir(p_bsdir)) | |
3982 errmsg = e_invarg; | |
3983 } | |
3984 #endif | |
3985 | |
3986 /* 'keymodel' */ | |
3987 else if (varp == &p_km) | |
3988 { | |
3989 if (check_opt_strings(p_km, p_km_values, TRUE) != OK) | |
3990 errmsg = e_invarg; | |
3991 else | |
3992 { | |
3993 km_stopsel = (vim_strchr(p_km, 'o') != NULL); | |
3994 km_startsel = (vim_strchr(p_km, 'a') != NULL); | |
3995 } | |
3996 } | |
3997 | |
3998 /* 'mousemodel' */ | |
3999 else if (varp == &p_mousem) | |
4000 { | |
4001 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK) | |
4002 errmsg = e_invarg; | |
4003 #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002) | |
4004 else if (*p_mousem != *oldval) | |
4005 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need | |
4006 * to create or delete the popup menus. */ | |
4007 gui_motif_update_mousemodel(root_menu); | |
4008 #endif | |
4009 } | |
4010 | |
4011 /* 'switchbuf' */ | |
4012 else if (varp == &p_swb) | |
4013 { | |
1622 | 4014 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK) |
7 | 4015 errmsg = e_invarg; |
4016 } | |
4017 | |
4018 /* 'debug' */ | |
4019 else if (varp == &p_debug) | |
4020 { | |
839 | 4021 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK) |
7 | 4022 errmsg = e_invarg; |
4023 } | |
4024 | |
4025 /* 'display' */ | |
4026 else if (varp == &p_dy) | |
4027 { | |
4028 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK) | |
4029 errmsg = e_invarg; | |
4030 else | |
4031 (void)init_chartab(); | |
4032 | |
4033 } | |
4034 | |
4035 /* 'eadirection' */ | |
4036 else if (varp == &p_ead) | |
4037 { | |
4038 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK) | |
4039 errmsg = e_invarg; | |
4040 } | |
4041 | |
4042 #ifdef FEAT_CLIPBOARD | |
4043 /* 'clipboard' */ | |
4044 else if (varp == &p_cb) | |
4045 errmsg = check_clipboard_option(); | |
4046 #endif | |
4047 | |
744 | 4048 #ifdef FEAT_SPELL |
323 | 4049 /* When 'spelllang' or 'spellfile' is set and there is a window for this |
4050 * buffer in which 'spell' is set load the wordlists. */ | |
6386 | 4051 else if (varp == &(curwin->w_s->b_p_spl) |
4052 || varp == &(curwin->w_s->b_p_spf)) | |
221 | 4053 { |
16279
36d97f2a4c2b
patch 8.1.1144: too strict checking of the 'spellfile' option
Bram Moolenaar <Bram@vim.org>
parents:
16277
diff
changeset
|
4054 int is_spellfile = varp == &(curwin->w_s->b_p_spf); |
36d97f2a4c2b
patch 8.1.1144: too strict checking of the 'spellfile' option
Bram Moolenaar <Bram@vim.org>
parents:
16277
diff
changeset
|
4055 |
36d97f2a4c2b
patch 8.1.1144: too strict checking of the 'spellfile' option
Bram Moolenaar <Bram@vim.org>
parents:
16277
diff
changeset
|
4056 if ((is_spellfile && !valid_spellfile(*varp)) |
36d97f2a4c2b
patch 8.1.1144: too strict checking of the 'spellfile' option
Bram Moolenaar <Bram@vim.org>
parents:
16277
diff
changeset
|
4057 || (!is_spellfile && !valid_spellang(*varp))) |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
4058 errmsg = e_invarg; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
4059 else |
16279
36d97f2a4c2b
patch 8.1.1144: too strict checking of the 'spellfile' option
Bram Moolenaar <Bram@vim.org>
parents:
16277
diff
changeset
|
4060 errmsg = did_set_spell_option(is_spellfile); |
221 | 4061 } |
386 | 4062 /* When 'spellcapcheck' is set compile the regexp program. */ |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
4063 else if (varp == &(curwin->w_s->b_p_spc)) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
4064 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
4065 errmsg = compile_cap_prog(curwin->w_s); |
386 | 4066 } |
344 | 4067 /* 'spellsuggest' */ |
4068 else if (varp == &p_sps) | |
4069 { | |
374 | 4070 if (spell_check_sps() != OK) |
344 | 4071 errmsg = e_invarg; |
4072 } | |
484 | 4073 /* 'mkspellmem' */ |
4074 else if (varp == &p_msm) | |
4075 { | |
4076 if (spell_check_msm() != OK) | |
4077 errmsg = e_invarg; | |
4078 } | |
221 | 4079 #endif |
4080 | |
7 | 4081 /* When 'bufhidden' is set, check for valid value. */ |
4082 else if (gvarp == &p_bh) | |
4083 { | |
4084 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK) | |
4085 errmsg = e_invarg; | |
4086 } | |
4087 | |
4088 /* When 'buftype' is set, check for valid value. */ | |
4089 else if (gvarp == &p_bt) | |
4090 { | |
4091 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK) | |
4092 errmsg = e_invarg; | |
4093 else | |
4094 { | |
4095 if (curwin->w_status_height) | |
4096 { | |
4097 curwin->w_redr_status = TRUE; | |
4098 redraw_later(VALID); | |
4099 } | |
4100 curbuf->b_help = (curbuf->b_p_bt[0] == 'h'); | |
11757
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11721
diff
changeset
|
4101 #ifdef FEAT_TITLE |
2060
1da25369227b
updated for version 7.2.345
Bram Moolenaar <bram@zimbu.org>
parents:
1958
diff
changeset
|
4102 redraw_titles(); |
11757
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11721
diff
changeset
|
4103 #endif |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11721
diff
changeset
|
4104 } |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11721
diff
changeset
|
4105 } |
7 | 4106 |
4107 #ifdef FEAT_STL_OPT | |
4108 /* 'statusline' or 'rulerformat' */ | |
40 | 4109 else if (gvarp == &p_stl || varp == &p_ruf) |
7 | 4110 { |
4111 int wid; | |
4112 | |
4113 if (varp == &p_ruf) /* reset ru_wid first */ | |
4114 ru_wid = 0; | |
4115 s = *varp; | |
4116 if (varp == &p_ruf && *s == '%') | |
4117 { | |
4118 /* set ru_wid if 'ruf' starts with "%99(" */ | |
4119 if (*++s == '-') /* ignore a '-' */ | |
4120 s++; | |
4121 wid = getdigits(&s); | |
4122 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL) | |
4123 ru_wid = wid; | |
4124 else | |
4125 errmsg = check_stl_option(p_ruf); | |
4126 } | |
917 | 4127 /* check 'statusline' only if it doesn't start with "%!" */ |
1382 | 4128 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!') |
7 | 4129 errmsg = check_stl_option(s); |
40 | 4130 if (varp == &p_ruf && errmsg == NULL) |
7 | 4131 comp_col(); |
4132 } | |
4133 #endif | |
4134 | |
4135 /* check if it is a valid value for 'complete' -- Acevedo */ | |
4136 else if (gvarp == &p_cpt) | |
4137 { | |
4138 for (s = *varp; *s;) | |
4139 { | |
3634 | 4140 while (*s == ',' || *s == ' ') |
7 | 4141 s++; |
4142 if (!*s) | |
4143 break; | |
4144 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL) | |
4145 { | |
4146 errmsg = illegal_char(errbuf, *s); | |
4147 break; | |
4148 } | |
4149 if (*++s != NUL && *s != ',' && *s != ' ') | |
4150 { | |
4151 if (s[-1] == 'k' || s[-1] == 's') | |
4152 { | |
4153 /* skip optional filename after 'k' and 's' */ | |
4154 while (*s && *s != ',' && *s != ' ') | |
4155 { | |
10887
40939b171432
patch 8.0.0333: illegal memory access when 'complete' ends in a backslash
Christian Brabandt <cb@256bit.org>
parents:
10831
diff
changeset
|
4156 if (*s == '\\' && s[1] != NUL) |
7 | 4157 ++s; |
4158 ++s; | |
4159 } | |
4160 } | |
4161 else | |
4162 { | |
4163 if (errbuf != NULL) | |
4164 { | |
4165 sprintf((char *)errbuf, | |
4166 _("E535: Illegal character after <%c>"), | |
4167 *--s); | |
4168 errmsg = errbuf; | |
4169 } | |
4170 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4171 errmsg = ""; |
7 | 4172 break; |
4173 } | |
4174 } | |
4175 } | |
4176 } | |
540 | 4177 |
17543
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
17476
diff
changeset
|
4178 // 'completeopt' |
540 | 4179 else if (varp == &p_cot) |
4180 { | |
4181 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK) | |
4182 errmsg = e_invarg; | |
8935
219d80fee92f
commit https://github.com/vim/vim/commit/c020042083b9c0a4e932b562c3bef97c76328e18
Christian Brabandt <cb@256bit.org>
parents:
8659
diff
changeset
|
4183 else |
219d80fee92f
commit https://github.com/vim/vim/commit/c020042083b9c0a4e932b562c3bef97c76328e18
Christian Brabandt <cb@256bit.org>
parents:
8659
diff
changeset
|
4184 completeopt_was_set(); |
540 | 4185 } |
17543
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
17476
diff
changeset
|
4186 |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17791
diff
changeset
|
4187 #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
|
4188 // 'completeslash' |
17549
e5dabc127143
patch 8.1.1772: options test still fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
17543
diff
changeset
|
4189 else if (gvarp == &p_csl) |
e5dabc127143
patch 8.1.1772: options test still fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
17543
diff
changeset
|
4190 { |
e5dabc127143
patch 8.1.1772: options test still fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
17543
diff
changeset
|
4191 if (check_opt_strings(p_csl, p_csl_values, FALSE) != OK |
e5dabc127143
patch 8.1.1772: options test still fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
17543
diff
changeset
|
4192 || check_opt_strings(curbuf->b_p_csl, p_csl_values, FALSE) != OK) |
17543
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
17476
diff
changeset
|
4193 errmsg = e_invarg; |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
17476
diff
changeset
|
4194 } |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17791
diff
changeset
|
4195 #endif |
7 | 4196 |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
4197 #ifdef FEAT_SIGNS |
17247
cbd0432cf8ff
patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents:
17229
diff
changeset
|
4198 // 'signcolumn' |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
4199 else if (varp == &curwin->w_p_scl) |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
4200 { |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
4201 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK) |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
4202 errmsg = e_invarg; |
17247
cbd0432cf8ff
patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents:
17229
diff
changeset
|
4203 // When changing the 'signcolumn' to or from 'number', recompute the |
cbd0432cf8ff
patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents:
17229
diff
changeset
|
4204 // width of the number column if 'number' or 'relativenumber' is set. |
cbd0432cf8ff
patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents:
17229
diff
changeset
|
4205 if (((*oldval == 'n' && *(oldval + 1) == 'u') |
cbd0432cf8ff
patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents:
17229
diff
changeset
|
4206 || (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) =='u')) |
cbd0432cf8ff
patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents:
17229
diff
changeset
|
4207 && (curwin->w_p_nu || curwin->w_p_rnu)) |
cbd0432cf8ff
patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents:
17229
diff
changeset
|
4208 curwin->w_nrwidth_line_count = 0; |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
4209 } |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
4210 #endif |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
4211 |
7 | 4212 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
4213 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) |
10414
dfad15fabd54
commit https://github.com/vim/vim/commit/031cb743ae154cfb727a9b7787bdcb61202ff1c8
Christian Brabandt <cb@256bit.org>
parents:
10412
diff
changeset
|
4214 /* 'toolbar' */ |
7 | 4215 else if (varp == &p_toolbar) |
4216 { | |
4217 if (opt_strings_flags(p_toolbar, p_toolbar_values, | |
4218 &toolbar_flags, TRUE) != OK) | |
4219 errmsg = e_invarg; | |
4220 else | |
4221 { | |
4222 out_flush(); | |
4223 gui_mch_show_toolbar((toolbar_flags & | |
4224 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0); | |
4225 } | |
4226 } | |
4227 #endif | |
4228 | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2271
diff
changeset
|
4229 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) |
7 | 4230 /* 'toolbariconsize': GTK+ 2 only */ |
4231 else if (varp == &p_tbis) | |
4232 { | |
4233 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK) | |
4234 errmsg = e_invarg; | |
4235 else | |
4236 { | |
4237 out_flush(); | |
4238 gui_mch_show_toolbar((toolbar_flags & | |
4239 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0); | |
4240 } | |
4241 } | |
4242 #endif | |
4243 | |
4244 /* 'pastetoggle': translate key codes like in a mapping */ | |
4245 else if (varp == &p_pt) | |
4246 { | |
4247 if (*p_pt) | |
4248 { | |
859 | 4249 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE); |
7 | 4250 if (p != NULL) |
4251 { | |
4252 if (new_value_alloced) | |
4253 free_string_option(p_pt); | |
4254 p_pt = p; | |
4255 new_value_alloced = TRUE; | |
4256 } | |
4257 } | |
4258 } | |
4259 | |
4260 /* 'backspace' */ | |
4261 else if (varp == &p_bs) | |
4262 { | |
4263 if (VIM_ISDIGIT(*p_bs)) | |
4264 { | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
4265 if (*p_bs > '2' || p_bs[1] != NUL) |
7 | 4266 errmsg = e_invarg; |
4267 } | |
4268 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK) | |
4269 errmsg = e_invarg; | |
4270 } | |
6949 | 4271 else if (varp == &p_bo) |
4272 { | |
4273 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK) | |
4274 errmsg = e_invarg; | |
4275 } | |
7 | 4276 |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4277 /* 'tagcase' */ |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4278 else if (gvarp == &p_tc) |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4279 { |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4280 unsigned int *flags; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4281 |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4282 if (opt_flags & OPT_LOCAL) |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4283 { |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4284 p = curbuf->b_p_tc; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4285 flags = &curbuf->b_tc_flags; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4286 } |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4287 else |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4288 { |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4289 p = p_tc; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4290 flags = &tc_flags; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4291 } |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4292 |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4293 if ((opt_flags & OPT_LOCAL) && *p == NUL) |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4294 /* make the local value empty: use the global value */ |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4295 *flags = 0; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4296 else if (*p == NUL |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4297 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK) |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4298 errmsg = e_invarg; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4299 } |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4300 |
7 | 4301 /* 'casemap' */ |
4302 else if (varp == &p_cmp) | |
4303 { | |
4304 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK) | |
4305 errmsg = e_invarg; | |
4306 } | |
4307 | |
4308 #ifdef FEAT_DIFF | |
4309 /* 'diffopt' */ | |
4310 else if (varp == &p_dip) | |
4311 { | |
4312 if (diffopt_changed() == FAIL) | |
4313 errmsg = e_invarg; | |
4314 } | |
4315 #endif | |
4316 | |
4317 #ifdef FEAT_FOLDING | |
4318 /* 'foldmethod' */ | |
4319 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm) | |
4320 { | |
4321 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK | |
4322 || *curwin->w_p_fdm == NUL) | |
4323 errmsg = e_invarg; | |
4324 else | |
2086
c11845a465ae
updated for version 7.2.370
Bram Moolenaar <bram@zimbu.org>
parents:
2073
diff
changeset
|
4325 { |
7 | 4326 foldUpdateAll(curwin); |
2086
c11845a465ae
updated for version 7.2.370
Bram Moolenaar <bram@zimbu.org>
parents:
2073
diff
changeset
|
4327 if (foldmethodIsDiff(curwin)) |
c11845a465ae
updated for version 7.2.370
Bram Moolenaar <bram@zimbu.org>
parents:
2073
diff
changeset
|
4328 newFoldLevel(); |
c11845a465ae
updated for version 7.2.370
Bram Moolenaar <bram@zimbu.org>
parents:
2073
diff
changeset
|
4329 } |
7 | 4330 } |
4331 # ifdef FEAT_EVAL | |
4332 /* 'foldexpr' */ | |
4333 else if (varp == &curwin->w_p_fde) | |
4334 { | |
4335 if (foldmethodIsExpr(curwin)) | |
4336 foldUpdateAll(curwin); | |
4337 } | |
4338 # endif | |
4339 /* 'foldmarker' */ | |
4340 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr) | |
4341 { | |
4342 p = vim_strchr(*varp, ','); | |
4343 if (p == NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4344 errmsg = N_("E536: comma required"); |
7 | 4345 else if (p == *varp || p[1] == NUL) |
4346 errmsg = e_invarg; | |
4347 else if (foldmethodIsMarker(curwin)) | |
4348 foldUpdateAll(curwin); | |
4349 } | |
4350 /* 'commentstring' */ | |
4351 else if (gvarp == &p_cms) | |
4352 { | |
4353 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4354 errmsg = N_("E537: 'commentstring' must be empty or contain %s"); |
7 | 4355 } |
4356 /* 'foldopen' */ | |
4357 else if (varp == &p_fdo) | |
4358 { | |
4359 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK) | |
4360 errmsg = e_invarg; | |
4361 } | |
4362 /* 'foldclose' */ | |
4363 else if (varp == &p_fcl) | |
4364 { | |
4365 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK) | |
4366 errmsg = e_invarg; | |
4367 } | |
828 | 4368 /* 'foldignore' */ |
4369 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi) | |
4370 { | |
4371 if (foldmethodIsIndent(curwin)) | |
4372 foldUpdateAll(curwin); | |
4373 } | |
7 | 4374 #endif |
4375 | |
4376 /* 'virtualedit' */ | |
4377 else if (varp == &p_ve) | |
4378 { | |
4379 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK) | |
4380 errmsg = e_invarg; | |
4381 else if (STRCMP(p_ve, oldval) != 0) | |
4382 { | |
4383 /* Recompute cursor position in case the new 've' setting | |
4384 * changes something. */ | |
4385 validate_virtcol(); | |
4386 coladvance(curwin->w_virtcol); | |
4387 } | |
4388 } | |
4389 | |
4390 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX) | |
4391 else if (varp == &p_csqf) | |
4392 { | |
4393 if (p_csqf != NULL) | |
4394 { | |
4395 p = p_csqf; | |
4396 while (*p != NUL) | |
4397 { | |
4398 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL | |
4399 || p[1] == NUL | |
4400 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL | |
4401 || (p[2] != NUL && p[2] != ',')) | |
4402 { | |
4403 errmsg = e_invarg; | |
4404 break; | |
4405 } | |
4406 else if (p[2] == NUL) | |
4407 break; | |
4408 else | |
4409 p += 3; | |
4410 } | |
4411 } | |
4412 } | |
4413 #endif | |
4414 | |
5438 | 4415 #ifdef FEAT_CINDENT |
4416 /* 'cinoptions' */ | |
4417 else if (gvarp == &p_cino) | |
4418 { | |
4419 /* TODO: recognize errors */ | |
4420 parse_cino(curbuf); | |
4421 } | |
4422 #endif | |
4423 | |
6110 | 4424 #if defined(FEAT_RENDER_OPTIONS) |
10414
dfad15fabd54
commit https://github.com/vim/vim/commit/031cb743ae154cfb727a9b7787bdcb61202ff1c8
Christian Brabandt <cb@256bit.org>
parents:
10412
diff
changeset
|
4425 /* 'renderoptions' */ |
12994
8566eaa08788
patch 8.0.1373: no error when settting 'renderoptions' before starting GUI
Christian Brabandt <cb@256bit.org>
parents:
12946
diff
changeset
|
4426 else if (varp == &p_rop) |
6110 | 4427 { |
4428 if (!gui_mch_set_rendering_options(p_rop)) | |
4429 errmsg = e_invarg; | |
4430 } | |
4431 #endif | |
4432 | |
10322
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
4433 else if (gvarp == &p_ft) |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
4434 { |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
4435 if (!valid_filetype(*varp)) |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
4436 errmsg = e_invarg; |
11533
c83dd5fa40d8
patch 8.0.0649: when opening a help file the filetype is set several times
Christian Brabandt <cb@256bit.org>
parents:
11516
diff
changeset
|
4437 else |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4438 { |
14097
db44cd9f8068
patch 8.1.0066: nasty autocommand causes using freed memory
Christian Brabandt <cb@256bit.org>
parents:
14087
diff
changeset
|
4439 value_changed = STRCMP(oldval, *varp) != 0; |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4440 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4441 // Since we check the value, there is no need to set P_INSECURE, |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4442 // even when the value comes from a modeline. |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4443 *value_checked = TRUE; |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4444 } |
10322
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
4445 } |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
4446 |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
4447 #ifdef FEAT_SYN_HL |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
4448 else if (gvarp == &p_syn) |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
4449 { |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
4450 if (!valid_filetype(*varp)) |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
4451 errmsg = e_invarg; |
14097
db44cd9f8068
patch 8.1.0066: nasty autocommand causes using freed memory
Christian Brabandt <cb@256bit.org>
parents:
14087
diff
changeset
|
4452 else |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4453 { |
14097
db44cd9f8068
patch 8.1.0066: nasty autocommand causes using freed memory
Christian Brabandt <cb@256bit.org>
parents:
14087
diff
changeset
|
4454 value_changed = STRCMP(oldval, *varp) != 0; |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4455 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4456 // Since we check the value, there is no need to set P_INSECURE, |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4457 // even when the value comes from a modeline. |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4458 *value_checked = TRUE; |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4459 } |
10322
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
4460 } |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
4461 #endif |
5adc318767be
commit https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a
Christian Brabandt <cb@256bit.org>
parents:
10268
diff
changeset
|
4462 |
11721
7e8a467acd6e
patch 8.0.0743: the 'termsize' option can be set to an invalid value
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
4463 #ifdef FEAT_TERMINAL |
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
|
4464 // 'termwinkey' |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
4465 else if (varp == &curwin->w_p_twk) |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
4466 { |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
4467 if (*curwin->w_p_twk != NUL |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
4468 && string_to_key(curwin->w_p_twk, TRUE) == 0) |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4469 errmsg = e_invarg; |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4470 } |
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
|
4471 // 'termwinsize' |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
4472 else if (varp == &curwin->w_p_tws) |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
4473 { |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
4474 if (*curwin->w_p_tws != NUL) |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
4475 { |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
4476 p = skipdigits(curwin->w_p_tws); |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
4477 if (p == curwin->w_p_tws |
13700
b28d679b1843
patch 8.0.1722: cannot specify a minimal size for a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13680
diff
changeset
|
4478 || (*p != 'x' && *p != '*') |
b28d679b1843
patch 8.0.1722: cannot specify a minimal size for a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13680
diff
changeset
|
4479 || *skipdigits(p + 1) != NUL) |
11721
7e8a467acd6e
patch 8.0.0743: the 'termsize' option can be set to an invalid value
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
4480 errmsg = e_invarg; |
7e8a467acd6e
patch 8.0.0743: the 'termsize' option can be set to an invalid value
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
4481 } |
7e8a467acd6e
patch 8.0.0743: the 'termsize' option can be set to an invalid value
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
4482 } |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
4483 # if defined(MSWIN) |
15746
c017195b121b
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty
Bram Moolenaar <Bram@vim.org>
parents:
15725
diff
changeset
|
4484 // 'termwintype' |
c017195b121b
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty
Bram Moolenaar <Bram@vim.org>
parents:
15725
diff
changeset
|
4485 else if (varp == &p_twt) |
c017195b121b
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty
Bram Moolenaar <Bram@vim.org>
parents:
15725
diff
changeset
|
4486 { |
c017195b121b
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty
Bram Moolenaar <Bram@vim.org>
parents:
15725
diff
changeset
|
4487 if (check_opt_strings(*varp, p_twt_values, FALSE) != OK) |
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
|
4488 errmsg = e_invarg; |
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
|
4489 } |
15746
c017195b121b
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty
Bram Moolenaar <Bram@vim.org>
parents:
15725
diff
changeset
|
4490 # endif |
11721
7e8a467acd6e
patch 8.0.0743: the 'termsize' option can be set to an invalid value
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
4491 #endif |
7e8a467acd6e
patch 8.0.0743: the 'termsize' option can be set to an invalid value
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
4492 |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4493 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4494 /* 'varsofttabstop' */ |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4495 else if (varp == &(curbuf->b_p_vsts)) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4496 { |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4497 char_u *cp; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4498 |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4499 if (!(*varp)[0] || ((*varp)[0] == '0' && !(*varp)[1])) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4500 { |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4501 if (curbuf->b_p_vsts_array) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4502 { |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4503 vim_free(curbuf->b_p_vsts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4504 curbuf->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
|
4505 } |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4506 } |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4507 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4508 { |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4509 for (cp = *varp; *cp; ++cp) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4510 { |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4511 if (vim_isdigit(*cp)) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4512 continue; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4513 if (*cp == ',' && cp > *varp && *(cp-1) != ',') |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4514 continue; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4515 errmsg = e_invarg; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4516 break; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4517 } |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4518 if (errmsg == NULL) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4519 { |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4520 int *oldarray = curbuf->b_p_vsts_array; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4521 if (tabstop_set(*varp, &(curbuf->b_p_vsts_array))) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4522 { |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4523 if (oldarray) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4524 vim_free(oldarray); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4525 } |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4526 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4527 errmsg = e_invarg; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4528 } |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4529 } |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4530 } |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4531 |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4532 /* 'vartabstop' */ |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4533 else if (varp == &(curbuf->b_p_vts)) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4534 { |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4535 char_u *cp; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4536 |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4537 if (!(*varp)[0] || ((*varp)[0] == '0' && !(*varp)[1])) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4538 { |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4539 if (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
|
4540 { |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4541 vim_free(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
|
4542 curbuf->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
|
4543 } |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4544 } |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4545 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4546 { |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4547 for (cp = *varp; *cp; ++cp) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4548 { |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4549 if (vim_isdigit(*cp)) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4550 continue; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4551 if (*cp == ',' && cp > *varp && *(cp-1) != ',') |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4552 continue; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4553 errmsg = e_invarg; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4554 break; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4555 } |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4556 if (errmsg == NULL) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4557 { |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4558 int *oldarray = curbuf->b_p_vts_array; |
15858
3a45b89639fb
patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
4559 |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4560 if (tabstop_set(*varp, &(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
|
4561 { |
15858
3a45b89639fb
patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
4562 vim_free(oldarray); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4563 #ifdef FEAT_FOLDING |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4564 if (foldmethodIsIndent(curwin)) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4565 foldUpdateAll(curwin); |
15858
3a45b89639fb
patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
4566 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4567 } |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4568 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4569 errmsg = e_invarg; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4570 } |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4571 } |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4572 } |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4573 #endif |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
4574 |
17431
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17247
diff
changeset
|
4575 #ifdef FEAT_TEXT_PROP |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17247
diff
changeset
|
4576 // 'previewpopup' |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17247
diff
changeset
|
4577 else if (varp == &p_pvp) |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17247
diff
changeset
|
4578 { |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17247
diff
changeset
|
4579 if (parse_previewpopup(NULL) == FAIL) |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17247
diff
changeset
|
4580 errmsg = e_invarg; |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17247
diff
changeset
|
4581 } |
17791
55c167b08c2b
patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
4582 # ifdef FEAT_QUICKFIX |
17771
4bd21046902b
patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
4583 // 'completepopup' |
4bd21046902b
patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
4584 else if (varp == &p_cpp) |
4bd21046902b
patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
4585 { |
4bd21046902b
patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
4586 if (parse_completepopup(NULL) == FAIL) |
4bd21046902b
patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
4587 errmsg = e_invarg; |
4bd21046902b
patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
4588 } |
17791
55c167b08c2b
patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
4589 # endif |
17431
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17247
diff
changeset
|
4590 #endif |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17247
diff
changeset
|
4591 |
7 | 4592 /* Options that are a list of flags. */ |
4593 else | |
4594 { | |
4595 p = NULL; | |
10414
dfad15fabd54
commit https://github.com/vim/vim/commit/031cb743ae154cfb727a9b7787bdcb61202ff1c8
Christian Brabandt <cb@256bit.org>
parents:
10412
diff
changeset
|
4596 if (varp == &p_ww) /* 'whichwrap' */ |
7 | 4597 p = (char_u *)WW_ALL; |
10414
dfad15fabd54
commit https://github.com/vim/vim/commit/031cb743ae154cfb727a9b7787bdcb61202ff1c8
Christian Brabandt <cb@256bit.org>
parents:
10412
diff
changeset
|
4598 if (varp == &p_shm) /* 'shortmess' */ |
7 | 4599 p = (char_u *)SHM_ALL; |
10414
dfad15fabd54
commit https://github.com/vim/vim/commit/031cb743ae154cfb727a9b7787bdcb61202ff1c8
Christian Brabandt <cb@256bit.org>
parents:
10412
diff
changeset
|
4600 else if (varp == &(p_cpo)) /* 'cpoptions' */ |
7 | 4601 p = (char_u *)CPO_ALL; |
10414
dfad15fabd54
commit https://github.com/vim/vim/commit/031cb743ae154cfb727a9b7787bdcb61202ff1c8
Christian Brabandt <cb@256bit.org>
parents:
10412
diff
changeset
|
4602 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */ |
7 | 4603 p = (char_u *)FO_ALL; |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
4604 #ifdef FEAT_CONCEAL |
10414
dfad15fabd54
commit https://github.com/vim/vim/commit/031cb743ae154cfb727a9b7787bdcb61202ff1c8
Christian Brabandt <cb@256bit.org>
parents:
10412
diff
changeset
|
4605 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */ |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
4606 p = (char_u *)COCU_ALL; |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
4607 #endif |
10414
dfad15fabd54
commit https://github.com/vim/vim/commit/031cb743ae154cfb727a9b7787bdcb61202ff1c8
Christian Brabandt <cb@256bit.org>
parents:
10412
diff
changeset
|
4608 else if (varp == &p_mouse) /* 'mouse' */ |
7 | 4609 { |
4610 #ifdef FEAT_MOUSE | |
4611 p = (char_u *)MOUSE_ALL; | |
4612 #else | |
4613 if (*p_mouse != NUL) | |
15472
0fcc1315c061
patch 8.1.0744: compiler warnings for signed/unsigned strings
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4614 errmsg = N_("E538: No mouse support"); |
7 | 4615 #endif |
4616 } | |
4617 #if defined(FEAT_GUI) | |
10414
dfad15fabd54
commit https://github.com/vim/vim/commit/031cb743ae154cfb727a9b7787bdcb61202ff1c8
Christian Brabandt <cb@256bit.org>
parents:
10412
diff
changeset
|
4618 else if (varp == &p_go) /* 'guioptions' */ |
7 | 4619 p = (char_u *)GO_ALL; |
4620 #endif | |
4621 if (p != NULL) | |
4622 { | |
4623 for (s = *varp; *s; ++s) | |
4624 if (vim_strchr(p, *s) == NULL) | |
4625 { | |
4626 errmsg = illegal_char(errbuf, *s); | |
4627 break; | |
4628 } | |
4629 } | |
4630 } | |
4631 | |
4632 /* | |
4633 * If error detected, restore the previous value. | |
4634 */ | |
4635 if (errmsg != NULL) | |
4636 { | |
4637 if (new_value_alloced) | |
4638 free_string_option(*varp); | |
4639 *varp = oldval; | |
4640 /* | |
4641 * When resetting some values, need to act on it. | |
4642 */ | |
4643 if (did_chartab) | |
4644 (void)init_chartab(); | |
4645 if (varp == &p_hl) | |
4646 (void)highlight_changed(); | |
4647 } | |
4648 else | |
4649 { | |
4650 #ifdef FEAT_EVAL | |
4651 /* 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
|
4652 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 4653 #endif |
4654 /* | |
4655 * Free string options that are in allocated memory. | |
24 | 4656 * Use "free_oldval", because recursiveness may change the flags under |
4657 * our fingers (esp. init_highlight()). | |
7 | 4658 */ |
24 | 4659 if (free_oldval) |
7 | 4660 free_string_option(oldval); |
4661 if (new_value_alloced) | |
4662 options[opt_idx].flags |= P_ALLOCED; | |
4663 else | |
4664 options[opt_idx].flags &= ~P_ALLOCED; | |
4665 | |
4666 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 | |
692 | 4667 && ((int)options[opt_idx].indir & PV_BOTH)) |
7 | 4668 { |
4669 /* global option with local value set to use global value; free | |
4670 * the local value and make it empty */ | |
4671 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL); | |
4672 free_string_option(*(char_u **)p); | |
4673 *(char_u **)p = empty_option; | |
4674 } | |
4675 | |
4676 /* May set global value for local option. */ | |
4677 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL) | |
4678 set_string_option_global(opt_idx, varp); | |
480 | 4679 |
4680 /* | |
4681 * Trigger the autocommand only after setting the flags. | |
4682 */ | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4683 #ifdef FEAT_SYN_HL |
480 | 4684 /* When 'syntax' is set, load the syntax of that name */ |
4685 if (varp == &(curbuf->b_p_syn)) | |
4686 { | |
14099
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4687 static int syn_recursive = 0; |
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4688 |
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4689 ++syn_recursive; |
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4690 // Only pass TRUE for "force" when the value changed or not used |
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4691 // recursively, to avoid endless recurrence. |
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4692 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, curbuf->b_fname, |
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4693 value_changed || syn_recursive == 1, curbuf); |
17596
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17549
diff
changeset
|
4694 curbuf->b_flags |= BF_SYN_SET; |
14099
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4695 --syn_recursive; |
480 | 4696 } |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4697 #endif |
480 | 4698 else if (varp == &(curbuf->b_p_ft)) |
4699 { | |
11533
c83dd5fa40d8
patch 8.0.0649: when opening a help file the filetype is set several times
Christian Brabandt <cb@256bit.org>
parents:
11516
diff
changeset
|
4700 /* 'filetype' is set, trigger the FileType autocommand. |
c83dd5fa40d8
patch 8.0.0649: when opening a help file the filetype is set several times
Christian Brabandt <cb@256bit.org>
parents:
11516
diff
changeset
|
4701 * Skip this when called from a modeline and the filetype was |
14099
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4702 * already set to this value. */ |
14097
db44cd9f8068
patch 8.1.0066: nasty autocommand causes using freed memory
Christian Brabandt <cb@256bit.org>
parents:
14087
diff
changeset
|
4703 if (!(opt_flags & OPT_MODELINE) || value_changed) |
11533
c83dd5fa40d8
patch 8.0.0649: when opening a help file the filetype is set several times
Christian Brabandt <cb@256bit.org>
parents:
11516
diff
changeset
|
4704 { |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4705 static int ft_recursive = 0; |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4706 int secure_save = secure; |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4707 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4708 // Reset the secure flag, since the value of 'filetype' has |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4709 // been checked to be safe. |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4710 secure = 0; |
14099
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4711 |
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4712 ++ft_recursive; |
11533
c83dd5fa40d8
patch 8.0.0649: when opening a help file the filetype is set several times
Christian Brabandt <cb@256bit.org>
parents:
11516
diff
changeset
|
4713 did_filetype = TRUE; |
14099
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4714 // Only pass TRUE for "force" when the value changed or not |
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4715 // used recursively, to avoid endless recurrence. |
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4716 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, curbuf->b_fname, |
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4717 value_changed || ft_recursive == 1, curbuf); |
1157f16150b3
patch 8.1.0067: syntax highlighting not working when re-entering a buffer
Christian Brabandt <cb@256bit.org>
parents:
14097
diff
changeset
|
4718 --ft_recursive; |
11643
db3ac953b942
patch 8.0.0704: problems with autocommands when opening help
Christian Brabandt <cb@256bit.org>
parents:
11621
diff
changeset
|
4719 /* Just in case the old "curbuf" is now invalid. */ |
db3ac953b942
patch 8.0.0704: problems with autocommands when opening help
Christian Brabandt <cb@256bit.org>
parents:
11621
diff
changeset
|
4720 if (varp != &(curbuf->b_p_ft)) |
db3ac953b942
patch 8.0.0704: problems with autocommands when opening help
Christian Brabandt <cb@256bit.org>
parents:
11621
diff
changeset
|
4721 varp = NULL; |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4722 |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
4723 secure = secure_save; |
11533
c83dd5fa40d8
patch 8.0.0649: when opening a help file the filetype is set several times
Christian Brabandt <cb@256bit.org>
parents:
11516
diff
changeset
|
4724 } |
480 | 4725 } |
744 | 4726 #ifdef FEAT_SPELL |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
4727 if (varp == &(curwin->w_s->b_p_spl)) |
480 | 4728 { |
4729 char_u fname[200]; | |
5477 | 4730 char_u *q = curwin->w_s->b_p_spl; |
4731 | |
4732 /* Skip the first name if it is "cjk". */ | |
4733 if (STRNCMP(q, "cjk,", 4) == 0) | |
4734 q += 4; | |
480 | 4735 |
4736 /* | |
4737 * Source the spell/LANG.vim in 'runtimepath'. | |
4738 * They could set 'spellcapcheck' depending on the language. | |
4739 * Use the first name in 'spelllang' up to '_region' or | |
4740 * '.encoding'. | |
4741 */ | |
5477 | 4742 for (p = q; *p != NUL; ++p) |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
4743 if (!ASCII_ISALNUM(*p) && *p != '-') |
480 | 4744 break; |
15056
a751ecdd07cc
patch 8.1.0539: cannot build without the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
4745 if (p > q) |
a751ecdd07cc
patch 8.1.0539: cannot build without the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
4746 { |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
4747 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
4748 (int)(p - q), q); |
15056
a751ecdd07cc
patch 8.1.0539: cannot build without the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
4749 source_runtime(fname, DIP_ALL); |
a751ecdd07cc
patch 8.1.0539: cannot build without the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
4750 } |
480 | 4751 } |
4752 #endif | |
7 | 4753 } |
4754 | |
4755 #ifdef FEAT_MOUSE | |
4756 if (varp == &p_mouse) | |
4757 { | |
4758 # ifdef FEAT_MOUSE_TTY | |
4759 if (*p_mouse == NUL) | |
4760 mch_setmouse(FALSE); /* switch mouse off */ | |
4761 else | |
4762 # endif | |
4763 setmouse(); /* in case 'mouse' changed */ | |
4764 } | |
4765 #endif | |
4766 | |
3443 | 4767 if (curwin->w_curswant != MAXCOL |
6669 | 4768 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 4769 curwin->w_set_curswant = TRUE; |
4770 | |
1801 | 4771 #ifdef FEAT_GUI |
4772 /* check redraw when it's not a GUI option or the GUI is active. */ | |
4773 if (!redraw_gui_only || gui.in_use) | |
4774 #endif | |
4775 check_redraw(options[opt_idx].flags); | |
7 | 4776 |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
4777 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
4778 if (did_swaptcap) |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
4779 { |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
4780 set_termname((char_u *)"win32"); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
4781 init_highlight(TRUE, FALSE); |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
4782 } |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
4783 #endif |
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
4784 |
7 | 4785 return errmsg; |
4786 } | |
4787 | |
4788 #ifdef FEAT_STL_OPT | |
4789 /* | |
4790 * Check validity of options with the 'statusline' format. | |
4791 * Return error message or NULL. | |
4792 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
4793 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4794 check_stl_option(char_u *s) |
7 | 4795 { |
4796 int itemcnt = 0; | |
4797 int groupdepth = 0; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4798 static char errbuf[80]; |
7 | 4799 |
4800 while (*s && itemcnt < STL_MAX_ITEM) | |
4801 { | |
4802 /* Check for valid keys after % sequences */ | |
4803 while (*s && *s != '%') | |
4804 s++; | |
4805 if (!*s) | |
4806 break; | |
4807 s++; | |
4808 if (*s != '%' && *s != ')') | |
4809 ++itemcnt; | |
4810 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK) | |
4811 { | |
4812 s++; | |
4813 continue; | |
4814 } | |
4815 if (*s == ')') | |
4816 { | |
4817 s++; | |
4818 if (--groupdepth < 0) | |
4819 break; | |
4820 continue; | |
4821 } | |
4822 if (*s == '-') | |
4823 s++; | |
4824 while (VIM_ISDIGIT(*s)) | |
4825 s++; | |
680 | 4826 if (*s == STL_USER_HL) |
7 | 4827 continue; |
4828 if (*s == '.') | |
4829 { | |
4830 s++; | |
4831 while (*s && VIM_ISDIGIT(*s)) | |
4832 s++; | |
4833 } | |
4834 if (*s == '(') | |
4835 { | |
4836 groupdepth++; | |
4837 continue; | |
4838 } | |
4839 if (vim_strchr(STL_ALL, *s) == NULL) | |
4840 { | |
4841 return illegal_char(errbuf, *s); | |
4842 } | |
4843 if (*s == '{') | |
4844 { | |
4845 s++; | |
4846 while (*s != '}' && *s) | |
4847 s++; | |
4848 if (*s != '}') | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4849 return N_("E540: Unclosed expression sequence"); |
7 | 4850 } |
4851 } | |
4852 if (itemcnt >= STL_MAX_ITEM) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4853 return N_("E541: too many items"); |
7 | 4854 if (groupdepth != 0) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4855 return N_("E542: unbalanced groups"); |
7 | 4856 return NULL; |
4857 } | |
4858 #endif | |
4859 | |
4860 #ifdef FEAT_CLIPBOARD | |
4861 /* | |
4862 * 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
|
4863 * 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
|
4864 */ |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4865 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4866 check_clipboard_option(void) |
7 | 4867 { |
2654 | 4868 int new_unnamed = 0; |
3678 | 4869 int new_autoselect_star = FALSE; |
4870 int new_autoselect_plus = FALSE; | |
7 | 4871 int new_autoselectml = FALSE; |
1904 | 4872 int new_html = FALSE; |
7 | 4873 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
|
4874 char *errmsg = NULL; |
7 | 4875 char_u *p; |
4876 | |
4877 for (p = p_cb; *p != NUL; ) | |
4878 { | |
4879 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL)) | |
4880 { | |
2654 | 4881 new_unnamed |= CLIP_UNNAMED; |
7 | 4882 p += 7; |
4883 } | |
3634 | 4884 else if (STRNCMP(p, "unnamedplus", 11) == 0 |
2654 | 4885 && (p[11] == ',' || p[11] == NUL)) |
4886 { | |
4887 new_unnamed |= CLIP_UNNAMED_PLUS; | |
4888 p += 11; | |
4889 } | |
7 | 4890 else if (STRNCMP(p, "autoselect", 10) == 0 |
3678 | 4891 && (p[10] == ',' || p[10] == NUL)) |
4892 { | |
4893 new_autoselect_star = TRUE; | |
7 | 4894 p += 10; |
4895 } | |
3678 | 4896 else if (STRNCMP(p, "autoselectplus", 14) == 0 |
4897 && (p[14] == ',' || p[14] == NUL)) | |
4898 { | |
4899 new_autoselect_plus = TRUE; | |
4900 p += 14; | |
4901 } | |
7 | 4902 else if (STRNCMP(p, "autoselectml", 12) == 0 |
3678 | 4903 && (p[12] == ',' || p[12] == NUL)) |
7 | 4904 { |
4905 new_autoselectml = TRUE; | |
4906 p += 12; | |
4907 } | |
1904 | 4908 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL)) |
4909 { | |
4910 new_html = TRUE; | |
4911 p += 4; | |
4912 } | |
7 | 4913 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL) |
4914 { | |
4915 p += 8; | |
4916 new_exclude_prog = vim_regcomp(p, RE_MAGIC); | |
4917 if (new_exclude_prog == NULL) | |
4918 errmsg = e_invarg; | |
4919 break; | |
4920 } | |
4921 else | |
4922 { | |
4923 errmsg = e_invarg; | |
4924 break; | |
4925 } | |
4926 if (*p == ',') | |
4927 ++p; | |
4928 } | |
4929 if (errmsg == NULL) | |
4930 { | |
4931 clip_unnamed = new_unnamed; | |
3678 | 4932 clip_autoselect_star = new_autoselect_star; |
4933 clip_autoselect_plus = new_autoselect_plus; | |
7 | 4934 clip_autoselectml = new_autoselectml; |
1904 | 4935 clip_html = new_html; |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4736
diff
changeset
|
4936 vim_regfree(clip_exclude_prog); |
7 | 4937 clip_exclude_prog = new_exclude_prog; |
2248 | 4938 #ifdef FEAT_GUI_GTK |
2183 | 4939 if (gui.in_use) |
4940 { | |
4941 gui_gtk_set_selection_targets(); | |
4942 gui_gtk_set_dnd_targets(); | |
4943 } | |
4944 #endif | |
7 | 4945 } |
4946 else | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4736
diff
changeset
|
4947 vim_regfree(new_exclude_prog); |
7 | 4948 |
4949 return errmsg; | |
4950 } | |
4951 #endif | |
4952 | |
681 | 4953 #if defined(FEAT_EVAL) || defined(PROTO) |
4954 /* | |
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
|
4955 * Set the script_ctx for an option, taking care of setting the buffer- or |
694 | 4956 * window-local value. |
681 | 4957 */ |
694 | 4958 static 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
|
4959 set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx) |
694 | 4960 { |
4961 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; | |
4962 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
|
4963 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
|
4964 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
4965 new_script_ctx.sc_lnum += sourcing_lnum; |
694 | 4966 |
4967 /* Remember where the option was set. For local options need to do that | |
4968 * in the buffer or window structure. */ | |
4969 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
|
4970 options[opt_idx].script_ctx = new_script_ctx; |
694 | 4971 if (both || (opt_flags & OPT_LOCAL)) |
4972 { | |
4973 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
|
4974 curbuf->b_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
694 | 4975 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
|
4976 curwin->w_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
694 | 4977 } |
681 | 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 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4980 /* |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4981 * 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
|
4982 * "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
|
4983 * 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
|
4984 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4985 void |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4986 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
|
4987 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4988 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
|
4989 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
|
4990 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4991 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
|
4992 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
|
4993 else |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4994 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4995 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
|
4996 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
|
4997 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
|
4998 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
|
4999 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
|
5000 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
|
5001 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
5002 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
|
5003 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
|
5004 } |
681 | 5005 #endif |
5006 | |
7 | 5007 /* |
5008 * Set the value of a boolean option, and take care of side effects. | |
5009 * Returns NULL for success, or an error message for an error. | |
5010 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
5011 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5012 set_bool_option( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5013 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
|
5014 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
|
5015 int value, /* new value */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5016 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ |
7 | 5017 { |
5018 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
|
5019 #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
|
5020 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
|
5021 #endif |
7 | 5022 |
5023 /* Disallow changing some options from secure mode */ | |
5024 if ((secure | |
5025 #ifdef HAVE_SANDBOX | |
5026 || sandbox != 0 | |
5027 #endif | |
5028 ) && (options[opt_idx].flags & P_SECURE)) | |
5029 return e_secure; | |
5030 | |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
5031 #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
|
5032 // 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
|
5033 // 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
|
5034 // 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
|
5035 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
|
5036 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
|
5037 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
|
5038 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
5039 |
7 | 5040 *(int *)varp = value; /* set the new value */ |
5041 #ifdef FEAT_EVAL | |
5042 /* 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
|
5043 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 5044 #endif |
5045 | |
634 | 5046 #ifdef FEAT_GUI |
5047 need_mouse_correct = TRUE; | |
5048 #endif | |
5049 | |
7 | 5050 /* May set global value for local option. */ |
5051 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) | |
5052 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; | |
5053 | |
5054 /* | |
5055 * Handle side effects of changing a bool option. | |
5056 */ | |
5057 | |
5058 /* 'compatible' */ | |
5059 if ((int *)varp == &p_cp) | |
5060 compatible_set(); | |
5061 | |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
5062 #ifdef FEAT_LANGMAP |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
5063 if ((int *)varp == &p_lrm) |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
5064 /* 'langremap' -> !'langnoremap' */ |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
5065 p_lnr = !p_lrm; |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
5066 else if ((int *)varp == &p_lnr) |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
5067 /* 'langnoremap' -> !'langremap' */ |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
5068 p_lrm = !p_lnr; |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
5069 #endif |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
5070 |
14846
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
5071 #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
|
5072 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
|
5073 reset_cursorline(); |
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
5074 #endif |
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
5075 |
3246 | 5076 #ifdef FEAT_PERSISTENT_UNDO |
5077 /* 'undofile' */ | |
5078 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) | |
5079 { | |
3894 | 5080 /* Only take action when the option was set. When reset we do not |
5081 * delete the undo file, the option may be set again without making | |
5082 * any changes in between. */ | |
5083 if (curbuf->b_p_udf || p_udf) | |
5084 { | |
5085 char_u hash[UNDO_HASH_SIZE]; | |
5086 buf_T *save_curbuf = curbuf; | |
5087 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
5088 FOR_ALL_BUFFERS(curbuf) |
3894 | 5089 { |
5090 /* When 'undofile' is set globally: for every buffer, otherwise | |
5091 * only for the current buffer: Try to read in the undofile, | |
5092 * if one exists, the buffer wasn't changed and the buffer was | |
5093 * loaded */ | |
5094 if ((curbuf == save_curbuf | |
3246 | 5095 || (opt_flags & OPT_GLOBAL) || opt_flags == 0) |
3894 | 5096 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) |
5097 { | |
5098 u_compute_hash(hash); | |
5099 u_read_undo(NULL, hash, curbuf->b_fname); | |
5100 } | |
5101 } | |
5102 curbuf = save_curbuf; | |
5103 } | |
3246 | 5104 } |
5105 #endif | |
5106 | |
7 | 5107 else if ((int *)varp == &curbuf->b_p_ro) |
5108 { | |
548 | 5109 /* when 'readonly' is reset globally, also reset readonlymode */ |
7 | 5110 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) |
5111 readonlymode = FALSE; | |
548 | 5112 |
5113 /* when 'readonly' is set may give W10 again */ | |
5114 if (curbuf->b_p_ro) | |
5115 curbuf->b_did_warn = FALSE; | |
5116 | |
7 | 5117 #ifdef FEAT_TITLE |
1805 | 5118 redraw_titles(); |
7 | 5119 #endif |
5120 } | |
5121 | |
2362
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
5122 #ifdef FEAT_GUI |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
5123 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
|
5124 { |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
5125 if (!p_mh) |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
5126 gui_mch_mousehide(FALSE); |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
5127 } |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
5128 #endif |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
5129 |
7 | 5130 /* when 'modifiable' is changed, redraw the window title */ |
5131 else if ((int *)varp == &curbuf->b_p_ma) | |
1805 | 5132 { |
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
|
5133 # 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
|
5134 /* 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
|
5135 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
|
5136 && 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
|
5137 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
5138 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
|
5139 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
|
5140 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
5141 # 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
|
5142 # ifdef FEAT_TITLE |
1805 | 5143 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
|
5144 # 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
|
5145 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
5146 #ifdef FEAT_TITLE |
7 | 5147 /* when 'endofline' is changed, redraw the window title */ |
5148 else if ((int *)varp == &curbuf->b_p_eol) | |
1805 | 5149 { |
5150 redraw_titles(); | |
5151 } | |
6933 | 5152 /* when 'fixeol' is changed, redraw the window title */ |
5153 else if ((int *)varp == &curbuf->b_p_fixeol) | |
5154 { | |
5155 redraw_titles(); | |
5156 } | |
1805 | 5157 /* when 'bomb' is changed, redraw the window title and tab page text */ |
1352 | 5158 else if ((int *)varp == &curbuf->b_p_bomb) |
1805 | 5159 { |
5160 redraw_titles(); | |
5161 } | |
7 | 5162 #endif |
5163 | |
5164 /* when 'bin' is set also set some other options */ | |
5165 else if ((int *)varp == &curbuf->b_p_bin) | |
5166 { | |
5167 set_options_bin(old_value, curbuf->b_p_bin, opt_flags); | |
5168 #ifdef FEAT_TITLE | |
1805 | 5169 redraw_titles(); |
7 | 5170 #endif |
5171 } | |
5172 | |
5173 /* when 'buflisted' changes, trigger autocommands */ | |
5174 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) | |
5175 { | |
5176 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, | |
5177 NULL, NULL, TRUE, curbuf); | |
5178 } | |
5179 | |
5180 /* when 'swf' is set, create swapfile, when reset remove swapfile */ | |
5181 else if ((int *)varp == &curbuf->b_p_swf) | |
5182 { | |
5183 if (curbuf->b_p_swf && p_uc) | |
5184 ml_open_file(curbuf); /* create the swap file */ | |
5185 else | |
1157 | 5186 /* no need to reset curbuf->b_may_swap, ml_open_file() will check |
5187 * buf->b_p_swf */ | |
7 | 5188 mf_close_file(curbuf, TRUE); /* remove the swap file */ |
5189 } | |
5190 | |
5191 /* when 'terse' is set change 'shortmess' */ | |
5192 else if ((int *)varp == &p_terse) | |
5193 { | |
5194 char_u *p; | |
5195 | |
5196 p = vim_strchr(p_shm, SHM_SEARCH); | |
5197 | |
5198 /* insert 's' in p_shm */ | |
5199 if (p_terse && p == NULL) | |
5200 { | |
5201 STRCPY(IObuff, p_shm); | |
5202 STRCAT(IObuff, "s"); | |
694 | 5203 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); |
7 | 5204 } |
5205 /* remove 's' from p_shm */ | |
5206 else if (!p_terse && p != NULL) | |
1622 | 5207 STRMOVE(p, p + 1); |
7 | 5208 } |
5209 | |
5210 /* when 'paste' is set or reset also change other options */ | |
5211 else if ((int *)varp == &p_paste) | |
5212 { | |
5213 paste_option_changed(); | |
5214 } | |
5215 | |
5216 /* when 'insertmode' is set from an autocommand need to do work here */ | |
5217 else if ((int *)varp == &p_im) | |
5218 { | |
5219 if (p_im) | |
5220 { | |
5221 if ((State & INSERT) == 0) | |
5222 need_start_insertmode = TRUE; | |
5223 stop_insert_mode = FALSE; | |
5224 } | |
9359
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
9228
diff
changeset
|
5225 /* 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
|
5226 else if (old_value) |
7 | 5227 { |
5228 need_start_insertmode = FALSE; | |
5229 stop_insert_mode = TRUE; | |
644 | 5230 if (restart_edit != 0 && mode_displayed) |
7 | 5231 clear_cmdline = TRUE; /* remove "(insert)" */ |
5232 restart_edit = 0; | |
5233 } | |
5234 } | |
5235 | |
5236 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */ | |
5237 else if ((int *)varp == &p_ic && p_hls) | |
5238 { | |
744 | 5239 redraw_all_later(SOME_VALID); |
7 | 5240 } |
5241 | |
5242 #ifdef FEAT_SEARCH_EXTRA | |
5243 /* when 'hlsearch' is set or reset: reset no_hlsearch */ | |
5244 else if ((int *)varp == &p_hls) | |
5245 { | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13774
diff
changeset
|
5246 set_no_hlsearch(FALSE); |
7 | 5247 } |
5248 #endif | |
5249 | |
5250 /* when 'scrollbind' is set: snapshot the current position to avoid a jump | |
5251 * at the end of normal_cmd() */ | |
5252 else if ((int *)varp == &curwin->w_p_scb) | |
5253 { | |
5254 if (curwin->w_p_scb) | |
5157
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
5255 { |
7 | 5256 do_check_scrollbind(FALSE); |
5157
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
5257 curwin->w_scbind_pos = curwin->w_topline; |
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
5258 } |
7 | 5259 } |
5260 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
5261 #if defined(FEAT_QUICKFIX) |
7 | 5262 /* There can be only one window with 'previewwindow' set. */ |
5263 else if ((int *)varp == &curwin->w_p_pvw) | |
5264 { | |
5265 if (curwin->w_p_pvw) | |
5266 { | |
5267 win_T *win; | |
5268 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
5269 FOR_ALL_WINDOWS(win) |
7 | 5270 if (win->w_p_pvw && win != curwin) |
5271 { | |
5272 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
|
5273 return N_("E590: A preview window already exists"); |
7 | 5274 } |
5275 } | |
5276 } | |
5277 #endif | |
5278 | |
5279 /* when 'textmode' is set or reset also change 'fileformat' */ | |
5280 else if ((int *)varp == &curbuf->b_p_tx) | |
5281 { | |
5282 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); | |
5283 } | |
5284 | |
5285 /* when 'textauto' is set or reset also change 'fileformats' */ | |
5286 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
|
5287 { |
7 | 5288 set_string_option_direct((char_u *)"ffs", -1, |
5289 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", | |
694 | 5290 OPT_FREE | opt_flags, 0); |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
16082
diff
changeset
|
5291 } |
7 | 5292 |
5293 /* | |
5294 * When 'lisp' option changes include/exclude '-' in | |
5295 * keyword characters. | |
5296 */ | |
5297 #ifdef FEAT_LISP | |
5298 else if (varp == (char_u *)&(curbuf->b_p_lisp)) | |
5299 { | |
5300 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */ | |
5301 } | |
5302 #endif | |
5303 | |
5304 #ifdef FEAT_TITLE | |
5305 /* 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
|
5306 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
|
5307 { |
1d25a3e8e03c
patch 8.1.0061: window title is wrong after resetting and setting 'title'
Christian Brabandt <cb@256bit.org>
parents:
14057
diff
changeset
|
5308 did_set_title(); |
7 | 5309 } |
5310 #endif | |
5311 | |
5312 else if ((int *)varp == &curbuf->b_changed) | |
5313 { | |
5314 if (!value) | |
5315 save_file_ff(curbuf); /* Buffer is unchanged */ | |
5316 #ifdef FEAT_TITLE | |
1805 | 5317 redraw_titles(); |
7 | 5318 #endif |
5319 modified_was_set = value; | |
5320 } | |
5321 | |
5322 #ifdef BACKSLASH_IN_FILENAME | |
5323 else if ((int *)varp == &p_ssl) | |
5324 { | |
5325 if (p_ssl) | |
5326 { | |
5327 psepc = '/'; | |
5328 psepcN = '\\'; | |
5329 pseps[0] = '/'; | |
5330 } | |
5331 else | |
5332 { | |
5333 psepc = '\\'; | |
5334 psepcN = '/'; | |
5335 pseps[0] = '\\'; | |
5336 } | |
5337 | |
5338 /* need to adjust the file name arguments and buffer names. */ | |
5339 buflist_slash_adjust(); | |
5340 alist_slash_adjust(); | |
5341 # ifdef FEAT_EVAL | |
5342 scriptnames_slash_adjust(); | |
5343 # endif | |
5344 } | |
5345 #endif | |
5346 | |
5347 /* If 'wrap' is set, set w_leftcol to zero. */ | |
5348 else if ((int *)varp == &curwin->w_p_wrap) | |
5349 { | |
5350 if (curwin->w_p_wrap) | |
5351 curwin->w_leftcol = 0; | |
5352 } | |
5353 | |
5354 else if ((int *)varp == &p_ea) | |
5355 { | |
5356 if (p_ea && !old_value) | |
5357 win_equal(curwin, FALSE, 0); | |
5358 } | |
5359 | |
5360 else if ((int *)varp == &p_wiv) | |
5361 { | |
5362 /* | |
5363 * When 'weirdinvert' changed, set/reset 't_xs'. | |
5364 * Then set 'weirdinvert' according to value of 't_xs'. | |
5365 */ | |
5366 if (p_wiv && !old_value) | |
5367 T_XS = (char_u *)"y"; | |
5368 else if (!p_wiv && old_value) | |
5369 T_XS = empty_option; | |
5370 p_wiv = (*T_XS != NUL); | |
5371 } | |
5372 | |
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
|
5373 #ifdef FEAT_BEVAL_GUI |
7 | 5374 else if ((int *)varp == &p_beval) |
5375 { | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
5376 if (!balloonEvalForTerm) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
5377 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
5378 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
|
5379 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
|
5380 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
|
5381 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
|
5382 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
5383 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
5384 #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
|
5385 #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
|
5386 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
|
5387 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
5388 mch_bevalterm_changed(); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
5389 } |
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
|
5390 #endif |
820 | 5391 |
5392 #ifdef FEAT_AUTOCHDIR | |
7 | 5393 else if ((int *)varp == &p_acd) |
5394 { | |
961 | 5395 /* 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
|
5396 DO_AUTOCHDIR; |
7 | 5397 } |
5398 #endif | |
5399 | |
5400 #ifdef FEAT_DIFF | |
5401 /* 'diff' */ | |
5402 else if ((int *)varp == &curwin->w_p_diff) | |
5403 { | |
16 | 5404 /* May add or remove the buffer from the list of diff buffers. */ |
5405 diff_buf_adjust(curwin); | |
5406 # ifdef FEAT_FOLDING | |
7 | 5407 if (foldmethodIsDiff(curwin)) |
5408 foldUpdateAll(curwin); | |
16 | 5409 # endif |
7 | 5410 } |
5411 #endif | |
5412 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
5413 #ifdef HAVE_INPUT_METHOD |
7 | 5414 /* 'imdisable' */ |
5415 else if ((int *)varp == &p_imdisable) | |
5416 { | |
5417 /* Only de-activate it here, it will be enabled when changing mode. */ | |
5418 if (p_imdisable) | |
5419 im_set_active(FALSE); | |
3129 | 5420 else if (State & INSERT) |
5421 /* When the option is set from an autocommand, it may need to take | |
5422 * effect right away. */ | |
5423 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); | |
7 | 5424 } |
5425 #endif | |
5426 | |
744 | 5427 #ifdef FEAT_SPELL |
258 | 5428 /* 'spell' */ |
5429 else if ((int *)varp == &curwin->w_p_spell) | |
5430 { | |
5431 if (curwin->w_p_spell) | |
5432 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
5433 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
|
5434 |
258 | 5435 if (errmsg != NULL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
5436 emsg(_(errmsg)); |
258 | 5437 } |
5438 } | |
5439 #endif | |
5440 | |
7 | 5441 #ifdef FEAT_ARABIC |
5442 if ((int *)varp == &curwin->w_p_arab) | |
5443 { | |
5444 if (curwin->w_p_arab) | |
5445 { | |
5446 /* | |
5447 * 'arabic' is set, handle various sub-settings. | |
5448 */ | |
5449 if (!p_tbidi) | |
5450 { | |
5451 /* set rightleft mode */ | |
5452 if (!curwin->w_p_rl) | |
5453 { | |
5454 curwin->w_p_rl = TRUE; | |
5455 changed_window_setting(); | |
5456 } | |
5457 | |
5458 /* Enable Arabic shaping (major part of what Arabic requires) */ | |
5459 if (!p_arshape) | |
5460 { | |
5461 p_arshape = TRUE; | |
5462 redraw_later_clear(); | |
5463 } | |
5464 } | |
5465 | |
5466 /* Arabic requires a utf-8 encoding, inform the user if its not | |
5467 * set. */ | |
5468 if (STRCMP(p_enc, "utf-8") != 0) | |
16 | 5469 { |
1848 | 5470 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); |
5471 | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
5472 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
|
5473 msg_attr(_(w_arabic), HL_ATTR(HLF_W)); |
1848 | 5474 #ifdef FEAT_EVAL |
5475 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); | |
5476 #endif | |
16 | 5477 } |
7 | 5478 |
5479 /* set 'delcombine' */ | |
5480 p_deco = TRUE; | |
5481 | |
5482 # ifdef FEAT_KEYMAP | |
5483 /* Force-set the necessary keymap for arabic */ | |
5484 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", | |
5485 OPT_LOCAL); | |
5486 # endif | |
5487 } | |
5488 else | |
5489 { | |
5490 /* | |
5491 * 'arabic' is reset, handle various sub-settings. | |
5492 */ | |
5493 if (!p_tbidi) | |
5494 { | |
5495 /* reset rightleft mode */ | |
5496 if (curwin->w_p_rl) | |
5497 { | |
5498 curwin->w_p_rl = FALSE; | |
5499 changed_window_setting(); | |
5500 } | |
5501 | |
5502 /* 'arabicshape' isn't reset, it is a global option and | |
5503 * another window may still need it "on". */ | |
5504 } | |
5505 | |
5506 /* 'delcombine' isn't reset, it is a global option and another | |
5507 * window may still want it "on". */ | |
5508 | |
5509 # ifdef FEAT_KEYMAP | |
5510 /* Revert to the default keymap */ | |
5511 curbuf->b_p_iminsert = B_IMODE_NONE; | |
5512 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; | |
5513 # endif | |
5514 } | |
3443 | 5515 } |
5516 | |
1958 | 5517 #endif |
5518 | |
17827
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
5519 #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
|
5520 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
|
5521 || (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
|
5522 && gui.in_use |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
5523 && (*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
|
5524 && curbuf->b_signlist != NULL) |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
5525 { |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
5526 // 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
|
5527 // '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
|
5528 // 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
|
5529 // 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
|
5530 // '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
|
5531 // (optimization). |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
5532 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
|
5533 redraw_all_later(CLEAR); |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
5534 } |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
5535 #endif |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
5536 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
5537 #ifdef FEAT_TERMGUICOLORS |
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
5538 /* 'termguicolors' */ |
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
5539 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
|
5540 { |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5541 # 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
|
5542 /* 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
|
5543 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
|
5544 # 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
|
5545 !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
|
5546 # 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
|
5547 !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
|
5548 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5549 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
|
5550 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
|
5551 } |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
5552 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
|
5553 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
|
5554 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
5555 # ifdef FEAT_GUI |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
5556 if (!gui.in_use && !gui.starting) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
5557 # endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
5558 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
|
5559 # 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
|
5560 /* 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
|
5561 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
|
5562 { |
2bebc49116fd
patch 8.1.0123: MS-Windows: colors are wrong after setting 'notgc'
Christian Brabandt <cb@256bit.org>
parents:
14194
diff
changeset
|
5563 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
|
5564 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
|
5565 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
|
5566 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5567 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
5568 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
5569 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
5570 |
7 | 5571 /* |
5572 * End of handling side effects for bool options. | |
5573 */ | |
5574 | |
6935 | 5575 /* after handling side effects, call autocommand */ |
5576 | |
7 | 5577 options[opt_idx].flags |= P_WAS_SET; |
5578 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
5579 #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
|
5580 // 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
|
5581 if (!starting && *get_vim_var_str(VV_OPTION_TYPE) == NUL) |
6935 | 5582 { |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
5583 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
|
5584 |
6937 | 5585 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
|
5586 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
|
5587 old_global_value ? TRUE: FALSE); |
6937 | 5588 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
|
5589 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
|
5590 (opt_flags & OPT_LOCAL) ? "local" : "global"); |
6935 | 5591 set_vim_var_string(VV_OPTION_NEW, buf_new, -1); |
5592 set_vim_var_string(VV_OPTION_OLD, buf_old, -1); | |
5593 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
|
5594 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
|
5595 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
5596 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
|
5597 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
|
5598 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
5599 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
|
5600 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
5601 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
|
5602 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
|
5603 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
5604 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
|
5605 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
5606 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
|
5607 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
|
5608 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
|
5609 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
5610 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
|
5611 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
5612 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
|
5613 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
|
5614 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
5615 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
|
5616 NULL, FALSE, NULL); |
6935 | 5617 reset_v_option_vars(); |
5618 } | |
5619 #endif | |
5620 | |
7 | 5621 comp_col(); /* in case 'ruler' or 'showcmd' changed */ |
3443 | 5622 if (curwin->w_curswant != MAXCOL |
6669 | 5623 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 5624 curwin->w_set_curswant = TRUE; |
7 | 5625 check_redraw(options[opt_idx].flags); |
5626 | |
5627 return NULL; | |
5628 } | |
5629 | |
5630 /* | |
5631 * Set the value of a number option, and take care of side effects. | |
5632 * Returns NULL for success, or an error message for an error. | |
5633 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
5634 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5635 set_num_option( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5636 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
|
5637 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
|
5638 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
|
5639 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
|
5640 size_t errbuflen, /* length of "errbuf" */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5641 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and |
7 | 5642 OPT_MODELINE */ |
5643 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
5644 char *errmsg = NULL; |
7 | 5645 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
|
5646 #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
|
5647 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
|
5648 // 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
|
5649 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
5650 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
|
5651 long old_Columns = Columns; // remember old Columns |
7 | 5652 long *pp = (long *)varp; |
5653 | |
634 | 5654 /* Disallow changing some options from secure mode. */ |
5655 if ((secure | |
5656 #ifdef HAVE_SANDBOX | |
5657 || sandbox != 0 | |
5658 #endif | |
5659 ) && (options[opt_idx].flags & P_SECURE)) | |
5660 return e_secure; | |
7 | 5661 |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
5662 #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
|
5663 // 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
|
5664 // 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
|
5665 // 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
|
5666 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
|
5667 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
|
5668 OPT_GLOBAL); |
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
5669 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
5670 |
7 | 5671 *pp = value; |
5672 #ifdef FEAT_EVAL | |
5673 /* 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
|
5674 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 5675 #endif |
634 | 5676 #ifdef FEAT_GUI |
5677 need_mouse_correct = TRUE; | |
5678 #endif | |
7 | 5679 |
3740 | 5680 if (curbuf->b_p_sw < 0) |
7 | 5681 { |
5682 errmsg = e_positive; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5683 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5684 // 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
|
5685 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
|
5686 ? 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
|
5687 : curbuf->b_p_ts; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5688 #else |
7 | 5689 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
|
5690 #endif |
7 | 5691 } |
5692 | |
5693 /* | |
5694 * Number options that need some action when changed | |
5695 */ | |
5696 if (pp == &p_wh || pp == &p_hh) | |
5697 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
5698 // 'winheight' and 'helpheight' |
7 | 5699 if (p_wh < 1) |
5700 { | |
5701 errmsg = e_positive; | |
5702 p_wh = 1; | |
5703 } | |
5704 if (p_wmh > p_wh) | |
5705 { | |
5706 errmsg = e_winheight; | |
5707 p_wh = p_wmh; | |
5708 } | |
5709 if (p_hh < 0) | |
5710 { | |
5711 errmsg = e_positive; | |
5712 p_hh = 0; | |
5713 } | |
5714 | |
5715 /* Change window height NOW */ | |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10340
diff
changeset
|
5716 if (!ONE_WINDOW) |
7 | 5717 { |
5718 if (pp == &p_wh && curwin->w_height < p_wh) | |
5719 win_setheight((int)p_wh); | |
5720 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) | |
5721 win_setheight((int)p_hh); | |
5722 } | |
5723 } | |
5724 else if (pp == &p_wmh) | |
5725 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
5726 // 'winminheight' |
7 | 5727 if (p_wmh < 0) |
5728 { | |
5729 errmsg = e_positive; | |
5730 p_wmh = 0; | |
5731 } | |
5732 if (p_wmh > p_wh) | |
5733 { | |
5734 errmsg = e_winheight; | |
5735 p_wmh = p_wh; | |
5736 } | |
5737 win_setminheight(); | |
5738 } | |
13 | 5739 else if (pp == &p_wiw) |
7 | 5740 { |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
5741 // 'winwidth' |
7 | 5742 if (p_wiw < 1) |
5743 { | |
5744 errmsg = e_positive; | |
5745 p_wiw = 1; | |
5746 } | |
5747 if (p_wmw > p_wiw) | |
5748 { | |
5749 errmsg = e_winwidth; | |
5750 p_wiw = p_wmw; | |
5751 } | |
5752 | |
5753 /* Change window width NOW */ | |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10340
diff
changeset
|
5754 if (!ONE_WINDOW && curwin->w_width < p_wiw) |
7 | 5755 win_setwidth((int)p_wiw); |
5756 } | |
5757 else if (pp == &p_wmw) | |
5758 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
5759 // 'winminwidth' |
7 | 5760 if (p_wmw < 0) |
5761 { | |
5762 errmsg = e_positive; | |
5763 p_wmw = 0; | |
5764 } | |
5765 if (p_wmw > p_wiw) | |
5766 { | |
5767 errmsg = e_winwidth; | |
5768 p_wmw = p_wiw; | |
5769 } | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
5770 win_setminwidth(); |
7 | 5771 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
5772 |
7 | 5773 /* (re)set last window status line */ |
5774 else if (pp == &p_ls) | |
5775 { | |
5776 last_status(FALSE); | |
5777 } | |
670 | 5778 |
5779 /* (re)set tab page line */ | |
677 | 5780 else if (pp == &p_stal) |
670 | 5781 { |
5782 shell_new_rows(); /* recompute window positions and heights */ | |
5783 } | |
7 | 5784 |
5785 #ifdef FEAT_GUI | |
5786 else if (pp == &p_linespace) | |
5787 { | |
444 | 5788 /* Recompute gui.char_height and resize the Vim window to keep the |
5789 * same number of lines. */ | |
5790 if (gui.in_use && gui_mch_adjust_charheight() == OK) | |
813 | 5791 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); |
7 | 5792 } |
5793 #endif | |
5794 | |
5795 #ifdef FEAT_FOLDING | |
5796 /* 'foldlevel' */ | |
5797 else if (pp == &curwin->w_p_fdl) | |
5798 { | |
5799 if (curwin->w_p_fdl < 0) | |
5800 curwin->w_p_fdl = 0; | |
5801 newFoldLevel(); | |
5802 } | |
5803 | |
1805 | 5804 /* 'foldminlines' */ |
7 | 5805 else if (pp == &curwin->w_p_fml) |
5806 { | |
5807 foldUpdateAll(curwin); | |
5808 } | |
5809 | |
5810 /* 'foldnestmax' */ | |
5811 else if (pp == &curwin->w_p_fdn) | |
5812 { | |
5813 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) | |
5814 foldUpdateAll(curwin); | |
5815 } | |
5816 | |
5817 /* 'foldcolumn' */ | |
5818 else if (pp == &curwin->w_p_fdc) | |
5819 { | |
5820 if (curwin->w_p_fdc < 0) | |
5821 { | |
5822 errmsg = e_positive; | |
5823 curwin->w_p_fdc = 0; | |
5824 } | |
5825 else if (curwin->w_p_fdc > 12) | |
5826 { | |
5827 errmsg = e_invarg; | |
5828 curwin->w_p_fdc = 12; | |
5829 } | |
5830 } | |
5438 | 5831 #endif /* FEAT_FOLDING */ |
5832 | |
5833 #if defined(FEAT_FOLDING) || defined(FEAT_CINDENT) | |
7 | 5834 /* 'shiftwidth' or 'tabstop' */ |
5835 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) | |
5836 { | |
5438 | 5837 # ifdef FEAT_FOLDING |
7 | 5838 if (foldmethodIsIndent(curwin)) |
5839 foldUpdateAll(curwin); | |
5438 | 5840 # endif |
5841 # ifdef FEAT_CINDENT | |
5842 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes: | |
5843 * parse 'cinoptions'. */ | |
5844 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) | |
5845 parse_cino(curbuf); | |
5846 # endif | |
5847 } | |
5848 #endif | |
7 | 5849 |
714 | 5850 /* 'maxcombine' */ |
5851 else if (pp == &p_mco) | |
5852 { | |
5853 if (p_mco > MAX_MCO) | |
5854 p_mco = MAX_MCO; | |
5855 else if (p_mco < 0) | |
5856 p_mco = 0; | |
5857 screenclear(); /* will re-allocate the screen */ | |
5858 } | |
5859 | |
7 | 5860 else if (pp == &curbuf->b_p_iminsert) |
5861 { | |
5862 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) | |
5863 { | |
5864 errmsg = e_invarg; | |
5865 curbuf->b_p_iminsert = B_IMODE_NONE; | |
5866 } | |
5867 p_iminsert = curbuf->b_p_iminsert; | |
5868 if (termcap_active) /* don't do this in the alternate screen */ | |
5869 showmode(); | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
5870 #if defined(FEAT_KEYMAP) |
7 | 5871 /* Show/unshow value of 'keymap' in status lines. */ |
5872 status_redraw_curbuf(); | |
5873 #endif | |
5874 } | |
5875 | |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
5876 #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
|
5877 /* 'imstyle' */ |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
5878 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
|
5879 { |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
5880 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
|
5881 errmsg = e_invarg; |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
5882 } |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
5883 #endif |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
5884 |
164 | 5885 else if (pp == &p_window) |
5886 { | |
5887 if (p_window < 1) | |
5888 p_window = 1; | |
5889 else if (p_window >= Rows) | |
5890 p_window = Rows - 1; | |
5891 } | |
5892 | |
7 | 5893 else if (pp == &curbuf->b_p_imsearch) |
5894 { | |
5895 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) | |
5896 { | |
5897 errmsg = e_invarg; | |
5898 curbuf->b_p_imsearch = B_IMODE_NONE; | |
5899 } | |
5900 p_imsearch = curbuf->b_p_imsearch; | |
5901 } | |
5902 | |
5903 #ifdef FEAT_TITLE | |
5904 /* if 'titlelen' has changed, redraw the title */ | |
5905 else if (pp == &p_titlelen) | |
5906 { | |
5907 if (p_titlelen < 0) | |
5908 { | |
5909 errmsg = e_positive; | |
5910 p_titlelen = 85; | |
5911 } | |
5912 if (starting != NO_SCREEN && old_value != p_titlelen) | |
5913 need_maketitle = TRUE; | |
5914 } | |
5915 #endif | |
5916 | |
5917 /* if p_ch changed value, change the command line height */ | |
5918 else if (pp == &p_ch) | |
5919 { | |
5920 if (p_ch < 1) | |
5921 { | |
5922 errmsg = e_positive; | |
5923 p_ch = 1; | |
5924 } | |
1404 | 5925 if (p_ch > Rows - min_rows() + 1) |
5926 p_ch = Rows - min_rows() + 1; | |
7 | 5927 |
5928 /* Only compute the new window layout when startup has been | |
5929 * completed. Otherwise the frame sizes may be wrong. */ | |
5930 if (p_ch != old_value && full_screen | |
5931 #ifdef FEAT_GUI | |
5932 && !gui.starting | |
5933 #endif | |
5934 ) | |
824 | 5935 command_height(); |
7 | 5936 } |
5937 | |
5938 /* when 'updatecount' changes from zero to non-zero, open swap files */ | |
5939 else if (pp == &p_uc) | |
5940 { | |
5941 if (p_uc < 0) | |
5942 { | |
5943 errmsg = e_positive; | |
5944 p_uc = 100; | |
5945 } | |
5946 if (p_uc && !old_value) | |
5947 ml_open_files(); | |
5948 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5949 #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
|
5950 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
|
5951 { |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
5952 if (curwin->w_p_cole < 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5953 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5954 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
|
5955 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
|
5956 } |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
5957 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
|
5958 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5959 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
|
5960 curwin->w_p_cole = 3; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5961 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5962 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5963 #endif |
16 | 5964 #ifdef MZSCHEME_GUI_THREADS |
14 | 5965 else if (pp == &p_mzq) |
5966 mzvim_reset_timer(); | |
5967 #endif | |
7 | 5968 |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
5969 #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
|
5970 /* 'pyxversion' */ |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
5971 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
|
5972 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
5973 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
|
5974 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
|
5975 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
5976 #endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
5977 |
7 | 5978 /* sync undo before 'undolevels' changes */ |
5979 else if (pp == &p_ul) | |
5980 { | |
5981 /* use the old value, otherwise u_sync() may not work properly */ | |
5982 p_ul = old_value; | |
825 | 5983 u_sync(TRUE); |
7 | 5984 p_ul = value; |
5985 } | |
5446 | 5986 else if (pp == &curbuf->b_p_ul) |
5987 { | |
5988 /* use the old value, otherwise u_sync() may not work properly */ | |
5989 curbuf->b_p_ul = old_value; | |
5990 u_sync(TRUE); | |
5991 curbuf->b_p_ul = value; | |
5992 } | |
7 | 5993 |
13 | 5994 #ifdef FEAT_LINEBREAK |
5995 /* 'numberwidth' must be positive */ | |
5996 else if (pp == &curwin->w_p_nuw) | |
5997 { | |
5998 if (curwin->w_p_nuw < 1) | |
5999 { | |
6000 errmsg = e_positive; | |
6001 curwin->w_p_nuw = 1; | |
6002 } | |
17229
f1c7b7a4d9e4
patch 8.1.1614: 'numberwidth' can only go up to 10
Bram Moolenaar <Bram@vim.org>
parents:
17176
diff
changeset
|
6003 if (curwin->w_p_nuw > 20) |
13 | 6004 { |
6005 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
|
6006 curwin->w_p_nuw = 20; |
13 | 6007 } |
6727 | 6008 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */ |
13 | 6009 } |
6010 #endif | |
6011 | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6012 else if (pp == &curbuf->b_p_tw) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6013 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6014 if (curbuf->b_p_tw < 0) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6015 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6016 errmsg = e_positive; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6017 curbuf->b_p_tw = 0; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6018 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6019 #ifdef FEAT_SYN_HL |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6020 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6021 win_T *wp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6022 tabpage_T *tp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6023 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6024 FOR_ALL_TAB_WINDOWS(tp, wp) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6025 check_colorcolumn(wp); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6026 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6027 #endif |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6028 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6029 |
7 | 6030 /* |
6031 * Check the bounds for numeric options here | |
6032 */ | |
6033 if (Rows < min_rows() && full_screen) | |
6034 { | |
6035 if (errbuf != NULL) | |
6036 { | |
274 | 6037 vim_snprintf((char *)errbuf, errbuflen, |
6038 _("E593: Need at least %d lines"), min_rows()); | |
7 | 6039 errmsg = errbuf; |
6040 } | |
6041 Rows = min_rows(); | |
6042 } | |
6043 if (Columns < MIN_COLUMNS && full_screen) | |
6044 { | |
6045 if (errbuf != NULL) | |
6046 { | |
274 | 6047 vim_snprintf((char *)errbuf, errbuflen, |
6048 _("E594: Need at least %d columns"), MIN_COLUMNS); | |
7 | 6049 errmsg = errbuf; |
6050 } | |
6051 Columns = MIN_COLUMNS; | |
6052 } | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
5039
diff
changeset
|
6053 limit_screen_size(); |
7 | 6054 |
6055 /* | |
6056 * If the screen (shell) height has been changed, assume it is the | |
6057 * physical screenheight. | |
6058 */ | |
6059 if (old_Rows != Rows || old_Columns != Columns) | |
6060 { | |
6061 /* Changing the screen size is not allowed while updating the screen. */ | |
6062 if (updating_screen) | |
6063 *pp = old_value; | |
6064 else if (full_screen | |
6065 #ifdef FEAT_GUI | |
6066 && !gui.starting | |
6067 #endif | |
6068 ) | |
6069 set_shellsize((int)Columns, (int)Rows, TRUE); | |
6070 else | |
6071 { | |
6072 /* Postpone the resizing; check the size and cmdline position for | |
6073 * messages. */ | |
6074 check_shellsize(); | |
6075 if (cmdline_row > Rows - p_ch && Rows > p_ch) | |
6076 cmdline_row = Rows - p_ch; | |
6077 } | |
857 | 6078 if (p_window >= Rows || !option_was_set((char_u *)"window")) |
164 | 6079 p_window = Rows - 1; |
7 | 6080 } |
6081 | |
6082 if (curbuf->b_p_ts <= 0) | |
6083 { | |
6084 errmsg = e_positive; | |
6085 curbuf->b_p_ts = 8; | |
6086 } | |
6087 if (p_tm < 0) | |
6088 { | |
6089 errmsg = e_positive; | |
6090 p_tm = 0; | |
6091 } | |
6092 if ((curwin->w_p_scr <= 0 | |
6093 || (curwin->w_p_scr > curwin->w_height | |
6094 && curwin->w_height > 0)) | |
6095 && full_screen) | |
6096 { | |
6097 if (pp == &(curwin->w_p_scr)) | |
6098 { | |
6099 if (curwin->w_p_scr != 0) | |
6100 errmsg = e_scroll; | |
6101 win_comp_scroll(curwin); | |
6102 } | |
6103 /* If 'scroll' became invalid because of a side effect silently adjust | |
6104 * it. */ | |
6105 else if (curwin->w_p_scr <= 0) | |
6106 curwin->w_p_scr = 1; | |
6107 else /* curwin->w_p_scr > curwin->w_height */ | |
6108 curwin->w_p_scr = curwin->w_height; | |
6109 } | |
1726 | 6110 if (p_hi < 0) |
6111 { | |
6112 errmsg = e_positive; | |
6113 p_hi = 0; | |
6114 } | |
5991 | 6115 else if (p_hi > 10000) |
6116 { | |
6117 errmsg = e_invarg; | |
6118 p_hi = 10000; | |
6119 } | |
4444 | 6120 if (p_re < 0 || p_re > 2) |
6121 { | |
6122 errmsg = e_invarg; | |
6123 p_re = 0; | |
6124 } | |
7 | 6125 if (p_report < 0) |
6126 { | |
6127 errmsg = e_positive; | |
6128 p_report = 1; | |
6129 } | |
532 | 6130 if ((p_sj < -100 || p_sj >= Rows) && full_screen) |
7 | 6131 { |
6132 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */ | |
6133 p_sj = Rows / 2; | |
6134 else | |
6135 { | |
6136 errmsg = e_scroll; | |
6137 p_sj = 1; | |
6138 } | |
6139 } | |
6140 if (p_so < 0 && full_screen) | |
6141 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6142 errmsg = e_positive; |
7 | 6143 p_so = 0; |
6144 } | |
6145 if (p_siso < 0 && full_screen) | |
6146 { | |
6147 errmsg = e_positive; | |
6148 p_siso = 0; | |
6149 } | |
6150 #ifdef FEAT_CMDWIN | |
6151 if (p_cwh < 1) | |
6152 { | |
6153 errmsg = e_positive; | |
6154 p_cwh = 1; | |
6155 } | |
6156 #endif | |
6157 if (p_ut < 0) | |
6158 { | |
6159 errmsg = e_positive; | |
6160 p_ut = 2000; | |
6161 } | |
6162 if (p_ss < 0) | |
6163 { | |
6164 errmsg = e_positive; | |
6165 p_ss = 0; | |
6166 } | |
6167 | |
6168 /* May set global value for local option. */ | |
6169 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) | |
6170 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; | |
6171 | |
6172 options[opt_idx].flags |= P_WAS_SET; | |
6173 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
6174 #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
|
6175 // 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
|
6176 if (!starting && errmsg == NULL && *get_vim_var_str(VV_OPTION_TYPE) == NUL) |
6935 | 6177 { |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
6178 char_u buf_old[11], buf_old_global[11], buf_new[11], buf_type[7]; |
6937 | 6179 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
|
6180 vim_snprintf((char *)buf_old_global, 10, "%ld", old_global_value); |
6937 | 6181 vim_snprintf((char *)buf_new, 10, "%ld", value); |
6182 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); | |
6935 | 6183 set_vim_var_string(VV_OPTION_NEW, buf_new, -1); |
6184 set_vim_var_string(VV_OPTION_OLD, buf_old, -1); | |
6185 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
|
6186 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
|
6187 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
6188 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
|
6189 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
|
6190 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
6191 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
|
6192 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
6193 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
|
6194 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
|
6195 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
6196 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
|
6197 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
6198 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
|
6199 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
|
6200 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
|
6201 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
6202 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
|
6203 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
6204 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
|
6205 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
|
6206 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
6207 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
|
6208 NULL, FALSE, NULL); |
6935 | 6209 reset_v_option_vars(); |
6210 } | |
6211 #endif | |
6212 | |
7 | 6213 comp_col(); /* in case 'columns' or 'ls' changed */ |
3443 | 6214 if (curwin->w_curswant != MAXCOL |
6669 | 6215 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 6216 curwin->w_set_curswant = TRUE; |
7 | 6217 check_redraw(options[opt_idx].flags); |
6218 | |
6219 return errmsg; | |
6220 } | |
6221 | |
6222 /* | |
6223 * Called after an option changed: check if something needs to be redrawn. | |
6224 */ | |
6225 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6226 check_redraw(long_u flags) |
7 | 6227 { |
6228 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */ | |
3263 | 6229 int doclear = (flags & P_RCLR) == P_RCLR; |
6230 int all = ((flags & P_RALL) == P_RALL || doclear); | |
7 | 6231 |
6232 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */ | |
6233 status_redraw_all(); | |
6234 | |
6235 if ((flags & P_RBUF) || (flags & P_RWIN) || all) | |
6236 changed_window_setting(); | |
6237 if (flags & P_RBUF) | |
6238 redraw_curbuf_later(NOT_VALID); | |
10456
536a7d49249c
commit https://github.com/vim/vim/commit/a2477fd3490c1166522631eee53c57d34321086a
Christian Brabandt <cb@256bit.org>
parents:
10424
diff
changeset
|
6239 if (flags & P_RWINONLY) |
536a7d49249c
commit https://github.com/vim/vim/commit/a2477fd3490c1166522631eee53c57d34321086a
Christian Brabandt <cb@256bit.org>
parents:
10424
diff
changeset
|
6240 redraw_later(NOT_VALID); |
3263 | 6241 if (doclear) |
7 | 6242 redraw_all_later(CLEAR); |
6243 else if (all) | |
6244 redraw_all_later(NOT_VALID); | |
6245 } | |
6246 | |
6247 /* | |
6248 * Find index for option 'arg'. | |
6249 * Return -1 if not found. | |
6250 */ | |
6251 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6252 findoption(char_u *arg) |
7 | 6253 { |
6254 int opt_idx; | |
6255 char *s, *p; | |
6256 static short quick_tab[27] = {0, 0}; /* quick access table */ | |
6257 int is_term_opt; | |
6258 | |
6259 /* | |
6260 * For first call: Initialize the quick-access table. | |
6261 * It contains the index for the first option that starts with a certain | |
6262 * letter. There are 26 letters, plus the first "t_" option. | |
6263 */ | |
6264 if (quick_tab[1] == 0) | |
6265 { | |
6266 p = options[0].fullname; | |
6267 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
6268 { | |
6269 if (s[0] != p[0]) | |
6270 { | |
6271 if (s[0] == 't' && s[1] == '_') | |
6272 quick_tab[26] = opt_idx; | |
6273 else | |
6274 quick_tab[CharOrdLow(s[0])] = opt_idx; | |
6275 } | |
6276 p = s; | |
6277 } | |
6278 } | |
6279 | |
6280 /* | |
6281 * Check for name starting with an illegal character. | |
6282 */ | |
6283 #ifdef EBCDIC | |
6284 if (!islower(arg[0])) | |
6285 #else | |
6286 if (arg[0] < 'a' || arg[0] > 'z') | |
6287 #endif | |
6288 return -1; | |
6289 | |
6290 is_term_opt = (arg[0] == 't' && arg[1] == '_'); | |
6291 if (is_term_opt) | |
6292 opt_idx = quick_tab[26]; | |
6293 else | |
6294 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
6295 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
6296 { | |
6297 if (STRCMP(arg, s) == 0) /* match full name */ | |
6298 break; | |
6299 } | |
6300 if (s == NULL && !is_term_opt) | |
6301 { | |
6302 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
6303 for ( ; options[opt_idx].fullname != NULL; opt_idx++) | |
6304 { | |
6305 s = options[opt_idx].shortname; | |
6306 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */ | |
6307 break; | |
6308 s = NULL; | |
6309 } | |
6310 } | |
6311 if (s == NULL) | |
6312 opt_idx = -1; | |
6313 return opt_idx; | |
6314 } | |
6315 | |
14 | 6316 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME) |
7 | 6317 /* |
6318 * Get the value for an option. | |
6319 * | |
6320 * Returns: | |
6321 * Number or Toggle option: 1, *numval gets value. | |
6322 * String option: 0, *stringval gets allocated string. | |
6323 * Hidden Number or Toggle option: -1. | |
6324 * hidden String option: -2. | |
6325 * unknown option: -3. | |
6326 */ | |
6327 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6328 get_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6329 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6330 long *numval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6331 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
|
6332 int opt_flags) |
7 | 6333 { |
6334 int opt_idx; | |
6335 char_u *varp; | |
6336 | |
6337 opt_idx = findoption(name); | |
6338 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
|
6339 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6340 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6341 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6342 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
|
6343 && (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
|
6344 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6345 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
|
6346 char_u *p; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6347 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6348 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6349 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6350 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
|
6351 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
|
6352 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6353 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6354 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6355 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
|
6356 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
|
6357 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6358 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
|
6359 if (p != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6360 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6361 if (stringval != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6362 *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
|
6363 return 0; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6364 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6365 } |
7 | 6366 return -3; |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6367 } |
7 | 6368 |
6369 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | |
6370 | |
6371 if (options[opt_idx].flags & P_STRING) | |
6372 { | |
6373 if (varp == NULL) /* hidden option */ | |
6374 return -2; | |
6375 if (stringval != NULL) | |
6376 { | |
6377 #ifdef FEAT_CRYPT | |
6378 /* never return the value of the crypt key */ | |
1622 | 6379 if ((char_u **)varp == &curbuf->b_p_key |
6380 && **(char_u **)(varp) != NUL) | |
7 | 6381 *stringval = vim_strsave((char_u *)"*****"); |
6382 else | |
6383 #endif | |
6384 *stringval = vim_strsave(*(char_u **)(varp)); | |
6385 } | |
6386 return 0; | |
6387 } | |
6388 | |
6389 if (varp == NULL) /* hidden option */ | |
6390 return -1; | |
6391 if (options[opt_idx].flags & P_NUM) | |
6392 *numval = *(long *)varp; | |
6393 else | |
6394 { | |
6395 /* Special case: 'modified' is b_changed, but we also want to consider | |
6396 * it set when 'ff' or 'fenc' changed. */ | |
6397 if ((int *)varp == &curbuf->b_changed) | |
6398 *numval = curbufIsChanged(); | |
6399 else | |
9395
beab399e3883
commit https://github.com/vim/vim/commit/2acfbed9dbea990f129535de7ff3df360365130b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
6400 *numval = (long) *(int *)varp; |
7 | 6401 } |
6402 return 1; | |
6403 } | |
6404 #endif | |
6405 | |
5610 | 6406 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
4350 | 6407 /* |
6408 * Returns the option attributes and its value. Unlike the above function it | |
6409 * will return either global value or local value of the option depending on | |
6410 * what was requested, but it will never return global value if it was | |
6411 * requested to return local one and vice versa. Neither it will return | |
6412 * buffer-local value if it was requested to return window-local one. | |
6413 * | |
6414 * Pretends that option is absent if it is not present in the requested scope | |
6415 * (i.e. has no global, window-local or buffer-local value depending on | |
6416 * opt_type). Uses | |
6417 * | |
6418 * Returned flags: | |
5867 | 6419 * 0 hidden or unknown option, also option that does not have requested |
6420 * type (see SREQ_* in vim.h) | |
4350 | 6421 * see SOPT_* in vim.h for other flags |
6422 * | |
6423 * Possible opt_type values: see SREQ_* in vim.h | |
6424 */ | |
6425 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6426 get_option_value_strict( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6427 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6428 long *numval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6429 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
|
6430 int opt_type, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6431 void *from) |
4350 | 6432 { |
6433 int opt_idx; | |
4367 | 6434 char_u *varp = NULL; |
4350 | 6435 struct vimoption *p; |
6436 int r = 0; | |
6437 | |
6438 opt_idx = findoption(name); | |
6439 if (opt_idx < 0) | |
6440 return 0; | |
6441 | |
6442 p = &(options[opt_idx]); | |
6443 | |
6444 /* Hidden option */ | |
6445 if (p->var == NULL) | |
6446 return 0; | |
6447 | |
6448 if (p->flags & P_BOOL) | |
6449 r |= SOPT_BOOL; | |
6450 else if (p->flags & P_NUM) | |
6451 r |= SOPT_NUM; | |
6452 else if (p->flags & P_STRING) | |
6453 r |= SOPT_STRING; | |
6454 | |
6455 if (p->indir == PV_NONE) | |
6456 { | |
6457 if (opt_type == SREQ_GLOBAL) | |
6458 r |= SOPT_GLOBAL; | |
6459 else | |
6460 return 0; /* Did not request global-only option */ | |
6461 } | |
6462 else | |
6463 { | |
6464 if (p->indir & PV_BOTH) | |
6465 r |= SOPT_GLOBAL; | |
6466 else if (opt_type == SREQ_GLOBAL) | |
6467 return 0; /* Requested global option */ | |
6468 | |
6469 if (p->indir & PV_WIN) | |
6470 { | |
6471 if (opt_type == SREQ_BUF) | |
6472 return 0; /* Did not request window-local option */ | |
6473 else | |
6474 r |= SOPT_WIN; | |
6475 } | |
6476 else if (p->indir & PV_BUF) | |
6477 { | |
6478 if (opt_type == SREQ_WIN) | |
6479 return 0; /* Did not request buffer-local option */ | |
6480 else | |
6481 r |= SOPT_BUF; | |
6482 } | |
6483 } | |
6484 | |
6485 if (stringval == NULL) | |
6486 return r; | |
6487 | |
6488 if (opt_type == SREQ_GLOBAL) | |
6489 varp = p->var; | |
6490 else | |
6491 { | |
6492 if (opt_type == SREQ_BUF) | |
6493 { | |
6494 /* Special case: 'modified' is b_changed, but we also want to | |
6495 * consider it set when 'ff' or 'fenc' changed. */ | |
6496 if (p->indir == PV_MOD) | |
6497 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
6498 *numval = bufIsChanged((buf_T *)from); |
4350 | 6499 varp = NULL; |
6500 } | |
6501 #ifdef FEAT_CRYPT | |
6502 else if (p->indir == PV_KEY) | |
6503 { | |
6504 /* never return the value of the crypt key */ | |
6505 *stringval = NULL; | |
6506 varp = NULL; | |
6507 } | |
6508 #endif | |
6509 else | |
6510 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
6511 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
|
6512 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
6513 // 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
|
6514 curbuf = (buf_T *)from; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
6515 curwin->w_buffer = curbuf; |
4350 | 6516 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
|
6517 curbuf = save_curbuf; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
6518 curwin->w_buffer = curbuf; |
4350 | 6519 } |
6520 } | |
6521 else if (opt_type == SREQ_WIN) | |
6522 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
6523 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
|
6524 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
6525 curwin = (win_T *)from; |
4350 | 6526 curbuf = curwin->w_buffer; |
6527 varp = get_varp(p); | |
6528 curwin = save_curwin; | |
6529 curbuf = curwin->w_buffer; | |
6530 } | |
6531 if (varp == p->var) | |
6532 return (r | SOPT_UNSET); | |
6533 } | |
6534 | |
6535 if (varp != NULL) | |
6536 { | |
6537 if (p->flags & P_STRING) | |
6538 *stringval = vim_strsave(*(char_u **)(varp)); | |
6539 else if (p->flags & P_NUM) | |
6540 *numval = *(long *) varp; | |
6541 else | |
6542 *numval = *(int *)varp; | |
6543 } | |
6544 | |
6545 return r; | |
6546 } | |
5610 | 6547 |
6548 /* | |
6243 | 6549 * Iterate over options. First argument is a pointer to a pointer to a |
6550 * structure inside options[] array, second is option type like in the above | |
6551 * function. | |
5610 | 6552 * |
6243 | 6553 * If first argument points to NULL it is assumed that iteration just started |
5610 | 6554 * and caller needs the very first value. |
6243 | 6555 * If first argument points to the end marker function returns NULL and sets |
5610 | 6556 * first argument to NULL. |
6557 * | |
6558 * Returns full option name for current option on each call. | |
6559 */ | |
6560 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6561 option_iter_next(void **option, int opt_type) |
5610 | 6562 { |
6563 struct vimoption *ret = NULL; | |
6564 do | |
6565 { | |
6566 if (*option == NULL) | |
6567 *option = (void *) options; | |
6568 else if (((struct vimoption *) (*option))->fullname == NULL) | |
6569 { | |
6570 *option = NULL; | |
6571 return NULL; | |
6572 } | |
6573 else | |
6574 *option = (void *) (((struct vimoption *) (*option)) + 1); | |
6575 | |
6576 ret = ((struct vimoption *) (*option)); | |
6577 | |
6578 /* Hidden option */ | |
6579 if (ret->var == NULL) | |
6580 { | |
6581 ret = NULL; | |
6582 continue; | |
6583 } | |
6584 | |
6585 switch (opt_type) | |
6586 { | |
6587 case SREQ_GLOBAL: | |
6588 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH)) | |
6589 ret = NULL; | |
6590 break; | |
6591 case SREQ_BUF: | |
6592 if (!(ret->indir & PV_BUF)) | |
6593 ret = NULL; | |
6594 break; | |
6595 case SREQ_WIN: | |
6596 if (!(ret->indir & PV_WIN)) | |
6597 ret = NULL; | |
6598 break; | |
6599 default: | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
6600 internal_error("option_iter_next()"); |
5610 | 6601 return NULL; |
6602 } | |
6603 } | |
6604 while (ret == NULL); | |
6605 | |
6606 return (char_u *)ret->fullname; | |
6607 } | |
4350 | 6608 #endif |
6609 | |
7 | 6610 /* |
6611 * Set the value of option "name". | |
6612 * 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
|
6613 * |
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
6614 * 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
|
6615 */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
6616 char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6617 set_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6618 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6619 long number, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6620 char_u *string, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6621 int opt_flags) /* OPT_LOCAL or 0 (both) */ |
7 | 6622 { |
6623 int opt_idx; | |
6624 char_u *varp; | |
835 | 6625 long_u flags; |
7 | 6626 |
6627 opt_idx = findoption(name); | |
838 | 6628 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
|
6629 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6630 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6631 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6632 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
|
6633 && (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
|
6634 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6635 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
|
6636 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6637 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6638 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6639 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
|
6640 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
|
6641 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6642 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6643 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6644 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
|
6645 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
|
6646 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6647 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
|
6648 if (full_screen) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6649 ttest(FALSE); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6650 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
|
6651 return NULL; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6652 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
6653 |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
6654 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
|
6655 } |
7 | 6656 else |
6657 { | |
6658 flags = options[opt_idx].flags; | |
6659 #ifdef HAVE_SANDBOX | |
6660 /* Disallow changing some options in the sandbox */ | |
6661 if (sandbox > 0 && (flags & P_SECURE)) | |
634 | 6662 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
6663 emsg(_(e_sandbox)); |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
6664 return NULL; |
634 | 6665 } |
6666 #endif | |
6667 if (flags & P_STRING) | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
6668 return set_string_option(opt_idx, string, opt_flags); |
7 | 6669 else |
6670 { | |
1667 | 6671 varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
7 | 6672 if (varp != NULL) /* hidden option is not changed */ |
6673 { | |
1298 | 6674 if (number == 0 && string != NULL) |
6675 { | |
1757 | 6676 int idx; |
1298 | 6677 |
6678 /* Either we are given a string or we are setting option | |
6679 * to zero. */ | |
1757 | 6680 for (idx = 0; string[idx] == '0'; ++idx) |
1298 | 6681 ; |
1757 | 6682 if (string[idx] != NUL || idx == 0) |
1298 | 6683 { |
6684 /* There's another character after zeros or the string | |
6685 * is empty. In both cases, we are trying to set a | |
6686 * 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
|
6687 semsg(_("E521: Number required: &%s = '%s'"), |
1298 | 6688 name, string); |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
6689 return NULL; /* do nothing as we hit an error */ |
1298 | 6690 |
6691 } | |
6692 } | |
7 | 6693 if (flags & P_NUM) |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
6694 return set_num_option(opt_idx, varp, number, |
274 | 6695 NULL, 0, opt_flags); |
7 | 6696 else |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
6697 return set_bool_option(opt_idx, varp, (int)number, |
634 | 6698 opt_flags); |
7 | 6699 } |
6700 } | |
6701 } | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
6702 return NULL; |
7 | 6703 } |
6704 | |
6705 /* | |
6706 * Get the terminal code for a terminal option. | |
6707 * Returns NULL when not found. | |
6708 */ | |
6709 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6710 get_term_code(char_u *tname) |
7 | 6711 { |
6712 int opt_idx; | |
6713 char_u *varp; | |
6714 | |
6715 if (tname[0] != 't' || tname[1] != '_' || | |
6716 tname[2] == NUL || tname[3] == NUL) | |
6717 return NULL; | |
6718 if ((opt_idx = findoption(tname)) >= 0) | |
6719 { | |
6720 varp = get_varp(&(options[opt_idx])); | |
6721 if (varp != NULL) | |
6722 varp = *(char_u **)(varp); | |
6723 return varp; | |
6724 } | |
6725 return find_termcode(tname + 2); | |
6726 } | |
6727 | |
6728 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6729 get_highlight_default(void) |
7 | 6730 { |
6731 int i; | |
6732 | |
6733 i = findoption((char_u *)"hl"); | |
6734 if (i >= 0) | |
6735 return options[i].def_val[VI_DEFAULT]; | |
6736 return (char_u *)NULL; | |
6737 } | |
6738 | |
39 | 6739 char_u * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6740 get_encoding_default(void) |
39 | 6741 { |
6742 int i; | |
6743 | |
6744 i = findoption((char_u *)"enc"); | |
6745 if (i >= 0) | |
6746 return options[i].def_val[VI_DEFAULT]; | |
6747 return (char_u *)NULL; | |
6748 } | |
6749 | |
7 | 6750 /* |
6751 * 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
|
6752 * 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
|
6753 * Returns 0 when the key is not recognized. |
7 | 6754 */ |
6755 static int | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
6756 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
|
6757 { |
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
6758 int key = 0; |
7 | 6759 int modifiers; |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
6760 char_u *arg = arg_arg; |
7 | 6761 |
6762 /* | |
6763 * Don't use get_special_key_code() for t_xx, we don't want it to call | |
6764 * add_termcap_entry(). | |
6765 */ | |
6766 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
6767 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
|
6768 else if (has_lt) |
7 | 6769 { |
6770 --arg; /* put arg at the '<' */ | |
6771 modifiers = 0; | |
9869
989d44d35a66
commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
6772 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE); |
7 | 6773 if (modifiers) /* can't handle modifiers here */ |
6774 key = 0; | |
6775 } | |
6776 return key; | |
6777 } | |
6778 | |
6779 /* | |
6780 * if 'all' == 0: show changed options | |
6781 * if 'all' == 1: show all normal options | |
6782 * if 'all' == 2: show all terminal options | |
6783 */ | |
6784 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6785 showoptions( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6786 int all, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6787 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ |
7 | 6788 { |
6789 struct vimoption *p; | |
6790 int col; | |
6791 int isterm; | |
6792 char_u *varp; | |
6793 struct vimoption **items; | |
6794 int item_count; | |
6795 int run; | |
6796 int row, rows; | |
6797 int cols; | |
6798 int i; | |
6799 int len; | |
6800 | |
6801 #define INC 20 | |
6802 #define GAP 3 | |
6803 | |
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
|
6804 items = ALLOC_MULT(struct vimoption *, PARAM_COUNT); |
7 | 6805 if (items == NULL) |
6806 return; | |
6807 | |
6808 /* Highlight title */ | |
6809 if (all == 2) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
6810 msg_puts_title(_("\n--- Terminal codes ---")); |
7 | 6811 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
|
6812 msg_puts_title(_("\n--- Global option values ---")); |
7 | 6813 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
|
6814 msg_puts_title(_("\n--- Local option values ---")); |
7 | 6815 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
6816 msg_puts_title(_("\n--- Options ---")); |
7 | 6817 |
6818 /* | |
6819 * do the loop two times: | |
6820 * 1. display the short items | |
6821 * 2. display the long items (only strings and numbers) | |
6822 */ | |
6823 for (run = 1; run <= 2 && !got_int; ++run) | |
6824 { | |
6825 /* | |
6826 * collect the items in items[] | |
6827 */ | |
6828 item_count = 0; | |
6829 for (p = &options[0]; p->fullname != NULL; p++) | |
6830 { | |
14968
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
6831 // apply :filter /pat/ |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
6832 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
|
6833 continue; |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
6834 |
7 | 6835 varp = NULL; |
6836 isterm = istermoption(p); | |
6837 if (opt_flags != 0) | |
6838 { | |
6839 if (p->indir != PV_NONE && !isterm) | |
6840 varp = get_varp_scope(p, opt_flags); | |
6841 } | |
6842 else | |
6843 varp = get_varp(p); | |
6844 if (varp != NULL | |
6845 && ((all == 2 && isterm) | |
6846 || (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
|
6847 || (all == 0 && !optval_default(p, varp, p_cp)))) |
7 | 6848 { |
6849 if (p->flags & P_BOOL) | |
6850 len = 1; /* a toggle option fits always */ | |
6851 else | |
6852 { | |
6853 option_value2string(p, opt_flags); | |
6854 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; | |
6855 } | |
6856 if ((len <= INC - GAP && run == 1) || | |
6857 (len > INC - GAP && run == 2)) | |
6858 items[item_count++] = p; | |
6859 } | |
6860 } | |
6861 | |
6862 /* | |
6863 * display the items | |
6864 */ | |
6865 if (run == 1) | |
6866 { | |
6867 cols = (Columns + GAP - 3) / INC; | |
6868 if (cols == 0) | |
6869 cols = 1; | |
6870 rows = (item_count + cols - 1) / cols; | |
6871 } | |
6872 else /* run == 2 */ | |
6873 rows = item_count; | |
6874 for (row = 0; row < rows && !got_int; ++row) | |
6875 { | |
6876 msg_putchar('\n'); /* go to next line */ | |
6877 if (got_int) /* 'q' typed in more */ | |
6878 break; | |
6879 col = 0; | |
6880 for (i = row; i < item_count; i += rows) | |
6881 { | |
6882 msg_col = col; /* make columns */ | |
6883 showoneopt(items[i], opt_flags); | |
6884 col += INC; | |
6885 } | |
6886 out_flush(); | |
6887 ui_breakcheck(); | |
6888 } | |
6889 } | |
6890 vim_free(items); | |
6891 } | |
6892 | |
6893 /* | |
6894 * Return TRUE if option "p" has its default value. | |
6895 */ | |
6896 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
|
6897 optval_default(struct vimoption *p, char_u *varp, int compatible) |
7 | 6898 { |
6899 int dvi; | |
6900 | |
6901 if (varp == NULL) | |
6902 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
|
6903 dvi = ((p->flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; |
7 | 6904 if (p->flags & P_NUM) |
840 | 6905 return (*(long *)varp == (long)(long_i)p->def_val[dvi]); |
7 | 6906 if (p->flags & P_BOOL) |
840 | 6907 /* the cast to long is required for Manx C, long_i is |
6908 * needed for MSVC */ | |
6909 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]); | |
7 | 6910 /* P_STRING */ |
6911 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); | |
6912 } | |
6913 | |
6914 /* | |
6915 * showoneopt: show the value of one option | |
6916 * must not be called with a hidden option! | |
6917 */ | |
6918 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6919 showoneopt( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6920 struct vimoption *p, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6921 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */ |
7 | 6922 { |
168 | 6923 char_u *varp; |
6924 int save_silent = silent_mode; | |
6925 | |
6926 silent_mode = FALSE; | |
6927 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ | |
7 | 6928 |
6929 varp = get_varp_scope(p, opt_flags); | |
6930 | |
6931 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */ | |
6932 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed | |
6933 ? !curbufIsChanged() : !*(int *)varp)) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
6934 msg_puts("no"); |
7 | 6935 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
|
6936 msg_puts("--"); |
7 | 6937 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
6938 msg_puts(" "); |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
6939 msg_puts(p->fullname); |
7 | 6940 if (!(p->flags & P_BOOL)) |
6941 { | |
6942 msg_putchar('='); | |
6943 /* put value string in NameBuff */ | |
6944 option_value2string(p, opt_flags); | |
6945 msg_outtrans(NameBuff); | |
6946 } | |
168 | 6947 |
6948 silent_mode = save_silent; | |
6949 info_message = FALSE; | |
7 | 6950 } |
6951 | |
6952 /* | |
6953 * Write modified options as ":set" commands to a file. | |
6954 * | |
6955 * There are three values for "opt_flags": | |
6956 * OPT_GLOBAL: Write global option values and fresh values of | |
6957 * buffer-local options (used for start of a session | |
6958 * file). | |
6959 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for | |
6960 * curwin (used for a vimrc file). | |
6961 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh | |
6962 * and local values for window-local options of | |
6963 * curwin. Local values are also written when at the | |
6964 * default value, because a modeline or autocommand | |
6965 * may have set them when doing ":edit file" and the | |
6966 * user has set them back at the default or fresh | |
6967 * value. | |
6968 * When "local_only" is TRUE, don't write fresh | |
6969 * values, only local values (for ":mkview"). | |
6970 * (fresh value = value used for a new buffer or window for a local option). | |
6971 * | |
6972 * Return FAIL on error, OK otherwise. | |
6973 */ | |
6974 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6975 makeset(FILE *fd, int opt_flags, int local_only) |
7 | 6976 { |
6977 struct vimoption *p; | |
6978 char_u *varp; /* currently used value */ | |
6979 char_u *varp_fresh; /* local value */ | |
6980 char_u *varp_local = NULL; /* fresh value */ | |
6981 char *cmd; | |
6982 int round; | |
1384 | 6983 int pri; |
7 | 6984 |
6985 /* | |
6986 * The options that don't have a default (terminal name, columns, lines) | |
6987 * are never written. Terminal options are also not written. | |
1384 | 6988 * Do the loop over "options[]" twice: once for options with the |
6989 * P_PRI_MKRC flag and once without. | |
7 | 6990 */ |
1384 | 6991 for (pri = 1; pri >= 0; --pri) |
6992 { | |
6993 for (p = &options[0]; !istermoption(p); p++) | |
6994 if (!(p->flags & P_NO_MKRC) | |
6995 && !istermoption(p) | |
6996 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) | |
7 | 6997 { |
6998 /* skip global option when only doing locals */ | |
6999 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) | |
7000 continue; | |
7001 | |
7002 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc | |
7003 * file, they are always buffer-specific. */ | |
7004 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) | |
7005 continue; | |
7006 | |
7007 /* Global values are only written when not at the default value. */ | |
7008 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
|
7009 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp, p_cp)) |
7 | 7010 continue; |
7011 | |
7012 round = 2; | |
7013 if (p->indir != PV_NONE) | |
7014 { | |
7015 if (p->var == VAR_WIN) | |
7016 { | |
7017 /* skip window-local option when only doing globals */ | |
7018 if (!(opt_flags & OPT_LOCAL)) | |
7019 continue; | |
7020 /* When fresh value of window-local option is not at the | |
7021 * default, need to write it too. */ | |
7022 if (!(opt_flags & OPT_GLOBAL) && !local_only) | |
7023 { | |
7024 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
|
7025 if (!optval_default(p, varp_fresh, p_cp)) |
7 | 7026 { |
7027 round = 1; | |
7028 varp_local = varp; | |
7029 varp = varp_fresh; | |
7030 } | |
7031 } | |
7032 } | |
7033 } | |
7034 | |
7035 /* Round 1: fresh value for window-local options. | |
7036 * Round 2: other values */ | |
7037 for ( ; round <= 2; varp = varp_local, ++round) | |
7038 { | |
7039 if (round == 1 || (opt_flags & OPT_GLOBAL)) | |
7040 cmd = "set"; | |
7041 else | |
7042 cmd = "setlocal"; | |
7043 | |
7044 if (p->flags & P_BOOL) | |
7045 { | |
7046 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) | |
7047 return FAIL; | |
7048 } | |
7049 else if (p->flags & P_NUM) | |
7050 { | |
7051 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) | |
7052 return FAIL; | |
7053 } | |
7054 else /* P_STRING */ | |
7055 { | |
694 | 7056 int do_endif = FALSE; |
7057 | |
7 | 7058 /* Don't set 'syntax' and 'filetype' again if the value is |
7059 * already right, avoids reloading the syntax file. */ | |
694 | 7060 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
7061 #if defined(FEAT_SYN_HL) |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
7062 p->indir == PV_SYN || |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
7063 #endif |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
7064 p->indir == PV_FT) |
7 | 7065 { |
7066 if (fprintf(fd, "if &%s != '%s'", p->fullname, | |
7067 *(char_u **)(varp)) < 0 | |
7068 || put_eol(fd) < 0) | |
7069 return FAIL; | |
694 | 7070 do_endif = TRUE; |
7 | 7071 } |
7072 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
|
7073 p->flags) == FAIL) |
7 | 7074 return FAIL; |
694 | 7075 if (do_endif) |
7 | 7076 { |
7077 if (put_line(fd, "endif") == FAIL) | |
7078 return FAIL; | |
7079 } | |
7080 } | |
7081 } | |
7082 } | |
1384 | 7083 } |
7 | 7084 return OK; |
7085 } | |
7086 | |
7087 #if defined(FEAT_FOLDING) || defined(PROTO) | |
7088 /* | |
7089 * Generate set commands for the local fold options only. Used when | |
7090 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options". | |
7091 */ | |
7092 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7093 makefoldset(FILE *fd) |
7 | 7094 { |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7095 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, 0) == FAIL |
7 | 7096 # 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
|
7097 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, 0) |
7 | 7098 == FAIL |
7099 # endif | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7100 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, 0) |
7 | 7101 == FAIL |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7102 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, 0) |
7 | 7103 == FAIL |
7104 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL | |
7105 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL | |
7106 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL | |
7107 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL | |
7108 ) | |
7109 return FAIL; | |
7110 | |
7111 return OK; | |
7112 } | |
7113 #endif | |
7114 | |
7115 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7116 put_setstring( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7117 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7118 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7119 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7120 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
|
7121 long_u flags) |
7 | 7122 { |
7123 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
|
7124 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
|
7125 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
|
7126 char_u *p; |
7 | 7127 |
7128 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
7129 return FAIL; | |
7130 if (*valuep != NULL) | |
7131 { | |
7132 /* Output 'pastetoggle' as key names. For other | |
7133 * options some characters have to be escaped with | |
7134 * CTRL-V or backslash */ | |
7135 if (valuep == &p_pt) | |
7136 { | |
7137 s = *valuep; | |
7138 while (*s != NUL) | |
1601 | 7139 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL) |
7 | 7140 return FAIL; |
7141 } | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7142 // 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
|
7143 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
|
7144 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7145 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
|
7146 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7147 // 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
|
7148 buf = alloc(size); |
2780 | 7149 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
|
7150 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7151 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
|
7152 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7153 // 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
|
7154 // 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
|
7155 // 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
|
7156 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
|
7157 && 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
|
7158 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7159 part = alloc(size); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7160 if (part == NULL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7161 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7162 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7163 // 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
|
7164 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
|
7165 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7166 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7167 p = buf; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7168 while (*p != NUL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7169 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7170 // 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
|
7171 // 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
|
7172 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
|
7173 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7174 (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
|
7175 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
|
7176 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7177 } |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7178 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7179 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7180 return OK; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7181 } |
7 | 7182 if (put_escstr(fd, buf, 2) == FAIL) |
2780 | 7183 { |
7184 vim_free(buf); | |
7 | 7185 return FAIL; |
2780 | 7186 } |
7187 vim_free(buf); | |
7 | 7188 } |
7189 else if (put_escstr(fd, *valuep, 2) == FAIL) | |
7190 return FAIL; | |
7191 } | |
7192 if (put_eol(fd) < 0) | |
7193 return FAIL; | |
7194 return OK; | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7195 fail: |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7196 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7197 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7198 return FAIL; |
7 | 7199 } |
7200 | |
7201 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7202 put_setnum( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7203 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7204 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7205 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7206 long *valuep) |
7 | 7207 { |
7208 long wc; | |
7209 | |
7210 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
7211 return FAIL; | |
7212 if (wc_use_keyname((char_u *)valuep, &wc)) | |
7213 { | |
7214 /* print 'wildchar' and 'wildcharm' as a key name */ | |
7215 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) | |
7216 return FAIL; | |
7217 } | |
7218 else if (fprintf(fd, "%ld", *valuep) < 0) | |
7219 return FAIL; | |
7220 if (put_eol(fd) < 0) | |
7221 return FAIL; | |
7222 return OK; | |
7223 } | |
7224 | |
7225 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7226 put_setbool( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7227 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7228 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7229 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7230 int value) |
7 | 7231 { |
1416 | 7232 if (value < 0) /* global/local option using global value */ |
7233 return OK; | |
7 | 7234 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 |
7235 || put_eol(fd) < 0) | |
7236 return FAIL; | |
7237 return OK; | |
7238 } | |
7239 | |
7240 /* | |
7241 * Clear all the terminal options. | |
7242 * If the option has been allocated, free the memory. | |
7243 * Terminal options are never hidden or indirect. | |
7244 */ | |
7245 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7246 clear_termoptions(void) |
7 | 7247 { |
7248 /* | |
7249 * Reset a few things before clearing the old options. This may cause | |
7250 * outputting a few things that the terminal doesn't understand, but the | |
7251 * screen will be cleared later, so this is OK. | |
7252 */ | |
7253 #ifdef FEAT_MOUSE_TTY | |
7254 mch_setmouse(FALSE); /* switch mouse off */ | |
7255 #endif | |
7256 #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
|
7257 mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */ |
7 | 7258 #endif |
7259 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI) | |
7260 /* When starting the GUI close the display opened for the clipboard. | |
7261 * After restoring the title, because that will need the display. */ | |
7262 if (gui.starting) | |
7263 clear_xterm_clip(); | |
7264 #endif | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10205
diff
changeset
|
7265 stoptermcap(); /* stop termcap mode */ |
7 | 7266 |
359 | 7267 free_termoptions(); |
7268 } | |
7269 | |
7270 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7271 free_termoptions(void) |
359 | 7272 { |
7273 struct vimoption *p; | |
7274 | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
7275 for (p = options; p->fullname != NULL; p++) |
7 | 7276 if (istermoption(p)) |
7277 { | |
7278 if (p->flags & P_ALLOCED) | |
7279 free_string_option(*(char_u **)(p->var)); | |
7280 if (p->flags & P_DEF_ALLOCED) | |
7281 free_string_option(p->def_val[VI_DEFAULT]); | |
7282 *(char_u **)(p->var) = empty_option; | |
7283 p->def_val[VI_DEFAULT] = empty_option; | |
7284 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
|
7285 #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
|
7286 // 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
|
7287 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
|
7288 #endif |
7 | 7289 } |
7290 clear_termcodes(); | |
7291 } | |
7292 | |
7293 /* | |
1941 | 7294 * Free the string for one term option, if it was allocated. |
7295 * Set the string to empty_option and clear allocated flag. | |
7296 * "var" points to the option value. | |
7297 */ | |
7298 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7299 free_one_termoption(char_u *var) |
1941 | 7300 { |
7301 struct vimoption *p; | |
7302 | |
7303 for (p = &options[0]; p->fullname != NULL; p++) | |
7304 if (p->var == var) | |
7305 { | |
7306 if (p->flags & P_ALLOCED) | |
7307 free_string_option(*(char_u **)(p->var)); | |
7308 *(char_u **)(p->var) = empty_option; | |
7309 p->flags &= ~P_ALLOCED; | |
7310 break; | |
7311 } | |
7312 } | |
7313 | |
7314 /* | |
7 | 7315 * Set the terminal option defaults to the current value. |
7316 * Used after setting the terminal name. | |
7317 */ | |
7318 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7319 set_term_defaults(void) |
7 | 7320 { |
7321 struct vimoption *p; | |
7322 | |
7323 for (p = &options[0]; p->fullname != NULL; p++) | |
7324 { | |
7325 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) | |
7326 { | |
7327 if (p->flags & P_DEF_ALLOCED) | |
7328 { | |
7329 free_string_option(p->def_val[VI_DEFAULT]); | |
7330 p->flags &= ~P_DEF_ALLOCED; | |
7331 } | |
7332 p->def_val[VI_DEFAULT] = *(char_u **)(p->var); | |
7333 if (p->flags & P_ALLOCED) | |
7334 { | |
7335 p->flags |= P_DEF_ALLOCED; | |
7336 p->flags &= ~P_ALLOCED; /* don't free the value now */ | |
7337 } | |
7338 } | |
7339 } | |
7340 } | |
7341 | |
7342 /* | |
7343 * return TRUE if 'p' starts with 't_' | |
7344 */ | |
7345 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7346 istermoption(struct vimoption *p) |
7 | 7347 { |
7348 return (p->fullname[0] == 't' && p->fullname[1] == '_'); | |
7349 } | |
7350 | |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
7351 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
7 | 7352 /* |
4350 | 7353 * Unset local option value, similar to ":set opt<". |
7354 */ | |
7355 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7356 unset_global_local_option(char_u *name, void *from) |
4350 | 7357 { |
7358 struct vimoption *p; | |
7359 int opt_idx; | |
4361 | 7360 buf_T *buf = (buf_T *)from; |
4350 | 7361 |
7362 opt_idx = findoption(name); | |
7007 | 7363 if (opt_idx < 0) |
7364 return; | |
4350 | 7365 p = &(options[opt_idx]); |
7366 | |
7367 switch ((int)p->indir) | |
7368 { | |
7369 /* global option with local value: use local value if it's been set */ | |
7370 case PV_EP: | |
4361 | 7371 clear_string_option(&buf->b_p_ep); |
4350 | 7372 break; |
7373 case PV_KP: | |
4361 | 7374 clear_string_option(&buf->b_p_kp); |
4350 | 7375 break; |
7376 case PV_PATH: | |
4361 | 7377 clear_string_option(&buf->b_p_path); |
4350 | 7378 break; |
7379 case PV_AR: | |
7380 buf->b_p_ar = -1; | |
7381 break; | |
6243 | 7382 case PV_BKC: |
7383 clear_string_option(&buf->b_p_bkc); | |
7384 buf->b_bkc_flags = 0; | |
7385 break; | |
4350 | 7386 case PV_TAGS: |
4361 | 7387 clear_string_option(&buf->b_p_tags); |
4350 | 7388 break; |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
7389 case PV_TC: |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
7390 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
|
7391 buf->b_tc_flags = 0; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
7392 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
|
7393 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
|
7394 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
|
7395 break; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7396 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
|
7397 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
|
7398 break; |
4350 | 7399 #ifdef FEAT_FIND_ID |
7400 case PV_DEF: | |
4361 | 7401 clear_string_option(&buf->b_p_def); |
4350 | 7402 break; |
7403 case PV_INC: | |
4361 | 7404 clear_string_option(&buf->b_p_inc); |
4350 | 7405 break; |
7406 #endif | |
7407 case PV_DICT: | |
4361 | 7408 clear_string_option(&buf->b_p_dict); |
4350 | 7409 break; |
7410 case PV_TSR: | |
4361 | 7411 clear_string_option(&buf->b_p_tsr); |
4350 | 7412 break; |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
7413 case PV_FP: |
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
7414 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
|
7415 break; |
4350 | 7416 #ifdef FEAT_QUICKFIX |
7417 case PV_EFM: | |
4361 | 7418 clear_string_option(&buf->b_p_efm); |
4350 | 7419 break; |
7420 case PV_GP: | |
4361 | 7421 clear_string_option(&buf->b_p_gp); |
4350 | 7422 break; |
7423 case PV_MP: | |
4361 | 7424 clear_string_option(&buf->b_p_mp); |
4350 | 7425 break; |
7426 #endif | |
7427 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) | |
7428 case PV_BEXPR: | |
4361 | 7429 clear_string_option(&buf->b_p_bexpr); |
4350 | 7430 break; |
7431 #endif | |
7432 #if defined(FEAT_CRYPT) | |
7433 case PV_CM: | |
4361 | 7434 clear_string_option(&buf->b_p_cm); |
4350 | 7435 break; |
7436 #endif | |
7437 #ifdef FEAT_STL_OPT | |
7438 case PV_STL: | |
4361 | 7439 clear_string_option(&((win_T *)from)->w_p_stl); |
4350 | 7440 break; |
7441 #endif | |
5446 | 7442 case PV_UL: |
7443 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; | |
7444 break; | |
5712 | 7445 #ifdef FEAT_LISP |
7446 case PV_LW: | |
7447 clear_string_option(&buf->b_p_lw); | |
7448 break; | |
7449 #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
|
7450 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
|
7451 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
|
7452 break; |
4350 | 7453 } |
7454 } | |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
7455 #endif |
4350 | 7456 |
7457 /* | |
7 | 7458 * Get pointer to option variable, depending on local or global scope. |
7459 */ | |
7460 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7461 get_varp_scope(struct vimoption *p, int opt_flags) |
7 | 7462 { |
7463 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE) | |
7464 { | |
7465 if (p->var == VAR_WIN) | |
7466 return (char_u *)GLOBAL_WO(get_varp(p)); | |
7467 return p->var; | |
7468 } | |
692 | 7469 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) |
7 | 7470 { |
7471 switch ((int)p->indir) | |
7472 { | |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
7473 case PV_FP: return (char_u *)&(curbuf->b_p_fp); |
7 | 7474 #ifdef FEAT_QUICKFIX |
694 | 7475 case PV_EFM: return (char_u *)&(curbuf->b_p_efm); |
7476 case PV_GP: return (char_u *)&(curbuf->b_p_gp); | |
7477 case PV_MP: return (char_u *)&(curbuf->b_p_mp); | |
7478 #endif | |
7479 case PV_EP: return (char_u *)&(curbuf->b_p_ep); | |
7480 case PV_KP: return (char_u *)&(curbuf->b_p_kp); | |
7481 case PV_PATH: return (char_u *)&(curbuf->b_p_path); | |
692 | 7482 case PV_AR: return (char_u *)&(curbuf->b_p_ar); |
694 | 7483 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
|
7484 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
|
7485 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
|
7486 case PV_SO: return (char_u *)&(curwin->w_p_so); |
7 | 7487 #ifdef FEAT_FIND_ID |
694 | 7488 case PV_DEF: return (char_u *)&(curbuf->b_p_def); |
7489 case PV_INC: return (char_u *)&(curbuf->b_p_inc); | |
7 | 7490 #endif |
694 | 7491 case PV_DICT: return (char_u *)&(curbuf->b_p_dict); |
7492 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr); | |
790 | 7493 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
7494 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr); | |
7495 #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
|
7496 #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
|
7497 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
|
7498 #endif |
40 | 7499 #ifdef FEAT_STL_OPT |
694 | 7500 case PV_STL: return (char_u *)&(curwin->w_p_stl); |
40 | 7501 #endif |
5446 | 7502 case PV_UL: return (char_u *)&(curbuf->b_p_ul); |
5712 | 7503 #ifdef FEAT_LISP |
7504 case PV_LW: return (char_u *)&(curbuf->b_p_lw); | |
7505 #endif | |
6243 | 7506 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
|
7507 case PV_MENC: return (char_u *)&(curbuf->b_p_menc); |
7 | 7508 } |
7509 return NULL; /* "cannot happen" */ | |
7510 } | |
7511 return get_varp(p); | |
7512 } | |
7513 | |
7514 /* | |
7515 * Get pointer to option variable. | |
7516 */ | |
7517 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7518 get_varp(struct vimoption *p) |
7 | 7519 { |
7520 /* hidden option, always return NULL */ | |
7521 if (p->var == NULL) | |
7522 return NULL; | |
7523 | |
7524 switch ((int)p->indir) | |
7525 { | |
7526 case PV_NONE: return p->var; | |
7527 | |
7528 /* global option with local value: use local value if it's been set */ | |
694 | 7529 case PV_EP: return *curbuf->b_p_ep != NUL |
7 | 7530 ? (char_u *)&curbuf->b_p_ep : p->var; |
694 | 7531 case PV_KP: return *curbuf->b_p_kp != NUL |
7 | 7532 ? (char_u *)&curbuf->b_p_kp : p->var; |
694 | 7533 case PV_PATH: return *curbuf->b_p_path != NUL |
7 | 7534 ? (char_u *)&(curbuf->b_p_path) : p->var; |
692 | 7535 case PV_AR: return curbuf->b_p_ar >= 0 |
7 | 7536 ? (char_u *)&(curbuf->b_p_ar) : p->var; |
694 | 7537 case PV_TAGS: return *curbuf->b_p_tags != NUL |
7 | 7538 ? (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
|
7539 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
|
7540 ? (char_u *)&(curbuf->b_p_tc) : p->var; |
6243 | 7541 case PV_BKC: return *curbuf->b_p_bkc != NUL |
7542 ? (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
|
7543 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
|
7544 ? (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
|
7545 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
|
7546 ? (char_u *)&(curwin->w_p_so) : p->var; |
7 | 7547 #ifdef FEAT_FIND_ID |
694 | 7548 case PV_DEF: return *curbuf->b_p_def != NUL |
7 | 7549 ? (char_u *)&(curbuf->b_p_def) : p->var; |
694 | 7550 case PV_INC: return *curbuf->b_p_inc != NUL |
7 | 7551 ? (char_u *)&(curbuf->b_p_inc) : p->var; |
7552 #endif | |
694 | 7553 case PV_DICT: return *curbuf->b_p_dict != NUL |
7 | 7554 ? (char_u *)&(curbuf->b_p_dict) : p->var; |
694 | 7555 case PV_TSR: return *curbuf->b_p_tsr != NUL |
7 | 7556 ? (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
|
7557 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
|
7558 ? (char_u *)&(curbuf->b_p_fp) : p->var; |
7 | 7559 #ifdef FEAT_QUICKFIX |
694 | 7560 case PV_EFM: return *curbuf->b_p_efm != NUL |
7561 ? (char_u *)&(curbuf->b_p_efm) : p->var; | |
7562 case PV_GP: return *curbuf->b_p_gp != NUL | |
7 | 7563 ? (char_u *)&(curbuf->b_p_gp) : p->var; |
694 | 7564 case PV_MP: return *curbuf->b_p_mp != NUL |
7 | 7565 ? (char_u *)&(curbuf->b_p_mp) : p->var; |
7566 #endif | |
790 | 7567 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
7568 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL | |
7569 ? (char_u *)&(curbuf->b_p_bexpr) : p->var; | |
7570 #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
|
7571 #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
|
7572 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
|
7573 ? (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
|
7574 #endif |
40 | 7575 #ifdef FEAT_STL_OPT |
694 | 7576 case PV_STL: return *curwin->w_p_stl != NUL |
40 | 7577 ? (char_u *)&(curwin->w_p_stl) : p->var; |
7578 #endif | |
5446 | 7579 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL |
7580 ? (char_u *)&(curbuf->b_p_ul) : p->var; | |
5712 | 7581 #ifdef FEAT_LISP |
7582 case PV_LW: return *curbuf->b_p_lw != NUL | |
7583 ? (char_u *)&(curbuf->b_p_lw) : p->var; | |
7584 #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
|
7585 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
|
7586 ? (char_u *)&(curbuf->b_p_menc) : p->var; |
7 | 7587 #ifdef FEAT_ARABIC |
7588 case PV_ARAB: return (char_u *)&(curwin->w_p_arab); | |
7589 #endif | |
7590 case PV_LIST: return (char_u *)&(curwin->w_p_list); | |
744 | 7591 #ifdef FEAT_SPELL |
7592 case PV_SPELL: return (char_u *)&(curwin->w_p_spell); | |
7593 #endif | |
221 | 7594 #ifdef FEAT_SYN_HL |
744 | 7595 case PV_CUC: return (char_u *)&(curwin->w_p_cuc); |
7596 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
|
7597 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
|
7598 case PV_CC: return (char_u *)&(curwin->w_p_cc); |
221 | 7599 #endif |
7 | 7600 #ifdef FEAT_DIFF |
7601 case PV_DIFF: return (char_u *)&(curwin->w_p_diff); | |
7602 #endif | |
7603 #ifdef FEAT_FOLDING | |
7604 case PV_FDC: return (char_u *)&(curwin->w_p_fdc); | |
7605 case PV_FEN: return (char_u *)&(curwin->w_p_fen); | |
7606 case PV_FDI: return (char_u *)&(curwin->w_p_fdi); | |
7607 case PV_FDL: return (char_u *)&(curwin->w_p_fdl); | |
7608 case PV_FDM: return (char_u *)&(curwin->w_p_fdm); | |
7609 case PV_FML: return (char_u *)&(curwin->w_p_fml); | |
7610 case PV_FDN: return (char_u *)&(curwin->w_p_fdn); | |
7611 # ifdef FEAT_EVAL | |
7612 case PV_FDE: return (char_u *)&(curwin->w_p_fde); | |
7613 case PV_FDT: return (char_u *)&(curwin->w_p_fdt); | |
7614 # endif | |
7615 case PV_FMR: return (char_u *)&(curwin->w_p_fmr); | |
7616 #endif | |
7617 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
|
7618 case PV_RNU: return (char_u *)&(curwin->w_p_rnu); |
13 | 7619 #ifdef FEAT_LINEBREAK |
7620 case PV_NUW: return (char_u *)&(curwin->w_p_nuw); | |
7621 #endif | |
7 | 7622 case PV_WFH: return (char_u *)&(curwin->w_p_wfh); |
782 | 7623 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
|
7624 #if defined(FEAT_QUICKFIX) |
7 | 7625 case PV_PVW: return (char_u *)&(curwin->w_p_pvw); |
7626 #endif | |
7627 #ifdef FEAT_RIGHTLEFT | |
7628 case PV_RL: return (char_u *)&(curwin->w_p_rl); | |
7629 case PV_RLC: return (char_u *)&(curwin->w_p_rlc); | |
7630 #endif | |
7631 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr); | |
7632 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); | |
7633 #ifdef FEAT_LINEBREAK | |
7634 case PV_LBR: return (char_u *)&(curwin->w_p_lbr); | |
5995 | 7635 case PV_BRI: return (char_u *)&(curwin->w_p_bri); |
7636 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt); | |
7 | 7637 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
7638 case PV_WCR: return (char_u *)&(curwin->w_p_wcr); |
7 | 7639 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
|
7640 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
|
7641 #ifdef FEAT_CONCEAL |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
7642 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
|
7643 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
|
7644 #endif |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
7645 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
7646 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
|
7647 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
|
7648 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
|
7649 #endif |
7 | 7650 |
7651 case PV_AI: return (char_u *)&(curbuf->b_p_ai); | |
7652 case PV_BIN: return (char_u *)&(curbuf->b_p_bin); | |
7653 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); | |
7654 case PV_BH: return (char_u *)&(curbuf->b_p_bh); | |
7655 case PV_BT: return (char_u *)&(curbuf->b_p_bt); | |
7656 case PV_BL: return (char_u *)&(curbuf->b_p_bl); | |
7657 case PV_CI: return (char_u *)&(curbuf->b_p_ci); | |
7658 #ifdef FEAT_CINDENT | |
7659 case PV_CIN: return (char_u *)&(curbuf->b_p_cin); | |
7660 case PV_CINK: return (char_u *)&(curbuf->b_p_cink); | |
7661 case PV_CINO: return (char_u *)&(curbuf->b_p_cino); | |
7662 #endif | |
7663 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) | |
7664 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); | |
7665 #endif | |
7666 #ifdef FEAT_COMMENTS | |
7667 case PV_COM: return (char_u *)&(curbuf->b_p_com); | |
7668 #endif | |
7669 #ifdef FEAT_FOLDING | |
7670 case PV_CMS: return (char_u *)&(curbuf->b_p_cms); | |
7671 #endif | |
7672 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
|
7673 #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
|
7674 case PV_CSL: return (char_u *)&(curbuf->b_p_csl); |
7 | 7675 #endif |
12 | 7676 #ifdef FEAT_COMPL_FUNC |
7677 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); | |
502 | 7678 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); |
12 | 7679 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
7680 #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
|
7681 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
|
7682 #endif |
7 | 7683 case PV_EOL: return (char_u *)&(curbuf->b_p_eol); |
6933 | 7684 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol); |
7 | 7685 case PV_ET: return (char_u *)&(curbuf->b_p_et); |
7686 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); | |
7687 case PV_FF: return (char_u *)&(curbuf->b_p_ff); | |
7688 case PV_FT: return (char_u *)&(curbuf->b_p_ft); | |
7689 case PV_FO: return (char_u *)&(curbuf->b_p_fo); | |
41 | 7690 case PV_FLP: return (char_u *)&(curbuf->b_p_flp); |
7 | 7691 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); |
7692 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); | |
7693 case PV_INF: return (char_u *)&(curbuf->b_p_inf); | |
7694 case PV_ISK: return (char_u *)&(curbuf->b_p_isk); | |
7695 #ifdef FEAT_FIND_ID | |
7696 # ifdef FEAT_EVAL | |
7697 case PV_INEX: return (char_u *)&(curbuf->b_p_inex); | |
7698 # endif | |
7699 #endif | |
7700 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
7701 case PV_INDE: return (char_u *)&(curbuf->b_p_inde); | |
7702 case PV_INDK: return (char_u *)&(curbuf->b_p_indk); | |
7703 #endif | |
694 | 7704 #ifdef FEAT_EVAL |
667 | 7705 case PV_FEX: return (char_u *)&(curbuf->b_p_fex); |
7706 #endif | |
7 | 7707 #ifdef FEAT_CRYPT |
7708 case PV_KEY: return (char_u *)&(curbuf->b_p_key); | |
7709 #endif | |
7710 #ifdef FEAT_LISP | |
7711 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp); | |
7712 #endif | |
7713 case PV_ML: return (char_u *)&(curbuf->b_p_ml); | |
7714 case PV_MPS: return (char_u *)&(curbuf->b_p_mps); | |
7715 case PV_MA: return (char_u *)&(curbuf->b_p_ma); | |
7716 case PV_MOD: return (char_u *)&(curbuf->b_changed); | |
7717 case PV_NF: return (char_u *)&(curbuf->b_p_nf); | |
7718 case PV_PI: return (char_u *)&(curbuf->b_p_pi); | |
12 | 7719 #ifdef FEAT_TEXTOBJ |
7720 case PV_QE: return (char_u *)&(curbuf->b_p_qe); | |
7721 #endif | |
7 | 7722 case PV_RO: return (char_u *)&(curbuf->b_p_ro); |
7723 #ifdef FEAT_SMARTINDENT | |
7724 case PV_SI: return (char_u *)&(curbuf->b_p_si); | |
7725 #endif | |
7726 case PV_SN: return (char_u *)&(curbuf->b_p_sn); | |
7727 case PV_STS: return (char_u *)&(curbuf->b_p_sts); | |
7728 #ifdef FEAT_SEARCHPATH | |
7729 case PV_SUA: return (char_u *)&(curbuf->b_p_sua); | |
7730 #endif | |
7731 case PV_SWF: return (char_u *)&(curbuf->b_p_swf); | |
7732 #ifdef FEAT_SYN_HL | |
410 | 7733 case PV_SMC: return (char_u *)&(curbuf->b_p_smc); |
744 | 7734 case PV_SYN: return (char_u *)&(curbuf->b_p_syn); |
7735 #endif | |
7736 #ifdef FEAT_SPELL | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7737 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
|
7738 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
|
7739 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl); |
7 | 7740 #endif |
7741 case PV_SW: return (char_u *)&(curbuf->b_p_sw); | |
7742 case PV_TS: return (char_u *)&(curbuf->b_p_ts); | |
7743 case PV_TW: return (char_u *)&(curbuf->b_p_tw); | |
7744 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
|
7745 #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
|
7746 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
|
7747 #endif |
7 | 7748 case PV_WM: return (char_u *)&(curbuf->b_p_wm); |
7749 #ifdef FEAT_KEYMAP | |
7750 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); | |
7751 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7752 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7753 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
|
7754 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7755 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7756 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
|
7757 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
|
7758 #endif |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
7759 default: iemsg(_("E356: get_varp ERROR")); |
7 | 7760 } |
7761 /* always return a valid pointer to avoid a crash! */ | |
7762 return (char_u *)&(curbuf->b_p_wm); | |
7763 } | |
7764 | |
7765 /* | |
7766 * Get the value of 'equalprg', either the buffer-local one or the global one. | |
7767 */ | |
7768 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7769 get_equalprg(void) |
7 | 7770 { |
7771 if (*curbuf->b_p_ep == NUL) | |
7772 return p_ep; | |
7773 return curbuf->b_p_ep; | |
7774 } | |
7775 | |
7776 /* | |
7777 * Copy options from one window to another. | |
7778 * Used when splitting a window. | |
7779 */ | |
7780 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7781 win_copy_options(win_T *wp_from, win_T *wp_to) |
7 | 7782 { |
7783 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); | |
7784 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt); | |
6162 | 7785 #if defined(FEAT_LINEBREAK) |
7786 briopt_check(wp_to); | |
7787 #endif | |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7788 #ifdef FEAT_SYN_HL |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7789 fill_culopt_flags(NULL, wp_to); |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7790 #endif |
7 | 7791 } |
7792 | |
7793 /* | |
7794 * Copy the options from one winopt_T to another. | |
7795 * Doesn't free the old option values in "to", use clear_winopt() for that. | |
7796 * The 'scroll' option is not copied, because it depends on the window height. | |
7797 * The 'previewwindow' option is reset, there can be only one preview window. | |
7798 */ | |
7799 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7800 copy_winopt(winopt_T *from, winopt_T *to) |
7 | 7801 { |
7802 #ifdef FEAT_ARABIC | |
7803 to->wo_arab = from->wo_arab; | |
7804 #endif | |
7805 to->wo_list = from->wo_list; | |
7806 to->wo_nu = from->wo_nu; | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
7807 to->wo_rnu = from->wo_rnu; |
13 | 7808 #ifdef FEAT_LINEBREAK |
7809 to->wo_nuw = from->wo_nuw; | |
7810 #endif | |
7 | 7811 #ifdef FEAT_RIGHTLEFT |
7812 to->wo_rl = from->wo_rl; | |
7813 to->wo_rlc = vim_strsave(from->wo_rlc); | |
7814 #endif | |
40 | 7815 #ifdef FEAT_STL_OPT |
7816 to->wo_stl = vim_strsave(from->wo_stl); | |
7817 #endif | |
7 | 7818 to->wo_wrap = from->wo_wrap; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
7819 #ifdef FEAT_DIFF |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
7820 to->wo_wrap_save = from->wo_wrap_save; |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
7821 #endif |
7 | 7822 #ifdef FEAT_LINEBREAK |
7823 to->wo_lbr = from->wo_lbr; | |
5995 | 7824 to->wo_bri = from->wo_bri; |
7825 to->wo_briopt = vim_strsave(from->wo_briopt); | |
7 | 7826 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
7827 to->wo_wcr = vim_strsave(from->wo_wcr); |
7 | 7828 to->wo_scb = from->wo_scb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
7829 to->wo_scb_save = from->wo_scb_save; |
2651 | 7830 to->wo_crb = from->wo_crb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
7831 to->wo_crb_save = from->wo_crb_save; |
744 | 7832 #ifdef FEAT_SPELL |
7833 to->wo_spell = from->wo_spell; | |
7834 #endif | |
221 | 7835 #ifdef FEAT_SYN_HL |
744 | 7836 to->wo_cuc = from->wo_cuc; |
7837 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
|
7838 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
|
7839 to->wo_cc = vim_strsave(from->wo_cc); |
221 | 7840 #endif |
7 | 7841 #ifdef FEAT_DIFF |
7842 to->wo_diff = from->wo_diff; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
7843 to->wo_diff_saved = from->wo_diff_saved; |
7 | 7844 #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
|
7845 #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
|
7846 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
|
7847 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
|
7848 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
7849 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
7850 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
|
7851 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
|
7852 #endif |
7 | 7853 #ifdef FEAT_FOLDING |
7854 to->wo_fdc = from->wo_fdc; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
7855 to->wo_fdc_save = from->wo_fdc_save; |
7 | 7856 to->wo_fen = from->wo_fen; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
7857 to->wo_fen_save = from->wo_fen_save; |
7 | 7858 to->wo_fdi = vim_strsave(from->wo_fdi); |
7859 to->wo_fml = from->wo_fml; | |
7860 to->wo_fdl = from->wo_fdl; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
7861 to->wo_fdl_save = from->wo_fdl_save; |
7 | 7862 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
|
7863 to->wo_fdm_save = from->wo_diff_saved |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
7864 ? vim_strsave(from->wo_fdm_save) : empty_option; |
7 | 7865 to->wo_fdn = from->wo_fdn; |
7866 # ifdef FEAT_EVAL | |
7867 to->wo_fde = vim_strsave(from->wo_fde); | |
7868 to->wo_fdt = vim_strsave(from->wo_fdt); | |
7869 # endif | |
7870 to->wo_fmr = vim_strsave(from->wo_fmr); | |
7871 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7872 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7873 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
|
7874 #endif |
7 | 7875 check_winopt(to); /* don't want NULL pointers */ |
7876 } | |
7877 | |
7878 /* | |
7879 * Check string options in a window for a NULL value. | |
7880 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
7881 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7882 check_win_options(win_T *win) |
7 | 7883 { |
7884 check_winopt(&win->w_onebuf_opt); | |
7885 check_winopt(&win->w_allbuf_opt); | |
7886 } | |
7887 | |
7888 /* | |
7889 * Check for NULL pointers in a winopt_T and replace them with empty_option. | |
7890 */ | |
5997 | 7891 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7892 check_winopt(winopt_T *wop UNUSED) |
7 | 7893 { |
7894 #ifdef FEAT_FOLDING | |
7895 check_string_option(&wop->wo_fdi); | |
7896 check_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
7897 check_string_option(&wop->wo_fdm_save); |
7 | 7898 # ifdef FEAT_EVAL |
7899 check_string_option(&wop->wo_fde); | |
7900 check_string_option(&wop->wo_fdt); | |
7901 # endif | |
7902 check_string_option(&wop->wo_fmr); | |
7903 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7904 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7905 check_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7906 #endif |
7 | 7907 #ifdef FEAT_RIGHTLEFT |
7908 check_string_option(&wop->wo_rlc); | |
7909 #endif | |
40 | 7910 #ifdef FEAT_STL_OPT |
7911 check_string_option(&wop->wo_stl); | |
7912 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7913 #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
|
7914 check_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7915 check_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7916 #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
|
7917 #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
|
7918 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
|
7919 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
7920 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
7921 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
|
7922 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
|
7923 #endif |
5995 | 7924 #ifdef FEAT_LINEBREAK |
7925 check_string_option(&wop->wo_briopt); | |
7926 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
7927 check_string_option(&wop->wo_wcr); |
7 | 7928 } |
7929 | |
7930 /* | |
7931 * Free the allocated memory inside a winopt_T. | |
7932 */ | |
7933 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7934 clear_winopt(winopt_T *wop UNUSED) |
7 | 7935 { |
7936 #ifdef FEAT_FOLDING | |
7937 clear_string_option(&wop->wo_fdi); | |
7938 clear_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
7939 clear_string_option(&wop->wo_fdm_save); |
7 | 7940 # ifdef FEAT_EVAL |
7941 clear_string_option(&wop->wo_fde); | |
7942 clear_string_option(&wop->wo_fdt); | |
7943 # endif | |
7944 clear_string_option(&wop->wo_fmr); | |
7945 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7946 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7947 clear_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7948 #endif |
5995 | 7949 #ifdef FEAT_LINEBREAK |
7950 clear_string_option(&wop->wo_briopt); | |
7951 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
7952 clear_string_option(&wop->wo_wcr); |
7 | 7953 #ifdef FEAT_RIGHTLEFT |
7954 clear_string_option(&wop->wo_rlc); | |
7955 #endif | |
40 | 7956 #ifdef FEAT_STL_OPT |
7957 clear_string_option(&wop->wo_stl); | |
7958 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7959 #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
|
7960 clear_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7961 clear_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
7962 #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
|
7963 #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
|
7964 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
|
7965 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
7966 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
7967 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
|
7968 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
|
7969 #endif |
7 | 7970 } |
7971 | |
7972 /* | |
7973 * Copy global option values to local options for one buffer. | |
7974 * Used when creating a new buffer and sometimes when entering a buffer. | |
7975 * flags: | |
7976 * BCO_ENTER We will enter the buf buffer. | |
7977 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when | |
7978 * appropriate. | |
7979 * BCO_NOHELP Don't copy the values to a help buffer. | |
7980 */ | |
7981 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7982 buf_copy_options(buf_T *buf, int flags) |
7 | 7983 { |
7984 int should_copy = TRUE; | |
7985 char_u *save_p_isk = NULL; /* init for GCC */ | |
7986 int dont_do_help; | |
7987 int did_isk = FALSE; | |
7988 | |
7989 /* | |
7990 * Skip this when the option defaults have not been set yet. Happens when | |
7991 * main() allocates the first buffer. | |
7992 */ | |
7993 if (p_cpo != NULL) | |
7994 { | |
7995 /* | |
7996 * Always copy when entering and 'cpo' contains 'S'. | |
7997 * Don't copy when already initialized. | |
7998 * Don't copy when 'cpo' contains 's' and not entering. | |
7999 * 'S' BCO_ENTER initialized 's' should_copy | |
8000 * yes yes X X TRUE | |
8001 * yes no yes X FALSE | |
8002 * no X yes X FALSE | |
8003 * X no no yes FALSE | |
8004 * X no no no TRUE | |
8005 * no yes no X TRUE | |
8006 */ | |
8007 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) | |
8008 && (buf->b_p_initialized | |
8009 || (!(flags & BCO_ENTER) | |
8010 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
8011 should_copy = FALSE; | |
8012 | |
8013 if (should_copy || (flags & BCO_ALWAYS)) | |
8014 { | |
8015 /* Don't copy the options specific to a help buffer when | |
8016 * BCO_NOHELP is given or the options were initialized already | |
8017 * (jumping back to a help file with CTRL-T or CTRL-O) */ | |
8018 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) | |
8019 || buf->b_p_initialized; | |
8020 if (dont_do_help) /* don't free b_p_isk */ | |
8021 { | |
8022 save_p_isk = buf->b_p_isk; | |
8023 buf->b_p_isk = NULL; | |
8024 } | |
8025 /* | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14381
diff
changeset
|
8026 * 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
|
8027 * reset 'readonly' and copy 'fileformat'. |
7 | 8028 */ |
8029 if (!buf->b_p_initialized) | |
8030 { | |
8031 free_buf_options(buf, TRUE); | |
8032 buf->b_p_ro = FALSE; /* don't copy readonly */ | |
8033 buf->b_p_tx = p_tx; | |
8034 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
|
8035 switch (*p_ffs) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
8036 { |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
8037 case 'm': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
8038 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
|
8039 case 'd': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
8040 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
|
8041 case 'u': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
8042 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
|
8043 default: |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
8044 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
|
8045 } |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
8046 if (buf->b_p_ff != NULL) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
8047 buf->b_start_ffc = *buf->b_p_ff; |
7 | 8048 buf->b_p_bh = empty_option; |
8049 buf->b_p_bt = empty_option; | |
8050 } | |
8051 else | |
8052 free_buf_options(buf, FALSE); | |
8053 | |
8054 buf->b_p_ai = p_ai; | |
8055 buf->b_p_ai_nopaste = p_ai_nopaste; | |
8056 buf->b_p_sw = p_sw; | |
8057 buf->b_p_tw = p_tw; | |
8058 buf->b_p_tw_nopaste = p_tw_nopaste; | |
8059 buf->b_p_tw_nobin = p_tw_nobin; | |
8060 buf->b_p_wm = p_wm; | |
8061 buf->b_p_wm_nopaste = p_wm_nopaste; | |
8062 buf->b_p_wm_nobin = p_wm_nobin; | |
8063 buf->b_p_bin = p_bin; | |
402 | 8064 buf->b_p_bomb = p_bomb; |
6954 | 8065 buf->b_p_fixeol = p_fixeol; |
7 | 8066 buf->b_p_et = p_et; |
8067 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
|
8068 buf->b_p_et_nopaste = p_et_nopaste; |
7 | 8069 buf->b_p_ml = p_ml; |
8070 buf->b_p_ml_nobin = p_ml_nobin; | |
8071 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
|
8072 buf->b_p_swf = cmdmod.noswapfile ? FALSE : p_swf; |
7 | 8073 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
|
8074 #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
|
8075 buf->b_p_csl = vim_strsave(p_csl); |
7 | 8076 #endif |
12 | 8077 #ifdef FEAT_COMPL_FUNC |
8078 buf->b_p_cfu = vim_strsave(p_cfu); | |
502 | 8079 buf->b_p_ofu = vim_strsave(p_ofu); |
12 | 8080 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
8081 #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
|
8082 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
|
8083 #endif |
7 | 8084 buf->b_p_sts = p_sts; |
8085 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
|
8086 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8087 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
|
8088 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
|
8089 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
|
8090 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8091 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
|
8092 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
|
8093 ? 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
|
8094 #endif |
7 | 8095 buf->b_p_sn = p_sn; |
8096 #ifdef FEAT_COMMENTS | |
8097 buf->b_p_com = vim_strsave(p_com); | |
8098 #endif | |
8099 #ifdef FEAT_FOLDING | |
8100 buf->b_p_cms = vim_strsave(p_cms); | |
8101 #endif | |
8102 buf->b_p_fo = vim_strsave(p_fo); | |
41 | 8103 buf->b_p_flp = vim_strsave(p_flp); |
7 | 8104 buf->b_p_nf = vim_strsave(p_nf); |
8105 buf->b_p_mps = vim_strsave(p_mps); | |
8106 #ifdef FEAT_SMARTINDENT | |
8107 buf->b_p_si = p_si; | |
8108 #endif | |
8109 buf->b_p_ci = p_ci; | |
8110 #ifdef FEAT_CINDENT | |
8111 buf->b_p_cin = p_cin; | |
8112 buf->b_p_cink = vim_strsave(p_cink); | |
8113 buf->b_p_cino = vim_strsave(p_cino); | |
8114 #endif | |
8115 /* Don't copy 'filetype', it must be detected */ | |
8116 buf->b_p_ft = empty_option; | |
8117 buf->b_p_pi = p_pi; | |
8118 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) | |
8119 buf->b_p_cinw = vim_strsave(p_cinw); | |
8120 #endif | |
8121 #ifdef FEAT_LISP | |
8122 buf->b_p_lisp = p_lisp; | |
8123 #endif | |
8124 #ifdef FEAT_SYN_HL | |
8125 /* Don't copy 'syntax', it must be set */ | |
8126 buf->b_p_syn = empty_option; | |
410 | 8127 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
|
8128 buf->b_s.b_syn_isk = empty_option; |
744 | 8129 #endif |
8130 #ifdef FEAT_SPELL | |
2599 | 8131 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
|
8132 (void)compile_cap_prog(&buf->b_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
8133 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
|
8134 buf->b_s.b_p_spl = vim_strsave(p_spl); |
7 | 8135 #endif |
8136 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
8137 buf->b_p_inde = vim_strsave(p_inde); | |
8138 buf->b_p_indk = vim_strsave(p_indk); | |
8139 #endif | |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
8140 buf->b_p_fp = empty_option; |
667 | 8141 #if defined(FEAT_EVAL) |
8142 buf->b_p_fex = vim_strsave(p_fex); | |
8143 #endif | |
7 | 8144 #ifdef FEAT_CRYPT |
8145 buf->b_p_key = vim_strsave(p_key); | |
8146 #endif | |
8147 #ifdef FEAT_SEARCHPATH | |
8148 buf->b_p_sua = vim_strsave(p_sua); | |
8149 #endif | |
8150 #ifdef FEAT_KEYMAP | |
8151 buf->b_p_keymap = vim_strsave(p_keymap); | |
8152 buf->b_kmap_state |= KEYMAP_INIT; | |
8153 #endif | |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
8154 #ifdef FEAT_TERMINAL |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
8155 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
|
8156 #endif |
7 | 8157 /* This isn't really an option, but copying the langmap and IME |
8158 * state from the current buffer is better than resetting it. */ | |
8159 buf->b_p_iminsert = p_iminsert; | |
8160 buf->b_p_imsearch = p_imsearch; | |
8161 | |
8162 /* options that are normally global but also have a local value | |
8163 * are not copied, start using the global value */ | |
8164 buf->b_p_ar = -1; | |
5446 | 8165 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
6243 | 8166 buf->b_p_bkc = empty_option; |
8167 buf->b_bkc_flags = 0; | |
7 | 8168 #ifdef FEAT_QUICKFIX |
8169 buf->b_p_gp = empty_option; | |
8170 buf->b_p_mp = empty_option; | |
8171 buf->b_p_efm = empty_option; | |
8172 #endif | |
8173 buf->b_p_ep = empty_option; | |
8174 buf->b_p_kp = empty_option; | |
8175 buf->b_p_path = empty_option; | |
8176 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
|
8177 buf->b_p_tc = empty_option; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
8178 buf->b_tc_flags = 0; |
7 | 8179 #ifdef FEAT_FIND_ID |
8180 buf->b_p_def = empty_option; | |
8181 buf->b_p_inc = empty_option; | |
8182 # ifdef FEAT_EVAL | |
8183 buf->b_p_inex = vim_strsave(p_inex); | |
8184 # endif | |
8185 #endif | |
8186 buf->b_p_dict = empty_option; | |
8187 buf->b_p_tsr = empty_option; | |
12 | 8188 #ifdef FEAT_TEXTOBJ |
8189 buf->b_p_qe = vim_strsave(p_qe); | |
8190 #endif | |
790 | 8191 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
8192 buf->b_p_bexpr = empty_option; | |
8193 #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
|
8194 #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
|
8195 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
|
8196 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
8197 #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
|
8198 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
|
8199 #endif |
5712 | 8200 #ifdef FEAT_LISP |
8201 buf->b_p_lw = empty_option; | |
8202 #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
|
8203 buf->b_p_menc = empty_option; |
7 | 8204 |
8205 /* | |
8206 * Don't copy the options set by ex_help(), use the saved values, | |
8207 * when going from a help buffer to a non-help buffer. | |
8208 * Don't touch these at all when BCO_NOHELP is used and going from | |
8209 * or to a help buffer. | |
8210 */ | |
8211 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
|
8212 { |
7 | 8213 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
|
8214 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8215 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
|
8216 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
|
8217 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8218 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
|
8219 #endif |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8220 } |
7 | 8221 else |
8222 { | |
8223 buf->b_p_isk = vim_strsave(p_isk); | |
8224 did_isk = TRUE; | |
8225 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
|
8226 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8227 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
|
8228 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
|
8229 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
|
8230 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8231 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
|
8232 #endif |
7 | 8233 buf->b_help = FALSE; |
8234 if (buf->b_p_bt[0] == 'h') | |
8235 clear_string_option(&buf->b_p_bt); | |
8236 buf->b_p_ma = p_ma; | |
8237 } | |
8238 } | |
8239 | |
8240 /* | |
8241 * When the options should be copied (ignoring BCO_ALWAYS), set the | |
8242 * flag that indicates that the options have been initialized. | |
8243 */ | |
8244 if (should_copy) | |
8245 buf->b_p_initialized = TRUE; | |
8246 } | |
8247 | |
8248 check_buf_options(buf); /* make sure we don't have NULLs */ | |
8249 if (did_isk) | |
8250 (void)buf_init_chartab(buf, FALSE); | |
8251 } | |
8252 | |
8253 /* | |
8254 * Reset the 'modifiable' option and its default value. | |
8255 */ | |
8256 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8257 reset_modifiable(void) |
7 | 8258 { |
8259 int opt_idx; | |
8260 | |
8261 curbuf->b_p_ma = FALSE; | |
8262 p_ma = FALSE; | |
8263 opt_idx = findoption((char_u *)"ma"); | |
838 | 8264 if (opt_idx >= 0) |
8265 options[opt_idx].def_val[VI_DEFAULT] = FALSE; | |
7 | 8266 } |
8267 | |
8268 /* | |
8269 * Set the global value for 'iminsert' to the local value. | |
8270 */ | |
8271 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8272 set_iminsert_global(void) |
7 | 8273 { |
8274 p_iminsert = curbuf->b_p_iminsert; | |
8275 } | |
8276 | |
8277 /* | |
8278 * Set the global value for 'imsearch' to the local value. | |
8279 */ | |
8280 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8281 set_imsearch_global(void) |
7 | 8282 { |
8283 p_imsearch = curbuf->b_p_imsearch; | |
8284 } | |
8285 | |
8286 static int expand_option_idx = -1; | |
8287 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; | |
8288 static int expand_option_flags = 0; | |
8289 | |
8290 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8291 set_context_in_set_cmd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8292 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8293 char_u *arg, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8294 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */ |
7 | 8295 { |
8296 int nextchar; | |
8297 long_u flags = 0; /* init for GCC */ | |
8298 int opt_idx = 0; /* init for GCC */ | |
8299 char_u *p; | |
8300 char_u *s; | |
8301 int is_term_option = FALSE; | |
8302 int key; | |
8303 | |
8304 expand_option_flags = opt_flags; | |
8305 | |
8306 xp->xp_context = EXPAND_SETTINGS; | |
8307 if (*arg == NUL) | |
8308 { | |
8309 xp->xp_pattern = arg; | |
8310 return; | |
8311 } | |
8312 p = arg + STRLEN(arg) - 1; | |
8313 if (*p == ' ' && *(p - 1) != '\\') | |
8314 { | |
8315 xp->xp_pattern = p + 1; | |
8316 return; | |
8317 } | |
8318 while (p > arg) | |
8319 { | |
8320 s = p; | |
8321 /* count number of backslashes before ' ' or ',' */ | |
8322 if (*p == ' ' || *p == ',') | |
8323 { | |
8324 while (s > arg && *(s - 1) == '\\') | |
8325 --s; | |
8326 } | |
8327 /* break at a space with an even number of backslashes */ | |
8328 if (*p == ' ' && ((p - s) & 1) == 0) | |
8329 { | |
8330 ++p; | |
8331 break; | |
8332 } | |
8333 --p; | |
8334 } | |
1911 | 8335 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0) |
7 | 8336 { |
8337 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
8338 p += 2; | |
8339 } | |
8340 if (STRNCMP(p, "inv", 3) == 0) | |
8341 { | |
8342 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
8343 p += 3; | |
8344 } | |
8345 xp->xp_pattern = arg = p; | |
8346 if (*arg == '<') | |
8347 { | |
8348 while (*p != '>') | |
8349 if (*p++ == NUL) /* expand terminal option name */ | |
8350 return; | |
8351 key = get_special_key_code(arg + 1); | |
8352 if (key == 0) /* unknown name */ | |
8353 { | |
8354 xp->xp_context = EXPAND_NOTHING; | |
8355 return; | |
8356 } | |
8357 nextchar = *++p; | |
8358 is_term_option = TRUE; | |
8359 expand_option_name[2] = KEY2TERMCAP0(key); | |
8360 expand_option_name[3] = KEY2TERMCAP1(key); | |
8361 } | |
8362 else | |
8363 { | |
8364 if (p[0] == 't' && p[1] == '_') | |
8365 { | |
8366 p += 2; | |
8367 if (*p != NUL) | |
8368 ++p; | |
8369 if (*p == NUL) | |
8370 return; /* expand option name */ | |
8371 nextchar = *++p; | |
8372 is_term_option = TRUE; | |
8373 expand_option_name[2] = p[-2]; | |
8374 expand_option_name[3] = p[-1]; | |
8375 } | |
8376 else | |
8377 { | |
8378 /* Allow * wildcard */ | |
8379 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') | |
8380 p++; | |
8381 if (*p == NUL) | |
8382 return; | |
8383 nextchar = *p; | |
8384 *p = NUL; | |
8385 opt_idx = findoption(arg); | |
8386 *p = nextchar; | |
8387 if (opt_idx == -1 || options[opt_idx].var == NULL) | |
8388 { | |
8389 xp->xp_context = EXPAND_NOTHING; | |
8390 return; | |
8391 } | |
8392 flags = options[opt_idx].flags; | |
8393 if (flags & P_BOOL) | |
8394 { | |
8395 xp->xp_context = EXPAND_NOTHING; | |
8396 return; | |
8397 } | |
8398 } | |
8399 } | |
8400 /* handle "-=" and "+=" */ | |
8401 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') | |
8402 { | |
8403 ++p; | |
8404 nextchar = '='; | |
8405 } | |
8406 if ((nextchar != '=' && nextchar != ':') | |
8407 || xp->xp_context == EXPAND_BOOL_SETTINGS) | |
8408 { | |
8409 xp->xp_context = EXPAND_UNSUCCESSFUL; | |
8410 return; | |
8411 } | |
8412 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) | |
8413 { | |
8414 xp->xp_context = EXPAND_OLD_SETTING; | |
8415 if (is_term_option) | |
8416 expand_option_idx = -1; | |
8417 else | |
8418 expand_option_idx = opt_idx; | |
8419 xp->xp_pattern = p + 1; | |
8420 return; | |
8421 } | |
8422 xp->xp_context = EXPAND_NOTHING; | |
8423 if (is_term_option || (flags & P_NUM)) | |
8424 return; | |
8425 | |
8426 xp->xp_pattern = p + 1; | |
8427 | |
8428 if (flags & P_EXPAND) | |
8429 { | |
8430 p = options[opt_idx].var; | |
8431 if (p == (char_u *)&p_bdir | |
8432 || p == (char_u *)&p_dir | |
8433 || p == (char_u *)&p_path | |
8182
95d59081580f
commit https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
8434 || p == (char_u *)&p_pp |
7 | 8435 || p == (char_u *)&p_rtp |
8436 #ifdef FEAT_SEARCHPATH | |
8437 || p == (char_u *)&p_cdpath | |
8438 #endif | |
8439 #ifdef FEAT_SESSION | |
8440 || p == (char_u *)&p_vdir | |
8441 #endif | |
8442 ) | |
8443 { | |
8444 xp->xp_context = EXPAND_DIRECTORIES; | |
8445 if (p == (char_u *)&p_path | |
8446 #ifdef FEAT_SEARCHPATH | |
8447 || p == (char_u *)&p_cdpath | |
8448 #endif | |
8449 ) | |
8450 xp->xp_backslash = XP_BS_THREE; | |
8451 else | |
8452 xp->xp_backslash = XP_BS_ONE; | |
8453 } | |
8454 else | |
8455 { | |
8456 xp->xp_context = EXPAND_FILES; | |
8457 /* for 'tags' need three backslashes for a space */ | |
8458 if (p == (char_u *)&p_tags) | |
8459 xp->xp_backslash = XP_BS_THREE; | |
8460 else | |
8461 xp->xp_backslash = XP_BS_ONE; | |
8462 } | |
8463 } | |
8464 | |
8465 /* For an option that is a list of file names, find the start of the | |
8466 * last file name. */ | |
8467 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) | |
8468 { | |
8469 /* count number of backslashes before ' ' or ',' */ | |
8470 if (*p == ' ' || *p == ',') | |
8471 { | |
8472 s = p; | |
8473 while (s > xp->xp_pattern && *(s - 1) == '\\') | |
8474 --s; | |
8475 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) | |
8476 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) | |
8477 { | |
8478 xp->xp_pattern = p + 1; | |
8479 break; | |
8480 } | |
8481 } | |
374 | 8482 |
744 | 8483 #ifdef FEAT_SPELL |
374 | 8484 /* for 'spellsuggest' start at "file:" */ |
8485 if (options[opt_idx].var == (char_u *)&p_sps | |
8486 && STRNCMP(p, "file:", 5) == 0) | |
8487 { | |
8488 xp->xp_pattern = p + 5; | |
8489 break; | |
8490 } | |
8491 #endif | |
7 | 8492 } |
8493 | |
8494 return; | |
8495 } | |
8496 | |
8497 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8498 ExpandSettings( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8499 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8500 regmatch_T *regmatch, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8501 int *num_file, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8502 char_u ***file) |
7 | 8503 { |
8504 int num_normal = 0; /* Nr of matching non-term-code settings */ | |
8505 int num_term = 0; /* Nr of matching terminal code settings */ | |
8506 int opt_idx; | |
8507 int match; | |
8508 int count = 0; | |
8509 char_u *str; | |
8510 int loop; | |
8511 int is_term_opt; | |
8512 char_u name_buf[MAX_KEY_NAME_LEN]; | |
8513 static char *(names[]) = {"all", "termcap"}; | |
8514 int ic = regmatch->rm_ic; /* remember the ignore-case flag */ | |
8515 | |
8516 /* do this loop twice: | |
8517 * loop == 0: count the number of matching options | |
8518 * loop == 1: copy the matching options into allocated memory | |
8519 */ | |
8520 for (loop = 0; loop <= 1; ++loop) | |
8521 { | |
8522 regmatch->rm_ic = ic; | |
8523 if (xp->xp_context != EXPAND_BOOL_SETTINGS) | |
8524 { | |
1883 | 8525 for (match = 0; match < (int)(sizeof(names) / sizeof(char *)); |
8526 ++match) | |
7 | 8527 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0)) |
8528 { | |
8529 if (loop == 0) | |
8530 num_normal++; | |
8531 else | |
8532 (*file)[count++] = vim_strsave((char_u *)names[match]); | |
8533 } | |
8534 } | |
8535 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; | |
8536 opt_idx++) | |
8537 { | |
8538 if (options[opt_idx].var == NULL) | |
8539 continue; | |
8540 if (xp->xp_context == EXPAND_BOOL_SETTINGS | |
8541 && !(options[opt_idx].flags & P_BOOL)) | |
8542 continue; | |
8543 is_term_opt = istermoption(&options[opt_idx]); | |
8544 if (is_term_opt && num_normal > 0) | |
8545 continue; | |
8546 match = FALSE; | |
8547 if (vim_regexec(regmatch, str, (colnr_T)0) | |
8548 || (options[opt_idx].shortname != NULL | |
8549 && vim_regexec(regmatch, | |
8550 (char_u *)options[opt_idx].shortname, (colnr_T)0))) | |
8551 match = TRUE; | |
8552 else if (is_term_opt) | |
8553 { | |
8554 name_buf[0] = '<'; | |
8555 name_buf[1] = 't'; | |
8556 name_buf[2] = '_'; | |
8557 name_buf[3] = str[2]; | |
8558 name_buf[4] = str[3]; | |
8559 name_buf[5] = '>'; | |
8560 name_buf[6] = NUL; | |
8561 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
8562 { | |
8563 match = TRUE; | |
8564 str = name_buf; | |
8565 } | |
8566 } | |
8567 if (match) | |
8568 { | |
8569 if (loop == 0) | |
8570 { | |
8571 if (is_term_opt) | |
8572 num_term++; | |
8573 else | |
8574 num_normal++; | |
8575 } | |
8576 else | |
8577 (*file)[count++] = vim_strsave(str); | |
8578 } | |
8579 } | |
8580 /* | |
8581 * Check terminal key codes, these are not in the option table | |
8582 */ | |
8583 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) | |
8584 { | |
8585 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) | |
8586 { | |
8587 if (!isprint(str[0]) || !isprint(str[1])) | |
8588 continue; | |
8589 | |
8590 name_buf[0] = 't'; | |
8591 name_buf[1] = '_'; | |
8592 name_buf[2] = str[0]; | |
8593 name_buf[3] = str[1]; | |
8594 name_buf[4] = NUL; | |
8595 | |
8596 match = FALSE; | |
8597 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
8598 match = TRUE; | |
8599 else | |
8600 { | |
8601 name_buf[0] = '<'; | |
8602 name_buf[1] = 't'; | |
8603 name_buf[2] = '_'; | |
8604 name_buf[3] = str[0]; | |
8605 name_buf[4] = str[1]; | |
8606 name_buf[5] = '>'; | |
8607 name_buf[6] = NUL; | |
8608 | |
8609 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
8610 match = TRUE; | |
8611 } | |
8612 if (match) | |
8613 { | |
8614 if (loop == 0) | |
8615 num_term++; | |
8616 else | |
8617 (*file)[count++] = vim_strsave(name_buf); | |
8618 } | |
8619 } | |
8620 | |
8621 /* | |
8622 * Check special key names. | |
8623 */ | |
8624 regmatch->rm_ic = TRUE; /* ignore case here */ | |
8625 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) | |
8626 { | |
8627 name_buf[0] = '<'; | |
8628 STRCPY(name_buf + 1, str); | |
8629 STRCAT(name_buf, ">"); | |
8630 | |
8631 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
8632 { | |
8633 if (loop == 0) | |
8634 num_term++; | |
8635 else | |
8636 (*file)[count++] = vim_strsave(name_buf); | |
8637 } | |
8638 } | |
8639 } | |
8640 if (loop == 0) | |
8641 { | |
8642 if (num_normal > 0) | |
8643 *num_file = num_normal; | |
8644 else if (num_term > 0) | |
8645 *num_file = num_term; | |
8646 else | |
8647 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
|
8648 *file = ALLOC_MULT(char_u *, *num_file); |
7 | 8649 if (*file == NULL) |
8650 { | |
8651 *file = (char_u **)""; | |
8652 return FAIL; | |
8653 } | |
8654 } | |
8655 } | |
8656 return OK; | |
8657 } | |
8658 | |
8659 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8660 ExpandOldSetting(int *num_file, char_u ***file) |
7 | 8661 { |
8662 char_u *var = NULL; /* init for GCC */ | |
8663 char_u *buf; | |
8664 | |
8665 *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
|
8666 *file = ALLOC_ONE(char_u *); |
7 | 8667 if (*file == NULL) |
8668 return FAIL; | |
8669 | |
8670 /* | |
8671 * For a terminal key code expand_option_idx is < 0. | |
8672 */ | |
8673 if (expand_option_idx < 0) | |
8674 { | |
8675 var = find_termcode(expand_option_name + 2); | |
8676 if (var == NULL) | |
8677 expand_option_idx = findoption(expand_option_name); | |
8678 } | |
8679 | |
8680 if (expand_option_idx >= 0) | |
8681 { | |
8682 /* put string of option value in NameBuff */ | |
8683 option_value2string(&options[expand_option_idx], expand_option_flags); | |
8684 var = NameBuff; | |
8685 } | |
8686 else if (var == NULL) | |
8687 var = (char_u *)""; | |
8688 | |
8689 /* A backslash is required before some characters. This is the reverse of | |
8690 * what happens in do_set(). */ | |
8691 buf = vim_strsave_escaped(var, escape_chars); | |
8692 | |
8693 if (buf == NULL) | |
8694 { | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13242
diff
changeset
|
8695 VIM_CLEAR(*file); |
7 | 8696 return FAIL; |
8697 } | |
8698 | |
8699 #ifdef BACKSLASH_IN_FILENAME | |
8700 /* For MS-Windows et al. we don't double backslashes at the start and | |
8701 * 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
|
8702 for (var = buf; *var != NUL; MB_PTR_ADV(var)) |
7 | 8703 if (var[0] == '\\' && var[1] == '\\' |
8704 && expand_option_idx >= 0 | |
8705 && (options[expand_option_idx].flags & P_EXPAND) | |
8706 && vim_isfilec(var[2]) | |
8707 && (var[2] != '\\' || (var == buf && var[4] != '\\'))) | |
1622 | 8708 STRMOVE(var, var + 1); |
7 | 8709 #endif |
8710 | |
8711 *file[0] = buf; | |
8712 *num_file = 1; | |
8713 return OK; | |
8714 } | |
8715 | |
8716 /* | |
8717 * Get the value for the numeric or string option *opp in a nice format into | |
8718 * NameBuff[]. Must not be called with a hidden option! | |
8719 */ | |
8720 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8721 option_value2string( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8722 struct vimoption *opp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8723 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */ |
7 | 8724 { |
8725 char_u *varp; | |
8726 | |
8727 varp = get_varp_scope(opp, opt_flags); | |
8728 | |
8729 if (opp->flags & P_NUM) | |
8730 { | |
8731 long wc = 0; | |
8732 | |
8733 if (wc_use_keyname(varp, &wc)) | |
8734 STRCPY(NameBuff, get_special_key_name((int)wc, 0)); | |
8735 else if (wc != 0) | |
8736 STRCPY(NameBuff, transchar((int)wc)); | |
8737 else | |
8738 sprintf((char *)NameBuff, "%ld", *(long *)varp); | |
8739 } | |
8740 else /* P_STRING */ | |
8741 { | |
8742 varp = *(char_u **)(varp); | |
8743 if (varp == NULL) /* just in case */ | |
8744 NameBuff[0] = NUL; | |
8745 #ifdef FEAT_CRYPT | |
8746 /* don't show the actual value of 'key', only that it's set */ | |
840 | 8747 else if (opp->var == (char_u *)&p_key && *varp) |
7 | 8748 STRCPY(NameBuff, "*****"); |
8749 #endif | |
8750 else if (opp->flags & P_EXPAND) | |
8751 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE); | |
8752 /* Translate 'pastetoggle' into special key names */ | |
8753 else if ((char_u **)opp->var == &p_pt) | |
8754 str2specialbuf(p_pt, NameBuff, MAXPATHL); | |
8755 else | |
419 | 8756 vim_strncpy(NameBuff, varp, MAXPATHL - 1); |
7 | 8757 } |
8758 } | |
8759 | |
8760 /* | |
8761 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be | |
8762 * printed as a keyname. | |
8763 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. | |
8764 */ | |
8765 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8766 wc_use_keyname(char_u *varp, long *wcp) |
7 | 8767 { |
8768 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) | |
8769 { | |
8770 *wcp = *(long *)varp; | |
8771 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0) | |
8772 return TRUE; | |
8773 } | |
8774 return FALSE; | |
8775 } | |
8776 | |
8777 /* | |
8778 * Return TRUE if format option 'x' is in effect. | |
8779 * Take care of no formatting when 'paste' is set. | |
8780 */ | |
8781 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8782 has_format_option(int x) |
7 | 8783 { |
8784 if (p_paste) | |
8785 return FALSE; | |
8786 return (vim_strchr(curbuf->b_p_fo, x) != NULL); | |
8787 } | |
8788 | |
8789 /* | |
8790 * Return TRUE if "x" is present in 'shortmess' option, or | |
8791 * 'shortmess' contains 'a' and "x" is present in SHM_A. | |
8792 */ | |
8793 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8794 shortmess(int x) |
7 | 8795 { |
3384 | 8796 return p_shm != NULL && |
8797 ( vim_strchr(p_shm, x) != NULL | |
7 | 8798 || (vim_strchr(p_shm, 'a') != NULL |
8799 && vim_strchr((char_u *)SHM_A, x) != NULL)); | |
8800 } | |
8801 | |
8802 /* | |
8803 * paste_option_changed() - Called after p_paste was set or reset. | |
8804 */ | |
8805 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8806 paste_option_changed(void) |
7 | 8807 { |
8808 static int old_p_paste = FALSE; | |
8809 static int save_sm = 0; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
8810 static int save_sta = 0; |
7 | 8811 #ifdef FEAT_CMDL_INFO |
8812 static int save_ru = 0; | |
8813 #endif | |
8814 #ifdef FEAT_RIGHTLEFT | |
8815 static int save_ri = 0; | |
8816 static int save_hkmap = 0; | |
8817 #endif | |
8818 buf_T *buf; | |
8819 | |
8820 if (p_paste) | |
8821 { | |
8822 /* | |
8823 * Paste switched from off to on. | |
8824 * Save the current values, so they can be restored later. | |
8825 */ | |
8826 if (!old_p_paste) | |
8827 { | |
8828 /* save options for each buffer */ | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
8829 FOR_ALL_BUFFERS(buf) |
7 | 8830 { |
8831 buf->b_p_tw_nopaste = buf->b_p_tw; | |
8832 buf->b_p_wm_nopaste = buf->b_p_wm; | |
8833 buf->b_p_sts_nopaste = buf->b_p_sts; | |
8834 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
|
8835 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
|
8836 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8837 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
|
8838 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
|
8839 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
|
8840 ? 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
|
8841 #endif |
7 | 8842 } |
8843 | |
8844 /* save global options */ | |
8845 save_sm = p_sm; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
8846 save_sta = p_sta; |
7 | 8847 #ifdef FEAT_CMDL_INFO |
8848 save_ru = p_ru; | |
8849 #endif | |
8850 #ifdef FEAT_RIGHTLEFT | |
8851 save_ri = p_ri; | |
8852 save_hkmap = p_hkmap; | |
8853 #endif | |
8854 /* 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
|
8855 p_ai_nopaste = p_ai; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
8856 p_et_nopaste = p_et; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
8857 p_sts_nopaste = p_sts; |
7 | 8858 p_tw_nopaste = p_tw; |
8859 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
|
8860 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8861 if (p_vsts_nopaste) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8862 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
|
8863 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
|
8864 #endif |
7 | 8865 } |
8866 | |
8867 /* | |
8868 * Always set the option values, also when 'paste' is set when it is | |
8869 * already on. | |
8870 */ | |
8871 /* set options for each buffer */ | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
8872 FOR_ALL_BUFFERS(buf) |
7 | 8873 { |
8874 buf->b_p_tw = 0; /* textwidth is 0 */ | |
8875 buf->b_p_wm = 0; /* wrapmargin is 0 */ | |
8876 buf->b_p_sts = 0; /* softtabstop is 0 */ | |
8877 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
|
8878 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
|
8879 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8880 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
|
8881 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
|
8882 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
|
8883 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
|
8884 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
|
8885 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
|
8886 #endif |
7 | 8887 } |
8888 | |
8889 /* set global options */ | |
8890 p_sm = 0; /* no showmatch */ | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
8891 p_sta = 0; /* no smarttab */ |
7 | 8892 #ifdef FEAT_CMDL_INFO |
8893 if (p_ru) | |
8894 status_redraw_all(); /* redraw to remove the ruler */ | |
8895 p_ru = 0; /* no ruler */ | |
8896 #endif | |
8897 #ifdef FEAT_RIGHTLEFT | |
8898 p_ri = 0; /* no reverse insert */ | |
8899 p_hkmap = 0; /* no Hebrew keyboard */ | |
8900 #endif | |
8901 /* set global values for local buffer options */ | |
8902 p_tw = 0; | |
8903 p_wm = 0; | |
8904 p_sts = 0; | |
8905 p_ai = 0; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8906 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8907 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8908 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
|
8909 p_vsts = empty_option; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8910 #endif |
7 | 8911 } |
8912 | |
8913 /* | |
8914 * Paste switched from on to off: Restore saved values. | |
8915 */ | |
8916 else if (old_p_paste) | |
8917 { | |
8918 /* restore options for each buffer */ | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
8919 FOR_ALL_BUFFERS(buf) |
7 | 8920 { |
8921 buf->b_p_tw = buf->b_p_tw_nopaste; | |
8922 buf->b_p_wm = buf->b_p_wm_nopaste; | |
8923 buf->b_p_sts = buf->b_p_sts_nopaste; | |
8924 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
|
8925 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
|
8926 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8927 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
|
8928 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
|
8929 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
|
8930 ? 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
|
8931 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
|
8932 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
|
8933 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
|
8934 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
|
8935 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8936 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
|
8937 #endif |
7 | 8938 } |
8939 | |
8940 /* restore global options */ | |
8941 p_sm = save_sm; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
8942 p_sta = save_sta; |
7 | 8943 #ifdef FEAT_CMDL_INFO |
8944 if (p_ru != save_ru) | |
8945 status_redraw_all(); /* redraw to draw the ruler */ | |
8946 p_ru = save_ru; | |
8947 #endif | |
8948 #ifdef FEAT_RIGHTLEFT | |
8949 p_ri = save_ri; | |
8950 p_hkmap = save_hkmap; | |
8951 #endif | |
8952 /* 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
|
8953 p_ai = p_ai_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
8954 p_et = p_et_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
8955 p_sts = p_sts_nopaste; |
7 | 8956 p_tw = p_tw_nopaste; |
8957 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
|
8958 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8959 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
8960 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
|
8961 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
|
8962 #endif |
7 | 8963 } |
8964 | |
8965 old_p_paste = p_paste; | |
8966 } | |
8967 | |
8968 /* | |
8969 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found. | |
8970 * | |
8971 * Reset 'compatible' and set the values for options that didn't get set yet | |
8972 * to the Vim defaults. | |
8973 * Don't do this if the 'compatible' option has been set or reset before. | |
819 | 8974 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet. |
7 | 8975 */ |
8976 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8977 vimrc_found(char_u *fname, char_u *envname) |
819 | 8978 { |
8979 int opt_idx; | |
826 | 8980 int dofree = FALSE; |
819 | 8981 char_u *p; |
7 | 8982 |
8983 if (!option_was_set((char_u *)"cp")) | |
8984 { | |
8985 p_cp = FALSE; | |
8986 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) | |
8987 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF))) | |
8988 set_option_default(opt_idx, OPT_FREE, FALSE); | |
8989 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
8990 didset_options2(); |
7 | 8991 } |
819 | 8992 |
8993 if (fname != NULL) | |
8994 { | |
8995 p = vim_getenv(envname, &dofree); | |
8996 if (p == NULL) | |
8997 { | |
8998 /* Set $MYVIMRC to the first vimrc file found. */ | |
8999 p = FullName_save(fname, FALSE); | |
9000 if (p != NULL) | |
9001 { | |
9002 vim_setenv(envname, p); | |
9003 vim_free(p); | |
9004 } | |
9005 } | |
9006 else if (dofree) | |
9007 vim_free(p); | |
9008 } | |
7 | 9009 } |
9010 | |
9011 /* | |
9012 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg. | |
9013 */ | |
9014 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9015 change_compatible(int on) |
7 | 9016 { |
838 | 9017 int opt_idx; |
9018 | |
7 | 9019 if (p_cp != on) |
9020 { | |
9021 p_cp = on; | |
9022 compatible_set(); | |
9023 } | |
838 | 9024 opt_idx = findoption((char_u *)"cp"); |
9025 if (opt_idx >= 0) | |
9026 options[opt_idx].flags |= P_WAS_SET; | |
7 | 9027 } |
9028 | |
9029 /* | |
9030 * 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
|
9031 * Only works correctly for global options. |
7 | 9032 */ |
9033 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9034 option_was_set(char_u *name) |
7 | 9035 { |
9036 int idx; | |
9037 | |
9038 idx = findoption(name); | |
9039 if (idx < 0) /* unknown option */ | |
9040 return FALSE; | |
9041 if (options[idx].flags & P_WAS_SET) | |
9042 return TRUE; | |
9043 return FALSE; | |
9044 } | |
9045 | |
9046 /* | |
3980 | 9047 * Reset the flag indicating option "name" was set. |
9048 */ | |
14748
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
9049 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9050 reset_option_was_set(char_u *name) |
3980 | 9051 { |
9052 int idx = findoption(name); | |
9053 | |
9054 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
|
9055 { |
3980 | 9056 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
|
9057 return OK; |
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
9058 } |
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
9059 return FAIL; |
3980 | 9060 } |
9061 | |
9062 /* | |
7 | 9063 * compatible_set() - Called when 'compatible' has been set or unset. |
9064 * | |
9065 * When 'compatible' set: Set all relevant options (those that have the P_VIM) | |
9066 * flag) to a Vi compatible value. | |
9067 * When 'compatible' is unset: Set all options that have a different default | |
9068 * for Vim (without the P_VI_DEF flag) to that default. | |
9069 */ | |
9070 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9071 compatible_set(void) |
7 | 9072 { |
9073 int opt_idx; | |
9074 | |
9075 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) | |
9076 if ( ((options[opt_idx].flags & P_VIM) && p_cp) | |
9077 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp)) | |
9078 set_option_default(opt_idx, OPT_FREE, p_cp); | |
9079 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
9080 didset_options2(); |
7 | 9081 } |
9082 | |
9083 #ifdef FEAT_LINEBREAK | |
9084 | |
9085 /* | |
9086 * fill_breakat_flags() -- called when 'breakat' changes value. | |
9087 */ | |
9088 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9089 fill_breakat_flags(void) |
7 | 9090 { |
500 | 9091 char_u *p; |
7 | 9092 int i; |
9093 | |
9094 for (i = 0; i < 256; i++) | |
9095 breakat_flags[i] = FALSE; | |
9096 | |
9097 if (p_breakat != NULL) | |
500 | 9098 for (p = p_breakat; *p; p++) |
9099 breakat_flags[*p] = TRUE; | |
7 | 9100 } |
9101 #endif | |
9102 | |
9103 /* | |
9104 * Check an option that can be a range of string values. | |
9105 * | |
9106 * Return OK for correct value, FAIL otherwise. | |
9107 * Empty is always OK. | |
9108 */ | |
9109 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9110 check_opt_strings( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9111 char_u *val, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9112 char **values, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9113 int list) /* when TRUE: accept a list of values */ |
7 | 9114 { |
9115 return opt_strings_flags(val, values, NULL, list); | |
9116 } | |
9117 | |
9118 /* | |
9119 * Handle an option that can be a range of string values. | |
9120 * Set a flag in "*flagp" for each string present. | |
9121 * | |
9122 * Return OK for correct value, FAIL otherwise. | |
9123 * Empty is always OK. | |
9124 */ | |
9125 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9126 opt_strings_flags( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9127 char_u *val, /* new value */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9128 char **values, /* array of valid string values */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9129 unsigned *flagp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9130 int list) /* when TRUE: accept a list of values */ |
7 | 9131 { |
9132 int i; | |
9133 int len; | |
9134 unsigned new_flags = 0; | |
9135 | |
9136 while (*val) | |
9137 { | |
9138 for (i = 0; ; ++i) | |
9139 { | |
9140 if (values[i] == NULL) /* val not found in values[] */ | |
9141 return FAIL; | |
9142 | |
9143 len = (int)STRLEN(values[i]); | |
9144 if (STRNCMP(values[i], val, len) == 0 | |
9145 && ((list && val[len] == ',') || val[len] == NUL)) | |
9146 { | |
9147 val += len + (val[len] == ','); | |
9148 new_flags |= (1 << i); | |
9149 break; /* check next item in val list */ | |
9150 } | |
9151 } | |
9152 } | |
9153 if (flagp != NULL) | |
9154 *flagp = new_flags; | |
9155 | |
9156 return OK; | |
9157 } | |
9158 | |
9159 /* | |
9160 * Read the 'wildmode' option, fill wim_flags[]. | |
9161 */ | |
9162 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9163 check_opt_wim(void) |
7 | 9164 { |
9165 char_u new_wim_flags[4]; | |
9166 char_u *p; | |
9167 int i; | |
9168 int idx = 0; | |
9169 | |
9170 for (i = 0; i < 4; ++i) | |
9171 new_wim_flags[i] = 0; | |
9172 | |
9173 for (p = p_wim; *p; ++p) | |
9174 { | |
9175 for (i = 0; ASCII_ISALPHA(p[i]); ++i) | |
9176 ; | |
9177 if (p[i] != NUL && p[i] != ',' && p[i] != ':') | |
9178 return FAIL; | |
9179 if (i == 7 && STRNCMP(p, "longest", 7) == 0) | |
9180 new_wim_flags[idx] |= WIM_LONGEST; | |
9181 else if (i == 4 && STRNCMP(p, "full", 4) == 0) | |
9182 new_wim_flags[idx] |= WIM_FULL; | |
9183 else if (i == 4 && STRNCMP(p, "list", 4) == 0) | |
9184 new_wim_flags[idx] |= WIM_LIST; | |
9185 else | |
9186 return FAIL; | |
9187 p += i; | |
9188 if (*p == NUL) | |
9189 break; | |
9190 if (*p == ',') | |
9191 { | |
9192 if (idx == 3) | |
9193 return FAIL; | |
9194 ++idx; | |
9195 } | |
9196 } | |
9197 | |
9198 /* fill remaining entries with last flag */ | |
9199 while (idx < 3) | |
9200 { | |
9201 new_wim_flags[idx + 1] = new_wim_flags[idx]; | |
9202 ++idx; | |
9203 } | |
9204 | |
9205 /* only when there are no errors, wim_flags[] is changed */ | |
9206 for (i = 0; i < 4; ++i) | |
9207 wim_flags[i] = new_wim_flags[i]; | |
9208 return OK; | |
9209 } | |
9210 | |
9211 /* | |
9212 * Check if backspacing over something is allowed. | |
9213 */ | |
9214 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9215 can_bs( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9216 int what) /* BS_INDENT, BS_EOL or BS_START */ |
7 | 9217 { |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
9218 #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
|
9219 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
|
9220 return FALSE; |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
9221 #endif |
7 | 9222 switch (*p_bs) |
9223 { | |
9224 case '2': return TRUE; | |
9225 case '1': return (what != BS_START); | |
9226 case '0': return FALSE; | |
9227 } | |
9228 return vim_strchr(p_bs, what) != NULL; | |
9229 } | |
9230 | |
9231 /* | |
9232 * Save the current values of 'fileformat' and 'fileencoding', so that we know | |
9233 * the file must be considered changed when the value is different. | |
9234 */ | |
9235 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9236 save_file_ff(buf_T *buf) |
7 | 9237 { |
9238 buf->b_start_ffc = *buf->b_p_ff; | |
9239 buf->b_start_eol = buf->b_p_eol; | |
1352 | 9240 buf->b_start_bomb = buf->b_p_bomb; |
9241 | |
7 | 9242 /* Only use free/alloc when necessary, they take time. */ |
9243 if (buf->b_start_fenc == NULL | |
9244 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0) | |
9245 { | |
9246 vim_free(buf->b_start_fenc); | |
9247 buf->b_start_fenc = vim_strsave(buf->b_p_fenc); | |
9248 } | |
9249 } | |
9250 | |
9251 /* | |
9252 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value | |
9253 * from when editing started (save_file_ff() called). | |
1352 | 9254 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was |
9255 * changed and 'binary' is not set. | |
6933 | 9256 * Also when 'endofline' was changed and 'fixeol' is not set. |
2685 | 9257 * When "ignore_empty" is true don't consider a new, empty buffer to be |
9258 * changed. | |
7 | 9259 */ |
9260 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9261 file_ff_differs(buf_T *buf, int ignore_empty) |
7 | 9262 { |
1319 | 9263 /* In a buffer that was never loaded the options are not valid. */ |
9264 if (buf->b_flags & BF_NEVERLOADED) | |
9265 return FALSE; | |
2685 | 9266 if (ignore_empty |
9267 && (buf->b_flags & BF_NEW) | |
7 | 9268 && buf->b_ml.ml_line_count == 1 |
9269 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL) | |
9270 return FALSE; | |
9271 if (buf->b_start_ffc != *buf->b_p_ff) | |
9272 return TRUE; | |
6933 | 9273 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol) |
7 | 9274 return TRUE; |
1352 | 9275 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb) |
9276 return TRUE; | |
7 | 9277 if (buf->b_start_fenc == NULL) |
9278 return (*buf->b_p_fenc != NUL); | |
9279 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0); | |
9280 } | |
9281 | |
9282 /* | |
9283 * return OK if "p" is a valid fileformat name, FAIL otherwise. | |
9284 */ | |
9285 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9286 check_ff_value(char_u *p) |
7 | 9287 { |
9288 return check_opt_strings(p, p_ff_values, FALSE); | |
9289 } | |
3740 | 9290 |
4029 | 9291 /* |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
9292 * 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
|
9293 * 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
|
9294 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
9295 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
9296 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
|
9297 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
9298 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
|
9299 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
9300 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
9301 /* |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
9302 * 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
|
9303 * 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
|
9304 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
9305 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
9306 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
|
9307 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
9308 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
|
9309 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
9310 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
9311 /* |
4029 | 9312 * Check matchpairs option for "*initc". |
9313 * If there is a match set "*initc" to the matching character and "*findc" to | |
9314 * the opposite character. Set "*backwards" to the direction. | |
9315 * When "switchit" is TRUE swap the direction. | |
9316 */ | |
9317 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9318 find_mps_values( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9319 int *initc, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9320 int *findc, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9321 int *backwards, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9322 int switchit) |
4029 | 9323 { |
9324 char_u *ptr; | |
9325 | |
9326 ptr = curbuf->b_p_mps; | |
9327 while (*ptr != NUL) | |
9328 { | |
9329 if (has_mbyte) | |
9330 { | |
9331 char_u *prev; | |
9332 | |
9333 if (mb_ptr2char(ptr) == *initc) | |
9334 { | |
9335 if (switchit) | |
9336 { | |
9337 *findc = *initc; | |
9338 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); | |
9339 *backwards = TRUE; | |
9340 } | |
9341 else | |
9342 { | |
9343 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); | |
9344 *backwards = FALSE; | |
9345 } | |
9346 return; | |
9347 } | |
9348 prev = ptr; | |
9349 ptr += mb_ptr2len(ptr) + 1; | |
9350 if (mb_ptr2char(ptr) == *initc) | |
9351 { | |
9352 if (switchit) | |
9353 { | |
9354 *findc = *initc; | |
9355 *initc = mb_ptr2char(prev); | |
9356 *backwards = FALSE; | |
9357 } | |
9358 else | |
9359 { | |
9360 *findc = mb_ptr2char(prev); | |
9361 *backwards = TRUE; | |
9362 } | |
9363 return; | |
9364 } | |
9365 ptr += mb_ptr2len(ptr); | |
9366 } | |
9367 else | |
9368 { | |
9369 if (*ptr == *initc) | |
9370 { | |
9371 if (switchit) | |
9372 { | |
9373 *backwards = TRUE; | |
9374 *findc = *initc; | |
9375 *initc = ptr[2]; | |
9376 } | |
9377 else | |
9378 { | |
9379 *backwards = FALSE; | |
9380 *findc = ptr[2]; | |
9381 } | |
9382 return; | |
9383 } | |
9384 ptr += 2; | |
9385 if (*ptr == *initc) | |
9386 { | |
9387 if (switchit) | |
9388 { | |
9389 *backwards = FALSE; | |
9390 *findc = *initc; | |
9391 *initc = ptr[-2]; | |
9392 } | |
9393 else | |
9394 { | |
9395 *backwards = TRUE; | |
9396 *findc = ptr[-2]; | |
9397 } | |
9398 return; | |
9399 } | |
9400 ++ptr; | |
9401 } | |
9402 if (*ptr == ',') | |
9403 ++ptr; | |
9404 } | |
9405 } | |
5995 | 9406 |
9407 #if defined(FEAT_LINEBREAK) || defined(PROTO) | |
9408 /* | |
9409 * This is called when 'breakindentopt' is changed and when a window is | |
9410 * initialized. | |
9411 */ | |
6162 | 9412 static int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9413 briopt_check(win_T *wp) |
5995 | 9414 { |
9415 char_u *p; | |
9416 int bri_shift = 0; | |
9417 long bri_min = 20; | |
9418 int bri_sbr = FALSE; | |
9419 | |
6162 | 9420 p = wp->w_p_briopt; |
5995 | 9421 while (*p != NUL) |
9422 { | |
9423 if (STRNCMP(p, "shift:", 6) == 0 | |
9424 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6]))) | |
9425 { | |
9426 p += 6; | |
9427 bri_shift = getdigits(&p); | |
9428 } | |
9429 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4])) | |
9430 { | |
9431 p += 4; | |
9432 bri_min = getdigits(&p); | |
9433 } | |
9434 else if (STRNCMP(p, "sbr", 3) == 0) | |
9435 { | |
9436 p += 3; | |
9437 bri_sbr = TRUE; | |
9438 } | |
9439 if (*p != ',' && *p != NUL) | |
9440 return FAIL; | |
9441 if (*p == ',') | |
9442 ++p; | |
9443 } | |
9444 | |
6162 | 9445 wp->w_p_brishift = bri_shift; |
9446 wp->w_p_brimin = bri_min; | |
9447 wp->w_p_brisbr = bri_sbr; | |
5995 | 9448 |
9449 return OK; | |
9450 } | |
9451 #endif | |
6243 | 9452 |
9453 /* | |
9454 * Get the local or global value of 'backupcopy'. | |
9455 */ | |
9456 unsigned int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
9457 get_bkc_value(buf_T *buf) |
6243 | 9458 { |
9459 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags; | |
9460 } | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9461 |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9462 #if defined(FEAT_SIGNS) || defined(PROTO) |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9463 /* |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9464 * 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
|
9465 */ |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9466 int |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9467 signcolumn_on(win_T *wp) |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9468 { |
17129
4fb68abc770f
patch 8.1.1564: sign column takes up space
Bram Moolenaar <Bram@vim.org>
parents:
17115
diff
changeset
|
9469 // 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
|
9470 // 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
|
9471 // column. |
4fb68abc770f
patch 8.1.1564: sign column takes up space
Bram Moolenaar <Bram@vim.org>
parents:
17115
diff
changeset
|
9472 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
|
9473 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
|
9474 |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9475 if (*wp->w_p_scl == 'n') |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9476 return FALSE; |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9477 if (*wp->w_p_scl == 'y') |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9478 return TRUE; |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9479 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
|
9480 # ifdef FEAT_NETBEANS_INTG |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9481 || 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
|
9482 # endif |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9483 ); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9484 } |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
9485 #endif |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9486 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9487 #if defined(FEAT_EVAL) || defined(PROTO) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9488 /* |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9489 * Get window or buffer local options. |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9490 */ |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9491 dict_T * |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9492 get_winbuf_options(int bufopt) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9493 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9494 dict_T *d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9495 int opt_idx; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9496 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9497 d = dict_alloc(); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9498 if (d == NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9499 return NULL; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9500 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9501 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9502 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9503 struct vimoption *opt = &options[opt_idx]; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9504 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9505 if ((bufopt && (opt->indir & PV_BUF)) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9506 || (!bufopt && (opt->indir & PV_WIN))) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9507 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9508 char_u *varp = get_varp(opt); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9509 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9510 if (varp != NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9511 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9512 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
|
9513 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
|
9514 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
|
9515 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
|
9516 else |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14243
diff
changeset
|
9517 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
|
9518 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9519 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9520 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9521 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9522 return d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9523 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
9524 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9525 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9526 #ifdef FEAT_SYN_HL |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9527 /* |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9528 * 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
|
9529 */ |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9530 static int |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9531 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
|
9532 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9533 char_u *p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9534 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
|
9535 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9536 if (val == NULL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9537 p = wp->w_p_culopt; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9538 else |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9539 p = val; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9540 while (*p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9541 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9542 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
|
9543 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9544 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9545 culopt_flags_new |= CULOPT_LINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9546 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9547 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
|
9548 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9549 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9550 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
|
9551 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9552 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
|
9553 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9554 p += 6; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9555 culopt_flags_new |= CULOPT_NBR; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9556 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9557 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
|
9558 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9559 p += 10; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9560 culopt_flags_new |= CULOPT_SCRLINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9561 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9562 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9563 if (*p != ',' && *p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9564 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9565 if (*p == ',') |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9566 ++p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9567 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9568 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9569 // 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
|
9570 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
|
9571 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9572 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
|
9573 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9574 return OK; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9575 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
9576 #endif |