Mercurial > vim
annotate src/option.c @ 25301:fe178301fc04
Added tag v8.2.3187 for changeset e56c8dc1a53482582e17bfd70b525f9e1e92fb36
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 19 Jul 2021 22:30:05 +0200 |
parents | af3d0198faad |
children | 1e6da8364a02 |
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); |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
40 static char_u *find_dup_item(char_u *origval, char_u *newval, long_u flags); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
41 static char_u *option_expand(int opt_idx, char_u *val); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
42 static void didset_options(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
43 static void didset_options2(void); |
681 | 44 #if defined(FEAT_EVAL) || defined(PROTO) |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
45 static long_u *insecure_flag(int opt_idx, int opt_flags); |
681 | 46 #else |
47 # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags) | |
48 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
49 static char *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags); |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
50 static char *set_num_option(int opt_idx, char_u *varp, long value, char *errbuf, size_t errbuflen, int opt_flags); |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
51 static int find_key_option(char_u *arg_arg, int has_lt); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
52 static void showoptions(int all, int opt_flags); |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
53 static int optval_default(struct vimoption *, char_u *varp, int compatible); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
54 static void showoneopt(struct vimoption *, int opt_flags); |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
55 static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, long_u flags); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
56 static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
57 static int put_setbool(FILE *fd, char *cmd, char *name, int value); |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
58 static int istermoption(struct vimoption *p); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
59 static char_u *get_varp_scope(struct vimoption *p, int opt_flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
60 static char_u *get_varp(struct vimoption *); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
61 static void check_win_options(win_T *win); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
62 static void option_value2string(struct vimoption *, int opt_flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
63 static void check_winopt(winopt_T *wop); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
64 static int wc_use_keyname(char_u *varp, long *wcp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
65 static void paste_option_changed(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
66 static void compatible_set(void); |
7 | 67 |
68 /* | |
69 * Initialize the options, first part. | |
70 * | |
71 * Called only once from main(), just after creating the first buffer. | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
72 * If "clean_arg" is TRUE Vim was started with --clean. |
7 | 73 */ |
74 void | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
75 set_init_1(int clean_arg) |
7 | 76 { |
77 char_u *p; | |
78 int opt_idx; | |
835 | 79 long_u n; |
7 | 80 |
81 #ifdef FEAT_LANGMAP | |
82 langmap_init(); | |
83 #endif | |
84 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
85 // Be Vi compatible by default |
7 | 86 p_cp = TRUE; |
87 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
88 // Use POSIX compatibility when $VIM_POSIX is set. |
164 | 89 if (mch_getenv((char_u *)"VIM_POSIX") != NULL) |
168 | 90 { |
164 | 91 set_string_default("cpo", (char_u *)CPO_ALL); |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
92 set_string_default("shm", (char_u *)SHM_POSIX); |
168 | 93 } |
164 | 94 |
7 | 95 /* |
96 * Find default value for 'shell' option. | |
161 | 97 * Don't use it if it is empty. |
7 | 98 */ |
161 | 99 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL) |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
100 #if defined(MSWIN) |
161 | 101 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL) |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7829
diff
changeset
|
102 || ((p = (char_u *)default_shell()) != NULL && *p != NUL) |
7 | 103 #endif |
161 | 104 ) |
18241
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
105 #if defined(MSWIN) |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
106 { |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
107 // For MS-Windows put the path in quotes instead of escaping spaces. |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
108 char_u *cmd; |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
109 size_t len; |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
110 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
111 if (vim_strchr(p, ' ') != NULL) |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
112 { |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
113 len = STRLEN(p) + 3; // two quotes and a trailing NUL |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
114 cmd = alloc(len); |
18243
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
115 if (cmd != NULL) |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
116 { |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
117 vim_snprintf((char *)cmd, len, "\"%s\"", p); |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
118 set_string_default("sh", cmd); |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
119 vim_free(cmd); |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
120 } |
18241
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
121 } |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
122 else |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
123 set_string_default("sh", p); |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
124 } |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
125 #else |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
126 set_string_default_esc("sh", p, TRUE); |
18241
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
127 #endif |
7 | 128 |
129 #ifdef FEAT_WILDIGN | |
130 /* | |
131 * Set the default for 'backupskip' to include environment variables for | |
132 * temp files. | |
133 */ | |
134 { | |
135 # ifdef UNIX | |
136 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"}; | |
137 # else | |
138 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"}; | |
139 # endif | |
170 | 140 int len; |
141 garray_T ga; | |
142 int mustfree; | |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
143 char_u *item; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
144 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
145 opt_idx = findoption((char_u *)"backupskip"); |
7 | 146 |
147 ga_init2(&ga, 1, 100); | |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
148 for (n = 0; n < (long)ARRAY_LENGTH(names); ++n) |
7 | 149 { |
170 | 150 mustfree = FALSE; |
7 | 151 # ifdef UNIX |
152 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
|
153 # ifdef MACOS_X |
f64c5e636c9f
patch 8.0.1704: 'backupskip' default doesn't work for Mac
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
154 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
|
155 # else |
7 | 156 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
|
157 # endif |
7 | 158 else |
159 # endif | |
170 | 160 p = vim_getenv((char_u *)names[n], &mustfree); |
7 | 161 if (p != NULL && *p != NUL) |
162 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
163 // First time count the NUL, otherwise count the ','. |
835 | 164 len = (int)STRLEN(p) + 3; |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
165 item = alloc(len); |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
166 STRCPY(item, p); |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
167 add_pathsep(item); |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
168 STRCAT(item, "*"); |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
169 if (find_dup_item(ga.ga_data, item, options[opt_idx].flags) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
170 == NULL |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
171 && ga_grow(&ga, len) == OK) |
7 | 172 { |
173 if (ga.ga_len > 0) | |
174 STRCAT(ga.ga_data, ","); | |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
175 STRCAT(ga.ga_data, item); |
7 | 176 ga.ga_len += len; |
177 } | |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
178 vim_free(item); |
7 | 179 } |
170 | 180 if (mustfree) |
181 vim_free(p); | |
7 | 182 } |
183 if (ga.ga_data != NULL) | |
184 { | |
185 set_string_default("bsk", ga.ga_data); | |
186 vim_free(ga.ga_data); | |
187 } | |
188 } | |
189 #endif | |
190 | |
191 /* | |
192 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory | |
193 */ | |
194 opt_idx = findoption((char_u *)"maxmemtot"); | |
838 | 195 if (opt_idx >= 0) |
196 { | |
7 | 197 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
838 | 198 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) |
199 #endif | |
200 { | |
7 | 201 #ifdef HAVE_AVAIL_MEM |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
202 // Use amount of memory available at this moment. |
3634 | 203 n = (mch_avail_mem(FALSE) >> 1); |
7 | 204 #else |
205 # ifdef HAVE_TOTAL_MEM | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
206 // Use amount of memory available to Vim. |
1110 | 207 n = (mch_total_mem(FALSE) >> 1); |
7 | 208 # else |
838 | 209 n = (0x7fffffff >> 11); |
7 | 210 # endif |
211 #endif | |
212 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; | |
838 | 213 opt_idx = findoption((char_u *)"maxmem"); |
214 if (opt_idx >= 0) | |
215 { | |
216 #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
|
217 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
|
218 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L) |
838 | 219 #endif |
220 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; | |
221 } | |
222 } | |
7 | 223 } |
224 | |
225 #ifdef FEAT_SEARCHPATH | |
226 { | |
227 char_u *cdpath; | |
228 char_u *buf; | |
229 int i; | |
230 int j; | |
170 | 231 int mustfree = FALSE; |
7 | 232 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
233 // Initialize the 'cdpath' option's default value. |
170 | 234 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree); |
7 | 235 if (cdpath != NULL) |
236 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16730
diff
changeset
|
237 buf = alloc((STRLEN(cdpath) << 1) + 2); |
7 | 238 if (buf != NULL) |
239 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
240 buf[0] = ','; // start with ",", current dir first |
7 | 241 j = 1; |
242 for (i = 0; cdpath[i] != NUL; ++i) | |
243 { | |
244 if (vim_ispathlistsep(cdpath[i])) | |
245 buf[j++] = ','; | |
246 else | |
247 { | |
248 if (cdpath[i] == ' ' || cdpath[i] == ',') | |
249 buf[j++] = '\\'; | |
250 buf[j++] = cdpath[i]; | |
251 } | |
252 } | |
253 buf[j] = NUL; | |
254 opt_idx = findoption((char_u *)"cdpath"); | |
838 | 255 if (opt_idx >= 0) |
256 { | |
257 options[opt_idx].def_val[VI_DEFAULT] = buf; | |
258 options[opt_idx].flags |= P_DEF_ALLOCED; | |
259 } | |
2445
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
260 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
261 vim_free(buf); // cannot happen |
7 | 262 } |
170 | 263 if (mustfree) |
264 vim_free(cdpath); | |
7 | 265 } |
266 } | |
267 #endif | |
268 | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
269 #if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux)) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
270 // Set print encoding on platforms that don't default to latin1 |
7 | 271 set_string_default("penc", |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
272 # if defined(MSWIN) |
7 | 273 (char_u *)"cp1252" |
274 # else | |
275 # ifdef VMS | |
276 (char_u *)"dec-mcs" | |
277 # else | |
278 # ifdef EBCDIC | |
279 (char_u *)"ebcdic-uk" | |
280 # else | |
281 # ifdef MAC | |
282 (char_u *)"mac-roman" | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
283 # else // HPUX |
7 | 284 (char_u *)"hp-roman8" |
285 # endif | |
286 # endif | |
287 # endif | |
288 # endif | |
289 ); | |
290 #endif | |
291 | |
292 #ifdef FEAT_POSTSCRIPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
293 // 'printexpr' must be allocated to be able to evaluate it. |
7 | 294 set_string_default("pexpr", |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
295 # if defined(MSWIN) |
8 | 296 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)" |
7 | 297 # else |
298 # ifdef VMS | |
299 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)" | |
300 | |
301 # else | |
302 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error" | |
303 # endif | |
304 # endif | |
305 ); | |
306 #endif | |
307 | |
308 /* | |
309 * Set all the options (except the terminal options) to their default | |
310 * value. Also set the global value for local options. | |
311 */ | |
312 set_options_default(0); | |
313 | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
314 #ifdef CLEAN_RUNTIMEPATH |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
315 if (clean_arg) |
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 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
|
318 if (opt_idx >= 0) |
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 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
|
321 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
|
322 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
323 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
|
324 if (opt_idx >= 0) |
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 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
|
327 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
|
328 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
329 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
330 #endif |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
331 |
7 | 332 #ifdef FEAT_GUI |
333 if (found_reverse_arg) | |
334 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0); | |
335 #endif | |
336 | |
337 curbuf->b_p_initialized = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
338 curbuf->b_p_ar = -1; // no local 'autoread' value |
5446 | 339 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
7 | 340 check_buf_options(curbuf); |
341 check_win_options(curwin); | |
342 check_options(); | |
343 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
344 // Must be before option_expand(), because that one needs vim_isIDc() |
7 | 345 didset_options(); |
346 | |
744 | 347 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
348 // Use the current chartab for the generic chartab. This is not in |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
349 // didset_options() because it only depends on 'encoding'. |
227 | 350 init_spell_chartab(); |
351 #endif | |
352 | |
7 | 353 /* |
354 * Expand environment variables and things like "~" for the defaults. | |
355 * If option_expand() returns non-NULL the variable is expanded. This can | |
356 * only happen for non-indirect options. | |
357 * Also set the default to the expanded value, so ":set" does not list | |
358 * them. | |
359 * Don't set the P_ALLOCED flag, because we don't want to free the | |
360 * default. | |
361 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
362 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 363 { |
364 if ((options[opt_idx].flags & P_GETTEXT) | |
365 && options[opt_idx].var != NULL) | |
366 p = (char_u *)_(*(char **)options[opt_idx].var); | |
367 else | |
368 p = option_expand(opt_idx, NULL); | |
369 if (p != NULL && (p = vim_strsave(p)) != NULL) | |
370 { | |
371 *(char_u **)options[opt_idx].var = p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
372 // VIMEXP |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
373 // Defaults for all expanded options are currently the same for Vi |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
374 // and Vim. When this changes, add some code here! Also need to |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
375 // split P_DEF_ALLOCED in two. |
7 | 376 if (options[opt_idx].flags & P_DEF_ALLOCED) |
377 vim_free(options[opt_idx].def_val[VI_DEFAULT]); | |
378 options[opt_idx].def_val[VI_DEFAULT] = p; | |
379 options[opt_idx].flags |= P_DEF_ALLOCED; | |
380 } | |
381 } | |
382 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
383 save_file_ff(curbuf); // Buffer is unchanged |
7 | 384 |
385 #if defined(FEAT_ARABIC) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
386 // Detect use of mlterm. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
387 // Mlterm is a terminal emulator akin to xterm that has some special |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
388 // abilities (bidi namely). |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
389 // NOTE: mlterm's author is being asked to 'set' a variable |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
390 // instead of an environment variable due to inheritance. |
7 | 391 if (mch_getenv((char_u *)"MLTERM") != NULL) |
392 set_option_value((char_u *)"tbidi", 1L, NULL, 0); | |
393 #endif | |
394 | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
395 didset_options2(); |
7 | 396 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
397 # if defined(MSWIN) && defined(FEAT_GETTEXT) |
7 | 398 /* |
399 * If $LANG isn't set, try to get a good value for it. This makes the | |
400 * right language be used automatically. Don't do this for English. | |
401 */ | |
402 if (mch_getenv((char_u *)"LANG") == NULL) | |
403 { | |
404 char buf[20]; | |
405 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
406 // Could use LOCALE_SISO639LANGNAME, but it's not in Win95. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
407 // LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
408 // only the first two. |
7 | 409 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, |
410 (LPTSTR)buf, 20); | |
411 if (n >= 2 && STRNICMP(buf, "en", 2) != 0) | |
412 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
413 // There are a few exceptions (probably more) |
7 | 414 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0) |
415 STRCPY(buf, "zh_TW"); | |
416 else if (STRNICMP(buf, "chs", 3) == 0 | |
417 || STRNICMP(buf, "zhc", 3) == 0) | |
418 STRCPY(buf, "zh_CN"); | |
419 else if (STRNICMP(buf, "jp", 2) == 0) | |
420 STRCPY(buf, "ja"); | |
421 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
422 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
|
423 vim_setenv((char_u *)"LANG", (char_u *)buf); |
7 | 424 } |
425 } | |
168 | 426 # else |
767 | 427 # ifdef MACOS_CONVERT |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
428 // Moved to os_mac_conv.c to avoid dependency problems. |
1622 | 429 mac_lang_init(); |
168 | 430 # endif |
7 | 431 # endif |
432 | |
24747
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
433 # ifdef MSWIN |
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
434 // MS-Windows has builtin support for conversion to and from Unicode, using |
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
435 // "utf-8" for 'encoding' should work best for most users. |
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
436 p = vim_strsave((char_u *)ENC_DFLT); |
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
437 # else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
438 // enc_locale() will try to find the encoding of the current locale. |
24747
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
439 // This works best for properly configured systems, old and new. |
7 | 440 p = enc_locale(); |
24747
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
441 # endif |
7 | 442 if (p != NULL) |
443 { | |
444 char_u *save_enc; | |
445 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
446 // Try setting 'encoding' and check if the value is valid. |
24747
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
447 // If not, go back to the default encoding. |
7 | 448 save_enc = p_enc; |
449 p_enc = p; | |
1080 | 450 if (STRCMP(p_enc, "gb18030") == 0) |
451 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
452 // We don't support "gb18030", but "cp936" is a good substitute |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
453 // for practical purposes, thus use that. It's not an alias to |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
454 // still support conversion between gb18030 and utf-8. |
1080 | 455 p_enc = vim_strsave((char_u *)"cp936"); |
456 vim_free(p); | |
457 } | |
7 | 458 if (mb_init() == NULL) |
459 { | |
460 opt_idx = findoption((char_u *)"encoding"); | |
838 | 461 if (opt_idx >= 0) |
462 { | |
463 options[opt_idx].def_val[VI_DEFAULT] = p_enc; | |
464 options[opt_idx].flags |= P_DEF_ALLOCED; | |
465 } | |
7 | 466 |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12636
diff
changeset
|
467 #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
|
468 if (STRCMP(p_enc, "latin1") == 0 || enc_utf8) |
24 | 469 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
470 // Adjust the default for 'isprint' and 'iskeyword' to match |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
471 // latin1. Also set the defaults for when 'nocompatible' is |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
472 // set. |
24 | 473 set_string_option_direct((char_u *)"isp", -1, |
719 | 474 ISP_LATIN1, OPT_FREE, SID_NONE); |
714 | 475 set_string_option_direct((char_u *)"isk", -1, |
476 ISK_LATIN1, OPT_FREE, SID_NONE); | |
477 opt_idx = findoption((char_u *)"isp"); | |
838 | 478 if (opt_idx >= 0) |
479 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1; | |
714 | 480 opt_idx = findoption((char_u *)"isk"); |
838 | 481 if (opt_idx >= 0) |
482 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1; | |
24 | 483 (void)init_chartab(); |
484 } | |
485 #endif | |
486 | |
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
|
487 #if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
488 // Win32 console: When GetACP() returns a different value from |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
489 // 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
|
490 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
|
491 # 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
|
492 (!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
|
493 # 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
|
494 GetACP() != GetConsoleCP()) |
7 | 495 { |
496 char buf[50]; | |
497 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
498 // Win32 console: In ConPTY, GetConsoleCP() returns zero. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
499 // Use an alternative value. |
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
|
500 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
|
501 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
|
502 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
|
503 sprintf(buf, "cp%ld", (long)GetConsoleCP()); |
7 | 504 p_tenc = vim_strsave((char_u *)buf); |
505 if (p_tenc != NULL) | |
506 { | |
507 opt_idx = findoption((char_u *)"termencoding"); | |
838 | 508 if (opt_idx >= 0) |
509 { | |
510 options[opt_idx].def_val[VI_DEFAULT] = p_tenc; | |
511 options[opt_idx].flags |= P_DEF_ALLOCED; | |
512 } | |
7 | 513 convert_setup(&input_conv, p_tenc, p_enc); |
514 convert_setup(&output_conv, p_enc, p_tenc); | |
515 } | |
516 else | |
517 p_tenc = empty_option; | |
518 } | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
519 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
520 #if defined(MSWIN) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
521 // $HOME may have characters in active code page. |
170 | 522 init_homedir(); |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
523 #endif |
7 | 524 } |
525 else | |
526 { | |
527 vim_free(p_enc); | |
528 p_enc = save_enc; | |
529 } | |
530 } | |
531 | |
532 #ifdef FEAT_MULTI_LANG | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
533 // Set the default for 'helplang'. |
7 | 534 set_helplang_default(get_mess_lang()); |
535 #endif | |
536 } | |
537 | |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
538 static char_u *fencs_utf8_default = (char_u *)"ucs-bom,utf-8,default,latin1"; |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
539 |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
540 /* |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
541 * Set the "fileencodings" option to the default value for when 'encoding' is |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
542 * utf-8. |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
543 */ |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
544 void |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
545 set_fencs_unicode() |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
546 { |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
547 set_string_option_direct((char_u *)"fencs", -1, fencs_utf8_default, |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
548 OPT_FREE, 0); |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
549 } |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
550 |
7 | 551 /* |
552 * Set an option to its default value. | |
553 * This does not take care of side effects! | |
554 */ | |
555 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
556 set_option_default( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
557 int opt_idx, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
558 int opt_flags, // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
559 int compatible) // use Vi default value |
7 | 560 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
561 char_u *varp; // pointer to variable for current option |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
562 int dvi; // index in def_val[] |
7 | 563 long_u flags; |
681 | 564 long_u *flagsp; |
7 | 565 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
566 | |
567 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); | |
568 flags = options[opt_idx].flags; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
569 if (varp != NULL) // skip hidden option, nothing to do for it |
7 | 570 { |
571 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; | |
572 if (flags & P_STRING) | |
573 { | |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
574 // 'fencs' default value depends on 'encoding' |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
575 if (options[opt_idx].var == (char_u *)&p_fencs && enc_utf8) |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
576 set_fencs_unicode(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
577 // Use set_string_option_direct() for local options to handle |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
578 // freeing and allocating the value. |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
579 else if (options[opt_idx].indir != PV_NONE) |
13845
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
580 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
|
581 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
|
582 else |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
583 { |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
584 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
|
585 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
|
586 *(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
|
587 options[opt_idx].flags &= ~P_ALLOCED; |
7 | 588 } |
589 } | |
590 else if (flags & P_NUM) | |
591 { | |
1017 | 592 if (options[opt_idx].indir == PV_SCROLL) |
7 | 593 win_comp_scroll(curwin); |
594 else | |
595 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
596 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
|
597 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
598 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
|
599 || (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
|
600 // '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
|
601 // 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
|
602 *(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
|
603 else |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
604 *(long *)varp = def_val; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
605 // May also set global value for local option. |
7 | 606 if (both) |
607 *(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
|
608 def_val; |
7 | 609 } |
610 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
611 else // P_BOOL |
7 | 612 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
613 // the cast to long is required for Manx C, long_i is needed for |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
614 // MSVC |
840 | 615 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; |
1111 | 616 #ifdef UNIX |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
617 // 'modeline' defaults to off for root |
1111 | 618 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) |
619 *(int *)varp = FALSE; | |
620 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
621 // May also set global value for local option. |
7 | 622 if (both) |
623 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | |
624 *(int *)varp; | |
625 } | |
634 | 626 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
627 // The default value is not insecure. |
681 | 628 flagsp = insecure_flag(opt_idx, opt_flags); |
629 *flagsp = *flagsp & ~P_INSECURE; | |
7 | 630 } |
631 | |
632 #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
|
633 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 634 #endif |
635 } | |
636 | |
637 /* | |
638 * 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
|
639 * When "opt_flags" is non-zero skip 'encoding'. |
7 | 640 */ |
641 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
642 set_options_default( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
643 int opt_flags) // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL |
7 | 644 { |
645 int i; | |
646 win_T *wp; | |
671 | 647 tabpage_T *tp; |
7 | 648 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
649 for (i = 0; !istermoption_idx(i); i++) |
7034
e668b160ac68
commit https://github.com/vim/vim/commit/b341dda575899458f7075614dcedf0a80ee9d080
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
650 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
|
651 && (opt_flags == 0 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
652 || (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
|
653 # if defined(FEAT_CRYPT) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
654 && 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
|
655 && 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
|
656 # endif |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
657 ))) |
7 | 658 set_option_default(i, opt_flags, p_cp); |
659 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
660 // The 'scroll' option must be computed for all windows. |
671 | 661 FOR_ALL_TAB_WINDOWS(tp, wp) |
7 | 662 win_comp_scroll(wp); |
6205 | 663 #ifdef FEAT_CINDENT |
664 parse_cino(curbuf); | |
665 #endif | |
7 | 666 } |
667 | |
668 /* | |
669 * Set the Vi-default value of a string option. | |
670 * 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
|
671 * 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
|
672 */ |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
673 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
|
674 set_string_default_esc(char *name, char_u *val, int escape) |
7 | 675 { |
676 char_u *p; | |
677 int opt_idx; | |
678 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
679 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
|
680 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
|
681 else |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
682 p = vim_strsave(val); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
683 if (p != NULL) // we don't want a NULL |
7 | 684 { |
685 opt_idx = findoption((char_u *)name); | |
838 | 686 if (opt_idx >= 0) |
687 { | |
688 if (options[opt_idx].flags & P_DEF_ALLOCED) | |
689 vim_free(options[opt_idx].def_val[VI_DEFAULT]); | |
690 options[opt_idx].def_val[VI_DEFAULT] = p; | |
691 options[opt_idx].flags |= P_DEF_ALLOCED; | |
692 } | |
7 | 693 } |
694 } | |
695 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
696 void |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
697 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
|
698 { |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
699 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
|
700 } |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
701 |
7 | 702 /* |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
703 * For an option value that contains comma separated items, find "newval" in |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
704 * "origval". Return NULL if not found. |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
705 */ |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
706 static char_u * |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
707 find_dup_item(char_u *origval, char_u *newval, long_u flags) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
708 { |
22242
f7871f02ddcd
patch 8.2.1670: a couple of gcc compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
22234
diff
changeset
|
709 int bs = 0; |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
710 size_t newlen; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
711 char_u *s; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
712 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
713 if (origval == NULL) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
714 return NULL; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
715 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
716 newlen = STRLEN(newval); |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
717 for (s = origval; *s != NUL; ++s) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
718 { |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
719 if ((!(flags & P_COMMA) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
720 || s == origval |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
721 || (s[-1] == ',' && !(bs & 1))) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
722 && STRNCMP(s, newval, newlen) == 0 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
723 && (!(flags & P_COMMA) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
724 || s[newlen] == ',' |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
725 || s[newlen] == NUL)) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
726 return s; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
727 // Count backslashes. Only a comma with an even number of backslashes |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
728 // or a single backslash preceded by a comma before it is recognized as |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
729 // a separator. |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
730 if ((s > origval + 1 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
731 && s[-1] == '\\' |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
732 && s[-2] != ',') |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
733 || (s == origval + 1 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
734 && s[-1] == '\\')) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
735 ++bs; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
736 else |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
737 bs = 0; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
738 } |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
739 return NULL; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
740 } |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
741 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
742 /* |
7 | 743 * Set the Vi-default value of a number option. |
744 * Used for 'lines' and 'columns'. | |
745 */ | |
746 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
747 set_number_default(char *name, long val) |
7 | 748 { |
838 | 749 int opt_idx; |
750 | |
751 opt_idx = findoption((char_u *)name); | |
752 if (opt_idx >= 0) | |
840 | 753 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 754 } |
755 | |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
756 /* |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
757 * 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
|
758 * 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
|
759 * 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
|
760 */ |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
761 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
|
762 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
|
763 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
764 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
|
765 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
|
766 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
767 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
|
768 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
|
769 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
|
770 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
771 for (i = 0; !istermoption_idx(i); i++) |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
772 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
773 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
|
774 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
|
775 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
776 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
|
777 && (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
|
778 && !(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
|
779 && !optval_default(p, varp, FALSE)) |
18225
6c3a8312486d
patch 8.1.2107: various memory leaks reported by asan
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
780 set_option_default(i, OPT_FREE|OPT_LOCAL, FALSE); |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
781 } |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
782 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
783 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
|
784 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
|
785 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
|
786 } |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
787 |
359 | 788 #if defined(EXITFREE) || defined(PROTO) |
789 /* | |
790 * Free all options. | |
791 */ | |
792 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
793 free_all_options(void) |
359 | 794 { |
795 int i; | |
796 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
797 for (i = 0; !istermoption_idx(i); i++) |
359 | 798 { |
799 if (options[i].indir == PV_NONE) | |
800 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
801 // 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
|
802 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL) |
359 | 803 free_string_option(*(char_u **)options[i].var); |
804 if (options[i].flags & P_DEF_ALLOCED) | |
805 free_string_option(options[i].def_val[VI_DEFAULT]); | |
806 } | |
807 else if (options[i].var != VAR_WIN | |
808 && (options[i].flags & P_STRING)) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
809 // buffer-local option: free global value |
359 | 810 free_string_option(*(char_u **)options[i].var); |
811 } | |
812 } | |
813 #endif | |
814 | |
815 | |
7 | 816 /* |
817 * Initialize the options, part two: After getting Rows and Columns and | |
818 * setting 'term'. | |
819 */ | |
820 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
821 set_init_2(void) |
7 | 822 { |
164 | 823 int idx; |
824 | |
7 | 825 /* |
12718
f8f505ffc0a6
patch 8.0.1237: ":set scroll&" often gives an error
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
826 * '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
|
827 * which results in the actual value computed from the window height. |
7 | 828 */ |
168 | 829 idx = findoption((char_u *)"scroll"); |
838 | 830 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
168 | 831 set_option_default(idx, OPT_LOCAL, p_cp); |
7 | 832 comp_col(); |
833 | |
164 | 834 /* |
835 * 'window' is only for backwards compatibility with Vi. | |
836 * Default is Rows - 1. | |
837 */ | |
857 | 838 if (!option_was_set((char_u *)"window")) |
164 | 839 p_window = Rows - 1; |
840 set_number_default("window", Rows - 1); | |
841 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
842 // 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
|
843 #if !((defined(MSWIN)) && !defined(FEAT_GUI)) |
671 | 844 /* |
845 * If 'background' wasn't set by the user, try guessing the value, | |
846 * depending on the terminal name. Only need to check for terminals | |
847 * with a dark background, that can handle color. | |
848 */ | |
849 idx = findoption((char_u *)"bg"); | |
838 | 850 if (idx >= 0 && !(options[idx].flags & P_WAS_SET) |
851 && *term_bg_default() == 'd') | |
671 | 852 { |
694 | 853 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
854 // don't mark it as set, when starting the GUI it may be |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
855 // changed again |
671 | 856 options[idx].flags &= ~P_WAS_SET; |
7 | 857 } |
858 #endif | |
440 | 859 |
860 #ifdef CURSOR_SHAPE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
861 parse_shape_opt(SHAPE_CURSOR); // set cursor shapes from 'guicursor' |
440 | 862 #endif |
863 #ifdef FEAT_MOUSESHAPE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
864 parse_shape_opt(SHAPE_MOUSE); // set mouse shapes from 'mouseshape' |
440 | 865 #endif |
866 #ifdef FEAT_PRINTER | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
867 (void)parse_printoptions(); // parse 'printoptions' default value |
440 | 868 #endif |
7 | 869 } |
870 | |
871 /* | |
872 * Initialize the options, part three: After reading the .vimrc | |
873 */ | |
874 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
875 set_init_3(void) |
7 | 876 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
877 #if defined(UNIX) || defined(MSWIN) |
7 | 878 /* |
879 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. | |
880 * This is done after other initializations, where 'shell' might have been | |
881 * set, but only if they have not been set before. | |
882 */ | |
883 char_u *p; | |
884 int idx_srr; | |
885 int do_srr; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
886 # ifdef FEAT_QUICKFIX |
7 | 887 int idx_sp; |
888 int do_sp; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
889 # endif |
7 | 890 |
891 idx_srr = findoption((char_u *)"srr"); | |
838 | 892 if (idx_srr < 0) |
893 do_srr = FALSE; | |
894 else | |
895 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
|
896 # ifdef FEAT_QUICKFIX |
7 | 897 idx_sp = findoption((char_u *)"sp"); |
838 | 898 if (idx_sp < 0) |
899 do_sp = FALSE; | |
900 else | |
901 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
|
902 # endif |
5867 | 903 p = get_isolated_shell_name(); |
7 | 904 if (p != NULL) |
905 { | |
906 /* | |
907 * Default for p_sp is "| tee", for p_srr is ">". | |
908 * For known shells it is changed here to include stderr. | |
909 */ | |
910 if ( fnamecmp(p, "csh") == 0 | |
911 || 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
|
912 # if defined(MSWIN) // also check with .exe extension |
7 | 913 || fnamecmp(p, "csh.exe") == 0 |
914 || fnamecmp(p, "tcsh.exe") == 0 | |
915 # endif | |
916 ) | |
917 { | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
918 # if defined(FEAT_QUICKFIX) |
7 | 919 if (do_sp) |
920 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
921 # ifdef MSWIN |
7 | 922 p_sp = (char_u *)">&"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
923 # else |
7 | 924 p_sp = (char_u *)"|& tee"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
925 # endif |
7 | 926 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
927 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
928 # endif |
7 | 929 if (do_srr) |
930 { | |
931 p_srr = (char_u *)">&"; | |
932 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
933 } | |
934 } | |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
935 # ifdef MSWIN |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
936 // Windows PowerShell output is UTF-16 with BOM so re-encode to the |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
937 // current codepage. |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
938 else if ( fnamecmp(p, "powershell") == 0 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
939 || fnamecmp(p, "powershell.exe") == 0 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
940 ) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
941 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
942 # if defined(FEAT_QUICKFIX) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
943 if (do_sp) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
944 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
945 p_sp = (char_u *)"2>&1 | Out-File -Encoding default"; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
946 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
947 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
948 # endif |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
949 if (do_srr) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
950 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
951 p_srr = (char_u *)"2>&1 | Out-File -Encoding default"; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
952 options[idx_srr].def_val[VI_DEFAULT] = p_srr; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
953 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
954 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
955 #endif |
7 | 956 else |
24600
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
957 // Always use POSIX shell style redirection if we reach this |
7 | 958 if ( fnamecmp(p, "sh") == 0 |
959 || fnamecmp(p, "ksh") == 0 | |
2774 | 960 || fnamecmp(p, "mksh") == 0 |
961 || fnamecmp(p, "pdksh") == 0 | |
7 | 962 || fnamecmp(p, "zsh") == 0 |
836 | 963 || fnamecmp(p, "zsh-beta") == 0 |
7 | 964 || fnamecmp(p, "bash") == 0 |
5867 | 965 || fnamecmp(p, "fish") == 0 |
24600
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
966 || fnamecmp(p, "ash") == 0 |
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
967 || fnamecmp(p, "dash") == 0 |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
968 || fnamecmp(p, "pwsh") == 0 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
969 # ifdef MSWIN |
7 | 970 || fnamecmp(p, "cmd") == 0 |
971 || fnamecmp(p, "sh.exe") == 0 | |
972 || fnamecmp(p, "ksh.exe") == 0 | |
2774 | 973 || fnamecmp(p, "mksh.exe") == 0 |
974 || fnamecmp(p, "pdksh.exe") == 0 | |
7 | 975 || fnamecmp(p, "zsh.exe") == 0 |
836 | 976 || fnamecmp(p, "zsh-beta.exe") == 0 |
7 | 977 || fnamecmp(p, "bash.exe") == 0 |
978 || fnamecmp(p, "cmd.exe") == 0 | |
24600
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
979 || fnamecmp(p, "dash.exe") == 0 |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
980 || fnamecmp(p, "pwsh.exe") == 0 |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
981 # endif |
7 | 982 ) |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
983 { |
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
984 # if defined(FEAT_QUICKFIX) |
7 | 985 if (do_sp) |
986 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
987 # ifdef MSWIN |
7 | 988 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
|
989 # else |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
990 if (fnamecmp(p, "pwsh") == 0) |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
991 p_sp = (char_u *)">%s 2>&1"; |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
992 else |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
993 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
|
994 # endif |
7 | 995 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
996 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
997 # endif |
7 | 998 if (do_srr) |
999 { | |
1000 p_srr = (char_u *)">%s 2>&1"; | |
1001 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
1002 } | |
1003 } | |
1004 vim_free(p); | |
1005 } | |
1006 #endif | |
1007 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
1008 #if defined(MSWIN) |
7 | 1009 /* |
3352 | 1010 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the |
1011 * 'shell' option. | |
7 | 1012 * This is done after other initializations, where 'shell' might have been |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1013 * set, but only if they have not been set before. |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1014 * Default values depend on shell (cmd.exe is default shell): |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1015 * |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1016 * p_shcf p_sxq |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1017 * cmd.exe - "/c" "(" |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1018 * powershell.exe - "-Command" "\"" |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
1019 * pwsh.exe - "-c" "\"" |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1020 * "sh" like shells - "-c" "\"" |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1021 * |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1022 * For Win32 p_sxq is set instead of p_shq to include shell redirection. |
7 | 1023 */ |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1024 if (strstr((char *)gettail(p_sh), "powershell") != NULL) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1025 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1026 int idx_opt; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1027 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1028 idx_opt = findoption((char_u *)"shcf"); |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1029 if (idx_opt >= 0 && !(options[idx_opt].flags & P_WAS_SET)) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1030 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1031 p_shcf = (char_u*)"-Command"; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1032 options[idx_opt].def_val[VI_DEFAULT] = p_shcf; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1033 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1034 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1035 idx_opt = findoption((char_u *)"sxq"); |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1036 if (idx_opt >= 0 && !(options[idx_opt].flags & P_WAS_SET)) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1037 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1038 p_sxq = (char_u*)"\""; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1039 options[idx_opt].def_val[VI_DEFAULT] = p_sxq; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1040 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1041 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1042 else if (strstr((char *)gettail(p_sh), "sh") != NULL) |
7 | 1043 { |
1044 int idx3; | |
1045 | |
1046 idx3 = findoption((char_u *)"shcf"); | |
838 | 1047 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 1048 { |
1049 p_shcf = (char_u *)"-c"; | |
1050 options[idx3].def_val[VI_DEFAULT] = p_shcf; | |
1051 } | |
1052 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1053 // Somehow Win32 requires the quotes around the redirection too |
7 | 1054 idx3 = findoption((char_u *)"sxq"); |
838 | 1055 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 1056 { |
1057 p_sxq = (char_u *)"\""; | |
1058 options[idx3].def_val[VI_DEFAULT] = p_sxq; | |
1059 } | |
1060 } | |
3352 | 1061 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL) |
1062 { | |
1063 int idx3; | |
1064 | |
1065 /* | |
1066 * cmd.exe on Windows will strip the first and last double quote given | |
1067 * on the command line, e.g. most of the time things like: | |
1068 * cmd /c "my path/to/echo" "my args to echo" | |
1069 * become: | |
1070 * my path/to/echo" "my args to echo | |
1071 * when executed. | |
1072 * | |
3357 | 1073 * To avoid this, set shellxquote to surround the command in |
1074 * parenthesis. This appears to make most commands work, without | |
1075 * breaking commands that worked previously, such as | |
1076 * '"path with spaces/cmd" "a&b"'. | |
3352 | 1077 */ |
1078 idx3 = findoption((char_u *)"sxq"); | |
1079 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
1080 { | |
3357 | 1081 p_sxq = (char_u *)"("; |
3352 | 1082 options[idx3].def_val[VI_DEFAULT] = p_sxq; |
1083 } | |
1084 | |
1085 idx3 = findoption((char_u *)"shcf"); | |
1086 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
1087 { | |
3357 | 1088 p_shcf = (char_u *)"/c"; |
3352 | 1089 options[idx3].def_val[VI_DEFAULT] = p_shcf; |
1090 } | |
1091 } | |
7 | 1092 #endif |
1093 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11107
diff
changeset
|
1094 if (BUFEMPTY()) |
8659
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1095 { |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1096 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
|
1097 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1098 // Apply the first entry of 'fileformats' to the initial buffer. |
8659
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1099 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
|
1100 set_fileformat(default_fileformat(), OPT_LOCAL); |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1101 } |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1102 |
7 | 1103 #ifdef FEAT_TITLE |
1104 set_title_defaults(); | |
1105 #endif | |
1106 } | |
1107 | |
1108 #if defined(FEAT_MULTI_LANG) || defined(PROTO) | |
1109 /* | |
1110 * When 'helplang' is still at its default value, set it to "lang". | |
1111 * Only the first two characters of "lang" are used. | |
1112 */ | |
1113 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1114 set_helplang_default(char_u *lang) |
7 | 1115 { |
1116 int idx; | |
1117 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1118 if (lang == NULL || STRLEN(lang) < 2) // safety check |
7 | 1119 return; |
1120 idx = findoption((char_u *)"hlg"); | |
838 | 1121 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
7 | 1122 { |
1123 if (options[idx].flags & P_ALLOCED) | |
1124 free_string_option(p_hlg); | |
1125 p_hlg = vim_strsave(lang); | |
1126 if (p_hlg == NULL) | |
1127 p_hlg = empty_option; | |
1128 else | |
18 | 1129 { |
14997
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1130 // zh_CN becomes "cn", zh_TW becomes "tw" |
18 | 1131 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) |
1132 { | |
1133 p_hlg[0] = TOLOWER_ASC(p_hlg[3]); | |
1134 p_hlg[1] = TOLOWER_ASC(p_hlg[4]); | |
1135 } | |
14997
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1136 // 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
|
1137 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
|
1138 { |
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1139 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
|
1140 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
|
1141 } |
7 | 1142 p_hlg[2] = NUL; |
18 | 1143 } |
7 | 1144 options[idx].flags |= P_ALLOCED; |
1145 } | |
1146 } | |
1147 #endif | |
1148 | |
1149 #ifdef FEAT_TITLE | |
1150 /* | |
1151 * 'title' and 'icon' only default to true if they have not been set or reset | |
1152 * in .vimrc and we can read the old value. | |
1153 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if | |
1154 * they can be reset. This reduces startup time when using X on a remote | |
1155 * machine. | |
1156 */ | |
1157 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1158 set_title_defaults(void) |
7 | 1159 { |
1160 int idx1; | |
1161 long val; | |
1162 | |
1163 /* | |
1164 * If GUI is (going to be) used, we can always set the window title and | |
1165 * icon name. Saves a bit of time, because the X11 display server does | |
1166 * not need to be contacted. | |
1167 */ | |
1168 idx1 = findoption((char_u *)"title"); | |
838 | 1169 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 1170 { |
1171 #ifdef FEAT_GUI | |
1172 if (gui.starting || gui.in_use) | |
1173 val = TRUE; | |
1174 else | |
1175 #endif | |
1176 val = mch_can_restore_title(); | |
840 | 1177 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 1178 p_title = val; |
1179 } | |
1180 idx1 = findoption((char_u *)"icon"); | |
838 | 1181 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 1182 { |
1183 #ifdef FEAT_GUI | |
1184 if (gui.starting || gui.in_use) | |
1185 val = TRUE; | |
1186 else | |
1187 #endif | |
1188 val = mch_can_restore_icon(); | |
840 | 1189 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 1190 p_icon = val; |
1191 } | |
1192 } | |
1193 #endif | |
1194 | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1195 void |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1196 ex_set(exarg_T *eap) |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1197 { |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1198 int flags = 0; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1199 |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1200 if (eap->cmdidx == CMD_setlocal) |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1201 flags = OPT_LOCAL; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1202 else if (eap->cmdidx == CMD_setglobal) |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1203 flags = OPT_GLOBAL; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1204 #if defined(FEAT_EVAL) && defined(FEAT_BROWSE) |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22242
diff
changeset
|
1205 if ((cmdmod.cmod_flags & CMOD_BROWSE) && flags == 0) |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1206 ex_options(eap); |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1207 else |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1208 #endif |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1209 { |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1210 if (eap->forceit) |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1211 flags |= OPT_ONECOLUMN; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1212 (void)do_set(eap->arg, flags); |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1213 } |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1214 } |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1215 |
7 | 1216 /* |
1217 * Parse 'arg' for option settings. | |
1218 * | |
1219 * 'arg' may be IObuff, but only when no errors can be present and option | |
1220 * does not need to be expanded with option_expand(). | |
1221 * "opt_flags": | |
1222 * 0 for ":set" | |
717 | 1223 * OPT_GLOBAL for ":setglobal" |
1224 * OPT_LOCAL for ":setlocal" and a modeline | |
7 | 1225 * OPT_MODELINE for a modeline |
717 | 1226 * OPT_WINONLY to only set window-local options |
1227 * OPT_NOWIN to skip setting window-local options | |
7 | 1228 * |
1229 * returns FAIL if an error is detected, OK otherwise | |
1230 */ | |
1231 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1232 do_set( |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
1233 char_u *arg_start, // option string (may be written to!) |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1234 int opt_flags) |
7 | 1235 { |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
1236 char_u *arg = arg_start; |
7 | 1237 int opt_idx; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1238 char *errmsg; |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1239 char errbuf[80]; |
7 | 1240 char_u *startarg; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1241 int prefix; // 1: nothing, 0: "no", 2: "inv" in front of name |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1242 int nextchar; // next non-white char after option name |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1243 int afterchar; // character just after option name |
7 | 1244 int len; |
1245 int i; | |
9389
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
1246 varnumber_T value; |
7 | 1247 int key; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1248 long_u flags; // flags for current option |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1249 char_u *varp = NULL; // pointer to variable for current option |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1250 int did_show = FALSE; // already showed one value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1251 int adding; // "opt+=arg" |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1252 int prepending; // "opt^=arg" |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1253 int removing; // "opt-=arg" |
7 | 1254 int cp_val = 0; |
1255 char_u key_name[2]; | |
1256 | |
1257 if (*arg == NUL) | |
1258 { | |
1259 showoptions(0, opt_flags); | |
168 | 1260 did_show = TRUE; |
1261 goto theend; | |
7 | 1262 } |
1263 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1264 while (*arg != NUL) // loop to process all options |
7 | 1265 { |
1266 errmsg = NULL; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1267 startarg = arg; // remember for error message |
7 | 1268 |
36 | 1269 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3]) |
1270 && !(opt_flags & OPT_MODELINE)) | |
7 | 1271 { |
1272 /* | |
1273 * ":set all" show all options. | |
1274 * ":set all&" set all options to their default value. | |
1275 */ | |
1276 arg += 3; | |
1277 if (*arg == '&') | |
1278 { | |
1279 ++arg; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1280 // Only for :set command set global value of local options. |
7 | 1281 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
|
1282 didset_options(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
1283 didset_options2(); |
7034
e668b160ac68
commit https://github.com/vim/vim/commit/b341dda575899458f7075614dcedf0a80ee9d080
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
1284 redraw_all_later(CLEAR); |
7 | 1285 } |
1286 else | |
168 | 1287 { |
7 | 1288 showoptions(1, opt_flags); |
168 | 1289 did_show = TRUE; |
1290 } | |
7 | 1291 } |
36 | 1292 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) |
7 | 1293 { |
1294 showoptions(2, opt_flags); | |
1295 show_termcodes(); | |
168 | 1296 did_show = TRUE; |
7 | 1297 arg += 7; |
1298 } | |
1299 else | |
1300 { | |
1301 prefix = 1; | |
1911 | 1302 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0) |
7 | 1303 { |
1304 prefix = 0; | |
1305 arg += 2; | |
1306 } | |
1307 else if (STRNCMP(arg, "inv", 3) == 0) | |
1308 { | |
1309 prefix = 2; | |
1310 arg += 3; | |
1311 } | |
1312 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1313 // find end of name |
7 | 1314 key = 0; |
1315 if (*arg == '<') | |
1316 { | |
1317 opt_idx = -1; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1318 // look out for <t_>;> |
7 | 1319 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) |
1320 len = 5; | |
1321 else | |
1322 { | |
1323 len = 1; | |
1324 while (arg[len] != NUL && arg[len] != '>') | |
1325 ++len; | |
1326 } | |
1327 if (arg[len] != '>') | |
1328 { | |
1329 errmsg = e_invarg; | |
1330 goto skip; | |
1331 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1332 arg[len] = NUL; // put NUL after name |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1333 if (arg[1] == 't' && arg[2] == '_') // could be term code |
7 | 1334 opt_idx = findoption(arg + 1); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1335 arg[len++] = '>'; // restore '>' |
7 | 1336 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
|
1337 key = find_key_option(arg + 1, TRUE); |
7 | 1338 } |
1339 else | |
1340 { | |
1341 len = 0; | |
1342 /* | |
1343 * The two characters after "t_" may not be alphanumeric. | |
1344 */ | |
1345 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
1346 len = 4; | |
1347 else | |
1348 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') | |
1349 ++len; | |
1350 nextchar = arg[len]; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1351 arg[len] = NUL; // put NUL after name |
7 | 1352 opt_idx = findoption(arg); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1353 arg[len] = nextchar; // restore nextchar |
7 | 1354 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
|
1355 key = find_key_option(arg, FALSE); |
7 | 1356 } |
1357 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1358 // remember character after option name |
7 | 1359 afterchar = arg[len]; |
1360 | |
25176
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1361 if (in_vim9script()) |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1362 { |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1363 char_u *p = skipwhite(arg + len); |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1364 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1365 // disallow white space before =val, +=val, -=val, ^=val |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1366 if (p > arg + len && (p[0] == '=' |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1367 || (vim_strchr((char_u *)"+-^", p[0]) != NULL |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1368 && p[1] == '='))) |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1369 { |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1370 errmsg = e_no_white_space_allowed_between_option_and; |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1371 arg = p; |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1372 startarg = p; |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1373 goto skip; |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1374 } |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1375 } |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1376 else |
24968
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24912
diff
changeset
|
1377 // skip white space, allow ":set ai ?", ":set hlsearch !" |
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24912
diff
changeset
|
1378 while (VIM_ISWHITE(arg[len])) |
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24912
diff
changeset
|
1379 ++len; |
7 | 1380 |
1381 adding = FALSE; | |
1382 prepending = FALSE; | |
1383 removing = FALSE; | |
1384 if (arg[len] != NUL && arg[len + 1] == '=') | |
1385 { | |
1386 if (arg[len] == '+') | |
1387 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1388 adding = TRUE; // "+=" |
7 | 1389 ++len; |
1390 } | |
1391 else if (arg[len] == '^') | |
1392 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1393 prepending = TRUE; // "^=" |
7 | 1394 ++len; |
1395 } | |
1396 else if (arg[len] == '-') | |
1397 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1398 removing = TRUE; // "-=" |
7 | 1399 ++len; |
1400 } | |
1401 } | |
1402 nextchar = arg[len]; | |
1403 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1404 if (opt_idx == -1 && key == 0) // found a mismatch: skip |
7 | 1405 { |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
1406 if (in_vim9script() && arg > arg_start |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
1407 && vim_strchr((char_u *)"!&<", *arg) != NULL) |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
1408 errmsg = e_no_white_space_allowed_between_option_and; |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
1409 else |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
1410 errmsg = N_("E518: Unknown option"); |
7 | 1411 goto skip; |
1412 } | |
1413 | |
1414 if (opt_idx >= 0) | |
1415 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1416 if (options[opt_idx].var == NULL) // hidden option: skip |
7 | 1417 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1418 // Only give an error message when requesting the value of |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1419 // a hidden option, ignore setting it. |
7 | 1420 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL |
1421 && (!(options[opt_idx].flags & P_BOOL) | |
1422 || nextchar == '?')) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1423 errmsg = N_("E519: Option not supported"); |
7 | 1424 goto skip; |
1425 } | |
1426 | |
1427 flags = options[opt_idx].flags; | |
1428 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | |
1429 } | |
1430 else | |
1431 { | |
1432 flags = P_STRING; | |
1433 if (key < 0) | |
1434 { | |
1435 key_name[0] = KEY2TERMCAP0(key); | |
1436 key_name[1] = KEY2TERMCAP1(key); | |
1437 } | |
1438 else | |
1439 { | |
1440 key_name[0] = KS_KEY; | |
1441 key_name[1] = (key & 0xff); | |
1442 } | |
1443 } | |
1444 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1445 // Skip all options that are not window-local (used when showing |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1446 // an already loaded buffer in a window). |
634 | 1447 if ((opt_flags & OPT_WINONLY) |
1448 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) | |
1449 goto skip; | |
1450 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1451 // Skip all options that are window-local (used for :vimgrep). |
717 | 1452 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0 |
1453 && options[opt_idx].var == VAR_WIN) | |
1454 goto skip; | |
1455 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1456 // Disallow changing some options from modelines. |
1807 | 1457 if (opt_flags & OPT_MODELINE) |
7 | 1458 { |
2317
2b2cd34569eb
Disallow setting 'enc' in a modeline. (Patrick Texier)
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
1459 if (flags & (P_SECURE | P_NO_ML)) |
1807 | 1460 { |
21672
9099eb378758
patch 8.2.1386: backslash not removed afer space with space in 'isfname'
Bram Moolenaar <Bram@vim.org>
parents:
20802
diff
changeset
|
1461 errmsg = N_("E520: Not allowed in a modeline"); |
1807 | 1462 goto skip; |
1463 } | |
16728
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1464 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
|
1465 { |
21672
9099eb378758
patch 8.2.1386: backslash not removed afer space with space in 'isfname'
Bram Moolenaar <Bram@vim.org>
parents:
20802
diff
changeset
|
1466 errmsg = N_("E992: Not allowed in a modeline when 'modelineexpr' is off"); |
16728
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1467 goto skip; |
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1468 } |
1810 | 1469 #ifdef FEAT_DIFF |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1470 // In diff mode some options are overruled. This avoids that |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1471 // 'foldmethod' becomes "marker" instead of "diff" and that |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1472 // "wrap" gets set. |
1807 | 1473 if (curwin->w_p_diff |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1474 && 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
|
1475 && ( |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1476 #ifdef FEAT_FOLDING |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1477 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
|
1478 #endif |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1479 options[opt_idx].indir == PV_WRAP)) |
1807 | 1480 goto skip; |
1810 | 1481 #endif |
7 | 1482 } |
1483 | |
1484 #ifdef HAVE_SANDBOX | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1485 // Disallow changing some options in the sandbox |
634 | 1486 if (sandbox != 0 && (flags & P_SECURE)) |
7 | 1487 { |
21672
9099eb378758
patch 8.2.1386: backslash not removed afer space with space in 'isfname'
Bram Moolenaar <Bram@vim.org>
parents:
20802
diff
changeset
|
1488 errmsg = e_sandbox; |
7 | 1489 goto skip; |
1490 } | |
1491 #endif | |
1492 | |
1493 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) | |
1494 { | |
1495 arg += len; | |
1496 cp_val = p_cp; | |
1497 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') | |
1498 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1499 if (arg[3] == 'm') // "opt&vim": set to Vim default |
7 | 1500 { |
1501 cp_val = FALSE; | |
1502 arg += 3; | |
1503 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1504 else // "opt&vi": set to Vi default |
7 | 1505 { |
1506 cp_val = TRUE; | |
1507 arg += 2; | |
1508 } | |
1509 } | |
1510 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
|
1511 && arg[1] != NUL && !VIM_ISWHITE(arg[1])) |
7 | 1512 { |
1513 errmsg = e_trailing; | |
1514 goto skip; | |
1515 } | |
1516 } | |
1517 | |
1518 /* | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
1519 * allow '=' and ':' for historical reasons (MSDOS command.com |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
1520 * allows only one '=' character per "set" command line. grrr. (jw) |
7 | 1521 */ |
1522 if (nextchar == '?' | |
1523 || (prefix == 1 | |
1524 && vim_strchr((char_u *)"=:&<", nextchar) == NULL | |
1525 && !(flags & P_BOOL))) | |
1526 { | |
1527 /* | |
1528 * print value | |
1529 */ | |
1530 if (did_show) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1531 msg_putchar('\n'); // cursor below last one |
7 | 1532 else |
1533 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1534 gotocmdline(TRUE); // cursor at status line |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1535 did_show = TRUE; // remember that we did a line |
7 | 1536 } |
1537 if (opt_idx >= 0) | |
1538 { | |
1539 showoneopt(&options[opt_idx], opt_flags); | |
1540 #ifdef FEAT_EVAL | |
1541 if (p_verbose > 0) | |
694 | 1542 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1543 // Mention where the option was last set. |
694 | 1544 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
|
1545 last_set_msg(options[opt_idx].script_ctx); |
694 | 1546 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
|
1547 last_set_msg(curwin->w_p_script_ctx[ |
694 | 1548 (int)options[opt_idx].indir & PV_MASK]); |
1549 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
|
1550 last_set_msg(curbuf->b_p_script_ctx[ |
694 | 1551 (int)options[opt_idx].indir & PV_MASK]); |
1552 } | |
7 | 1553 #endif |
1554 } | |
1555 else | |
1556 { | |
1557 char_u *p; | |
1558 | |
1559 p = find_termcode(key_name); | |
1560 if (p == NULL) | |
1561 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1562 errmsg = N_("E846: Key code not set"); |
7 | 1563 goto skip; |
1564 } | |
1565 else | |
1566 (void)show_one_termcode(key_name, p, TRUE); | |
1567 } | |
1568 if (nextchar != '?' | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1569 && nextchar != NUL && !VIM_ISWHITE(afterchar)) |
7 | 1570 errmsg = e_trailing; |
1571 } | |
1572 else | |
1573 { | |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1574 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
|
1575 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
|
1576 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1577 if (flags & P_BOOL) // boolean |
7 | 1578 { |
1579 if (nextchar == '=' || nextchar == ':') | |
1580 { | |
1581 errmsg = e_invarg; | |
1582 goto skip; | |
1583 } | |
1584 | |
1585 /* | |
1586 * ":set opt!": invert | |
1587 * ":set opt&": reset to default value | |
1588 * ":set opt<": reset to global value | |
1589 */ | |
1590 if (nextchar == '!') | |
1591 value = *(int *)(varp) ^ 1; | |
1592 else if (nextchar == '&') | |
840 | 1593 value = (int)(long)(long_i)options[opt_idx].def_val[ |
7 | 1594 ((flags & P_VI_DEF) || cp_val) |
1595 ? VI_DEFAULT : VIM_DEFAULT]; | |
1596 else if (nextchar == '<') | |
1597 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1598 // For 'autoread' -1 means to use global value. |
7 | 1599 if ((int *)varp == &curbuf->b_p_ar |
1600 && opt_flags == OPT_LOCAL) | |
1601 value = -1; | |
1602 else | |
1603 value = *(int *)get_varp_scope(&(options[opt_idx]), | |
1604 OPT_GLOBAL); | |
1605 } | |
1606 else | |
1607 { | |
1608 /* | |
1609 * ":set invopt": invert | |
1610 * ":set opt" or ":set noopt": set or reset | |
1611 */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1612 if (nextchar != NUL && !VIM_ISWHITE(afterchar)) |
7 | 1613 { |
1614 errmsg = e_trailing; | |
1615 goto skip; | |
1616 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1617 if (prefix == 2) // inv |
7 | 1618 value = *(int *)(varp) ^ 1; |
1619 else | |
1620 value = prefix; | |
1621 } | |
1622 | |
1623 errmsg = set_bool_option(opt_idx, varp, (int)value, | |
1624 opt_flags); | |
1625 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1626 else // numeric or string |
7 | 1627 { |
1628 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL | |
1629 || prefix != 1) | |
1630 { | |
1631 errmsg = e_invarg; | |
1632 goto skip; | |
1633 } | |
1634 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1635 if (flags & P_NUM) // numeric |
7 | 1636 { |
1637 /* | |
1638 * Different ways to set a number option: | |
1639 * & set to default value | |
1640 * < set to global value | |
1641 * <xx> accept special key codes for 'wildchar' | |
1642 * c accept any non-digit for 'wildchar' | |
1643 * [-]0-9 set number | |
1644 * other error | |
1645 */ | |
1646 ++arg; | |
1647 if (nextchar == '&') | |
840 | 1648 value = (long)(long_i)options[opt_idx].def_val[ |
7 | 1649 ((flags & P_VI_DEF) || cp_val) |
1650 ? VI_DEFAULT : VIM_DEFAULT]; | |
1651 else if (nextchar == '<') | |
5446 | 1652 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1653 // For 'undolevels' NO_LOCAL_UNDOLEVEL means to |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1654 // use the global value. |
5446 | 1655 if ((long *)varp == &curbuf->b_p_ul |
1656 && opt_flags == OPT_LOCAL) | |
1657 value = NO_LOCAL_UNDOLEVEL; | |
1658 else | |
1659 value = *(long *)get_varp_scope( | |
1660 &(options[opt_idx]), OPT_GLOBAL); | |
1661 } | |
7 | 1662 else if (((long *)varp == &p_wc |
1663 || (long *)varp == &p_wcm) | |
1664 && (*arg == '<' | |
1665 || *arg == '^' | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1666 || (*arg != NUL |
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1667 && (!arg[1] || VIM_ISWHITE(arg[1])) |
7 | 1668 && !VIM_ISDIGIT(*arg)))) |
1669 { | |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1670 value = string_to_key(arg, FALSE); |
7 | 1671 if (value == 0 && (long *)varp != &p_wcm) |
1672 { | |
1673 errmsg = e_invarg; | |
1674 goto skip; | |
1675 } | |
1676 } | |
1677 else if (*arg == '-' || VIM_ISDIGIT(*arg)) | |
1678 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1679 // Allow negative (for 'undolevels'), octal and |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1680 // hex numbers. |
7447
ad432f8f68fb
commit https://github.com/vim/vim/commit/887c1fea4a114e7170091942d0446c8882701b5b
Christian Brabandt <cb@256bit.org>
parents:
7426
diff
changeset
|
1681 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
|
1682 &value, NULL, 0, TRUE); |
17039
d726d8cce996
patch 8.1.1519: 'backupskip' may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
16843
diff
changeset
|
1683 if (i == 0 || (arg[i] != NUL |
d726d8cce996
patch 8.1.1519: 'backupskip' may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
16843
diff
changeset
|
1684 && !VIM_ISWHITE(arg[i]))) |
7 | 1685 { |
16706
77bcb5055fec
patch 8.1.1355: obvious mistakes are accepted as valid expressions
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
1686 errmsg = N_("E521: Number required after ="); |
7 | 1687 goto skip; |
1688 } | |
1689 } | |
1690 else | |
1691 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1692 errmsg = N_("E521: Number required after ="); |
7 | 1693 goto skip; |
1694 } | |
1695 | |
1696 if (adding) | |
1697 value = *(long *)varp + value; | |
1698 if (prepending) | |
1699 value = *(long *)varp * value; | |
1700 if (removing) | |
1701 value = *(long *)varp - value; | |
1702 errmsg = set_num_option(opt_idx, varp, value, | |
274 | 1703 errbuf, sizeof(errbuf), opt_flags); |
7 | 1704 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1705 else if (opt_idx >= 0) // string |
7 | 1706 { |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1707 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
|
1708 char_u *s = NULL; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1709 char_u *oldval = NULL; // previous value if *varp |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1710 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
|
1711 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
|
1712 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
|
1713 char_u *origval_g = NULL; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
1714 #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
|
1715 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
|
1716 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
|
1717 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
|
1718 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
|
1719 #endif |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1720 unsigned newlen; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1721 int comma; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1722 int new_value_alloced; // new string option |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1723 // was allocated |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1724 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1725 // When using ":set opt=val" for a global option |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1726 // with a local value the local value will be |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1727 // reset, use the global value here. |
7 | 1728 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
692 | 1729 && ((int)options[opt_idx].indir & PV_BOTH)) |
7 | 1730 varp = options[opt_idx].var; |
1731 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1732 // The old value is kept until we are sure that the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1733 // new value is valid. |
7 | 1734 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
|
1735 |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1736 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
|
1737 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1738 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
|
1739 &(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
|
1740 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
|
1741 &(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
|
1742 |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1743 // 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
|
1744 // 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
|
1745 // 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
|
1746 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
|
1747 && 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
|
1748 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
|
1749 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1750 |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1751 // 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
|
1752 // 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
|
1753 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
|
1754 && (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
|
1755 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
|
1756 &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
|
1757 else |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1758 origval = oldval; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1759 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1760 if (nextchar == '&') // set to default val |
7 | 1761 { |
1762 newval = options[opt_idx].def_val[ | |
1763 ((flags & P_VI_DEF) || cp_val) | |
1764 ? VI_DEFAULT : VIM_DEFAULT]; | |
1765 if ((char_u **)varp == &p_bg) | |
1766 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1767 // guess the value of 'background' |
7 | 1768 #ifdef FEAT_GUI |
1769 if (gui.in_use) | |
1770 newval = gui_bg_default(); | |
1771 else | |
1772 #endif | |
671 | 1773 newval = term_bg_default(); |
7 | 1774 } |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
1775 else if ((char_u **)varp == &p_fencs && enc_utf8) |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
1776 newval = fencs_utf8_default; |
7 | 1777 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1778 // expand environment variables and ~ (since the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1779 // default value was already expanded, only |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1780 // required when an environment variable was set |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1781 // later |
7 | 1782 if (newval == NULL) |
1783 newval = empty_option; | |
1784 else | |
1785 { | |
1786 s = option_expand(opt_idx, newval); | |
1787 if (s == NULL) | |
1788 s = newval; | |
1789 newval = vim_strsave(s); | |
1790 } | |
1791 new_value_alloced = TRUE; | |
1792 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1793 else if (nextchar == '<') // set to global val |
7 | 1794 { |
1795 newval = vim_strsave(*(char_u **)get_varp_scope( | |
1796 &(options[opt_idx]), OPT_GLOBAL)); | |
1797 new_value_alloced = TRUE; | |
1798 } | |
1799 else | |
1800 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1801 ++arg; // jump to after the '=' or ':' |
7 | 1802 |
1803 /* | |
1804 * Set 'keywordprg' to ":help" if an empty | |
1805 * value was passed to :set by the user. | |
1806 * Misuse errbuf[] for the resulting string. | |
1807 */ | |
1808 if (varp == (char_u *)&p_kp | |
1809 && (*arg == NUL || *arg == ' ')) | |
1810 { | |
1811 STRCPY(errbuf, ":help"); | |
1812 save_arg = arg; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1813 arg = (char_u *)errbuf; |
7 | 1814 } |
1815 /* | |
3168 | 1816 * Convert 'backspace' number to string, for |
1817 * adding, prepending and removing string. | |
1818 */ | |
1819 else if (varp == (char_u *)&p_bs | |
1820 && VIM_ISDIGIT(**(char_u **)varp)) | |
1821 { | |
1822 i = getdigits((char_u **)varp); | |
1823 switch (i) | |
1824 { | |
1825 case 0: | |
1826 *(char_u **)varp = empty_option; | |
1827 break; | |
1828 case 1: | |
1829 *(char_u **)varp = vim_strsave( | |
1830 (char_u *)"indent,eol"); | |
1831 break; | |
1832 case 2: | |
1833 *(char_u **)varp = vim_strsave( | |
1834 (char_u *)"indent,eol,start"); | |
1835 break; | |
20069
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1836 case 3: |
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1837 *(char_u **)varp = vim_strsave( |
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1838 (char_u *)"indent,eol,nostop"); |
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1839 break; |
3168 | 1840 } |
1841 vim_free(oldval); | |
12190
497b78526358
patch 8.0.0975: using freed memory when setting 'backspace'
Christian Brabandt <cb@256bit.org>
parents:
12188
diff
changeset
|
1842 if (origval == oldval) |
497b78526358
patch 8.0.0975: using freed memory when setting 'backspace'
Christian Brabandt <cb@256bit.org>
parents:
12188
diff
changeset
|
1843 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
|
1844 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
|
1845 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
|
1846 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
|
1847 origval_g = *(char_u **)varp; |
3168 | 1848 oldval = *(char_u **)varp; |
1849 } | |
1850 /* | |
7 | 1851 * Convert 'whichwrap' number to string, for |
1852 * backwards compatibility with Vim 3.0. | |
1853 * Misuse errbuf[] for the resulting string. | |
1854 */ | |
1855 else if (varp == (char_u *)&p_ww | |
1856 && VIM_ISDIGIT(*arg)) | |
1857 { | |
1858 *errbuf = NUL; | |
1859 i = getdigits(&arg); | |
1860 if (i & 1) | |
1861 STRCAT(errbuf, "b,"); | |
1862 if (i & 2) | |
1863 STRCAT(errbuf, "s,"); | |
1864 if (i & 4) | |
1865 STRCAT(errbuf, "h,l,"); | |
1866 if (i & 8) | |
1867 STRCAT(errbuf, "<,>,"); | |
1868 if (i & 16) | |
1869 STRCAT(errbuf, "[,],"); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1870 if (*errbuf != NUL) // remove trailing , |
7 | 1871 errbuf[STRLEN(errbuf) - 1] = NUL; |
1872 save_arg = arg; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1873 arg = (char_u *)errbuf; |
7 | 1874 } |
1875 /* | |
1876 * Remove '>' before 'dir' and 'bdir', for | |
1877 * backwards compatibility with version 3.0 | |
1878 */ | |
1879 else if ( *arg == '>' | |
1880 && (varp == (char_u *)&p_dir | |
1881 || varp == (char_u *)&p_bdir)) | |
1882 { | |
1883 ++arg; | |
1884 } | |
1885 | |
1886 /* | |
1887 * Copy the new string into allocated memory. | |
1888 * Can't use set_string_option_direct(), because | |
1889 * we need to remove the backslashes. | |
1890 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1891 // get a bit too much |
7 | 1892 newlen = (unsigned)STRLEN(arg) + 1; |
1893 if (adding || prepending || removing) | |
1894 newlen += (unsigned)STRLEN(origval) + 1; | |
1895 newval = alloc(newlen); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1896 if (newval == NULL) // out of mem, don't change |
7 | 1897 break; |
1898 s = newval; | |
1899 | |
1900 /* | |
1901 * Copy the string, skip over escaped chars. | |
1902 * For MS-DOS and WIN32 backslashes before normal | |
1903 * file name characters are not removed, and keep | |
1904 * backslash at start, for "\\machine\path", but | |
1905 * do remove it for "\\\\machine\\path". | |
1906 * The reverse is found in ExpandOldSetting(). | |
1907 */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1908 while (*arg && !VIM_ISWHITE(*arg)) |
7 | 1909 { |
1910 if (*arg == '\\' && arg[1] != NUL | |
1911 #ifdef BACKSLASH_IN_FILENAME | |
1912 && !((flags & P_EXPAND) | |
1913 && vim_isfilec(arg[1]) | |
21672
9099eb378758
patch 8.2.1386: backslash not removed afer space with space in 'isfname'
Bram Moolenaar <Bram@vim.org>
parents:
20802
diff
changeset
|
1914 && !VIM_ISWHITE(arg[1]) |
7 | 1915 && (arg[1] != '\\' |
1916 || (s == newval | |
1917 && arg[2] != '\\'))) | |
1918 #endif | |
1919 ) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1920 ++arg; // remove backslash |
7 | 1921 if (has_mbyte |
474 | 1922 && (i = (*mb_ptr2len)(arg)) > 1) |
7 | 1923 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1924 // copy multibyte char |
7 | 1925 mch_memmove(s, arg, (size_t)i); |
1926 arg += i; | |
1927 s += i; | |
1928 } | |
1929 else | |
1930 *s++ = *arg++; | |
1931 } | |
1932 *s = NUL; | |
1933 | |
1934 /* | |
1935 * Expand environment variables and ~. | |
1936 * Don't do it when adding without inserting a | |
1937 * comma. | |
1938 */ | |
1939 if (!(adding || prepending || removing) | |
1940 || (flags & P_COMMA)) | |
1941 { | |
1942 s = option_expand(opt_idx, newval); | |
1943 if (s != NULL) | |
1944 { | |
1945 vim_free(newval); | |
1946 newlen = (unsigned)STRLEN(s) + 1; | |
1947 if (adding || prepending || removing) | |
1948 newlen += (unsigned)STRLEN(origval) + 1; | |
1949 newval = alloc(newlen); | |
1950 if (newval == NULL) | |
1951 break; | |
1952 STRCPY(newval, s); | |
1953 } | |
1954 } | |
1955 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1956 // locate newval[] in origval[] when removing it |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1957 // and when adding to avoid duplicates |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1958 i = 0; // init for GCC |
7 | 1959 if (removing || (flags & P_NODUP)) |
1960 { | |
1961 i = (int)STRLEN(newval); | |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
1962 s = find_dup_item(origval, newval, flags); |
7 | 1963 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1964 // do not add if already there |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
1965 if ((adding || prepending) && s != NULL) |
7 | 1966 { |
1967 prepending = FALSE; | |
1968 adding = FALSE; | |
1969 STRCPY(newval, origval); | |
1970 } | |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
1971 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
1972 // if no duplicate, move pointer to end of |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
1973 // original value |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
1974 if (s == NULL) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
1975 s = origval + (int)STRLEN(origval); |
7 | 1976 } |
1977 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1978 // concatenate the two strings; add a ',' if |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1979 // needed |
7 | 1980 if (adding || prepending) |
1981 { | |
1982 comma = ((flags & P_COMMA) && *origval != NUL | |
1983 && *newval != NUL); | |
1984 if (adding) | |
1985 { | |
1986 i = (int)STRLEN(origval); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1987 // 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
|
1988 if (comma && i > 1 |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1989 && (flags & P_ONECOMMA) == P_ONECOMMA |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1990 && origval[i - 1] == ',' |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1991 && origval[i - 2] != '\\') |
6841 | 1992 i--; |
7 | 1993 mch_memmove(newval + i + comma, newval, |
1994 STRLEN(newval) + 1); | |
1995 mch_memmove(newval, origval, (size_t)i); | |
1996 } | |
1997 else | |
1998 { | |
1999 i = (int)STRLEN(newval); | |
1622 | 2000 STRMOVE(newval + i + comma, origval); |
7 | 2001 } |
2002 if (comma) | |
2003 newval[i] = ','; | |
2004 } | |
2005 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2006 // Remove newval[] from origval[]. (Note: "i" has |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2007 // been set above and is used here). |
7 | 2008 if (removing) |
2009 { | |
2010 STRCPY(newval, origval); | |
2011 if (*s) | |
2012 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2013 // may need to remove a comma |
7 | 2014 if (flags & P_COMMA) |
2015 { | |
2016 if (s == origval) | |
2017 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2018 // include comma after string |
7 | 2019 if (s[i] == ',') |
2020 ++i; | |
2021 } | |
2022 else | |
2023 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2024 // include comma before string |
7 | 2025 --s; |
2026 ++i; | |
2027 } | |
2028 } | |
1622 | 2029 STRMOVE(newval + (s - origval), s + i); |
7 | 2030 } |
2031 } | |
2032 | |
2033 if (flags & P_FLAGLIST) | |
2034 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2035 // 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
|
2036 for (s = newval; *s;) |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2037 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2038 // if options have P_FLAGLIST and |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2039 // P_ONECOMMA such as 'whichwrap' |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2040 if (flags & P_ONECOMMA) |
7 | 2041 { |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2042 if (*s != ',' && *(s + 1) == ',' |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2043 && vim_strchr(s + 2, *s) != NULL) |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2044 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2045 // Remove the duplicated value and |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2046 // the next comma. |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2047 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
|
2048 continue; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2049 } |
7 | 2050 } |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2051 else |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2052 { |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2053 if ((!(flags & P_COMMA) || *s != ',') |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2054 && vim_strchr(s + 1, *s) != NULL) |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2055 { |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2056 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
|
2057 continue; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2058 } |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2059 } |
10831
e926c5a7f9bf
patch 8.0.0305: invalid memory access when option has duplicate flag
Christian Brabandt <cb@256bit.org>
parents:
10825
diff
changeset
|
2060 ++s; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
2061 } |
7 | 2062 } |
2063 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2064 if (save_arg != NULL) // number for 'whichwrap' |
7 | 2065 arg = save_arg; |
2066 new_value_alloced = TRUE; | |
2067 } | |
2068 | |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2069 /* |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2070 * 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
|
2071 */ |
7 | 2072 *(char_u **)(varp) = newval; |
2073 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
2074 #if defined(FEAT_EVAL) |
6939 | 2075 if (!starting |
2076 # ifdef FEAT_CRYPT | |
2077 && options[opt_idx].indir != PV_KEY | |
2078 # endif | |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
2079 && 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
|
2080 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2081 // origval may be freed by |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2082 // did_set_string_option(), make a copy. |
6935 | 2083 saved_origval = vim_strsave(origval); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2084 // newval (and varp) may become invalid if the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2085 // buffer is closed by autocommands. |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
2086 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
|
2087 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
|
2088 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
|
2089 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
|
2090 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
|
2091 } |
6935 | 2092 #endif |
2093 | |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
2094 { |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
2095 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
|
2096 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
|
2097 |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
2098 // 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
|
2099 // 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
|
2100 // 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
|
2101 // 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
|
2102 // completely replaced. |
16082
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
2103 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
|
2104 #ifdef HAVE_SANDBOX |
16082
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
2105 || sandbox != 0 |
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
2106 #endif |
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
2107 || (!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
|
2108 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
|
2109 |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
2110 // 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
|
2111 // 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
|
2112 // '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
|
2113 // 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
|
2114 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
|
2115 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
|
2116 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
|
2117 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
|
2118 |
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
|
2119 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
|
2120 } |
7 | 2121 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
2122 #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
|
2123 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
|
2124 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
|
2125 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
|
2126 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
|
2127 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
|
2128 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
|
2129 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
|
2130 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
|
2131 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
|
2132 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2133 // If error detected, print the error message. |
7 | 2134 if (errmsg != NULL) |
2135 goto skip; | |
2136 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2137 else // key code option |
7 | 2138 { |
2139 char_u *p; | |
2140 | |
2141 if (nextchar == '&') | |
2142 { | |
2143 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
|
2144 errmsg = N_("E522: Not found in termcap"); |
7 | 2145 } |
2146 else | |
2147 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2148 ++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
|
2149 for (p = arg; *p && !VIM_ISWHITE(*p); ++p) |
7 | 2150 if (*p == '\\' && p[1] != NUL) |
2151 ++p; | |
2152 nextchar = *p; | |
2153 *p = NUL; | |
2154 add_termcode(key_name, arg, FALSE); | |
2155 *p = nextchar; | |
2156 } | |
2157 if (full_screen) | |
2158 ttest(FALSE); | |
2159 redraw_all_later(CLEAR); | |
2160 } | |
2161 } | |
634 | 2162 |
7 | 2163 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
|
2164 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
|
2165 opt_idx, opt_flags, value_is_replaced, value_checked); |
7 | 2166 } |
2167 | |
2168 skip: | |
2169 /* | |
2170 * Advance to next argument. | |
2171 * - skip until a blank found, taking care of backslashes | |
2172 * - skip blanks | |
2173 * - skip one "=val" argument (for hidden options ":set gfn =xx") | |
2174 */ | |
2175 for (i = 0; i < 2 ; ++i) | |
2176 { | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2177 while (*arg != NUL && !VIM_ISWHITE(*arg)) |
7 | 2178 if (*arg++ == '\\' && *arg != NUL) |
2179 ++arg; | |
2180 arg = skipwhite(arg); | |
2181 if (*arg != '=') | |
2182 break; | |
2183 } | |
2184 } | |
2185 | |
2186 if (errmsg != NULL) | |
2187 { | |
419 | 2188 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1); |
835 | 2189 i = (int)STRLEN(IObuff) + 2; |
7 | 2190 if (i + (arg - startarg) < IOSIZE) |
2191 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2192 // append the argument with the error |
7 | 2193 STRCAT(IObuff, ": "); |
2194 mch_memmove(IObuff + i, startarg, (arg - startarg)); | |
2195 IObuff[i + (arg - startarg)] = NUL; | |
2196 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2197 // make sure all characters are printable |
7 | 2198 trans_characters(IObuff, IOSIZE); |
2199 | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2200 ++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
|
2201 emsg((char *)IObuff); // show error highlighted |
7 | 2202 --no_wait_return; |
2203 | |
2204 return FAIL; | |
2205 } | |
2206 | |
2207 arg = skipwhite(arg); | |
2208 } | |
2209 | |
168 | 2210 theend: |
2211 if (silent_mode && did_show) | |
2212 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2213 // After displaying option values in silent mode. |
168 | 2214 silent_mode = FALSE; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2215 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
168 | 2216 msg_putchar('\n'); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2217 cursor_on(); // msg_start() switches it off |
168 | 2218 out_flush(); |
2219 silent_mode = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2220 info_message = FALSE; // use mch_msg(), not mch_errmsg() |
168 | 2221 } |
2222 | |
7 | 2223 return OK; |
2224 } | |
2225 | |
634 | 2226 /* |
2227 * Call this when an option has been given a new value through a user command. | |
2228 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag. | |
2229 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2230 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2231 did_set_option( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2232 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
|
2233 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
|
2234 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
|
2235 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
|
2236 // P_INSECURE flag. |
634 | 2237 { |
681 | 2238 long_u *p; |
2239 | |
634 | 2240 options[opt_idx].flags |= P_WAS_SET; |
2241 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2242 // When an option is set in the sandbox, from a modeline or in secure mode |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2243 // set the P_INSECURE flag. Otherwise, if a new value is stored reset the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2244 // flag. |
681 | 2245 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
|
2246 if (!value_checked && (secure |
634 | 2247 #ifdef HAVE_SANDBOX |
2248 || sandbox != 0 | |
2249 #endif | |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2250 || (opt_flags & OPT_MODELINE))) |
681 | 2251 *p = *p | P_INSECURE; |
2252 else if (new_value) | |
2253 *p = *p & ~P_INSECURE; | |
634 | 2254 } |
2255 | |
7 | 2256 /* |
2257 * Convert a key name or string into a key value. | |
2258 * 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
|
2259 * 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
|
2260 */ |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2261 int |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2262 string_to_key(char_u *arg, int multi_byte) |
7 | 2263 { |
2264 if (*arg == '<') | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
2265 return find_key_option(arg + 1, TRUE); |
7 | 2266 if (*arg == '^') |
2267 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
|
2268 if (multi_byte) |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2269 return PTR2CHAR(arg); |
7 | 2270 return *arg; |
2271 } | |
2272 | |
2273 #ifdef FEAT_TITLE | |
2274 /* | |
2275 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call | |
2276 * maketitle() to create and display it. | |
2277 * When switching the title or icon off, call mch_restore_title() to get | |
2278 * the old value back. | |
2279 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2280 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
|
2281 did_set_title(void) |
7 | 2282 { |
2283 if (starting != NO_SCREEN | |
2284 #ifdef FEAT_GUI | |
2285 && !gui.starting | |
2286 #endif | |
2287 ) | |
2288 maketitle(); | |
2289 } | |
2290 #endif | |
2291 | |
2292 /* | |
2293 * set_options_bin - called when 'bin' changes value. | |
2294 */ | |
2295 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2296 set_options_bin( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2297 int oldval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2298 int newval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2299 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 2300 { |
2301 /* | |
2302 * The option values that are changed when 'bin' changes are | |
2303 * copied when 'bin is set and restored when 'bin' is reset. | |
2304 */ | |
2305 if (newval) | |
2306 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2307 if (!oldval) // switched on |
7 | 2308 { |
2309 if (!(opt_flags & OPT_GLOBAL)) | |
2310 { | |
2311 curbuf->b_p_tw_nobin = curbuf->b_p_tw; | |
2312 curbuf->b_p_wm_nobin = curbuf->b_p_wm; | |
2313 curbuf->b_p_ml_nobin = curbuf->b_p_ml; | |
2314 curbuf->b_p_et_nobin = curbuf->b_p_et; | |
2315 } | |
2316 if (!(opt_flags & OPT_LOCAL)) | |
2317 { | |
2318 p_tw_nobin = p_tw; | |
2319 p_wm_nobin = p_wm; | |
2320 p_ml_nobin = p_ml; | |
2321 p_et_nobin = p_et; | |
2322 } | |
2323 } | |
2324 | |
2325 if (!(opt_flags & OPT_GLOBAL)) | |
2326 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2327 curbuf->b_p_tw = 0; // no automatic line wrap |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2328 curbuf->b_p_wm = 0; // no automatic line wrap |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2329 curbuf->b_p_ml = 0; // no modelines |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2330 curbuf->b_p_et = 0; // no expandtab |
7 | 2331 } |
2332 if (!(opt_flags & OPT_LOCAL)) | |
2333 { | |
2334 p_tw = 0; | |
2335 p_wm = 0; | |
2336 p_ml = FALSE; | |
2337 p_et = FALSE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2338 p_bin = TRUE; // needed when called for the "-b" argument |
7 | 2339 } |
2340 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2341 else if (oldval) // switched off |
7 | 2342 { |
2343 if (!(opt_flags & OPT_GLOBAL)) | |
2344 { | |
2345 curbuf->b_p_tw = curbuf->b_p_tw_nobin; | |
2346 curbuf->b_p_wm = curbuf->b_p_wm_nobin; | |
2347 curbuf->b_p_ml = curbuf->b_p_ml_nobin; | |
2348 curbuf->b_p_et = curbuf->b_p_et_nobin; | |
2349 } | |
2350 if (!(opt_flags & OPT_LOCAL)) | |
2351 { | |
2352 p_tw = p_tw_nobin; | |
2353 p_wm = p_wm_nobin; | |
2354 p_ml = p_ml_nobin; | |
2355 p_et = p_et_nobin; | |
2356 } | |
2357 } | |
2358 } | |
2359 | |
2360 /* | |
2361 * Expand environment variables for some string options. | |
2362 * These string options cannot be indirect! | |
2363 * If "val" is NULL expand the current value of the option. | |
2364 * Return pointer to NameBuff, or NULL when not expanded. | |
2365 */ | |
2366 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2367 option_expand(int opt_idx, char_u *val) |
7 | 2368 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2369 // if option doesn't need expansion nothing to do |
7 | 2370 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) |
2371 return NULL; | |
2372 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2373 // If val is longer than MAXPATHL no meaningful expansion can be done, |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2374 // expand_env() would truncate the string. |
7 | 2375 if (val != NULL && STRLEN(val) > MAXPATHL) |
2376 return NULL; | |
2377 | |
2378 if (val == NULL) | |
2379 val = *(char_u **)options[opt_idx].var; | |
2380 | |
2381 /* | |
2382 * Expanding this with NameBuff, expand_env() must not be passed IObuff. | |
2383 * Escape spaces when expanding 'tags', they are used to separate file | |
2384 * names. | |
374 | 2385 * For 'spellsuggest' expand after "file:". |
7 | 2386 */ |
2387 expand_env_esc(val, NameBuff, MAXPATHL, | |
1408 | 2388 (char_u **)options[opt_idx].var == &p_tags, FALSE, |
744 | 2389 #ifdef FEAT_SPELL |
374 | 2390 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : |
2391 #endif | |
2392 NULL); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2393 if (STRCMP(NameBuff, val) == 0) // they are the same |
7 | 2394 return NULL; |
2395 | |
2396 return NameBuff; | |
2397 } | |
2398 | |
2399 /* | |
2400 * After setting various option values: recompute variables that depend on | |
2401 * option values. | |
2402 */ | |
2403 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2404 didset_options(void) |
7 | 2405 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2406 // initialize the table for 'iskeyword' et.al. |
7 | 2407 (void)init_chartab(); |
2408 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2409 didset_string_options(); |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2410 |
744 | 2411 #ifdef FEAT_SPELL |
484 | 2412 (void)spell_check_msm(); |
374 | 2413 (void)spell_check_sps(); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
2414 (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
|
2415 (void)did_set_spell_option(TRUE); |
344 | 2416 #endif |
7 | 2417 #ifdef FEAT_CMDWIN |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2418 // set cedit_key |
7 | 2419 (void)check_cedit(); |
2420 #endif | |
5995 | 2421 #ifdef FEAT_LINEBREAK |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2422 // initialize the table for 'breakat'. |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2423 fill_breakat_flags(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2424 #endif |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2425 after_copy_winopt(curwin); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2426 } |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2427 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2428 /* |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2429 * More side effects of setting options. |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2430 */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2431 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2432 didset_options2(void) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2433 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2434 // Initialize the highlight_attr[] table. |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2435 (void)highlight_changed(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2436 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2437 // Parse default for 'wildmode' |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2438 check_opt_wim(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2439 |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2440 // Parse default for 'listchars'. |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2441 (void)set_chars_option(curwin, &curwin->w_p_lcs); |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2442 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2443 // Parse default for 'fillchars'. |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2444 (void)set_chars_option(curwin, &p_fcs); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2445 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2446 #ifdef FEAT_CLIPBOARD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2447 // Parse default for 'clipboard' |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2448 (void)check_clipboard_option(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2449 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2450 #ifdef FEAT_VARTABS |
15858
3a45b89639fb
patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2451 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
|
2452 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
|
2453 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
|
2454 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
|
2455 #endif |
7 | 2456 } |
2457 | |
2458 /* | |
2459 * Check for string options that are NULL (normally only termcap options). | |
2460 */ | |
2461 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2462 check_options(void) |
7 | 2463 { |
2464 int opt_idx; | |
2465 | |
2466 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) | |
2467 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL) | |
2468 check_string_option((char_u **)get_varp(&(options[opt_idx]))); | |
2469 } | |
2470 | |
2471 /* | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2472 * 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
|
2473 * 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
|
2474 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2475 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2476 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
|
2477 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2478 int opt_idx; |
7 | 2479 |
2480 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) | |
2481 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
|
2482 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
|
2483 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
|
2484 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2485 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2486 /* |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2487 * 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
|
2488 * 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
|
2489 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2490 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2491 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
|
2492 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2493 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
|
2494 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2495 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
|
2496 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
|
2497 return opt_idx; |
7 | 2498 } |
2499 | |
634 | 2500 #if defined(FEAT_EVAL) || defined(PROTO) |
2501 /* | |
2502 * Return TRUE when option "opt" was set from a modeline or in secure mode. | |
2503 * Return FALSE when it wasn't. | |
2504 * Return -1 for an unknown option. | |
2505 */ | |
2506 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2507 was_set_insecurely(char_u *opt, int opt_flags) |
634 | 2508 { |
2509 int idx = findoption(opt); | |
681 | 2510 long_u *flagp; |
634 | 2511 |
2512 if (idx >= 0) | |
681 | 2513 { |
2514 flagp = insecure_flag(idx, opt_flags); | |
2515 return (*flagp & P_INSECURE) != 0; | |
2516 } | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
2517 internal_error("was_set_insecurely()"); |
634 | 2518 return -1; |
2519 } | |
681 | 2520 |
2521 /* | |
2522 * Get a pointer to the flags used for the P_INSECURE flag of option | |
2523 * "opt_idx". For some local options a local flags field is used. | |
23821
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
2524 * NOTE: Caller must make sure that "curwin" is set to the window from which |
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
2525 * the option is used. |
681 | 2526 */ |
2527 static long_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2528 insecure_flag(int opt_idx, int opt_flags) |
681 | 2529 { |
2530 if (opt_flags & OPT_LOCAL) | |
2531 switch ((int)options[opt_idx].indir) | |
2532 { | |
2533 #ifdef FEAT_STL_OPT | |
694 | 2534 case PV_STL: return &curwin->w_p_stl_flags; |
681 | 2535 #endif |
2536 #ifdef FEAT_EVAL | |
885 | 2537 # ifdef FEAT_FOLDING |
694 | 2538 case PV_FDE: return &curwin->w_p_fde_flags; |
2539 case PV_FDT: return &curwin->w_p_fdt_flags; | |
885 | 2540 # endif |
790 | 2541 # ifdef FEAT_BEVAL |
2542 case PV_BEXPR: return &curbuf->b_p_bexpr_flags; | |
2543 # endif | |
681 | 2544 # if defined(FEAT_CINDENT) |
694 | 2545 case PV_INDE: return &curbuf->b_p_inde_flags; |
681 | 2546 # endif |
694 | 2547 case PV_FEX: return &curbuf->b_p_fex_flags; |
681 | 2548 # ifdef FEAT_FIND_ID |
694 | 2549 case PV_INEX: return &curbuf->b_p_inex_flags; |
681 | 2550 # endif |
2551 #endif | |
2552 } | |
2553 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2554 // Nothing special, return global flags field. |
681 | 2555 return &options[opt_idx].flags; |
2556 } | |
634 | 2557 #endif |
2558 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2559 #if defined(FEAT_TITLE) || defined(PROTO) |
1805 | 2560 /* |
2561 * Redraw the window title and/or tab page text later. | |
2562 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2563 void redraw_titles(void) |
1805 | 2564 { |
2565 need_maketitle = TRUE; | |
2566 redraw_tabline = TRUE; | |
2567 } | |
2568 #endif | |
2569 | |
7 | 2570 /* |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2571 * 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
|
2572 * 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
|
2573 */ |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17845
diff
changeset
|
2574 int |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2575 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
|
2576 { |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2577 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
|
2578 |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2579 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
|
2580 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
|
2581 return FALSE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2582 return TRUE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2583 } |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2584 |
681 | 2585 #if defined(FEAT_EVAL) || defined(PROTO) |
2586 /* | |
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
|
2587 * Set the script_ctx for an option, taking care of setting the buffer- or |
694 | 2588 * window-local value. |
681 | 2589 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2590 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
|
2591 set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx) |
694 | 2592 { |
2593 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; | |
2594 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
|
2595 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
|
2596 |
20269
246101db63a4
patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents:
20237
diff
changeset
|
2597 // Modeline already has the line number set. |
246101db63a4
patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents:
20237
diff
changeset
|
2598 if (!(opt_flags & OPT_MODELINE)) |
246101db63a4
patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents:
20237
diff
changeset
|
2599 new_script_ctx.sc_lnum += SOURCING_LNUM; |
694 | 2600 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2601 // Remember where the option was set. For local options need to do that |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2602 // in the buffer or window structure. |
694 | 2603 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
|
2604 options[opt_idx].script_ctx = new_script_ctx; |
694 | 2605 if (both || (opt_flags & OPT_LOCAL)) |
2606 { | |
2607 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
|
2608 curbuf->b_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
694 | 2609 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
|
2610 curwin->w_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
694 | 2611 } |
681 | 2612 } |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2613 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2614 /* |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2615 * Set 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
|
2616 * "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
|
2617 * 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
|
2618 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2619 void |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2620 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
|
2621 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2622 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
|
2623 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
|
2624 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2625 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
|
2626 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
|
2627 else |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2628 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2629 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
|
2630 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
|
2631 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
|
2632 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
|
2633 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
|
2634 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
|
2635 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2636 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
|
2637 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
|
2638 } |
681 | 2639 #endif |
2640 | |
19405
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2641 #if defined(FEAT_EVAL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2642 /* |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2643 * Apply the OptionSet autocommand. |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2644 */ |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2645 static void |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2646 apply_optionset_autocmd( |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2647 int opt_idx, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2648 long opt_flags, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2649 long oldval, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2650 long oldval_g, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2651 long newval, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2652 char *errmsg) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2653 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2654 char_u buf_old[12], buf_old_global[12], buf_new[12], buf_type[12]; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2655 |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2656 // Don't do this while starting up, failure or recursively. |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2657 if (starting || errmsg != NULL || *get_vim_var_str(VV_OPTION_TYPE) != NUL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2658 return; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2659 |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2660 vim_snprintf((char *)buf_old, sizeof(buf_old), "%ld", oldval); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2661 vim_snprintf((char *)buf_old_global, sizeof(buf_old_global), "%ld", |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2662 oldval_g); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2663 vim_snprintf((char *)buf_new, sizeof(buf_new), "%ld", newval); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2664 vim_snprintf((char *)buf_type, sizeof(buf_type), "%s", |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2665 (opt_flags & OPT_LOCAL) ? "local" : "global"); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2666 set_vim_var_string(VV_OPTION_NEW, buf_new, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2667 set_vim_var_string(VV_OPTION_OLD, buf_old, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2668 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2669 if (opt_flags & OPT_LOCAL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2670 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2671 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2672 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2673 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2674 if (opt_flags & OPT_GLOBAL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2675 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2676 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2677 set_vim_var_string(VV_OPTION_OLDGLOBAL, buf_old, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2678 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2679 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2680 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2681 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2682 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2683 set_vim_var_string(VV_OPTION_OLDGLOBAL, buf_old_global, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2684 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2685 if (opt_flags & OPT_MODELINE) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2686 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2687 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2688 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2689 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2690 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2691 NULL, FALSE, NULL); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2692 reset_v_option_vars(); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2693 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2694 #endif |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2695 |
7 | 2696 /* |
2697 * Set the value of a boolean option, and take care of side effects. | |
2698 * Returns NULL for success, or an error message for an error. | |
2699 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2700 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2701 set_bool_option( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2702 int opt_idx, // index in options[] table |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2703 char_u *varp, // pointer to the option variable |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2704 int value, // new value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2705 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 2706 { |
2707 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
|
2708 #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
|
2709 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
|
2710 #endif |
7 | 2711 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2712 // Disallow changing some options from secure mode |
7 | 2713 if ((secure |
2714 #ifdef HAVE_SANDBOX | |
2715 || sandbox != 0 | |
2716 #endif | |
2717 ) && (options[opt_idx].flags & P_SECURE)) | |
2718 return e_secure; | |
2719 | |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
2720 #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
|
2721 // 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
|
2722 // 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
|
2723 // 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
|
2724 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
|
2725 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
|
2726 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
|
2727 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2728 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2729 *(int *)varp = value; // set the new value |
7 | 2730 #ifdef FEAT_EVAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2731 // 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
|
2732 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 2733 #endif |
2734 | |
634 | 2735 #ifdef FEAT_GUI |
2736 need_mouse_correct = TRUE; | |
2737 #endif | |
2738 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2739 // May set global value for local option. |
7 | 2740 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
2741 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; | |
2742 | |
2743 /* | |
2744 * Handle side effects of changing a bool option. | |
2745 */ | |
2746 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2747 // 'compatible' |
7 | 2748 if ((int *)varp == &p_cp) |
2749 compatible_set(); | |
2750 | |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2751 #ifdef FEAT_LANGMAP |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2752 if ((int *)varp == &p_lrm) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2753 // 'langremap' -> !'langnoremap' |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2754 p_lnr = !p_lrm; |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2755 else if ((int *)varp == &p_lnr) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2756 // 'langnoremap' -> !'langremap' |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2757 p_lrm = !p_lnr; |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2758 #endif |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2759 |
14846
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2760 #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
|
2761 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
|
2762 reset_cursorline(); |
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2763 #endif |
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2764 |
3246 | 2765 #ifdef FEAT_PERSISTENT_UNDO |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2766 // 'undofile' |
3246 | 2767 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) |
2768 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2769 // Only take action when the option was set. When reset we do not |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2770 // delete the undo file, the option may be set again without making |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2771 // any changes in between. |
3894 | 2772 if (curbuf->b_p_udf || p_udf) |
2773 { | |
2774 char_u hash[UNDO_HASH_SIZE]; | |
2775 buf_T *save_curbuf = curbuf; | |
2776 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
2777 FOR_ALL_BUFFERS(curbuf) |
3894 | 2778 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2779 // When 'undofile' is set globally: for every buffer, otherwise |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2780 // only for the current buffer: Try to read in the undofile, |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2781 // if one exists, the buffer wasn't changed and the buffer was |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2782 // loaded |
3894 | 2783 if ((curbuf == save_curbuf |
3246 | 2784 || (opt_flags & OPT_GLOBAL) || opt_flags == 0) |
3894 | 2785 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) |
2786 { | |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2787 #ifdef FEAT_CRYPT |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2788 if (crypt_get_method_nr(curbuf) == CRYPT_M_SOD) |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2789 continue; |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2790 #endif |
3894 | 2791 u_compute_hash(hash); |
2792 u_read_undo(NULL, hash, curbuf->b_fname); | |
2793 } | |
2794 } | |
2795 curbuf = save_curbuf; | |
2796 } | |
3246 | 2797 } |
2798 #endif | |
2799 | |
7 | 2800 else if ((int *)varp == &curbuf->b_p_ro) |
2801 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2802 // when 'readonly' is reset globally, also reset readonlymode |
7 | 2803 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) |
2804 readonlymode = FALSE; | |
548 | 2805 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2806 // when 'readonly' is set may give W10 again |
548 | 2807 if (curbuf->b_p_ro) |
2808 curbuf->b_did_warn = FALSE; | |
2809 | |
7 | 2810 #ifdef FEAT_TITLE |
1805 | 2811 redraw_titles(); |
7 | 2812 #endif |
2813 } | |
2814 | |
2362
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2815 #ifdef FEAT_GUI |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2816 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
|
2817 { |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2818 if (!p_mh) |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2819 gui_mch_mousehide(FALSE); |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2820 } |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2821 #endif |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2822 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2823 // when 'modifiable' is changed, redraw the window title |
7 | 2824 else if ((int *)varp == &curbuf->b_p_ma) |
1805 | 2825 { |
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
|
2826 # ifdef FEAT_TERMINAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2827 // 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
|
2828 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
|
2829 && 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
|
2830 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2831 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
|
2832 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
|
2833 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2834 # 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
|
2835 # ifdef FEAT_TITLE |
1805 | 2836 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
|
2837 # 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
|
2838 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2839 #ifdef FEAT_TITLE |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2840 // when 'endofline' is changed, redraw the window title |
7 | 2841 else if ((int *)varp == &curbuf->b_p_eol) |
1805 | 2842 { |
2843 redraw_titles(); | |
2844 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2845 // when 'fixeol' is changed, redraw the window title |
6933 | 2846 else if ((int *)varp == &curbuf->b_p_fixeol) |
2847 { | |
2848 redraw_titles(); | |
2849 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2850 // when 'bomb' is changed, redraw the window title and tab page text |
1352 | 2851 else if ((int *)varp == &curbuf->b_p_bomb) |
1805 | 2852 { |
2853 redraw_titles(); | |
2854 } | |
7 | 2855 #endif |
2856 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2857 // when 'bin' is set also set some other options |
7 | 2858 else if ((int *)varp == &curbuf->b_p_bin) |
2859 { | |
2860 set_options_bin(old_value, curbuf->b_p_bin, opt_flags); | |
2861 #ifdef FEAT_TITLE | |
1805 | 2862 redraw_titles(); |
7 | 2863 #endif |
2864 } | |
2865 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2866 // when 'buflisted' changes, trigger autocommands |
7 | 2867 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) |
2868 { | |
2869 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, | |
2870 NULL, NULL, TRUE, curbuf); | |
2871 } | |
2872 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2873 // when 'swf' is set, create swapfile, when reset remove swapfile |
7 | 2874 else if ((int *)varp == &curbuf->b_p_swf) |
2875 { | |
2876 if (curbuf->b_p_swf && p_uc) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2877 ml_open_file(curbuf); // create the swap file |
7 | 2878 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2879 // no need to reset curbuf->b_may_swap, ml_open_file() will check |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2880 // buf->b_p_swf |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2881 mf_close_file(curbuf, TRUE); // remove the swap file |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2882 } |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2883 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2884 // when 'terse' is set change 'shortmess' |
7 | 2885 else if ((int *)varp == &p_terse) |
2886 { | |
2887 char_u *p; | |
2888 | |
2889 p = vim_strchr(p_shm, SHM_SEARCH); | |
2890 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2891 // insert 's' in p_shm |
7 | 2892 if (p_terse && p == NULL) |
2893 { | |
2894 STRCPY(IObuff, p_shm); | |
2895 STRCAT(IObuff, "s"); | |
694 | 2896 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); |
7 | 2897 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2898 // remove 's' from p_shm |
7 | 2899 else if (!p_terse && p != NULL) |
1622 | 2900 STRMOVE(p, p + 1); |
7 | 2901 } |
2902 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2903 // when 'paste' is set or reset also change other options |
7 | 2904 else if ((int *)varp == &p_paste) |
2905 { | |
2906 paste_option_changed(); | |
2907 } | |
2908 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2909 // when 'insertmode' is set from an autocommand need to do work here |
7 | 2910 else if ((int *)varp == &p_im) |
2911 { | |
2912 if (p_im) | |
2913 { | |
2914 if ((State & INSERT) == 0) | |
2915 need_start_insertmode = TRUE; | |
2916 stop_insert_mode = FALSE; | |
2917 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2918 // only reset if it was set previously |
9359
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
9228
diff
changeset
|
2919 else if (old_value) |
7 | 2920 { |
2921 need_start_insertmode = FALSE; | |
2922 stop_insert_mode = TRUE; | |
644 | 2923 if (restart_edit != 0 && mode_displayed) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2924 clear_cmdline = TRUE; // remove "(insert)" |
7 | 2925 restart_edit = 0; |
2926 } | |
2927 } | |
2928 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2929 // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw |
7 | 2930 else if ((int *)varp == &p_ic && p_hls) |
2931 { | |
744 | 2932 redraw_all_later(SOME_VALID); |
7 | 2933 } |
2934 | |
2935 #ifdef FEAT_SEARCH_EXTRA | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2936 // when 'hlsearch' is set or reset: reset no_hlsearch |
7 | 2937 else if ((int *)varp == &p_hls) |
2938 { | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13774
diff
changeset
|
2939 set_no_hlsearch(FALSE); |
7 | 2940 } |
2941 #endif | |
2942 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2943 // when 'scrollbind' is set: snapshot the current position to avoid a jump |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2944 // at the end of normal_cmd() |
7 | 2945 else if ((int *)varp == &curwin->w_p_scb) |
2946 { | |
2947 if (curwin->w_p_scb) | |
5157
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2948 { |
7 | 2949 do_check_scrollbind(FALSE); |
5157
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2950 curwin->w_scbind_pos = curwin->w_topline; |
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2951 } |
7 | 2952 } |
2953 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
2954 #if defined(FEAT_QUICKFIX) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2955 // There can be only one window with 'previewwindow' set. |
7 | 2956 else if ((int *)varp == &curwin->w_p_pvw) |
2957 { | |
2958 if (curwin->w_p_pvw) | |
2959 { | |
2960 win_T *win; | |
2961 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
2962 FOR_ALL_WINDOWS(win) |
7 | 2963 if (win->w_p_pvw && win != curwin) |
2964 { | |
2965 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
|
2966 return N_("E590: A preview window already exists"); |
7 | 2967 } |
2968 } | |
2969 } | |
2970 #endif | |
2971 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2972 // when 'textmode' is set or reset also change 'fileformat' |
7 | 2973 else if ((int *)varp == &curbuf->b_p_tx) |
2974 { | |
2975 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); | |
2976 } | |
2977 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2978 // when 'textauto' is set or reset also change 'fileformats' |
7 | 2979 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
|
2980 { |
7 | 2981 set_string_option_direct((char_u *)"ffs", -1, |
2982 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", | |
694 | 2983 OPT_FREE | opt_flags, 0); |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
16082
diff
changeset
|
2984 } |
7 | 2985 |
2986 /* | |
2987 * When 'lisp' option changes include/exclude '-' in | |
2988 * keyword characters. | |
2989 */ | |
2990 #ifdef FEAT_LISP | |
2991 else if (varp == (char_u *)&(curbuf->b_p_lisp)) | |
2992 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2993 (void)buf_init_chartab(curbuf, FALSE); // ignore errors |
7 | 2994 } |
2995 #endif | |
2996 | |
2997 #ifdef FEAT_TITLE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2998 // 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
|
2999 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
|
3000 { |
1d25a3e8e03c
patch 8.1.0061: window title is wrong after resetting and setting 'title'
Christian Brabandt <cb@256bit.org>
parents:
14057
diff
changeset
|
3001 did_set_title(); |
7 | 3002 } |
3003 #endif | |
3004 | |
3005 else if ((int *)varp == &curbuf->b_changed) | |
3006 { | |
3007 if (!value) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3008 save_file_ff(curbuf); // Buffer is unchanged |
7 | 3009 #ifdef FEAT_TITLE |
1805 | 3010 redraw_titles(); |
7 | 3011 #endif |
3012 modified_was_set = value; | |
3013 } | |
3014 | |
3015 #ifdef BACKSLASH_IN_FILENAME | |
3016 else if ((int *)varp == &p_ssl) | |
3017 { | |
3018 if (p_ssl) | |
3019 { | |
3020 psepc = '/'; | |
3021 psepcN = '\\'; | |
3022 pseps[0] = '/'; | |
3023 } | |
3024 else | |
3025 { | |
3026 psepc = '\\'; | |
3027 psepcN = '/'; | |
3028 pseps[0] = '\\'; | |
3029 } | |
3030 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3031 // need to adjust the file name arguments and buffer names. |
7 | 3032 buflist_slash_adjust(); |
3033 alist_slash_adjust(); | |
3034 # ifdef FEAT_EVAL | |
3035 scriptnames_slash_adjust(); | |
3036 # endif | |
3037 } | |
3038 #endif | |
3039 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3040 // If 'wrap' is set, set w_leftcol to zero. |
7 | 3041 else if ((int *)varp == &curwin->w_p_wrap) |
3042 { | |
3043 if (curwin->w_p_wrap) | |
3044 curwin->w_leftcol = 0; | |
3045 } | |
3046 | |
3047 else if ((int *)varp == &p_ea) | |
3048 { | |
3049 if (p_ea && !old_value) | |
3050 win_equal(curwin, FALSE, 0); | |
3051 } | |
3052 | |
3053 else if ((int *)varp == &p_wiv) | |
3054 { | |
3055 /* | |
3056 * When 'weirdinvert' changed, set/reset 't_xs'. | |
3057 * Then set 'weirdinvert' according to value of 't_xs'. | |
3058 */ | |
3059 if (p_wiv && !old_value) | |
3060 T_XS = (char_u *)"y"; | |
3061 else if (!p_wiv && old_value) | |
3062 T_XS = empty_option; | |
3063 p_wiv = (*T_XS != NUL); | |
3064 } | |
3065 | |
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
|
3066 #ifdef FEAT_BEVAL_GUI |
7 | 3067 else if ((int *)varp == &p_beval) |
3068 { | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3069 if (!balloonEvalForTerm) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3070 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3071 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
|
3072 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
|
3073 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
|
3074 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
|
3075 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3076 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3077 #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
|
3078 #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
|
3079 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
|
3080 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3081 mch_bevalterm_changed(); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3082 } |
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
|
3083 #endif |
820 | 3084 |
3085 #ifdef FEAT_AUTOCHDIR | |
7 | 3086 else if ((int *)varp == &p_acd) |
3087 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3088 // 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
|
3089 DO_AUTOCHDIR; |
7 | 3090 } |
3091 #endif | |
3092 | |
3093 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3094 // 'diff' |
7 | 3095 else if ((int *)varp == &curwin->w_p_diff) |
3096 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3097 // May add or remove the buffer from the list of diff buffers. |
16 | 3098 diff_buf_adjust(curwin); |
3099 # ifdef FEAT_FOLDING | |
7 | 3100 if (foldmethodIsDiff(curwin)) |
3101 foldUpdateAll(curwin); | |
16 | 3102 # endif |
7 | 3103 } |
3104 #endif | |
3105 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3106 #ifdef HAVE_INPUT_METHOD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3107 // 'imdisable' |
7 | 3108 else if ((int *)varp == &p_imdisable) |
3109 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3110 // Only de-activate it here, it will be enabled when changing mode. |
7 | 3111 if (p_imdisable) |
3112 im_set_active(FALSE); | |
3129 | 3113 else if (State & INSERT) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3114 // When the option is set from an autocommand, it may need to take |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3115 // effect right away. |
3129 | 3116 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); |
7 | 3117 } |
3118 #endif | |
3119 | |
744 | 3120 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3121 // 'spell' |
258 | 3122 else if ((int *)varp == &curwin->w_p_spell) |
3123 { | |
3124 if (curwin->w_p_spell) | |
3125 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3126 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
|
3127 |
258 | 3128 if (errmsg != NULL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3129 emsg(_(errmsg)); |
258 | 3130 } |
3131 } | |
3132 #endif | |
3133 | |
7 | 3134 #ifdef FEAT_ARABIC |
3135 if ((int *)varp == &curwin->w_p_arab) | |
3136 { | |
3137 if (curwin->w_p_arab) | |
3138 { | |
3139 /* | |
3140 * 'arabic' is set, handle various sub-settings. | |
3141 */ | |
3142 if (!p_tbidi) | |
3143 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3144 // set rightleft mode |
7 | 3145 if (!curwin->w_p_rl) |
3146 { | |
3147 curwin->w_p_rl = TRUE; | |
3148 changed_window_setting(); | |
3149 } | |
3150 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3151 // Enable Arabic shaping (major part of what Arabic requires) |
7 | 3152 if (!p_arshape) |
3153 { | |
3154 p_arshape = TRUE; | |
3155 redraw_later_clear(); | |
3156 } | |
3157 } | |
3158 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3159 // Arabic requires a utf-8 encoding, inform the user if its not |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3160 // set. |
7 | 3161 if (STRCMP(p_enc, "utf-8") != 0) |
16 | 3162 { |
1848 | 3163 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); |
3164 | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
3165 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
|
3166 msg_attr(_(w_arabic), HL_ATTR(HLF_W)); |
1848 | 3167 #ifdef FEAT_EVAL |
3168 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); | |
3169 #endif | |
16 | 3170 } |
7 | 3171 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3172 // set 'delcombine' |
7 | 3173 p_deco = TRUE; |
3174 | |
3175 # ifdef FEAT_KEYMAP | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3176 // Force-set the necessary keymap for arabic |
7 | 3177 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", |
3178 OPT_LOCAL); | |
3179 # endif | |
3180 } | |
3181 else | |
3182 { | |
3183 /* | |
3184 * 'arabic' is reset, handle various sub-settings. | |
3185 */ | |
3186 if (!p_tbidi) | |
3187 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3188 // reset rightleft mode |
7 | 3189 if (curwin->w_p_rl) |
3190 { | |
3191 curwin->w_p_rl = FALSE; | |
3192 changed_window_setting(); | |
3193 } | |
3194 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3195 // 'arabicshape' isn't reset, it is a global option and |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3196 // another window may still need it "on". |
7 | 3197 } |
3198 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3199 // 'delcombine' isn't reset, it is a global option and another |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3200 // window may still want it "on". |
7 | 3201 |
3202 # ifdef FEAT_KEYMAP | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3203 // Revert to the default keymap |
7 | 3204 curbuf->b_p_iminsert = B_IMODE_NONE; |
3205 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; | |
3206 # endif | |
3207 } | |
3443 | 3208 } |
3209 | |
1958 | 3210 #endif |
3211 | |
17827
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3212 #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
|
3213 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
|
3214 || (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
|
3215 && gui.in_use |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3216 && (*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
|
3217 && curbuf->b_signlist != NULL) |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3218 { |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3219 // 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
|
3220 // '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
|
3221 // 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
|
3222 // 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
|
3223 // '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
|
3224 // (optimization). |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3225 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
|
3226 redraw_all_later(CLEAR); |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3227 } |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3228 #endif |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3229 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3230 #ifdef FEAT_TERMGUICOLORS |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3231 // 'termguicolors' |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3232 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
|
3233 { |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3234 # ifdef FEAT_VTP |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3235 // 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
|
3236 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
|
3237 # 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
|
3238 !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
|
3239 # 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
|
3240 !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
|
3241 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3242 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
|
3243 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
|
3244 } |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3245 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
|
3246 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
|
3247 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3248 # ifdef FEAT_GUI |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3249 if (!gui.in_use && !gui.starting) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3250 # endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3251 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
|
3252 # ifdef FEAT_VTP |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3253 // 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
|
3254 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
|
3255 { |
2bebc49116fd
patch 8.1.0123: MS-Windows: colors are wrong after setting 'notgc'
Christian Brabandt <cb@256bit.org>
parents:
14194
diff
changeset
|
3256 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
|
3257 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
|
3258 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
|
3259 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3260 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3261 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3262 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3263 |
7 | 3264 /* |
3265 * End of handling side effects for bool options. | |
3266 */ | |
3267 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3268 // after handling side effects, call autocommand |
6935 | 3269 |
7 | 3270 options[opt_idx].flags |= P_WAS_SET; |
3271 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3272 #if defined(FEAT_EVAL) |
19405
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3273 apply_optionset_autocmd(opt_idx, opt_flags, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3274 (long)(old_value ? TRUE : FALSE), |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3275 (long)(old_global_value ? TRUE : FALSE), |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3276 (long)(value ? TRUE : FALSE), NULL); |
6935 | 3277 #endif |
3278 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3279 comp_col(); // in case 'ruler' or 'showcmd' changed |
3443 | 3280 if (curwin->w_curswant != MAXCOL |
6669 | 3281 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 3282 curwin->w_set_curswant = TRUE; |
24079
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3283 |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3284 if ((opt_flags & OPT_NO_REDRAW) == 0) |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3285 check_redraw(options[opt_idx].flags); |
7 | 3286 |
3287 return NULL; | |
3288 } | |
3289 | |
3290 /* | |
3291 * Set the value of a number option, and take care of side effects. | |
3292 * Returns NULL for success, or an error message for an error. | |
3293 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3294 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3295 set_num_option( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3296 int opt_idx, // index in options[] table |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3297 char_u *varp, // pointer to the option variable |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3298 long value, // new value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3299 char *errbuf, // buffer for error messages |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3300 size_t errbuflen, // length of "errbuf" |
24079
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3301 int opt_flags) // OPT_LOCAL, OPT_GLOBAL, |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3302 // OPT_MODELINE, etc. |
7 | 3303 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3304 char *errmsg = NULL; |
7 | 3305 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
|
3306 #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
|
3307 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
|
3308 // 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
|
3309 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3310 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
|
3311 long old_Columns = Columns; // remember old Columns |
7 | 3312 long *pp = (long *)varp; |
3313 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3314 // Disallow changing some options from secure mode. |
634 | 3315 if ((secure |
3316 #ifdef HAVE_SANDBOX | |
3317 || sandbox != 0 | |
3318 #endif | |
3319 ) && (options[opt_idx].flags & P_SECURE)) | |
3320 return e_secure; | |
7 | 3321 |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3322 #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
|
3323 // Save the global value before changing anything. This is needed as for |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3324 // a global-only option setting the "local value" in fact sets the global |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3325 // 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
|
3326 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
|
3327 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
|
3328 OPT_GLOBAL); |
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3329 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3330 |
7 | 3331 *pp = value; |
3332 #ifdef FEAT_EVAL | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3333 // 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
|
3334 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 3335 #endif |
634 | 3336 #ifdef FEAT_GUI |
3337 need_mouse_correct = TRUE; | |
3338 #endif | |
7 | 3339 |
3740 | 3340 if (curbuf->b_p_sw < 0) |
7 | 3341 { |
3342 errmsg = e_positive; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3343 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3344 // 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
|
3345 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
|
3346 ? 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
|
3347 : curbuf->b_p_ts; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3348 #else |
7 | 3349 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
|
3350 #endif |
7 | 3351 } |
3352 | |
3353 /* | |
3354 * Number options that need some action when changed | |
3355 */ | |
3356 if (pp == &p_wh || pp == &p_hh) | |
3357 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3358 // 'winheight' and 'helpheight' |
7 | 3359 if (p_wh < 1) |
3360 { | |
3361 errmsg = e_positive; | |
3362 p_wh = 1; | |
3363 } | |
3364 if (p_wmh > p_wh) | |
3365 { | |
3366 errmsg = e_winheight; | |
3367 p_wh = p_wmh; | |
3368 } | |
3369 if (p_hh < 0) | |
3370 { | |
3371 errmsg = e_positive; | |
3372 p_hh = 0; | |
3373 } | |
3374 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3375 // Change window height NOW |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10340
diff
changeset
|
3376 if (!ONE_WINDOW) |
7 | 3377 { |
3378 if (pp == &p_wh && curwin->w_height < p_wh) | |
3379 win_setheight((int)p_wh); | |
3380 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) | |
3381 win_setheight((int)p_hh); | |
3382 } | |
3383 } | |
3384 else if (pp == &p_wmh) | |
3385 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3386 // 'winminheight' |
7 | 3387 if (p_wmh < 0) |
3388 { | |
3389 errmsg = e_positive; | |
3390 p_wmh = 0; | |
3391 } | |
3392 if (p_wmh > p_wh) | |
3393 { | |
3394 errmsg = e_winheight; | |
3395 p_wmh = p_wh; | |
3396 } | |
3397 win_setminheight(); | |
3398 } | |
13 | 3399 else if (pp == &p_wiw) |
7 | 3400 { |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3401 // 'winwidth' |
7 | 3402 if (p_wiw < 1) |
3403 { | |
3404 errmsg = e_positive; | |
3405 p_wiw = 1; | |
3406 } | |
3407 if (p_wmw > p_wiw) | |
3408 { | |
3409 errmsg = e_winwidth; | |
3410 p_wiw = p_wmw; | |
3411 } | |
3412 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3413 // Change window width NOW |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10340
diff
changeset
|
3414 if (!ONE_WINDOW && curwin->w_width < p_wiw) |
7 | 3415 win_setwidth((int)p_wiw); |
3416 } | |
3417 else if (pp == &p_wmw) | |
3418 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3419 // 'winminwidth' |
7 | 3420 if (p_wmw < 0) |
3421 { | |
3422 errmsg = e_positive; | |
3423 p_wmw = 0; | |
3424 } | |
3425 if (p_wmw > p_wiw) | |
3426 { | |
3427 errmsg = e_winwidth; | |
3428 p_wmw = p_wiw; | |
3429 } | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3430 win_setminwidth(); |
7 | 3431 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
3432 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3433 // (re)set last window status line |
7 | 3434 else if (pp == &p_ls) |
3435 { | |
3436 last_status(FALSE); | |
3437 } | |
670 | 3438 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3439 // (re)set tab page line |
677 | 3440 else if (pp == &p_stal) |
670 | 3441 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3442 shell_new_rows(); // recompute window positions and heights |
670 | 3443 } |
7 | 3444 |
3445 #ifdef FEAT_GUI | |
3446 else if (pp == &p_linespace) | |
3447 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3448 // Recompute gui.char_height and resize the Vim window to keep the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3449 // same number of lines. |
444 | 3450 if (gui.in_use && gui_mch_adjust_charheight() == OK) |
813 | 3451 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); |
7 | 3452 } |
3453 #endif | |
3454 | |
3455 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3456 // 'foldlevel' |
7 | 3457 else if (pp == &curwin->w_p_fdl) |
3458 { | |
3459 if (curwin->w_p_fdl < 0) | |
3460 curwin->w_p_fdl = 0; | |
3461 newFoldLevel(); | |
3462 } | |
3463 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3464 // 'foldminlines' |
7 | 3465 else if (pp == &curwin->w_p_fml) |
3466 { | |
3467 foldUpdateAll(curwin); | |
3468 } | |
3469 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3470 // 'foldnestmax' |
7 | 3471 else if (pp == &curwin->w_p_fdn) |
3472 { | |
3473 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) | |
3474 foldUpdateAll(curwin); | |
3475 } | |
3476 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3477 // 'foldcolumn' |
7 | 3478 else if (pp == &curwin->w_p_fdc) |
3479 { | |
3480 if (curwin->w_p_fdc < 0) | |
3481 { | |
3482 errmsg = e_positive; | |
3483 curwin->w_p_fdc = 0; | |
3484 } | |
3485 else if (curwin->w_p_fdc > 12) | |
3486 { | |
3487 errmsg = e_invarg; | |
3488 curwin->w_p_fdc = 12; | |
3489 } | |
3490 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3491 #endif // FEAT_FOLDING |
5438 | 3492 |
3493 #if defined(FEAT_FOLDING) || defined(FEAT_CINDENT) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3494 // 'shiftwidth' or 'tabstop' |
7 | 3495 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) |
3496 { | |
5438 | 3497 # ifdef FEAT_FOLDING |
7 | 3498 if (foldmethodIsIndent(curwin)) |
3499 foldUpdateAll(curwin); | |
5438 | 3500 # endif |
3501 # ifdef FEAT_CINDENT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3502 // When 'shiftwidth' changes, or it's zero and 'tabstop' changes: |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3503 // parse 'cinoptions'. |
5438 | 3504 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) |
3505 parse_cino(curbuf); | |
3506 # endif | |
3507 } | |
3508 #endif | |
7 | 3509 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3510 // 'maxcombine' |
714 | 3511 else if (pp == &p_mco) |
3512 { | |
3513 if (p_mco > MAX_MCO) | |
3514 p_mco = MAX_MCO; | |
3515 else if (p_mco < 0) | |
3516 p_mco = 0; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3517 screenclear(); // will re-allocate the screen |
714 | 3518 } |
3519 | |
7 | 3520 else if (pp == &curbuf->b_p_iminsert) |
3521 { | |
3522 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) | |
3523 { | |
3524 errmsg = e_invarg; | |
3525 curbuf->b_p_iminsert = B_IMODE_NONE; | |
3526 } | |
3527 p_iminsert = curbuf->b_p_iminsert; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3528 if (termcap_active) // don't do this in the alternate screen |
7 | 3529 showmode(); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
3530 #if defined(FEAT_KEYMAP) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3531 // Show/unshow value of 'keymap' in status lines. |
7 | 3532 status_redraw_curbuf(); |
3533 #endif | |
3534 } | |
3535 | |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3536 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3537 // 'imstyle' |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3538 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
|
3539 { |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3540 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
|
3541 errmsg = e_invarg; |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3542 } |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3543 #endif |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3544 |
164 | 3545 else if (pp == &p_window) |
3546 { | |
3547 if (p_window < 1) | |
3548 p_window = 1; | |
3549 else if (p_window >= Rows) | |
3550 p_window = Rows - 1; | |
3551 } | |
3552 | |
7 | 3553 else if (pp == &curbuf->b_p_imsearch) |
3554 { | |
3555 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) | |
3556 { | |
3557 errmsg = e_invarg; | |
3558 curbuf->b_p_imsearch = B_IMODE_NONE; | |
3559 } | |
3560 p_imsearch = curbuf->b_p_imsearch; | |
3561 } | |
3562 | |
3563 #ifdef FEAT_TITLE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3564 // if 'titlelen' has changed, redraw the title |
7 | 3565 else if (pp == &p_titlelen) |
3566 { | |
3567 if (p_titlelen < 0) | |
3568 { | |
3569 errmsg = e_positive; | |
3570 p_titlelen = 85; | |
3571 } | |
3572 if (starting != NO_SCREEN && old_value != p_titlelen) | |
3573 need_maketitle = TRUE; | |
3574 } | |
3575 #endif | |
3576 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3577 // if p_ch changed value, change the command line height |
7 | 3578 else if (pp == &p_ch) |
3579 { | |
3580 if (p_ch < 1) | |
3581 { | |
3582 errmsg = e_positive; | |
3583 p_ch = 1; | |
3584 } | |
1404 | 3585 if (p_ch > Rows - min_rows() + 1) |
3586 p_ch = Rows - min_rows() + 1; | |
7 | 3587 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3588 // Only compute the new window layout when startup has been |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3589 // completed. Otherwise the frame sizes may be wrong. |
7 | 3590 if (p_ch != old_value && full_screen |
3591 #ifdef FEAT_GUI | |
3592 && !gui.starting | |
3593 #endif | |
3594 ) | |
824 | 3595 command_height(); |
7 | 3596 } |
3597 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3598 // when 'updatecount' changes from zero to non-zero, open swap files |
7 | 3599 else if (pp == &p_uc) |
3600 { | |
3601 if (p_uc < 0) | |
3602 { | |
3603 errmsg = e_positive; | |
3604 p_uc = 100; | |
3605 } | |
3606 if (p_uc && !old_value) | |
3607 ml_open_files(); | |
3608 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3609 #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
|
3610 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
|
3611 { |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3612 if (curwin->w_p_cole < 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3613 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3614 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
|
3615 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
|
3616 } |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3617 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
|
3618 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3619 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
|
3620 curwin->w_p_cole = 3; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3621 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3622 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3623 #endif |
16 | 3624 #ifdef MZSCHEME_GUI_THREADS |
14 | 3625 else if (pp == &p_mzq) |
3626 mzvim_reset_timer(); | |
3627 #endif | |
7 | 3628 |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3629 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3630 // 'pyxversion' |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3631 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
|
3632 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3633 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
|
3634 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
|
3635 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3636 #endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3637 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3638 // sync undo before 'undolevels' changes |
7 | 3639 else if (pp == &p_ul) |
3640 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3641 // use the old value, otherwise u_sync() may not work properly |
7 | 3642 p_ul = old_value; |
825 | 3643 u_sync(TRUE); |
7 | 3644 p_ul = value; |
3645 } | |
5446 | 3646 else if (pp == &curbuf->b_p_ul) |
3647 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3648 // use the old value, otherwise u_sync() may not work properly |
5446 | 3649 curbuf->b_p_ul = old_value; |
3650 u_sync(TRUE); | |
3651 curbuf->b_p_ul = value; | |
3652 } | |
7 | 3653 |
13 | 3654 #ifdef FEAT_LINEBREAK |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3655 // 'numberwidth' must be positive |
13 | 3656 else if (pp == &curwin->w_p_nuw) |
3657 { | |
3658 if (curwin->w_p_nuw < 1) | |
3659 { | |
3660 errmsg = e_positive; | |
3661 curwin->w_p_nuw = 1; | |
3662 } | |
17229
f1c7b7a4d9e4
patch 8.1.1614: 'numberwidth' can only go up to 10
Bram Moolenaar <Bram@vim.org>
parents:
17176
diff
changeset
|
3663 if (curwin->w_p_nuw > 20) |
13 | 3664 { |
3665 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
|
3666 curwin->w_p_nuw = 20; |
13 | 3667 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3668 curwin->w_nrwidth_line_count = 0; // trigger a redraw |
13 | 3669 } |
3670 #endif | |
3671 | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3672 else if (pp == &curbuf->b_p_tw) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3673 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3674 if (curbuf->b_p_tw < 0) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3675 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3676 errmsg = e_positive; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3677 curbuf->b_p_tw = 0; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3678 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3679 #ifdef FEAT_SYN_HL |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3680 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3681 win_T *wp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3682 tabpage_T *tp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3683 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3684 FOR_ALL_TAB_WINDOWS(tp, wp) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3685 check_colorcolumn(wp); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3686 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3687 #endif |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3688 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3689 |
7 | 3690 /* |
3691 * Check the bounds for numeric options here | |
3692 */ | |
3693 if (Rows < min_rows() && full_screen) | |
3694 { | |
3695 if (errbuf != NULL) | |
3696 { | |
274 | 3697 vim_snprintf((char *)errbuf, errbuflen, |
3698 _("E593: Need at least %d lines"), min_rows()); | |
7 | 3699 errmsg = errbuf; |
3700 } | |
3701 Rows = min_rows(); | |
3702 } | |
3703 if (Columns < MIN_COLUMNS && full_screen) | |
3704 { | |
3705 if (errbuf != NULL) | |
3706 { | |
274 | 3707 vim_snprintf((char *)errbuf, errbuflen, |
3708 _("E594: Need at least %d columns"), MIN_COLUMNS); | |
7 | 3709 errmsg = errbuf; |
3710 } | |
3711 Columns = MIN_COLUMNS; | |
3712 } | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
5039
diff
changeset
|
3713 limit_screen_size(); |
7 | 3714 |
3715 /* | |
3716 * If the screen (shell) height has been changed, assume it is the | |
3717 * physical screenheight. | |
3718 */ | |
3719 if (old_Rows != Rows || old_Columns != Columns) | |
3720 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3721 // Changing the screen size is not allowed while updating the screen. |
7 | 3722 if (updating_screen) |
3723 *pp = old_value; | |
3724 else if (full_screen | |
3725 #ifdef FEAT_GUI | |
3726 && !gui.starting | |
3727 #endif | |
3728 ) | |
3729 set_shellsize((int)Columns, (int)Rows, TRUE); | |
3730 else | |
3731 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3732 // Postpone the resizing; check the size and cmdline position for |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3733 // messages. |
7 | 3734 check_shellsize(); |
3735 if (cmdline_row > Rows - p_ch && Rows > p_ch) | |
3736 cmdline_row = Rows - p_ch; | |
3737 } | |
857 | 3738 if (p_window >= Rows || !option_was_set((char_u *)"window")) |
164 | 3739 p_window = Rows - 1; |
7 | 3740 } |
3741 | |
3742 if (curbuf->b_p_ts <= 0) | |
3743 { | |
3744 errmsg = e_positive; | |
3745 curbuf->b_p_ts = 8; | |
3746 } | |
3747 if (p_tm < 0) | |
3748 { | |
3749 errmsg = e_positive; | |
3750 p_tm = 0; | |
3751 } | |
3752 if ((curwin->w_p_scr <= 0 | |
3753 || (curwin->w_p_scr > curwin->w_height | |
3754 && curwin->w_height > 0)) | |
3755 && full_screen) | |
3756 { | |
3757 if (pp == &(curwin->w_p_scr)) | |
3758 { | |
3759 if (curwin->w_p_scr != 0) | |
3760 errmsg = e_scroll; | |
3761 win_comp_scroll(curwin); | |
3762 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3763 // If 'scroll' became invalid because of a side effect silently adjust |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3764 // it. |
7 | 3765 else if (curwin->w_p_scr <= 0) |
3766 curwin->w_p_scr = 1; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3767 else // curwin->w_p_scr > curwin->w_height |
7 | 3768 curwin->w_p_scr = curwin->w_height; |
3769 } | |
1726 | 3770 if (p_hi < 0) |
3771 { | |
3772 errmsg = e_positive; | |
3773 p_hi = 0; | |
3774 } | |
5991 | 3775 else if (p_hi > 10000) |
3776 { | |
3777 errmsg = e_invarg; | |
3778 p_hi = 10000; | |
3779 } | |
4444 | 3780 if (p_re < 0 || p_re > 2) |
3781 { | |
3782 errmsg = e_invarg; | |
3783 p_re = 0; | |
3784 } | |
7 | 3785 if (p_report < 0) |
3786 { | |
3787 errmsg = e_positive; | |
3788 p_report = 1; | |
3789 } | |
532 | 3790 if ((p_sj < -100 || p_sj >= Rows) && full_screen) |
7 | 3791 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3792 if (Rows != old_Rows) // Rows changed, just adjust p_sj |
7 | 3793 p_sj = Rows / 2; |
3794 else | |
3795 { | |
3796 errmsg = e_scroll; | |
3797 p_sj = 1; | |
3798 } | |
3799 } | |
3800 if (p_so < 0 && full_screen) | |
3801 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
3802 errmsg = e_positive; |
7 | 3803 p_so = 0; |
3804 } | |
3805 if (p_siso < 0 && full_screen) | |
3806 { | |
3807 errmsg = e_positive; | |
3808 p_siso = 0; | |
3809 } | |
3810 #ifdef FEAT_CMDWIN | |
3811 if (p_cwh < 1) | |
3812 { | |
3813 errmsg = e_positive; | |
3814 p_cwh = 1; | |
3815 } | |
3816 #endif | |
3817 if (p_ut < 0) | |
3818 { | |
3819 errmsg = e_positive; | |
3820 p_ut = 2000; | |
3821 } | |
3822 if (p_ss < 0) | |
3823 { | |
3824 errmsg = e_positive; | |
3825 p_ss = 0; | |
3826 } | |
3827 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3828 // May set global value for local option. |
7 | 3829 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
3830 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; | |
3831 | |
3832 options[opt_idx].flags |= P_WAS_SET; | |
3833 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3834 #if defined(FEAT_EVAL) |
19405
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3835 apply_optionset_autocmd(opt_idx, opt_flags, old_value, old_global_value, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3836 value, errmsg); |
6935 | 3837 #endif |
3838 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3839 comp_col(); // in case 'columns' or 'ls' changed |
3443 | 3840 if (curwin->w_curswant != MAXCOL |
6669 | 3841 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 3842 curwin->w_set_curswant = TRUE; |
24079
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3843 if ((opt_flags & OPT_NO_REDRAW) == 0) |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3844 check_redraw(options[opt_idx].flags); |
7 | 3845 |
3846 return errmsg; | |
3847 } | |
3848 | |
3849 /* | |
3850 * Called after an option changed: check if something needs to be redrawn. | |
3851 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
3852 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3853 check_redraw(long_u flags) |
7 | 3854 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3855 // Careful: P_RCLR and P_RALL are a combination of other P_ flags |
3263 | 3856 int doclear = (flags & P_RCLR) == P_RCLR; |
3857 int all = ((flags & P_RALL) == P_RALL || doclear); | |
7 | 3858 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3859 if ((flags & P_RSTAT) || all) // mark all status lines dirty |
7 | 3860 status_redraw_all(); |
3861 | |
3862 if ((flags & P_RBUF) || (flags & P_RWIN) || all) | |
3863 changed_window_setting(); | |
3864 if (flags & P_RBUF) | |
3865 redraw_curbuf_later(NOT_VALID); | |
10456
536a7d49249c
commit https://github.com/vim/vim/commit/a2477fd3490c1166522631eee53c57d34321086a
Christian Brabandt <cb@256bit.org>
parents:
10424
diff
changeset
|
3866 if (flags & P_RWINONLY) |
536a7d49249c
commit https://github.com/vim/vim/commit/a2477fd3490c1166522631eee53c57d34321086a
Christian Brabandt <cb@256bit.org>
parents:
10424
diff
changeset
|
3867 redraw_later(NOT_VALID); |
3263 | 3868 if (doclear) |
7 | 3869 redraw_all_later(CLEAR); |
3870 else if (all) | |
3871 redraw_all_later(NOT_VALID); | |
3872 } | |
3873 | |
3874 /* | |
3875 * Find index for option 'arg'. | |
3876 * Return -1 if not found. | |
3877 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
3878 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3879 findoption(char_u *arg) |
7 | 3880 { |
3881 int opt_idx; | |
3882 char *s, *p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3883 static short quick_tab[27] = {0, 0}; // quick access table |
7 | 3884 int is_term_opt; |
3885 | |
3886 /* | |
3887 * For first call: Initialize the quick-access table. | |
3888 * It contains the index for the first option that starts with a certain | |
3889 * letter. There are 26 letters, plus the first "t_" option. | |
3890 */ | |
3891 if (quick_tab[1] == 0) | |
3892 { | |
3893 p = options[0].fullname; | |
3894 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
3895 { | |
3896 if (s[0] != p[0]) | |
3897 { | |
3898 if (s[0] == 't' && s[1] == '_') | |
3899 quick_tab[26] = opt_idx; | |
3900 else | |
3901 quick_tab[CharOrdLow(s[0])] = opt_idx; | |
3902 } | |
3903 p = s; | |
3904 } | |
3905 } | |
3906 | |
3907 /* | |
3908 * Check for name starting with an illegal character. | |
3909 */ | |
3910 #ifdef EBCDIC | |
3911 if (!islower(arg[0])) | |
3912 #else | |
3913 if (arg[0] < 'a' || arg[0] > 'z') | |
3914 #endif | |
3915 return -1; | |
3916 | |
3917 is_term_opt = (arg[0] == 't' && arg[1] == '_'); | |
3918 if (is_term_opt) | |
3919 opt_idx = quick_tab[26]; | |
3920 else | |
3921 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
3922 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
3923 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3924 if (STRCMP(arg, s) == 0) // match full name |
7 | 3925 break; |
3926 } | |
3927 if (s == NULL && !is_term_opt) | |
3928 { | |
3929 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
3930 for ( ; options[opt_idx].fullname != NULL; opt_idx++) | |
3931 { | |
3932 s = options[opt_idx].shortname; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3933 if (s != NULL && STRCMP(arg, s) == 0) // match short name |
7 | 3934 break; |
3935 s = NULL; | |
3936 } | |
3937 } | |
3938 if (s == NULL) | |
3939 opt_idx = -1; | |
3940 return opt_idx; | |
3941 } | |
3942 | |
14 | 3943 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME) |
7 | 3944 /* |
3945 * Get the value for an option. | |
3946 * | |
3947 * Returns: | |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3948 * Number option: gov_number, *numval gets value. |
23467
826a6406ea7b
patch 8.2.2276: list of distributed files is outdated
Bram Moolenaar <Bram@vim.org>
parents:
23422
diff
changeset
|
3949 * Toggle option: gov_bool, *numval gets value. |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3950 * String option: gov_string, *stringval gets allocated string. |
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3951 * Hidden Number option: gov_hidden_number. |
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3952 * Hidden Toggle option: gov_hidden_bool. |
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3953 * Hidden String option: gov_hidden_string. |
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3954 * Unknown option: gov_unknown. |
7 | 3955 */ |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3956 getoption_T |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3957 get_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3958 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3959 long *numval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3960 char_u **stringval, // NULL when only checking existence |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3961 int opt_flags) |
7 | 3962 { |
3963 int opt_idx; | |
3964 char_u *varp; | |
3965 | |
3966 opt_idx = findoption(name); | |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3967 if (opt_idx < 0) // option not in the table |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3968 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3969 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3970 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3971 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_' |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3972 && (key = find_key_option(name, FALSE)) != 0) |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3973 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3974 char_u key_name[2]; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3975 char_u *p; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3976 |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3977 // check for a terminal option |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3978 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3979 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3980 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
|
3981 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
|
3982 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3983 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3984 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3985 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
|
3986 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
|
3987 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3988 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
|
3989 if (p != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3990 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3991 if (stringval != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3992 *stringval = vim_strsave(p); |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3993 return gov_string; |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3994 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3995 } |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3996 return gov_unknown; |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3997 } |
7 | 3998 |
3999 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | |
4000 | |
4001 if (options[opt_idx].flags & P_STRING) | |
4002 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4003 if (varp == NULL) // hidden option |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4004 return gov_hidden_string; |
7 | 4005 if (stringval != NULL) |
4006 { | |
4007 #ifdef FEAT_CRYPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4008 // never return the value of the crypt key |
1622 | 4009 if ((char_u **)varp == &curbuf->b_p_key |
4010 && **(char_u **)(varp) != NUL) | |
7 | 4011 *stringval = vim_strsave((char_u *)"*****"); |
4012 else | |
4013 #endif | |
4014 *stringval = vim_strsave(*(char_u **)(varp)); | |
4015 } | |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4016 return gov_string; |
7 | 4017 } |
4018 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4019 if (varp == NULL) // hidden option |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4020 return (options[opt_idx].flags & P_NUM) |
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4021 ? gov_hidden_number : gov_hidden_bool; |
7 | 4022 if (options[opt_idx].flags & P_NUM) |
4023 *numval = *(long *)varp; | |
4024 else | |
4025 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4026 // Special case: 'modified' is b_changed, but we also want to consider |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4027 // it set when 'ff' or 'fenc' changed. |
7 | 4028 if ((int *)varp == &curbuf->b_changed) |
4029 *numval = curbufIsChanged(); | |
4030 else | |
9395
beab399e3883
commit https://github.com/vim/vim/commit/2acfbed9dbea990f129535de7ff3df360365130b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4031 *numval = (long) *(int *)varp; |
7 | 4032 } |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4033 return (options[opt_idx].flags & P_NUM) ? gov_number : gov_bool; |
7 | 4034 } |
4035 #endif | |
4036 | |
5610 | 4037 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
4350 | 4038 /* |
4039 * Returns the option attributes and its value. Unlike the above function it | |
4040 * will return either global value or local value of the option depending on | |
4041 * what was requested, but it will never return global value if it was | |
4042 * requested to return local one and vice versa. Neither it will return | |
4043 * buffer-local value if it was requested to return window-local one. | |
4044 * | |
4045 * Pretends that option is absent if it is not present in the requested scope | |
4046 * (i.e. has no global, window-local or buffer-local value depending on | |
4047 * opt_type). Uses | |
4048 * | |
4049 * Returned flags: | |
5867 | 4050 * 0 hidden or unknown option, also option that does not have requested |
4051 * type (see SREQ_* in vim.h) | |
4350 | 4052 * see SOPT_* in vim.h for other flags |
4053 * | |
4054 * Possible opt_type values: see SREQ_* in vim.h | |
4055 */ | |
4056 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4057 get_option_value_strict( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4058 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4059 long *numval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4060 char_u **stringval, // NULL when only obtaining attributes |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4061 int opt_type, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4062 void *from) |
4350 | 4063 { |
4064 int opt_idx; | |
4367 | 4065 char_u *varp = NULL; |
4350 | 4066 struct vimoption *p; |
4067 int r = 0; | |
4068 | |
4069 opt_idx = findoption(name); | |
4070 if (opt_idx < 0) | |
4071 return 0; | |
4072 | |
4073 p = &(options[opt_idx]); | |
4074 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4075 // Hidden option |
4350 | 4076 if (p->var == NULL) |
4077 return 0; | |
4078 | |
4079 if (p->flags & P_BOOL) | |
4080 r |= SOPT_BOOL; | |
4081 else if (p->flags & P_NUM) | |
4082 r |= SOPT_NUM; | |
4083 else if (p->flags & P_STRING) | |
4084 r |= SOPT_STRING; | |
4085 | |
4086 if (p->indir == PV_NONE) | |
4087 { | |
4088 if (opt_type == SREQ_GLOBAL) | |
4089 r |= SOPT_GLOBAL; | |
4090 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4091 return 0; // Did not request global-only option |
4350 | 4092 } |
4093 else | |
4094 { | |
4095 if (p->indir & PV_BOTH) | |
4096 r |= SOPT_GLOBAL; | |
4097 else if (opt_type == SREQ_GLOBAL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4098 return 0; // Requested global option |
4350 | 4099 |
4100 if (p->indir & PV_WIN) | |
4101 { | |
4102 if (opt_type == SREQ_BUF) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4103 return 0; // Did not request window-local option |
4350 | 4104 else |
4105 r |= SOPT_WIN; | |
4106 } | |
4107 else if (p->indir & PV_BUF) | |
4108 { | |
4109 if (opt_type == SREQ_WIN) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4110 return 0; // Did not request buffer-local option |
4350 | 4111 else |
4112 r |= SOPT_BUF; | |
4113 } | |
4114 } | |
4115 | |
4116 if (stringval == NULL) | |
4117 return r; | |
4118 | |
4119 if (opt_type == SREQ_GLOBAL) | |
4120 varp = p->var; | |
4121 else | |
4122 { | |
4123 if (opt_type == SREQ_BUF) | |
4124 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4125 // Special case: 'modified' is b_changed, but we also want to |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4126 // consider it set when 'ff' or 'fenc' changed. |
4350 | 4127 if (p->indir == PV_MOD) |
4128 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4129 *numval = bufIsChanged((buf_T *)from); |
4350 | 4130 varp = NULL; |
4131 } | |
4132 #ifdef FEAT_CRYPT | |
4133 else if (p->indir == PV_KEY) | |
4134 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4135 // never return the value of the crypt key |
4350 | 4136 *stringval = NULL; |
4137 varp = NULL; | |
4138 } | |
4139 #endif | |
4140 else | |
4141 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4142 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
|
4143 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4144 // 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
|
4145 curbuf = (buf_T *)from; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4146 curwin->w_buffer = curbuf; |
4350 | 4147 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
|
4148 curbuf = save_curbuf; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4149 curwin->w_buffer = curbuf; |
4350 | 4150 } |
4151 } | |
4152 else if (opt_type == SREQ_WIN) | |
4153 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4154 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
|
4155 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4156 curwin = (win_T *)from; |
4350 | 4157 curbuf = curwin->w_buffer; |
4158 varp = get_varp(p); | |
4159 curwin = save_curwin; | |
4160 curbuf = curwin->w_buffer; | |
4161 } | |
4162 if (varp == p->var) | |
4163 return (r | SOPT_UNSET); | |
4164 } | |
4165 | |
4166 if (varp != NULL) | |
4167 { | |
4168 if (p->flags & P_STRING) | |
4169 *stringval = vim_strsave(*(char_u **)(varp)); | |
4170 else if (p->flags & P_NUM) | |
4171 *numval = *(long *) varp; | |
4172 else | |
4173 *numval = *(int *)varp; | |
4174 } | |
4175 | |
4176 return r; | |
4177 } | |
5610 | 4178 |
4179 /* | |
6243 | 4180 * Iterate over options. First argument is a pointer to a pointer to a |
4181 * structure inside options[] array, second is option type like in the above | |
4182 * function. | |
5610 | 4183 * |
6243 | 4184 * If first argument points to NULL it is assumed that iteration just started |
5610 | 4185 * and caller needs the very first value. |
6243 | 4186 * If first argument points to the end marker function returns NULL and sets |
5610 | 4187 * first argument to NULL. |
4188 * | |
4189 * Returns full option name for current option on each call. | |
4190 */ | |
4191 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4192 option_iter_next(void **option, int opt_type) |
5610 | 4193 { |
4194 struct vimoption *ret = NULL; | |
4195 do | |
4196 { | |
4197 if (*option == NULL) | |
4198 *option = (void *) options; | |
4199 else if (((struct vimoption *) (*option))->fullname == NULL) | |
4200 { | |
4201 *option = NULL; | |
4202 return NULL; | |
4203 } | |
4204 else | |
4205 *option = (void *) (((struct vimoption *) (*option)) + 1); | |
4206 | |
4207 ret = ((struct vimoption *) (*option)); | |
4208 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4209 // Hidden option |
5610 | 4210 if (ret->var == NULL) |
4211 { | |
4212 ret = NULL; | |
4213 continue; | |
4214 } | |
4215 | |
4216 switch (opt_type) | |
4217 { | |
4218 case SREQ_GLOBAL: | |
4219 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH)) | |
4220 ret = NULL; | |
4221 break; | |
4222 case SREQ_BUF: | |
4223 if (!(ret->indir & PV_BUF)) | |
4224 ret = NULL; | |
4225 break; | |
4226 case SREQ_WIN: | |
4227 if (!(ret->indir & PV_WIN)) | |
4228 ret = NULL; | |
4229 break; | |
4230 default: | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
4231 internal_error("option_iter_next()"); |
5610 | 4232 return NULL; |
4233 } | |
4234 } | |
4235 while (ret == NULL); | |
4236 | |
4237 return (char_u *)ret->fullname; | |
4238 } | |
4350 | 4239 #endif |
4240 | |
7 | 4241 /* |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4242 * Return the flags for the option at 'opt_idx'. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4243 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4244 long_u |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4245 get_option_flags(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4246 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4247 return options[opt_idx].flags; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4248 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4249 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4250 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4251 * Set a flag for the option at 'opt_idx'. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4252 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4253 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4254 set_option_flag(int opt_idx, long_u flag) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4255 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4256 options[opt_idx].flags |= flag; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4257 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4258 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4259 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4260 * Clear a flag for the option at 'opt_idx'. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4261 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4262 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4263 clear_option_flag(int opt_idx, long_u flag) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4264 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4265 options[opt_idx].flags &= ~flag; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4266 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4267 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4268 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4269 * Returns TRUE if the option at 'opt_idx' is a global option |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4270 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4271 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4272 is_global_option(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4273 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4274 return options[opt_idx].indir == PV_NONE; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4275 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4276 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4277 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4278 * Returns TRUE if the option at 'opt_idx' is a global option which also has a |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4279 * local value. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4280 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4281 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4282 is_global_local_option(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4283 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4284 return options[opt_idx].indir & PV_BOTH; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4285 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4286 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4287 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4288 * Returns TRUE if the option at 'opt_idx' is a window-local option |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4289 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4290 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4291 is_window_local_option(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4292 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4293 return options[opt_idx].var == VAR_WIN; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4294 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4295 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4296 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4297 * Returns TRUE if the option at 'opt_idx' is a hidden option |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4298 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4299 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4300 is_hidden_option(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4301 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4302 return options[opt_idx].var == NULL; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4303 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4304 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4305 #if defined(FEAT_CRYPT) || defined(PROTO) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4306 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4307 * Returns TRUE if the option at 'opt_idx' is a crypt key option |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4308 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4309 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4310 is_crypt_key_option(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4311 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4312 return options[opt_idx].indir == PV_KEY; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4313 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4314 #endif |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4315 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4316 /* |
7 | 4317 * Set the value of option "name". |
4318 * 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
|
4319 * |
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4320 * 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
|
4321 */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4322 char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4323 set_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4324 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4325 long number, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4326 char_u *string, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4327 int opt_flags) // OPT_LOCAL or 0 (both) |
7 | 4328 { |
4329 int opt_idx; | |
4330 char_u *varp; | |
835 | 4331 long_u flags; |
7 | 4332 |
4333 opt_idx = findoption(name); | |
838 | 4334 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
|
4335 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4336 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4337 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4338 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
|
4339 && (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
|
4340 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4341 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
|
4342 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4343 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4344 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4345 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
|
4346 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
|
4347 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4348 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4349 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4350 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
|
4351 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
|
4352 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4353 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
|
4354 if (full_screen) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4355 ttest(FALSE); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4356 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
|
4357 return NULL; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4358 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4359 |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4360 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
|
4361 } |
7 | 4362 else |
4363 { | |
4364 flags = options[opt_idx].flags; | |
4365 #ifdef HAVE_SANDBOX | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4366 // Disallow changing some options in the sandbox |
7 | 4367 if (sandbox > 0 && (flags & P_SECURE)) |
634 | 4368 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4369 emsg(_(e_sandbox)); |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4370 return NULL; |
634 | 4371 } |
4372 #endif | |
4373 if (flags & P_STRING) | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4374 return set_string_option(opt_idx, string, opt_flags); |
7 | 4375 else |
4376 { | |
1667 | 4377 varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4378 if (varp != NULL) // hidden option is not changed |
7 | 4379 { |
1298 | 4380 if (number == 0 && string != NULL) |
4381 { | |
1757 | 4382 int idx; |
1298 | 4383 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4384 // Either we are given a string or we are setting option |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4385 // to zero. |
1757 | 4386 for (idx = 0; string[idx] == '0'; ++idx) |
1298 | 4387 ; |
1757 | 4388 if (string[idx] != NUL || idx == 0) |
1298 | 4389 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4390 // There's another character after zeros or the string |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4391 // is empty. In both cases, we are trying to set a |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4392 // 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
|
4393 semsg(_("E521: Number required: &%s = '%s'"), |
1298 | 4394 name, string); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4395 return NULL; // do nothing as we hit an error |
1298 | 4396 |
4397 } | |
4398 } | |
7 | 4399 if (flags & P_NUM) |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4400 return set_num_option(opt_idx, varp, number, |
274 | 4401 NULL, 0, opt_flags); |
7 | 4402 else |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4403 return set_bool_option(opt_idx, varp, (int)number, |
634 | 4404 opt_flags); |
7 | 4405 } |
4406 } | |
4407 } | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4408 return NULL; |
7 | 4409 } |
4410 | |
4411 /* | |
4412 * Get the terminal code for a terminal option. | |
4413 * Returns NULL when not found. | |
4414 */ | |
4415 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4416 get_term_code(char_u *tname) |
7 | 4417 { |
4418 int opt_idx; | |
4419 char_u *varp; | |
4420 | |
4421 if (tname[0] != 't' || tname[1] != '_' || | |
4422 tname[2] == NUL || tname[3] == NUL) | |
4423 return NULL; | |
4424 if ((opt_idx = findoption(tname)) >= 0) | |
4425 { | |
4426 varp = get_varp(&(options[opt_idx])); | |
4427 if (varp != NULL) | |
4428 varp = *(char_u **)(varp); | |
4429 return varp; | |
4430 } | |
4431 return find_termcode(tname + 2); | |
4432 } | |
4433 | |
4434 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4435 get_highlight_default(void) |
7 | 4436 { |
4437 int i; | |
4438 | |
4439 i = findoption((char_u *)"hl"); | |
4440 if (i >= 0) | |
4441 return options[i].def_val[VI_DEFAULT]; | |
4442 return (char_u *)NULL; | |
4443 } | |
4444 | |
39 | 4445 char_u * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4446 get_encoding_default(void) |
39 | 4447 { |
4448 int i; | |
4449 | |
4450 i = findoption((char_u *)"enc"); | |
4451 if (i >= 0) | |
4452 return options[i].def_val[VI_DEFAULT]; | |
4453 return (char_u *)NULL; | |
4454 } | |
4455 | |
7 | 4456 /* |
4457 * 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
|
4458 * 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
|
4459 * Returns 0 when the key is not recognized. |
7 | 4460 */ |
4461 static int | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4462 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
|
4463 { |
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4464 int key = 0; |
7 | 4465 int modifiers; |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4466 char_u *arg = arg_arg; |
7 | 4467 |
4468 /* | |
4469 * Don't use get_special_key_code() for t_xx, we don't want it to call | |
4470 * add_termcap_entry(). | |
4471 */ | |
4472 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
4473 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
|
4474 else if (has_lt) |
7 | 4475 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4476 --arg; // put arg at the '<' |
7 | 4477 modifiers = 0; |
20603
c2570baa2e4c
patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents:
20269
diff
changeset
|
4478 key = find_special_key(&arg, &modifiers, |
c2570baa2e4c
patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents:
20269
diff
changeset
|
4479 FSK_KEYCODE | FSK_KEEP_X_KEY | FSK_SIMPLIFY, NULL); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4480 if (modifiers) // can't handle modifiers here |
7 | 4481 key = 0; |
4482 } | |
4483 return key; | |
4484 } | |
4485 | |
4486 /* | |
4487 * if 'all' == 0: show changed options | |
4488 * if 'all' == 1: show all normal options | |
4489 * if 'all' == 2: show all terminal options | |
4490 */ | |
4491 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4492 showoptions( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4493 int all, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4494 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 4495 { |
4496 struct vimoption *p; | |
4497 int col; | |
4498 int isterm; | |
4499 char_u *varp; | |
4500 struct vimoption **items; | |
4501 int item_count; | |
4502 int run; | |
4503 int row, rows; | |
4504 int cols; | |
4505 int i; | |
4506 int len; | |
4507 | |
4508 #define INC 20 | |
4509 #define GAP 3 | |
4510 | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4511 items = ALLOC_MULT(struct vimoption *, OPTION_COUNT); |
7 | 4512 if (items == NULL) |
4513 return; | |
4514 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4515 // Highlight title |
7 | 4516 if (all == 2) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4517 msg_puts_title(_("\n--- Terminal codes ---")); |
7 | 4518 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
|
4519 msg_puts_title(_("\n--- Global option values ---")); |
7 | 4520 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
|
4521 msg_puts_title(_("\n--- Local option values ---")); |
7 | 4522 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4523 msg_puts_title(_("\n--- Options ---")); |
7 | 4524 |
4525 /* | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4526 * Do the loop two times: |
7 | 4527 * 1. display the short items |
4528 * 2. display the long items (only strings and numbers) | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4529 * When "opt_flags" has OPT_ONECOLUMN do everything in run 2. |
7 | 4530 */ |
4531 for (run = 1; run <= 2 && !got_int; ++run) | |
4532 { | |
4533 /* | |
4534 * collect the items in items[] | |
4535 */ | |
4536 item_count = 0; | |
4537 for (p = &options[0]; p->fullname != NULL; p++) | |
4538 { | |
14968
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4539 // apply :filter /pat/ |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4540 if (message_filtered((char_u *)p->fullname)) |
14968
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4541 continue; |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4542 |
7 | 4543 varp = NULL; |
4544 isterm = istermoption(p); | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4545 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) != 0) |
7 | 4546 { |
4547 if (p->indir != PV_NONE && !isterm) | |
4548 varp = get_varp_scope(p, opt_flags); | |
4549 } | |
4550 else | |
4551 varp = get_varp(p); | |
4552 if (varp != NULL | |
4553 && ((all == 2 && isterm) | |
4554 || (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
|
4555 || (all == 0 && !optval_default(p, varp, p_cp)))) |
7 | 4556 { |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4557 if (opt_flags & OPT_ONECOLUMN) |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4558 len = Columns; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4559 else if (p->flags & P_BOOL) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4560 len = 1; // a toggle option fits always |
7 | 4561 else |
4562 { | |
4563 option_value2string(p, opt_flags); | |
4564 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; | |
4565 } | |
4566 if ((len <= INC - GAP && run == 1) || | |
4567 (len > INC - GAP && run == 2)) | |
4568 items[item_count++] = p; | |
4569 } | |
4570 } | |
4571 | |
4572 /* | |
4573 * display the items | |
4574 */ | |
4575 if (run == 1) | |
4576 { | |
4577 cols = (Columns + GAP - 3) / INC; | |
4578 if (cols == 0) | |
4579 cols = 1; | |
4580 rows = (item_count + cols - 1) / cols; | |
4581 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4582 else // run == 2 |
7 | 4583 rows = item_count; |
4584 for (row = 0; row < rows && !got_int; ++row) | |
4585 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4586 msg_putchar('\n'); // go to next line |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4587 if (got_int) // 'q' typed in more |
7 | 4588 break; |
4589 col = 0; | |
4590 for (i = row; i < item_count; i += rows) | |
4591 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4592 msg_col = col; // make columns |
7 | 4593 showoneopt(items[i], opt_flags); |
4594 col += INC; | |
4595 } | |
4596 out_flush(); | |
4597 ui_breakcheck(); | |
4598 } | |
4599 } | |
4600 vim_free(items); | |
4601 } | |
4602 | |
4603 /* | |
4604 * Return TRUE if option "p" has its default value. | |
4605 */ | |
4606 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
|
4607 optval_default(struct vimoption *p, char_u *varp, int compatible) |
7 | 4608 { |
4609 int dvi; | |
4610 | |
4611 if (varp == NULL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4612 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
|
4613 dvi = ((p->flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; |
7 | 4614 if (p->flags & P_NUM) |
840 | 4615 return (*(long *)varp == (long)(long_i)p->def_val[dvi]); |
7 | 4616 if (p->flags & P_BOOL) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4617 // the cast to long is required for Manx C, long_i is |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4618 // needed for MSVC |
840 | 4619 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4620 // P_STRING |
7 | 4621 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); |
4622 } | |
4623 | |
4624 /* | |
4625 * showoneopt: show the value of one option | |
4626 * must not be called with a hidden option! | |
4627 */ | |
4628 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4629 showoneopt( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4630 struct vimoption *p, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4631 int opt_flags) // OPT_LOCAL or OPT_GLOBAL |
7 | 4632 { |
168 | 4633 char_u *varp; |
4634 int save_silent = silent_mode; | |
4635 | |
4636 silent_mode = FALSE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4637 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
7 | 4638 |
4639 varp = get_varp_scope(p, opt_flags); | |
4640 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4641 // for 'modified' we also need to check if 'ff' or 'fenc' changed. |
7 | 4642 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed |
4643 ? !curbufIsChanged() : !*(int *)varp)) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4644 msg_puts("no"); |
7 | 4645 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
|
4646 msg_puts("--"); |
7 | 4647 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4648 msg_puts(" "); |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4649 msg_puts(p->fullname); |
7 | 4650 if (!(p->flags & P_BOOL)) |
4651 { | |
4652 msg_putchar('='); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4653 // put value string in NameBuff |
7 | 4654 option_value2string(p, opt_flags); |
4655 msg_outtrans(NameBuff); | |
4656 } | |
168 | 4657 |
4658 silent_mode = save_silent; | |
4659 info_message = FALSE; | |
7 | 4660 } |
4661 | |
4662 /* | |
4663 * Write modified options as ":set" commands to a file. | |
4664 * | |
4665 * There are three values for "opt_flags": | |
4666 * OPT_GLOBAL: Write global option values and fresh values of | |
4667 * buffer-local options (used for start of a session | |
4668 * file). | |
4669 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for | |
4670 * curwin (used for a vimrc file). | |
4671 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh | |
4672 * and local values for window-local options of | |
4673 * curwin. Local values are also written when at the | |
4674 * default value, because a modeline or autocommand | |
4675 * may have set them when doing ":edit file" and the | |
4676 * user has set them back at the default or fresh | |
4677 * value. | |
4678 * When "local_only" is TRUE, don't write fresh | |
4679 * values, only local values (for ":mkview"). | |
4680 * (fresh value = value used for a new buffer or window for a local option). | |
4681 * | |
4682 * Return FAIL on error, OK otherwise. | |
4683 */ | |
4684 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4685 makeset(FILE *fd, int opt_flags, int local_only) |
7 | 4686 { |
4687 struct vimoption *p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4688 char_u *varp; // currently used value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4689 char_u *varp_fresh; // local value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4690 char_u *varp_local = NULL; // fresh value |
7 | 4691 char *cmd; |
4692 int round; | |
1384 | 4693 int pri; |
7 | 4694 |
4695 /* | |
4696 * The options that don't have a default (terminal name, columns, lines) | |
4697 * are never written. Terminal options are also not written. | |
1384 | 4698 * Do the loop over "options[]" twice: once for options with the |
4699 * P_PRI_MKRC flag and once without. | |
7 | 4700 */ |
1384 | 4701 for (pri = 1; pri >= 0; --pri) |
4702 { | |
4703 for (p = &options[0]; !istermoption(p); p++) | |
4704 if (!(p->flags & P_NO_MKRC) | |
4705 && !istermoption(p) | |
4706 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) | |
7 | 4707 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4708 // skip global option when only doing locals |
7 | 4709 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) |
4710 continue; | |
4711 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4712 // Do not store options like 'bufhidden' and 'syntax' in a vimrc |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4713 // file, they are always buffer-specific. |
7 | 4714 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) |
4715 continue; | |
4716 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4717 // Global values are only written when not at the default value. |
7 | 4718 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
|
4719 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp, p_cp)) |
7 | 4720 continue; |
4721 | |
24476
e79d1475fc89
patch 8.2.2778: problem restoring 'packpath' in session
Bram Moolenaar <Bram@vim.org>
parents:
24464
diff
changeset
|
4722 if ((opt_flags & OPT_SKIPRTP) && (p->var == (char_u *)&p_rtp |
e79d1475fc89
patch 8.2.2778: problem restoring 'packpath' in session
Bram Moolenaar <Bram@vim.org>
parents:
24464
diff
changeset
|
4723 || p->var == (char_u *)&p_pp)) |
24464
a56f9c2ba51c
patch 8.2.2772: problems when restoring 'runtimepath' from a session file
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4724 continue; |
a56f9c2ba51c
patch 8.2.2772: problems when restoring 'runtimepath' from a session file
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4725 |
7 | 4726 round = 2; |
4727 if (p->indir != PV_NONE) | |
4728 { | |
4729 if (p->var == VAR_WIN) | |
4730 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4731 // skip window-local option when only doing globals |
7 | 4732 if (!(opt_flags & OPT_LOCAL)) |
4733 continue; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4734 // When fresh value of window-local option is not at the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4735 // default, need to write it too. |
7 | 4736 if (!(opt_flags & OPT_GLOBAL) && !local_only) |
4737 { | |
4738 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
|
4739 if (!optval_default(p, varp_fresh, p_cp)) |
7 | 4740 { |
4741 round = 1; | |
4742 varp_local = varp; | |
4743 varp = varp_fresh; | |
4744 } | |
4745 } | |
4746 } | |
4747 } | |
4748 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4749 // Round 1: fresh value for window-local options. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4750 // Round 2: other values |
7 | 4751 for ( ; round <= 2; varp = varp_local, ++round) |
4752 { | |
4753 if (round == 1 || (opt_flags & OPT_GLOBAL)) | |
4754 cmd = "set"; | |
4755 else | |
4756 cmd = "setlocal"; | |
4757 | |
4758 if (p->flags & P_BOOL) | |
4759 { | |
4760 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) | |
4761 return FAIL; | |
4762 } | |
4763 else if (p->flags & P_NUM) | |
4764 { | |
4765 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) | |
4766 return FAIL; | |
4767 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4768 else // P_STRING |
7 | 4769 { |
694 | 4770 int do_endif = FALSE; |
4771 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4772 // Don't set 'syntax' and 'filetype' again if the value is |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4773 // already right, avoids reloading the syntax file. |
694 | 4774 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4775 #if defined(FEAT_SYN_HL) |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4776 p->indir == PV_SYN || |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4777 #endif |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4778 p->indir == PV_FT) |
7 | 4779 { |
4780 if (fprintf(fd, "if &%s != '%s'", p->fullname, | |
4781 *(char_u **)(varp)) < 0 | |
4782 || put_eol(fd) < 0) | |
4783 return FAIL; | |
694 | 4784 do_endif = TRUE; |
7 | 4785 } |
4786 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
|
4787 p->flags) == FAIL) |
7 | 4788 return FAIL; |
694 | 4789 if (do_endif) |
7 | 4790 { |
4791 if (put_line(fd, "endif") == FAIL) | |
4792 return FAIL; | |
4793 } | |
4794 } | |
4795 } | |
4796 } | |
1384 | 4797 } |
7 | 4798 return OK; |
4799 } | |
4800 | |
4801 #if defined(FEAT_FOLDING) || defined(PROTO) | |
4802 /* | |
4803 * Generate set commands for the local fold options only. Used when | |
4804 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options". | |
4805 */ | |
4806 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4807 makefoldset(FILE *fd) |
7 | 4808 { |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4809 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, 0) == FAIL |
7 | 4810 # 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
|
4811 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, 0) |
7 | 4812 == FAIL |
4813 # endif | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4814 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, 0) |
7 | 4815 == FAIL |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4816 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, 0) |
7 | 4817 == FAIL |
4818 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL | |
4819 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL | |
4820 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL | |
4821 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL | |
4822 ) | |
4823 return FAIL; | |
4824 | |
4825 return OK; | |
4826 } | |
4827 #endif | |
4828 | |
4829 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4830 put_setstring( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4831 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4832 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4833 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4834 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
|
4835 long_u flags) |
7 | 4836 { |
4837 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
|
4838 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
|
4839 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
|
4840 char_u *p; |
7 | 4841 |
4842 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
4843 return FAIL; | |
4844 if (*valuep != NULL) | |
4845 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4846 // Output 'pastetoggle' as key names. For other |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4847 // options some characters have to be escaped with |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4848 // CTRL-V or backslash |
7 | 4849 if (valuep == &p_pt) |
4850 { | |
4851 s = *valuep; | |
4852 while (*s != NUL) | |
1601 | 4853 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL) |
7 | 4854 return FAIL; |
4855 } | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4856 // 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
|
4857 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
|
4858 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4859 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
|
4860 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4861 // 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
|
4862 buf = alloc(size); |
2780 | 4863 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
|
4864 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4865 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
|
4866 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4867 // If the option value is longer than MAXPATHL, we need to append |
18498
9e6d5a4abb1c
patch 8.1.2243: typos in comments
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4868 // each comma separated part of the option separately, so that it |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4869 // 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
|
4870 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
|
4871 && 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
|
4872 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4873 part = alloc(size); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4874 if (part == NULL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4875 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4876 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4877 // 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
|
4878 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
|
4879 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4880 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4881 p = buf; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4882 while (*p != NUL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4883 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4884 // 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
|
4885 // 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
|
4886 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
|
4887 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4888 (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
|
4889 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
|
4890 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4891 } |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4892 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4893 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4894 return OK; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4895 } |
7 | 4896 if (put_escstr(fd, buf, 2) == FAIL) |
2780 | 4897 { |
4898 vim_free(buf); | |
7 | 4899 return FAIL; |
2780 | 4900 } |
4901 vim_free(buf); | |
7 | 4902 } |
4903 else if (put_escstr(fd, *valuep, 2) == FAIL) | |
4904 return FAIL; | |
4905 } | |
4906 if (put_eol(fd) < 0) | |
4907 return FAIL; | |
4908 return OK; | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4909 fail: |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4910 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4911 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4912 return FAIL; |
7 | 4913 } |
4914 | |
4915 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4916 put_setnum( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4917 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4918 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4919 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4920 long *valuep) |
7 | 4921 { |
4922 long wc; | |
4923 | |
4924 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
4925 return FAIL; | |
4926 if (wc_use_keyname((char_u *)valuep, &wc)) | |
4927 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4928 // print 'wildchar' and 'wildcharm' as a key name |
7 | 4929 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) |
4930 return FAIL; | |
4931 } | |
4932 else if (fprintf(fd, "%ld", *valuep) < 0) | |
4933 return FAIL; | |
4934 if (put_eol(fd) < 0) | |
4935 return FAIL; | |
4936 return OK; | |
4937 } | |
4938 | |
4939 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4940 put_setbool( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4941 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4942 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4943 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4944 int value) |
7 | 4945 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4946 if (value < 0) // global/local option using global value |
1416 | 4947 return OK; |
7 | 4948 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 |
4949 || put_eol(fd) < 0) | |
4950 return FAIL; | |
4951 return OK; | |
4952 } | |
4953 | |
4954 /* | |
4955 * Clear all the terminal options. | |
4956 * If the option has been allocated, free the memory. | |
4957 * Terminal options are never hidden or indirect. | |
4958 */ | |
4959 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4960 clear_termoptions(void) |
7 | 4961 { |
4962 /* | |
4963 * Reset a few things before clearing the old options. This may cause | |
4964 * outputting a few things that the terminal doesn't understand, but the | |
4965 * screen will be cleared later, so this is OK. | |
4966 */ | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
4967 mch_setmouse(FALSE); // switch mouse off |
7 | 4968 #ifdef FEAT_TITLE |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4969 mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles |
7 | 4970 #endif |
4971 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4972 // When starting the GUI close the display opened for the clipboard. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4973 // After restoring the title, because that will need the display. |
7 | 4974 if (gui.starting) |
4975 clear_xterm_clip(); | |
4976 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4977 stoptermcap(); // stop termcap mode |
7 | 4978 |
359 | 4979 free_termoptions(); |
4980 } | |
4981 | |
4982 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4983 free_termoptions(void) |
359 | 4984 { |
4985 struct vimoption *p; | |
4986 | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4987 for (p = options; p->fullname != NULL; p++) |
7 | 4988 if (istermoption(p)) |
4989 { | |
4990 if (p->flags & P_ALLOCED) | |
4991 free_string_option(*(char_u **)(p->var)); | |
4992 if (p->flags & P_DEF_ALLOCED) | |
4993 free_string_option(p->def_val[VI_DEFAULT]); | |
4994 *(char_u **)(p->var) = empty_option; | |
4995 p->def_val[VI_DEFAULT] = empty_option; | |
4996 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
|
4997 #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
|
4998 // 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
|
4999 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
|
5000 #endif |
7 | 5001 } |
5002 clear_termcodes(); | |
5003 } | |
5004 | |
5005 /* | |
1941 | 5006 * Free the string for one term option, if it was allocated. |
5007 * Set the string to empty_option and clear allocated flag. | |
5008 * "var" points to the option value. | |
5009 */ | |
5010 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5011 free_one_termoption(char_u *var) |
1941 | 5012 { |
5013 struct vimoption *p; | |
5014 | |
5015 for (p = &options[0]; p->fullname != NULL; p++) | |
5016 if (p->var == var) | |
5017 { | |
5018 if (p->flags & P_ALLOCED) | |
5019 free_string_option(*(char_u **)(p->var)); | |
5020 *(char_u **)(p->var) = empty_option; | |
5021 p->flags &= ~P_ALLOCED; | |
5022 break; | |
5023 } | |
5024 } | |
5025 | |
5026 /* | |
7 | 5027 * Set the terminal option defaults to the current value. |
5028 * Used after setting the terminal name. | |
5029 */ | |
5030 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5031 set_term_defaults(void) |
7 | 5032 { |
5033 struct vimoption *p; | |
5034 | |
5035 for (p = &options[0]; p->fullname != NULL; p++) | |
5036 { | |
5037 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) | |
5038 { | |
5039 if (p->flags & P_DEF_ALLOCED) | |
5040 { | |
5041 free_string_option(p->def_val[VI_DEFAULT]); | |
5042 p->flags &= ~P_DEF_ALLOCED; | |
5043 } | |
5044 p->def_val[VI_DEFAULT] = *(char_u **)(p->var); | |
5045 if (p->flags & P_ALLOCED) | |
5046 { | |
5047 p->flags |= P_DEF_ALLOCED; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5048 p->flags &= ~P_ALLOCED; // don't free the value now |
7 | 5049 } |
5050 } | |
5051 } | |
5052 } | |
5053 | |
5054 /* | |
5055 * return TRUE if 'p' starts with 't_' | |
5056 */ | |
5057 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5058 istermoption(struct vimoption *p) |
7 | 5059 { |
5060 return (p->fullname[0] == 't' && p->fullname[1] == '_'); | |
5061 } | |
5062 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5063 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5064 * Returns TRUE if the option at 'opt_idx' starts with 't_' |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5065 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5066 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5067 istermoption_idx(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5068 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5069 return istermoption(&options[opt_idx]); |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5070 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5071 |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
5072 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
7 | 5073 /* |
4350 | 5074 * Unset local option value, similar to ":set opt<". |
5075 */ | |
5076 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5077 unset_global_local_option(char_u *name, void *from) |
4350 | 5078 { |
5079 struct vimoption *p; | |
5080 int opt_idx; | |
4361 | 5081 buf_T *buf = (buf_T *)from; |
4350 | 5082 |
5083 opt_idx = findoption(name); | |
7007 | 5084 if (opt_idx < 0) |
5085 return; | |
4350 | 5086 p = &(options[opt_idx]); |
5087 | |
5088 switch ((int)p->indir) | |
5089 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5090 // global option with local value: use local value if it's been set |
4350 | 5091 case PV_EP: |
4361 | 5092 clear_string_option(&buf->b_p_ep); |
4350 | 5093 break; |
5094 case PV_KP: | |
4361 | 5095 clear_string_option(&buf->b_p_kp); |
4350 | 5096 break; |
5097 case PV_PATH: | |
4361 | 5098 clear_string_option(&buf->b_p_path); |
4350 | 5099 break; |
5100 case PV_AR: | |
5101 buf->b_p_ar = -1; | |
5102 break; | |
6243 | 5103 case PV_BKC: |
5104 clear_string_option(&buf->b_p_bkc); | |
5105 buf->b_bkc_flags = 0; | |
5106 break; | |
4350 | 5107 case PV_TAGS: |
4361 | 5108 clear_string_option(&buf->b_p_tags); |
4350 | 5109 break; |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5110 case PV_TC: |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5111 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
|
5112 buf->b_tc_flags = 0; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5113 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
|
5114 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
|
5115 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
|
5116 break; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5117 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
|
5118 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
|
5119 break; |
4350 | 5120 #ifdef FEAT_FIND_ID |
5121 case PV_DEF: | |
4361 | 5122 clear_string_option(&buf->b_p_def); |
4350 | 5123 break; |
5124 case PV_INC: | |
4361 | 5125 clear_string_option(&buf->b_p_inc); |
4350 | 5126 break; |
5127 #endif | |
5128 case PV_DICT: | |
4361 | 5129 clear_string_option(&buf->b_p_dict); |
4350 | 5130 break; |
5131 case PV_TSR: | |
4361 | 5132 clear_string_option(&buf->b_p_tsr); |
4350 | 5133 break; |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5134 case PV_FP: |
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5135 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
|
5136 break; |
4350 | 5137 #ifdef FEAT_QUICKFIX |
5138 case PV_EFM: | |
4361 | 5139 clear_string_option(&buf->b_p_efm); |
4350 | 5140 break; |
5141 case PV_GP: | |
4361 | 5142 clear_string_option(&buf->b_p_gp); |
4350 | 5143 break; |
5144 case PV_MP: | |
4361 | 5145 clear_string_option(&buf->b_p_mp); |
4350 | 5146 break; |
5147 #endif | |
5148 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) | |
5149 case PV_BEXPR: | |
4361 | 5150 clear_string_option(&buf->b_p_bexpr); |
4350 | 5151 break; |
5152 #endif | |
5153 #if defined(FEAT_CRYPT) | |
5154 case PV_CM: | |
4361 | 5155 clear_string_option(&buf->b_p_cm); |
4350 | 5156 break; |
5157 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5158 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5159 case PV_SBR: |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5160 clear_string_option(&((win_T *)from)->w_p_sbr); |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5161 break; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5162 #endif |
4350 | 5163 #ifdef FEAT_STL_OPT |
5164 case PV_STL: | |
4361 | 5165 clear_string_option(&((win_T *)from)->w_p_stl); |
4350 | 5166 break; |
5167 #endif | |
5446 | 5168 case PV_UL: |
5169 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; | |
5170 break; | |
5712 | 5171 #ifdef FEAT_LISP |
5172 case PV_LW: | |
5173 clear_string_option(&buf->b_p_lw); | |
5174 break; | |
5175 #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
|
5176 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
|
5177 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
|
5178 break; |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5179 case PV_LCS: |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5180 clear_string_option(&((win_T *)from)->w_p_lcs); |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5181 set_chars_option((win_T *)from, &((win_T *)from)->w_p_lcs); |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5182 redraw_later(NOT_VALID); |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5183 break; |
4350 | 5184 } |
5185 } | |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
5186 #endif |
4350 | 5187 |
5188 /* | |
7 | 5189 * Get pointer to option variable, depending on local or global scope. |
5190 */ | |
5191 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5192 get_varp_scope(struct vimoption *p, int opt_flags) |
7 | 5193 { |
5194 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE) | |
5195 { | |
5196 if (p->var == VAR_WIN) | |
5197 return (char_u *)GLOBAL_WO(get_varp(p)); | |
5198 return p->var; | |
5199 } | |
692 | 5200 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) |
7 | 5201 { |
5202 switch ((int)p->indir) | |
5203 { | |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5204 case PV_FP: return (char_u *)&(curbuf->b_p_fp); |
7 | 5205 #ifdef FEAT_QUICKFIX |
694 | 5206 case PV_EFM: return (char_u *)&(curbuf->b_p_efm); |
5207 case PV_GP: return (char_u *)&(curbuf->b_p_gp); | |
5208 case PV_MP: return (char_u *)&(curbuf->b_p_mp); | |
5209 #endif | |
5210 case PV_EP: return (char_u *)&(curbuf->b_p_ep); | |
5211 case PV_KP: return (char_u *)&(curbuf->b_p_kp); | |
5212 case PV_PATH: return (char_u *)&(curbuf->b_p_path); | |
692 | 5213 case PV_AR: return (char_u *)&(curbuf->b_p_ar); |
694 | 5214 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
|
5215 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
|
5216 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
|
5217 case PV_SO: return (char_u *)&(curwin->w_p_so); |
7 | 5218 #ifdef FEAT_FIND_ID |
694 | 5219 case PV_DEF: return (char_u *)&(curbuf->b_p_def); |
5220 case PV_INC: return (char_u *)&(curbuf->b_p_inc); | |
7 | 5221 #endif |
694 | 5222 case PV_DICT: return (char_u *)&(curbuf->b_p_dict); |
5223 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr); | |
790 | 5224 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5225 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr); | |
5226 #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
|
5227 #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
|
5228 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
|
5229 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5230 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5231 case PV_SBR: return (char_u *)&(curwin->w_p_sbr); |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5232 #endif |
40 | 5233 #ifdef FEAT_STL_OPT |
694 | 5234 case PV_STL: return (char_u *)&(curwin->w_p_stl); |
40 | 5235 #endif |
5446 | 5236 case PV_UL: return (char_u *)&(curbuf->b_p_ul); |
5712 | 5237 #ifdef FEAT_LISP |
5238 case PV_LW: return (char_u *)&(curbuf->b_p_lw); | |
5239 #endif | |
6243 | 5240 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
|
5241 case PV_MENC: return (char_u *)&(curbuf->b_p_menc); |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5242 case PV_LCS: return (char_u *)&(curwin->w_p_lcs); |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5243 |
7 | 5244 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5245 return NULL; // "cannot happen" |
7 | 5246 } |
5247 return get_varp(p); | |
5248 } | |
5249 | |
5250 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5251 * Get pointer to option variable at 'opt_idx', depending on local or global |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5252 * scope. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5253 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5254 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5255 get_option_varp_scope(int opt_idx, int opt_flags) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5256 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5257 return get_varp_scope(&(options[opt_idx]), opt_flags); |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5258 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5259 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5260 /* |
7 | 5261 * Get pointer to option variable. |
5262 */ | |
5263 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5264 get_varp(struct vimoption *p) |
7 | 5265 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5266 // hidden option, always return NULL |
7 | 5267 if (p->var == NULL) |
5268 return NULL; | |
5269 | |
5270 switch ((int)p->indir) | |
5271 { | |
5272 case PV_NONE: return p->var; | |
5273 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5274 // global option with local value: use local value if it's been set |
694 | 5275 case PV_EP: return *curbuf->b_p_ep != NUL |
7 | 5276 ? (char_u *)&curbuf->b_p_ep : p->var; |
694 | 5277 case PV_KP: return *curbuf->b_p_kp != NUL |
7 | 5278 ? (char_u *)&curbuf->b_p_kp : p->var; |
694 | 5279 case PV_PATH: return *curbuf->b_p_path != NUL |
7 | 5280 ? (char_u *)&(curbuf->b_p_path) : p->var; |
692 | 5281 case PV_AR: return curbuf->b_p_ar >= 0 |
7 | 5282 ? (char_u *)&(curbuf->b_p_ar) : p->var; |
694 | 5283 case PV_TAGS: return *curbuf->b_p_tags != NUL |
7 | 5284 ? (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
|
5285 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
|
5286 ? (char_u *)&(curbuf->b_p_tc) : p->var; |
6243 | 5287 case PV_BKC: return *curbuf->b_p_bkc != NUL |
5288 ? (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
|
5289 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
|
5290 ? (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
|
5291 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
|
5292 ? (char_u *)&(curwin->w_p_so) : p->var; |
7 | 5293 #ifdef FEAT_FIND_ID |
694 | 5294 case PV_DEF: return *curbuf->b_p_def != NUL |
7 | 5295 ? (char_u *)&(curbuf->b_p_def) : p->var; |
694 | 5296 case PV_INC: return *curbuf->b_p_inc != NUL |
7 | 5297 ? (char_u *)&(curbuf->b_p_inc) : p->var; |
5298 #endif | |
694 | 5299 case PV_DICT: return *curbuf->b_p_dict != NUL |
7 | 5300 ? (char_u *)&(curbuf->b_p_dict) : p->var; |
694 | 5301 case PV_TSR: return *curbuf->b_p_tsr != NUL |
7 | 5302 ? (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
|
5303 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
|
5304 ? (char_u *)&(curbuf->b_p_fp) : p->var; |
7 | 5305 #ifdef FEAT_QUICKFIX |
694 | 5306 case PV_EFM: return *curbuf->b_p_efm != NUL |
5307 ? (char_u *)&(curbuf->b_p_efm) : p->var; | |
5308 case PV_GP: return *curbuf->b_p_gp != NUL | |
7 | 5309 ? (char_u *)&(curbuf->b_p_gp) : p->var; |
694 | 5310 case PV_MP: return *curbuf->b_p_mp != NUL |
7 | 5311 ? (char_u *)&(curbuf->b_p_mp) : p->var; |
5312 #endif | |
790 | 5313 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5314 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL | |
5315 ? (char_u *)&(curbuf->b_p_bexpr) : p->var; | |
5316 #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
|
5317 #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
|
5318 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
|
5319 ? (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
|
5320 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5321 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5322 case PV_SBR: return *curwin->w_p_sbr != NUL |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5323 ? (char_u *)&(curwin->w_p_sbr) : p->var; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5324 #endif |
40 | 5325 #ifdef FEAT_STL_OPT |
694 | 5326 case PV_STL: return *curwin->w_p_stl != NUL |
40 | 5327 ? (char_u *)&(curwin->w_p_stl) : p->var; |
5328 #endif | |
5446 | 5329 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL |
5330 ? (char_u *)&(curbuf->b_p_ul) : p->var; | |
5712 | 5331 #ifdef FEAT_LISP |
5332 case PV_LW: return *curbuf->b_p_lw != NUL | |
5333 ? (char_u *)&(curbuf->b_p_lw) : p->var; | |
5334 #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
|
5335 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
|
5336 ? (char_u *)&(curbuf->b_p_menc) : p->var; |
7 | 5337 #ifdef FEAT_ARABIC |
5338 case PV_ARAB: return (char_u *)&(curwin->w_p_arab); | |
5339 #endif | |
5340 case PV_LIST: return (char_u *)&(curwin->w_p_list); | |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5341 case PV_LCS: return *curwin->w_p_lcs != NUL |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5342 ? (char_u *)&(curwin->w_p_lcs) : p->var; |
744 | 5343 #ifdef FEAT_SPELL |
5344 case PV_SPELL: return (char_u *)&(curwin->w_p_spell); | |
5345 #endif | |
221 | 5346 #ifdef FEAT_SYN_HL |
744 | 5347 case PV_CUC: return (char_u *)&(curwin->w_p_cuc); |
5348 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
|
5349 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
|
5350 case PV_CC: return (char_u *)&(curwin->w_p_cc); |
221 | 5351 #endif |
7 | 5352 #ifdef FEAT_DIFF |
5353 case PV_DIFF: return (char_u *)&(curwin->w_p_diff); | |
5354 #endif | |
5355 #ifdef FEAT_FOLDING | |
5356 case PV_FDC: return (char_u *)&(curwin->w_p_fdc); | |
5357 case PV_FEN: return (char_u *)&(curwin->w_p_fen); | |
5358 case PV_FDI: return (char_u *)&(curwin->w_p_fdi); | |
5359 case PV_FDL: return (char_u *)&(curwin->w_p_fdl); | |
5360 case PV_FDM: return (char_u *)&(curwin->w_p_fdm); | |
5361 case PV_FML: return (char_u *)&(curwin->w_p_fml); | |
5362 case PV_FDN: return (char_u *)&(curwin->w_p_fdn); | |
5363 # ifdef FEAT_EVAL | |
5364 case PV_FDE: return (char_u *)&(curwin->w_p_fde); | |
5365 case PV_FDT: return (char_u *)&(curwin->w_p_fdt); | |
5366 # endif | |
5367 case PV_FMR: return (char_u *)&(curwin->w_p_fmr); | |
5368 #endif | |
5369 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
|
5370 case PV_RNU: return (char_u *)&(curwin->w_p_rnu); |
13 | 5371 #ifdef FEAT_LINEBREAK |
5372 case PV_NUW: return (char_u *)&(curwin->w_p_nuw); | |
5373 #endif | |
7 | 5374 case PV_WFH: return (char_u *)&(curwin->w_p_wfh); |
782 | 5375 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
|
5376 #if defined(FEAT_QUICKFIX) |
7 | 5377 case PV_PVW: return (char_u *)&(curwin->w_p_pvw); |
5378 #endif | |
5379 #ifdef FEAT_RIGHTLEFT | |
5380 case PV_RL: return (char_u *)&(curwin->w_p_rl); | |
5381 case PV_RLC: return (char_u *)&(curwin->w_p_rlc); | |
5382 #endif | |
5383 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr); | |
5384 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); | |
5385 #ifdef FEAT_LINEBREAK | |
5386 case PV_LBR: return (char_u *)&(curwin->w_p_lbr); | |
5995 | 5387 case PV_BRI: return (char_u *)&(curwin->w_p_bri); |
5388 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt); | |
7 | 5389 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5390 case PV_WCR: return (char_u *)&(curwin->w_p_wcr); |
7 | 5391 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
|
5392 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
|
5393 #ifdef FEAT_CONCEAL |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5394 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
|
5395 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
|
5396 #endif |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5397 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5398 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
|
5399 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
|
5400 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
|
5401 #endif |
7 | 5402 |
5403 case PV_AI: return (char_u *)&(curbuf->b_p_ai); | |
5404 case PV_BIN: return (char_u *)&(curbuf->b_p_bin); | |
5405 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); | |
5406 case PV_BH: return (char_u *)&(curbuf->b_p_bh); | |
5407 case PV_BT: return (char_u *)&(curbuf->b_p_bt); | |
5408 case PV_BL: return (char_u *)&(curbuf->b_p_bl); | |
5409 case PV_CI: return (char_u *)&(curbuf->b_p_ci); | |
5410 #ifdef FEAT_CINDENT | |
5411 case PV_CIN: return (char_u *)&(curbuf->b_p_cin); | |
5412 case PV_CINK: return (char_u *)&(curbuf->b_p_cink); | |
5413 case PV_CINO: return (char_u *)&(curbuf->b_p_cino); | |
5414 #endif | |
5415 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) | |
5416 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); | |
5417 #endif | |
5418 case PV_COM: return (char_u *)&(curbuf->b_p_com); | |
5419 #ifdef FEAT_FOLDING | |
5420 case PV_CMS: return (char_u *)&(curbuf->b_p_cms); | |
5421 #endif | |
5422 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
|
5423 #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
|
5424 case PV_CSL: return (char_u *)&(curbuf->b_p_csl); |
7 | 5425 #endif |
12 | 5426 #ifdef FEAT_COMPL_FUNC |
5427 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); | |
502 | 5428 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); |
12 | 5429 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5430 #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
|
5431 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
|
5432 #endif |
7 | 5433 case PV_EOL: return (char_u *)&(curbuf->b_p_eol); |
6933 | 5434 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol); |
7 | 5435 case PV_ET: return (char_u *)&(curbuf->b_p_et); |
5436 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); | |
5437 case PV_FF: return (char_u *)&(curbuf->b_p_ff); | |
5438 case PV_FT: return (char_u *)&(curbuf->b_p_ft); | |
5439 case PV_FO: return (char_u *)&(curbuf->b_p_fo); | |
41 | 5440 case PV_FLP: return (char_u *)&(curbuf->b_p_flp); |
7 | 5441 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); |
5442 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); | |
5443 case PV_INF: return (char_u *)&(curbuf->b_p_inf); | |
5444 case PV_ISK: return (char_u *)&(curbuf->b_p_isk); | |
5445 #ifdef FEAT_FIND_ID | |
5446 # ifdef FEAT_EVAL | |
5447 case PV_INEX: return (char_u *)&(curbuf->b_p_inex); | |
5448 # endif | |
5449 #endif | |
5450 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
5451 case PV_INDE: return (char_u *)&(curbuf->b_p_inde); | |
5452 case PV_INDK: return (char_u *)&(curbuf->b_p_indk); | |
5453 #endif | |
694 | 5454 #ifdef FEAT_EVAL |
667 | 5455 case PV_FEX: return (char_u *)&(curbuf->b_p_fex); |
5456 #endif | |
7 | 5457 #ifdef FEAT_CRYPT |
5458 case PV_KEY: return (char_u *)&(curbuf->b_p_key); | |
5459 #endif | |
5460 #ifdef FEAT_LISP | |
5461 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp); | |
5462 #endif | |
5463 case PV_ML: return (char_u *)&(curbuf->b_p_ml); | |
5464 case PV_MPS: return (char_u *)&(curbuf->b_p_mps); | |
5465 case PV_MA: return (char_u *)&(curbuf->b_p_ma); | |
5466 case PV_MOD: return (char_u *)&(curbuf->b_changed); | |
5467 case PV_NF: return (char_u *)&(curbuf->b_p_nf); | |
5468 case PV_PI: return (char_u *)&(curbuf->b_p_pi); | |
12 | 5469 #ifdef FEAT_TEXTOBJ |
5470 case PV_QE: return (char_u *)&(curbuf->b_p_qe); | |
5471 #endif | |
7 | 5472 case PV_RO: return (char_u *)&(curbuf->b_p_ro); |
5473 #ifdef FEAT_SMARTINDENT | |
5474 case PV_SI: return (char_u *)&(curbuf->b_p_si); | |
5475 #endif | |
5476 case PV_SN: return (char_u *)&(curbuf->b_p_sn); | |
5477 case PV_STS: return (char_u *)&(curbuf->b_p_sts); | |
5478 #ifdef FEAT_SEARCHPATH | |
5479 case PV_SUA: return (char_u *)&(curbuf->b_p_sua); | |
5480 #endif | |
5481 case PV_SWF: return (char_u *)&(curbuf->b_p_swf); | |
5482 #ifdef FEAT_SYN_HL | |
410 | 5483 case PV_SMC: return (char_u *)&(curbuf->b_p_smc); |
744 | 5484 case PV_SYN: return (char_u *)&(curbuf->b_p_syn); |
5485 #endif | |
5486 #ifdef FEAT_SPELL | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5487 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
|
5488 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
|
5489 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl); |
20802
ed00f0fbdaef
patch 8.2.0953: spell checking doesn't work for CamelCased words
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
5490 case PV_SPO: return (char_u *)&(curwin->w_s->b_p_spo); |
7 | 5491 #endif |
5492 case PV_SW: return (char_u *)&(curbuf->b_p_sw); | |
5493 case PV_TS: return (char_u *)&(curbuf->b_p_ts); | |
5494 case PV_TW: return (char_u *)&(curbuf->b_p_tw); | |
5495 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
|
5496 #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
|
5497 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
|
5498 #endif |
7 | 5499 case PV_WM: return (char_u *)&(curbuf->b_p_wm); |
5500 #ifdef FEAT_KEYMAP | |
5501 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); | |
5502 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5503 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5504 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
|
5505 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5506 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5507 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
|
5508 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
|
5509 #endif |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
5510 default: iemsg(_("E356: get_varp ERROR")); |
7 | 5511 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5512 // always return a valid pointer to avoid a crash! |
7 | 5513 return (char_u *)&(curbuf->b_p_wm); |
5514 } | |
5515 | |
5516 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5517 * Return a pointer to the variable for option at 'opt_idx' |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5518 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5519 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5520 get_option_var(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5521 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5522 return options[opt_idx].var; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5523 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5524 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5525 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5526 * Return the full name of the option at 'opt_idx' |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5527 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5528 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5529 get_option_fullname(int opt_idx) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5530 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5531 return (char_u *)options[opt_idx].fullname; |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5532 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5533 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5534 /* |
7 | 5535 * Get the value of 'equalprg', either the buffer-local one or the global one. |
5536 */ | |
5537 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5538 get_equalprg(void) |
7 | 5539 { |
5540 if (*curbuf->b_p_ep == NUL) | |
5541 return p_ep; | |
5542 return curbuf->b_p_ep; | |
5543 } | |
5544 | |
5545 /* | |
5546 * Copy options from one window to another. | |
5547 * Used when splitting a window. | |
5548 */ | |
5549 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5550 win_copy_options(win_T *wp_from, win_T *wp_to) |
7 | 5551 { |
5552 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); | |
5553 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt); | |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5554 after_copy_winopt(wp_to); |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5555 } |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5556 |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5557 /* |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5558 * After copying window options: update variables depending on options. |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5559 */ |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5560 void |
18199
e2be5a6485f5
patch 8.1.2094: the fileio.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18156
diff
changeset
|
5561 after_copy_winopt(win_T *wp UNUSED) |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5562 { |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5563 #ifdef FEAT_LINEBREAK |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5564 briopt_check(wp); |
6162 | 5565 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
5566 #ifdef FEAT_SYN_HL |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5567 fill_culopt_flags(NULL, wp); |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5568 check_colorcolumn(wp); |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
5569 #endif |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5570 set_chars_option(wp, &wp->w_p_lcs); |
7 | 5571 } |
5572 | |
5573 /* | |
5574 * Copy the options from one winopt_T to another. | |
5575 * Doesn't free the old option values in "to", use clear_winopt() for that. | |
5576 * The 'scroll' option is not copied, because it depends on the window height. | |
5577 * The 'previewwindow' option is reset, there can be only one preview window. | |
5578 */ | |
5579 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5580 copy_winopt(winopt_T *from, winopt_T *to) |
7 | 5581 { |
5582 #ifdef FEAT_ARABIC | |
5583 to->wo_arab = from->wo_arab; | |
5584 #endif | |
5585 to->wo_list = from->wo_list; | |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5586 to->wo_lcs = vim_strsave(from->wo_lcs); |
7 | 5587 to->wo_nu = from->wo_nu; |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
5588 to->wo_rnu = from->wo_rnu; |
13 | 5589 #ifdef FEAT_LINEBREAK |
5590 to->wo_nuw = from->wo_nuw; | |
5591 #endif | |
7 | 5592 #ifdef FEAT_RIGHTLEFT |
5593 to->wo_rl = from->wo_rl; | |
5594 to->wo_rlc = vim_strsave(from->wo_rlc); | |
5595 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5596 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5597 to->wo_sbr = vim_strsave(from->wo_sbr); |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5598 #endif |
40 | 5599 #ifdef FEAT_STL_OPT |
5600 to->wo_stl = vim_strsave(from->wo_stl); | |
5601 #endif | |
7 | 5602 to->wo_wrap = from->wo_wrap; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5603 #ifdef FEAT_DIFF |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5604 to->wo_wrap_save = from->wo_wrap_save; |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5605 #endif |
7 | 5606 #ifdef FEAT_LINEBREAK |
5607 to->wo_lbr = from->wo_lbr; | |
5995 | 5608 to->wo_bri = from->wo_bri; |
5609 to->wo_briopt = vim_strsave(from->wo_briopt); | |
7 | 5610 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5611 to->wo_wcr = vim_strsave(from->wo_wcr); |
7 | 5612 to->wo_scb = from->wo_scb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5613 to->wo_scb_save = from->wo_scb_save; |
2651 | 5614 to->wo_crb = from->wo_crb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5615 to->wo_crb_save = from->wo_crb_save; |
744 | 5616 #ifdef FEAT_SPELL |
5617 to->wo_spell = from->wo_spell; | |
5618 #endif | |
221 | 5619 #ifdef FEAT_SYN_HL |
744 | 5620 to->wo_cuc = from->wo_cuc; |
5621 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
|
5622 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
|
5623 to->wo_cc = vim_strsave(from->wo_cc); |
221 | 5624 #endif |
7 | 5625 #ifdef FEAT_DIFF |
5626 to->wo_diff = from->wo_diff; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5627 to->wo_diff_saved = from->wo_diff_saved; |
7 | 5628 #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
|
5629 #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
|
5630 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
|
5631 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
|
5632 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5633 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5634 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
|
5635 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
|
5636 #endif |
7 | 5637 #ifdef FEAT_FOLDING |
5638 to->wo_fdc = from->wo_fdc; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5639 to->wo_fdc_save = from->wo_fdc_save; |
7 | 5640 to->wo_fen = from->wo_fen; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5641 to->wo_fen_save = from->wo_fen_save; |
7 | 5642 to->wo_fdi = vim_strsave(from->wo_fdi); |
5643 to->wo_fml = from->wo_fml; | |
5644 to->wo_fdl = from->wo_fdl; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5645 to->wo_fdl_save = from->wo_fdl_save; |
7 | 5646 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
|
5647 to->wo_fdm_save = from->wo_diff_saved |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5648 ? vim_strsave(from->wo_fdm_save) : empty_option; |
7 | 5649 to->wo_fdn = from->wo_fdn; |
5650 # ifdef FEAT_EVAL | |
5651 to->wo_fde = vim_strsave(from->wo_fde); | |
5652 to->wo_fdt = vim_strsave(from->wo_fdt); | |
5653 # endif | |
5654 to->wo_fmr = vim_strsave(from->wo_fmr); | |
5655 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5656 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5657 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
|
5658 #endif |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5659 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5660 #ifdef FEAT_EVAL |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5661 // Copy the script context so that we know where the value was last set. |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5662 mch_memmove(to->wo_script_ctx, from->wo_script_ctx, |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5663 sizeof(to->wo_script_ctx)); |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5664 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5665 check_winopt(to); // don't want NULL pointers |
7 | 5666 } |
5667 | |
5668 /* | |
5669 * Check string options in a window for a NULL value. | |
5670 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
5671 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5672 check_win_options(win_T *win) |
7 | 5673 { |
5674 check_winopt(&win->w_onebuf_opt); | |
5675 check_winopt(&win->w_allbuf_opt); | |
5676 } | |
5677 | |
5678 /* | |
5679 * Check for NULL pointers in a winopt_T and replace them with empty_option. | |
5680 */ | |
5997 | 5681 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5682 check_winopt(winopt_T *wop UNUSED) |
7 | 5683 { |
5684 #ifdef FEAT_FOLDING | |
5685 check_string_option(&wop->wo_fdi); | |
5686 check_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5687 check_string_option(&wop->wo_fdm_save); |
7 | 5688 # ifdef FEAT_EVAL |
5689 check_string_option(&wop->wo_fde); | |
5690 check_string_option(&wop->wo_fdt); | |
5691 # endif | |
5692 check_string_option(&wop->wo_fmr); | |
5693 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5694 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5695 check_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5696 #endif |
7 | 5697 #ifdef FEAT_RIGHTLEFT |
5698 check_string_option(&wop->wo_rlc); | |
5699 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5700 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5701 check_string_option(&wop->wo_sbr); |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5702 #endif |
40 | 5703 #ifdef FEAT_STL_OPT |
5704 check_string_option(&wop->wo_stl); | |
5705 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5706 #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
|
5707 check_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5708 check_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5709 #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
|
5710 #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
|
5711 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
|
5712 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5713 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5714 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
|
5715 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
|
5716 #endif |
5995 | 5717 #ifdef FEAT_LINEBREAK |
5718 check_string_option(&wop->wo_briopt); | |
5719 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5720 check_string_option(&wop->wo_wcr); |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5721 check_string_option(&wop->wo_lcs); |
7 | 5722 } |
5723 | |
5724 /* | |
5725 * Free the allocated memory inside a winopt_T. | |
5726 */ | |
5727 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5728 clear_winopt(winopt_T *wop UNUSED) |
7 | 5729 { |
5730 #ifdef FEAT_FOLDING | |
5731 clear_string_option(&wop->wo_fdi); | |
5732 clear_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5733 clear_string_option(&wop->wo_fdm_save); |
7 | 5734 # ifdef FEAT_EVAL |
5735 clear_string_option(&wop->wo_fde); | |
5736 clear_string_option(&wop->wo_fdt); | |
5737 # endif | |
5738 clear_string_option(&wop->wo_fmr); | |
5739 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5740 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5741 clear_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5742 #endif |
5995 | 5743 #ifdef FEAT_LINEBREAK |
5744 clear_string_option(&wop->wo_briopt); | |
5745 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5746 clear_string_option(&wop->wo_wcr); |
7 | 5747 #ifdef FEAT_RIGHTLEFT |
5748 clear_string_option(&wop->wo_rlc); | |
5749 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5750 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5751 clear_string_option(&wop->wo_sbr); |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5752 #endif |
40 | 5753 #ifdef FEAT_STL_OPT |
5754 clear_string_option(&wop->wo_stl); | |
5755 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5756 #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
|
5757 clear_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5758 clear_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5759 #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
|
5760 #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
|
5761 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
|
5762 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5763 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5764 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
|
5765 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
|
5766 #endif |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5767 clear_string_option(&wop->wo_lcs); |
7 | 5768 } |
5769 | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5770 #ifdef FEAT_EVAL |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5771 // Index into the options table for a buffer-local option enum. |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5772 static int buf_opt_idx[BV_COUNT]; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5773 # define COPY_OPT_SCTX(buf, bv) buf->b_p_script_ctx[bv] = options[buf_opt_idx[bv]].script_ctx |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5774 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5775 /* |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5776 * Initialize buf_opt_idx[] if not done already. |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5777 */ |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5778 static void |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5779 init_buf_opt_idx(void) |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5780 { |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5781 static int did_init_buf_opt_idx = FALSE; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5782 int i; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5783 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5784 if (did_init_buf_opt_idx) |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5785 return; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5786 did_init_buf_opt_idx = TRUE; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5787 for (i = 0; !istermoption_idx(i); i++) |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5788 if (options[i].indir & PV_BUF) |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5789 buf_opt_idx[options[i].indir & PV_MASK] = i; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5790 } |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5791 #else |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5792 # define COPY_OPT_SCTX(buf, bv) |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5793 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5794 |
7 | 5795 /* |
5796 * Copy global option values to local options for one buffer. | |
5797 * Used when creating a new buffer and sometimes when entering a buffer. | |
5798 * flags: | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5799 * BCO_ENTER We will enter the buffer "buf". |
7 | 5800 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when |
5801 * appropriate. | |
5802 * BCO_NOHELP Don't copy the values to a help buffer. | |
5803 */ | |
5804 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5805 buf_copy_options(buf_T *buf, int flags) |
7 | 5806 { |
5807 int should_copy = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5808 char_u *save_p_isk = NULL; // init for GCC |
7 | 5809 int dont_do_help; |
5810 int did_isk = FALSE; | |
5811 | |
5812 /* | |
5813 * Skip this when the option defaults have not been set yet. Happens when | |
5814 * main() allocates the first buffer. | |
5815 */ | |
5816 if (p_cpo != NULL) | |
5817 { | |
5818 /* | |
5819 * Always copy when entering and 'cpo' contains 'S'. | |
5820 * Don't copy when already initialized. | |
5821 * Don't copy when 'cpo' contains 's' and not entering. | |
5822 * 'S' BCO_ENTER initialized 's' should_copy | |
5823 * yes yes X X TRUE | |
5824 * yes no yes X FALSE | |
5825 * no X yes X FALSE | |
5826 * X no no yes FALSE | |
5827 * X no no no TRUE | |
5828 * no yes no X TRUE | |
5829 */ | |
5830 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) | |
5831 && (buf->b_p_initialized | |
5832 || (!(flags & BCO_ENTER) | |
5833 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
5834 should_copy = FALSE; | |
5835 | |
5836 if (should_copy || (flags & BCO_ALWAYS)) | |
5837 { | |
18384
63dd78ea6610
patch 8.1.2186: error for bad regexp even though regexp is not used
Bram Moolenaar <Bram@vim.org>
parents:
18380
diff
changeset
|
5838 #ifdef FEAT_EVAL |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
5839 CLEAR_FIELD(buf->b_p_script_ctx); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5840 init_buf_opt_idx(); |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5841 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5842 // Don't copy the options specific to a help buffer when |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5843 // BCO_NOHELP is given or the options were initialized already |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5844 // (jumping back to a help file with CTRL-T or CTRL-O) |
7 | 5845 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) |
5846 || buf->b_p_initialized; | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5847 if (dont_do_help) // don't free b_p_isk |
7 | 5848 { |
5849 save_p_isk = buf->b_p_isk; | |
5850 buf->b_p_isk = NULL; | |
5851 } | |
5852 /* | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14381
diff
changeset
|
5853 * 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
|
5854 * reset 'readonly' and copy 'fileformat'. |
7 | 5855 */ |
5856 if (!buf->b_p_initialized) | |
5857 { | |
5858 free_buf_options(buf, TRUE); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5859 buf->b_p_ro = FALSE; // don't copy readonly |
7 | 5860 buf->b_p_tx = p_tx; |
5861 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
|
5862 switch (*p_ffs) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5863 { |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5864 case 'm': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5865 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
|
5866 case 'd': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5867 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
|
5868 case 'u': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5869 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
|
5870 default: |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5871 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
|
5872 } |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5873 if (buf->b_p_ff != NULL) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5874 buf->b_start_ffc = *buf->b_p_ff; |
7 | 5875 buf->b_p_bh = empty_option; |
5876 buf->b_p_bt = empty_option; | |
5877 } | |
5878 else | |
5879 free_buf_options(buf, FALSE); | |
5880 | |
5881 buf->b_p_ai = p_ai; | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5882 COPY_OPT_SCTX(buf, BV_AI); |
7 | 5883 buf->b_p_ai_nopaste = p_ai_nopaste; |
5884 buf->b_p_sw = p_sw; | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5885 COPY_OPT_SCTX(buf, BV_SW); |
7 | 5886 buf->b_p_tw = p_tw; |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5887 COPY_OPT_SCTX(buf, BV_TW); |
7 | 5888 buf->b_p_tw_nopaste = p_tw_nopaste; |
5889 buf->b_p_tw_nobin = p_tw_nobin; | |
5890 buf->b_p_wm = p_wm; | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5891 COPY_OPT_SCTX(buf, BV_WM); |
7 | 5892 buf->b_p_wm_nopaste = p_wm_nopaste; |
5893 buf->b_p_wm_nobin = p_wm_nobin; | |
5894 buf->b_p_bin = p_bin; | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5895 COPY_OPT_SCTX(buf, BV_BIN); |
402 | 5896 buf->b_p_bomb = p_bomb; |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5897 COPY_OPT_SCTX(buf, BV_BOMB); |
6954 | 5898 buf->b_p_fixeol = p_fixeol; |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5899 COPY_OPT_SCTX(buf, BV_FIXEOL); |
7 | 5900 buf->b_p_et = p_et; |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5901 COPY_OPT_SCTX(buf, BV_ET); |
7 | 5902 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
|
5903 buf->b_p_et_nopaste = p_et_nopaste; |
7 | 5904 buf->b_p_ml = p_ml; |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5905 COPY_OPT_SCTX(buf, BV_ML); |
7 | 5906 buf->b_p_ml_nobin = p_ml_nobin; |
5907 buf->b_p_inf = p_inf; | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5908 COPY_OPT_SCTX(buf, BV_INF); |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22242
diff
changeset
|
5909 if (cmdmod.cmod_flags & CMOD_NOSWAPFILE) |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5910 buf->b_p_swf = FALSE; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5911 else |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5912 { |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5913 buf->b_p_swf = p_swf; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5914 COPY_OPT_SCTX(buf, BV_INF); |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5915 } |
7 | 5916 buf->b_p_cpt = vim_strsave(p_cpt); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5917 COPY_OPT_SCTX(buf, BV_CPT); |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17791
diff
changeset
|
5918 #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
|
5919 buf->b_p_csl = vim_strsave(p_csl); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5920 COPY_OPT_SCTX(buf, BV_CSL); |
7 | 5921 #endif |
12 | 5922 #ifdef FEAT_COMPL_FUNC |
5923 buf->b_p_cfu = vim_strsave(p_cfu); | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5924 COPY_OPT_SCTX(buf, BV_CFU); |
502 | 5925 buf->b_p_ofu = vim_strsave(p_ofu); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5926 COPY_OPT_SCTX(buf, BV_OFU); |
12 | 5927 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5928 #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
|
5929 buf->b_p_tfu = vim_strsave(p_tfu); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5930 COPY_OPT_SCTX(buf, BV_TFU); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5931 #endif |
7 | 5932 buf->b_p_sts = p_sts; |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5933 COPY_OPT_SCTX(buf, BV_STS); |
7 | 5934 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
|
5935 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5936 buf->b_p_vsts = vim_strsave(p_vsts); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5937 COPY_OPT_SCTX(buf, BV_VSTS); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5938 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
|
5939 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
|
5940 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5941 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
|
5942 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
|
5943 ? 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
|
5944 #endif |
7 | 5945 buf->b_p_sn = p_sn; |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5946 COPY_OPT_SCTX(buf, BV_SN); |
7 | 5947 buf->b_p_com = vim_strsave(p_com); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5948 COPY_OPT_SCTX(buf, BV_COM); |
7 | 5949 #ifdef FEAT_FOLDING |
5950 buf->b_p_cms = vim_strsave(p_cms); | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5951 COPY_OPT_SCTX(buf, BV_CMS); |
7 | 5952 #endif |
5953 buf->b_p_fo = vim_strsave(p_fo); | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5954 COPY_OPT_SCTX(buf, BV_FO); |
41 | 5955 buf->b_p_flp = vim_strsave(p_flp); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5956 COPY_OPT_SCTX(buf, BV_FLP); |
18199
e2be5a6485f5
patch 8.1.2094: the fileio.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18156
diff
changeset
|
5957 // NOTE: Valgrind may report a bogus memory leak for 'nrformats' |
e2be5a6485f5
patch 8.1.2094: the fileio.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18156
diff
changeset
|
5958 // when it is set to 8 bytes in defaults.vim. |
7 | 5959 buf->b_p_nf = vim_strsave(p_nf); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5960 COPY_OPT_SCTX(buf, BV_NF); |
7 | 5961 buf->b_p_mps = vim_strsave(p_mps); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5962 COPY_OPT_SCTX(buf, BV_MPS); |
7 | 5963 #ifdef FEAT_SMARTINDENT |
5964 buf->b_p_si = p_si; | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5965 COPY_OPT_SCTX(buf, BV_SI); |
7 | 5966 #endif |
5967 buf->b_p_ci = p_ci; | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5968 COPY_OPT_SCTX(buf, BV_CI); |
7 | 5969 #ifdef FEAT_CINDENT |
5970 buf->b_p_cin = p_cin; | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5971 COPY_OPT_SCTX(buf, BV_CIN); |
7 | 5972 buf->b_p_cink = vim_strsave(p_cink); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5973 COPY_OPT_SCTX(buf, BV_CINK); |
7 | 5974 buf->b_p_cino = vim_strsave(p_cino); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5975 COPY_OPT_SCTX(buf, BV_CINO); |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5976 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5977 // Don't copy 'filetype', it must be detected |
7 | 5978 buf->b_p_ft = empty_option; |
5979 buf->b_p_pi = p_pi; | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5980 COPY_OPT_SCTX(buf, BV_PI); |
7 | 5981 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) |
5982 buf->b_p_cinw = vim_strsave(p_cinw); | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5983 COPY_OPT_SCTX(buf, BV_CINW); |
7 | 5984 #endif |
5985 #ifdef FEAT_LISP | |
5986 buf->b_p_lisp = p_lisp; | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5987 COPY_OPT_SCTX(buf, BV_LISP); |
7 | 5988 #endif |
5989 #ifdef FEAT_SYN_HL | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5990 // Don't copy 'syntax', it must be set |
7 | 5991 buf->b_p_syn = empty_option; |
410 | 5992 buf->b_p_smc = p_smc; |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5993 COPY_OPT_SCTX(buf, BV_SMC); |
7687
61354fabf8a2
commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents:
7538
diff
changeset
|
5994 buf->b_s.b_syn_isk = empty_option; |
744 | 5995 #endif |
5996 #ifdef FEAT_SPELL | |
2599 | 5997 buf->b_s.b_p_spc = vim_strsave(p_spc); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5998 COPY_OPT_SCTX(buf, BV_SPC); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5999 (void)compile_cap_prog(&buf->b_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6000 buf->b_s.b_p_spf = vim_strsave(p_spf); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6001 COPY_OPT_SCTX(buf, BV_SPF); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6002 buf->b_s.b_p_spl = vim_strsave(p_spl); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6003 COPY_OPT_SCTX(buf, BV_SPL); |
20802
ed00f0fbdaef
patch 8.2.0953: spell checking doesn't work for CamelCased words
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
6004 buf->b_s.b_p_spo = vim_strsave(p_spo); |
ed00f0fbdaef
patch 8.2.0953: spell checking doesn't work for CamelCased words
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
6005 COPY_OPT_SCTX(buf, BV_SPO); |
7 | 6006 #endif |
6007 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
6008 buf->b_p_inde = vim_strsave(p_inde); | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6009 COPY_OPT_SCTX(buf, BV_INDE); |
7 | 6010 buf->b_p_indk = vim_strsave(p_indk); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6011 COPY_OPT_SCTX(buf, BV_INDK); |
7 | 6012 #endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
6013 buf->b_p_fp = empty_option; |
667 | 6014 #if defined(FEAT_EVAL) |
6015 buf->b_p_fex = vim_strsave(p_fex); | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6016 COPY_OPT_SCTX(buf, BV_FEX); |
667 | 6017 #endif |
7 | 6018 #ifdef FEAT_CRYPT |
6019 buf->b_p_key = vim_strsave(p_key); | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6020 COPY_OPT_SCTX(buf, BV_KEY); |
7 | 6021 #endif |
6022 #ifdef FEAT_SEARCHPATH | |
6023 buf->b_p_sua = vim_strsave(p_sua); | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6024 COPY_OPT_SCTX(buf, BV_SUA); |
7 | 6025 #endif |
6026 #ifdef FEAT_KEYMAP | |
6027 buf->b_p_keymap = vim_strsave(p_keymap); | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6028 COPY_OPT_SCTX(buf, BV_KMAP); |
7 | 6029 buf->b_kmap_state |= KEYMAP_INIT; |
6030 #endif | |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6031 #ifdef FEAT_TERMINAL |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6032 buf->b_p_twsl = p_twsl; |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6033 COPY_OPT_SCTX(buf, BV_TWSL); |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6034 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6035 // This isn't really an option, but copying the langmap and IME |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6036 // state from the current buffer is better than resetting it. |
7 | 6037 buf->b_p_iminsert = p_iminsert; |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6038 COPY_OPT_SCTX(buf, BV_IMI); |
7 | 6039 buf->b_p_imsearch = p_imsearch; |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6040 COPY_OPT_SCTX(buf, BV_IMS); |
7 | 6041 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6042 // options that are normally global but also have a local value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6043 // are not copied, start using the global value |
7 | 6044 buf->b_p_ar = -1; |
5446 | 6045 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
6243 | 6046 buf->b_p_bkc = empty_option; |
6047 buf->b_bkc_flags = 0; | |
7 | 6048 #ifdef FEAT_QUICKFIX |
6049 buf->b_p_gp = empty_option; | |
6050 buf->b_p_mp = empty_option; | |
6051 buf->b_p_efm = empty_option; | |
6052 #endif | |
6053 buf->b_p_ep = empty_option; | |
6054 buf->b_p_kp = empty_option; | |
6055 buf->b_p_path = empty_option; | |
6056 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
|
6057 buf->b_p_tc = empty_option; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
6058 buf->b_tc_flags = 0; |
7 | 6059 #ifdef FEAT_FIND_ID |
6060 buf->b_p_def = empty_option; | |
6061 buf->b_p_inc = empty_option; | |
6062 # ifdef FEAT_EVAL | |
6063 buf->b_p_inex = vim_strsave(p_inex); | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6064 COPY_OPT_SCTX(buf, BV_INEX); |
7 | 6065 # endif |
6066 #endif | |
6067 buf->b_p_dict = empty_option; | |
6068 buf->b_p_tsr = empty_option; | |
12 | 6069 #ifdef FEAT_TEXTOBJ |
6070 buf->b_p_qe = vim_strsave(p_qe); | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6071 COPY_OPT_SCTX(buf, BV_QE); |
12 | 6072 #endif |
790 | 6073 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
6074 buf->b_p_bexpr = empty_option; | |
6075 #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
|
6076 #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
|
6077 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
|
6078 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
6079 #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
|
6080 buf->b_p_udf = p_udf; |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6081 COPY_OPT_SCTX(buf, BV_UDF); |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
6082 #endif |
5712 | 6083 #ifdef FEAT_LISP |
6084 buf->b_p_lw = empty_option; | |
6085 #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
|
6086 buf->b_p_menc = empty_option; |
7 | 6087 |
6088 /* | |
6089 * Don't copy the options set by ex_help(), use the saved values, | |
6090 * when going from a help buffer to a non-help buffer. | |
6091 * Don't touch these at all when BCO_NOHELP is used and going from | |
6092 * or to a help buffer. | |
6093 */ | |
6094 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
|
6095 { |
7 | 6096 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
|
6097 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6098 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
|
6099 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
|
6100 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6101 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
|
6102 #endif |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6103 } |
7 | 6104 else |
6105 { | |
6106 buf->b_p_isk = vim_strsave(p_isk); | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6107 COPY_OPT_SCTX(buf, BV_ISK); |
7 | 6108 did_isk = TRUE; |
6109 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
|
6110 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6111 buf->b_p_vts = vim_strsave(p_vts); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6112 COPY_OPT_SCTX(buf, BV_VTS); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6113 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
|
6114 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
|
6115 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6116 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
|
6117 #endif |
7 | 6118 buf->b_help = FALSE; |
6119 if (buf->b_p_bt[0] == 'h') | |
6120 clear_string_option(&buf->b_p_bt); | |
6121 buf->b_p_ma = p_ma; | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6122 COPY_OPT_SCTX(buf, BV_MA); |
7 | 6123 } |
6124 } | |
6125 | |
6126 /* | |
6127 * When the options should be copied (ignoring BCO_ALWAYS), set the | |
6128 * flag that indicates that the options have been initialized. | |
6129 */ | |
6130 if (should_copy) | |
6131 buf->b_p_initialized = TRUE; | |
6132 } | |
6133 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6134 check_buf_options(buf); // make sure we don't have NULLs |
7 | 6135 if (did_isk) |
6136 (void)buf_init_chartab(buf, FALSE); | |
6137 } | |
6138 | |
6139 /* | |
6140 * Reset the 'modifiable' option and its default value. | |
6141 */ | |
6142 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6143 reset_modifiable(void) |
7 | 6144 { |
6145 int opt_idx; | |
6146 | |
6147 curbuf->b_p_ma = FALSE; | |
6148 p_ma = FALSE; | |
6149 opt_idx = findoption((char_u *)"ma"); | |
838 | 6150 if (opt_idx >= 0) |
6151 options[opt_idx].def_val[VI_DEFAULT] = FALSE; | |
7 | 6152 } |
6153 | |
6154 /* | |
6155 * Set the global value for 'iminsert' to the local value. | |
6156 */ | |
6157 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6158 set_iminsert_global(void) |
7 | 6159 { |
6160 p_iminsert = curbuf->b_p_iminsert; | |
6161 } | |
6162 | |
6163 /* | |
6164 * Set the global value for 'imsearch' to the local value. | |
6165 */ | |
6166 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6167 set_imsearch_global(void) |
7 | 6168 { |
6169 p_imsearch = curbuf->b_p_imsearch; | |
6170 } | |
6171 | |
6172 static int expand_option_idx = -1; | |
6173 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; | |
6174 static int expand_option_flags = 0; | |
6175 | |
6176 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6177 set_context_in_set_cmd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6178 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6179 char_u *arg, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6180 int opt_flags) // OPT_GLOBAL and/or OPT_LOCAL |
7 | 6181 { |
6182 int nextchar; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6183 long_u flags = 0; // init for GCC |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6184 int opt_idx = 0; // init for GCC |
7 | 6185 char_u *p; |
6186 char_u *s; | |
6187 int is_term_option = FALSE; | |
6188 int key; | |
6189 | |
6190 expand_option_flags = opt_flags; | |
6191 | |
6192 xp->xp_context = EXPAND_SETTINGS; | |
6193 if (*arg == NUL) | |
6194 { | |
6195 xp->xp_pattern = arg; | |
6196 return; | |
6197 } | |
6198 p = arg + STRLEN(arg) - 1; | |
6199 if (*p == ' ' && *(p - 1) != '\\') | |
6200 { | |
6201 xp->xp_pattern = p + 1; | |
6202 return; | |
6203 } | |
6204 while (p > arg) | |
6205 { | |
6206 s = p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6207 // count number of backslashes before ' ' or ',' |
7 | 6208 if (*p == ' ' || *p == ',') |
6209 { | |
6210 while (s > arg && *(s - 1) == '\\') | |
6211 --s; | |
6212 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6213 // break at a space with an even number of backslashes |
7 | 6214 if (*p == ' ' && ((p - s) & 1) == 0) |
6215 { | |
6216 ++p; | |
6217 break; | |
6218 } | |
6219 --p; | |
6220 } | |
1911 | 6221 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0) |
7 | 6222 { |
6223 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
6224 p += 2; | |
6225 } | |
6226 if (STRNCMP(p, "inv", 3) == 0) | |
6227 { | |
6228 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
6229 p += 3; | |
6230 } | |
6231 xp->xp_pattern = arg = p; | |
6232 if (*arg == '<') | |
6233 { | |
6234 while (*p != '>') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6235 if (*p++ == NUL) // expand terminal option name |
7 | 6236 return; |
6237 key = get_special_key_code(arg + 1); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6238 if (key == 0) // unknown name |
7 | 6239 { |
6240 xp->xp_context = EXPAND_NOTHING; | |
6241 return; | |
6242 } | |
6243 nextchar = *++p; | |
6244 is_term_option = TRUE; | |
6245 expand_option_name[2] = KEY2TERMCAP0(key); | |
6246 expand_option_name[3] = KEY2TERMCAP1(key); | |
6247 } | |
6248 else | |
6249 { | |
6250 if (p[0] == 't' && p[1] == '_') | |
6251 { | |
6252 p += 2; | |
6253 if (*p != NUL) | |
6254 ++p; | |
6255 if (*p == NUL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6256 return; // expand option name |
7 | 6257 nextchar = *++p; |
6258 is_term_option = TRUE; | |
6259 expand_option_name[2] = p[-2]; | |
6260 expand_option_name[3] = p[-1]; | |
6261 } | |
6262 else | |
6263 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6264 // Allow * wildcard |
7 | 6265 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') |
6266 p++; | |
6267 if (*p == NUL) | |
6268 return; | |
6269 nextchar = *p; | |
6270 *p = NUL; | |
6271 opt_idx = findoption(arg); | |
6272 *p = nextchar; | |
6273 if (opt_idx == -1 || options[opt_idx].var == NULL) | |
6274 { | |
6275 xp->xp_context = EXPAND_NOTHING; | |
6276 return; | |
6277 } | |
6278 flags = options[opt_idx].flags; | |
6279 if (flags & P_BOOL) | |
6280 { | |
6281 xp->xp_context = EXPAND_NOTHING; | |
6282 return; | |
6283 } | |
6284 } | |
6285 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6286 // handle "-=" and "+=" |
7 | 6287 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') |
6288 { | |
6289 ++p; | |
6290 nextchar = '='; | |
6291 } | |
6292 if ((nextchar != '=' && nextchar != ':') | |
6293 || xp->xp_context == EXPAND_BOOL_SETTINGS) | |
6294 { | |
6295 xp->xp_context = EXPAND_UNSUCCESSFUL; | |
6296 return; | |
6297 } | |
6298 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) | |
6299 { | |
6300 xp->xp_context = EXPAND_OLD_SETTING; | |
6301 if (is_term_option) | |
6302 expand_option_idx = -1; | |
6303 else | |
6304 expand_option_idx = opt_idx; | |
6305 xp->xp_pattern = p + 1; | |
6306 return; | |
6307 } | |
6308 xp->xp_context = EXPAND_NOTHING; | |
6309 if (is_term_option || (flags & P_NUM)) | |
6310 return; | |
6311 | |
6312 xp->xp_pattern = p + 1; | |
6313 | |
6314 if (flags & P_EXPAND) | |
6315 { | |
6316 p = options[opt_idx].var; | |
6317 if (p == (char_u *)&p_bdir | |
6318 || p == (char_u *)&p_dir | |
6319 || p == (char_u *)&p_path | |
8182
95d59081580f
commit https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
6320 || p == (char_u *)&p_pp |
7 | 6321 || p == (char_u *)&p_rtp |
6322 #ifdef FEAT_SEARCHPATH | |
6323 || p == (char_u *)&p_cdpath | |
6324 #endif | |
6325 #ifdef FEAT_SESSION | |
6326 || p == (char_u *)&p_vdir | |
6327 #endif | |
6328 ) | |
6329 { | |
6330 xp->xp_context = EXPAND_DIRECTORIES; | |
6331 if (p == (char_u *)&p_path | |
6332 #ifdef FEAT_SEARCHPATH | |
6333 || p == (char_u *)&p_cdpath | |
6334 #endif | |
6335 ) | |
6336 xp->xp_backslash = XP_BS_THREE; | |
6337 else | |
6338 xp->xp_backslash = XP_BS_ONE; | |
6339 } | |
23821
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
6340 else if (p == (char_u *)&p_ft) |
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
6341 { |
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
6342 xp->xp_context = EXPAND_FILETYPE; |
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
6343 } |
7 | 6344 else |
6345 { | |
6346 xp->xp_context = EXPAND_FILES; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6347 // for 'tags' need three backslashes for a space |
7 | 6348 if (p == (char_u *)&p_tags) |
6349 xp->xp_backslash = XP_BS_THREE; | |
6350 else | |
6351 xp->xp_backslash = XP_BS_ONE; | |
6352 } | |
6353 } | |
6354 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6355 // For an option that is a list of file names, find the start of the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6356 // last file name. |
7 | 6357 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) |
6358 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6359 // count number of backslashes before ' ' or ',' |
7 | 6360 if (*p == ' ' || *p == ',') |
6361 { | |
6362 s = p; | |
6363 while (s > xp->xp_pattern && *(s - 1) == '\\') | |
6364 --s; | |
6365 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) | |
6366 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) | |
6367 { | |
6368 xp->xp_pattern = p + 1; | |
6369 break; | |
6370 } | |
6371 } | |
374 | 6372 |
744 | 6373 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6374 // for 'spellsuggest' start at "file:" |
374 | 6375 if (options[opt_idx].var == (char_u *)&p_sps |
6376 && STRNCMP(p, "file:", 5) == 0) | |
6377 { | |
6378 xp->xp_pattern = p + 5; | |
6379 break; | |
6380 } | |
6381 #endif | |
7 | 6382 } |
6383 | |
6384 return; | |
6385 } | |
6386 | |
6387 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6388 ExpandSettings( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6389 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6390 regmatch_T *regmatch, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6391 int *num_file, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6392 char_u ***file) |
7 | 6393 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6394 int num_normal = 0; // Nr of matching non-term-code settings |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6395 int num_term = 0; // Nr of matching terminal code settings |
7 | 6396 int opt_idx; |
6397 int match; | |
6398 int count = 0; | |
6399 char_u *str; | |
6400 int loop; | |
6401 int is_term_opt; | |
6402 char_u name_buf[MAX_KEY_NAME_LEN]; | |
6403 static char *(names[]) = {"all", "termcap"}; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6404 int ic = regmatch->rm_ic; // remember the ignore-case flag |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6405 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6406 // do this loop twice: |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6407 // loop == 0: count the number of matching options |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6408 // loop == 1: copy the matching options into allocated memory |
7 | 6409 for (loop = 0; loop <= 1; ++loop) |
6410 { | |
6411 regmatch->rm_ic = ic; | |
6412 if (xp->xp_context != EXPAND_BOOL_SETTINGS) | |
6413 { | |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
6414 for (match = 0; match < (int)ARRAY_LENGTH(names); ++match) |
7 | 6415 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0)) |
6416 { | |
6417 if (loop == 0) | |
6418 num_normal++; | |
6419 else | |
6420 (*file)[count++] = vim_strsave((char_u *)names[match]); | |
6421 } | |
6422 } | |
6423 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; | |
6424 opt_idx++) | |
6425 { | |
6426 if (options[opt_idx].var == NULL) | |
6427 continue; | |
6428 if (xp->xp_context == EXPAND_BOOL_SETTINGS | |
6429 && !(options[opt_idx].flags & P_BOOL)) | |
6430 continue; | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6431 is_term_opt = istermoption_idx(opt_idx); |
7 | 6432 if (is_term_opt && num_normal > 0) |
6433 continue; | |
6434 match = FALSE; | |
6435 if (vim_regexec(regmatch, str, (colnr_T)0) | |
6436 || (options[opt_idx].shortname != NULL | |
6437 && vim_regexec(regmatch, | |
6438 (char_u *)options[opt_idx].shortname, (colnr_T)0))) | |
6439 match = TRUE; | |
6440 else if (is_term_opt) | |
6441 { | |
6442 name_buf[0] = '<'; | |
6443 name_buf[1] = 't'; | |
6444 name_buf[2] = '_'; | |
6445 name_buf[3] = str[2]; | |
6446 name_buf[4] = str[3]; | |
6447 name_buf[5] = '>'; | |
6448 name_buf[6] = NUL; | |
6449 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6450 { | |
6451 match = TRUE; | |
6452 str = name_buf; | |
6453 } | |
6454 } | |
6455 if (match) | |
6456 { | |
6457 if (loop == 0) | |
6458 { | |
6459 if (is_term_opt) | |
6460 num_term++; | |
6461 else | |
6462 num_normal++; | |
6463 } | |
6464 else | |
6465 (*file)[count++] = vim_strsave(str); | |
6466 } | |
6467 } | |
6468 /* | |
6469 * Check terminal key codes, these are not in the option table | |
6470 */ | |
6471 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) | |
6472 { | |
6473 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) | |
6474 { | |
6475 if (!isprint(str[0]) || !isprint(str[1])) | |
6476 continue; | |
6477 | |
6478 name_buf[0] = 't'; | |
6479 name_buf[1] = '_'; | |
6480 name_buf[2] = str[0]; | |
6481 name_buf[3] = str[1]; | |
6482 name_buf[4] = NUL; | |
6483 | |
6484 match = FALSE; | |
6485 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6486 match = TRUE; | |
6487 else | |
6488 { | |
6489 name_buf[0] = '<'; | |
6490 name_buf[1] = 't'; | |
6491 name_buf[2] = '_'; | |
6492 name_buf[3] = str[0]; | |
6493 name_buf[4] = str[1]; | |
6494 name_buf[5] = '>'; | |
6495 name_buf[6] = NUL; | |
6496 | |
6497 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6498 match = TRUE; | |
6499 } | |
6500 if (match) | |
6501 { | |
6502 if (loop == 0) | |
6503 num_term++; | |
6504 else | |
6505 (*file)[count++] = vim_strsave(name_buf); | |
6506 } | |
6507 } | |
6508 | |
6509 /* | |
6510 * Check special key names. | |
6511 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6512 regmatch->rm_ic = TRUE; // ignore case here |
7 | 6513 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) |
6514 { | |
6515 name_buf[0] = '<'; | |
6516 STRCPY(name_buf + 1, str); | |
6517 STRCAT(name_buf, ">"); | |
6518 | |
6519 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6520 { | |
6521 if (loop == 0) | |
6522 num_term++; | |
6523 else | |
6524 (*file)[count++] = vim_strsave(name_buf); | |
6525 } | |
6526 } | |
6527 } | |
6528 if (loop == 0) | |
6529 { | |
6530 if (num_normal > 0) | |
6531 *num_file = num_normal; | |
6532 else if (num_term > 0) | |
6533 *num_file = num_term; | |
6534 else | |
6535 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
|
6536 *file = ALLOC_MULT(char_u *, *num_file); |
7 | 6537 if (*file == NULL) |
6538 { | |
6539 *file = (char_u **)""; | |
6540 return FAIL; | |
6541 } | |
6542 } | |
6543 } | |
6544 return OK; | |
6545 } | |
6546 | |
6547 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6548 ExpandOldSetting(int *num_file, char_u ***file) |
7 | 6549 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6550 char_u *var = NULL; // init for GCC |
7 | 6551 char_u *buf; |
6552 | |
6553 *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
|
6554 *file = ALLOC_ONE(char_u *); |
7 | 6555 if (*file == NULL) |
6556 return FAIL; | |
6557 | |
6558 /* | |
6559 * For a terminal key code expand_option_idx is < 0. | |
6560 */ | |
6561 if (expand_option_idx < 0) | |
6562 { | |
6563 var = find_termcode(expand_option_name + 2); | |
6564 if (var == NULL) | |
6565 expand_option_idx = findoption(expand_option_name); | |
6566 } | |
6567 | |
6568 if (expand_option_idx >= 0) | |
6569 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6570 // put string of option value in NameBuff |
7 | 6571 option_value2string(&options[expand_option_idx], expand_option_flags); |
6572 var = NameBuff; | |
6573 } | |
6574 else if (var == NULL) | |
6575 var = (char_u *)""; | |
6576 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6577 // A backslash is required before some characters. This is the reverse of |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6578 // what happens in do_set(). |
7 | 6579 buf = vim_strsave_escaped(var, escape_chars); |
6580 | |
6581 if (buf == NULL) | |
6582 { | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13242
diff
changeset
|
6583 VIM_CLEAR(*file); |
7 | 6584 return FAIL; |
6585 } | |
6586 | |
6587 #ifdef BACKSLASH_IN_FILENAME | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6588 // For MS-Windows et al. we don't double backslashes at the start and |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6589 // 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
|
6590 for (var = buf; *var != NUL; MB_PTR_ADV(var)) |
7 | 6591 if (var[0] == '\\' && var[1] == '\\' |
6592 && expand_option_idx >= 0 | |
6593 && (options[expand_option_idx].flags & P_EXPAND) | |
6594 && vim_isfilec(var[2]) | |
6595 && (var[2] != '\\' || (var == buf && var[4] != '\\'))) | |
1622 | 6596 STRMOVE(var, var + 1); |
7 | 6597 #endif |
6598 | |
6599 *file[0] = buf; | |
6600 *num_file = 1; | |
6601 return OK; | |
6602 } | |
6603 | |
6604 /* | |
6605 * Get the value for the numeric or string option *opp in a nice format into | |
6606 * NameBuff[]. Must not be called with a hidden option! | |
6607 */ | |
6608 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6609 option_value2string( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6610 struct vimoption *opp, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6611 int opt_flags) // OPT_GLOBAL and/or OPT_LOCAL |
7 | 6612 { |
6613 char_u *varp; | |
6614 | |
6615 varp = get_varp_scope(opp, opt_flags); | |
6616 | |
6617 if (opp->flags & P_NUM) | |
6618 { | |
6619 long wc = 0; | |
6620 | |
6621 if (wc_use_keyname(varp, &wc)) | |
6622 STRCPY(NameBuff, get_special_key_name((int)wc, 0)); | |
6623 else if (wc != 0) | |
6624 STRCPY(NameBuff, transchar((int)wc)); | |
6625 else | |
6626 sprintf((char *)NameBuff, "%ld", *(long *)varp); | |
6627 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6628 else // P_STRING |
7 | 6629 { |
6630 varp = *(char_u **)(varp); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6631 if (varp == NULL) // just in case |
7 | 6632 NameBuff[0] = NUL; |
6633 #ifdef FEAT_CRYPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6634 // don't show the actual value of 'key', only that it's set |
840 | 6635 else if (opp->var == (char_u *)&p_key && *varp) |
7 | 6636 STRCPY(NameBuff, "*****"); |
6637 #endif | |
6638 else if (opp->flags & P_EXPAND) | |
6639 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6640 // Translate 'pastetoggle' into special key names |
7 | 6641 else if ((char_u **)opp->var == &p_pt) |
6642 str2specialbuf(p_pt, NameBuff, MAXPATHL); | |
6643 else | |
419 | 6644 vim_strncpy(NameBuff, varp, MAXPATHL - 1); |
7 | 6645 } |
6646 } | |
6647 | |
6648 /* | |
6649 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be | |
6650 * printed as a keyname. | |
6651 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. | |
6652 */ | |
6653 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6654 wc_use_keyname(char_u *varp, long *wcp) |
7 | 6655 { |
6656 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) | |
6657 { | |
6658 *wcp = *(long *)varp; | |
6659 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0) | |
6660 return TRUE; | |
6661 } | |
6662 return FALSE; | |
6663 } | |
6664 | |
6665 /* | |
6666 * Return TRUE if "x" is present in 'shortmess' option, or | |
6667 * 'shortmess' contains 'a' and "x" is present in SHM_A. | |
6668 */ | |
6669 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6670 shortmess(int x) |
7 | 6671 { |
3384 | 6672 return p_shm != NULL && |
6673 ( vim_strchr(p_shm, x) != NULL | |
7 | 6674 || (vim_strchr(p_shm, 'a') != NULL |
6675 && vim_strchr((char_u *)SHM_A, x) != NULL)); | |
6676 } | |
6677 | |
6678 /* | |
6679 * paste_option_changed() - Called after p_paste was set or reset. | |
6680 */ | |
6681 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6682 paste_option_changed(void) |
7 | 6683 { |
6684 static int old_p_paste = FALSE; | |
6685 static int save_sm = 0; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6686 static int save_sta = 0; |
7 | 6687 #ifdef FEAT_CMDL_INFO |
6688 static int save_ru = 0; | |
6689 #endif | |
6690 #ifdef FEAT_RIGHTLEFT | |
6691 static int save_ri = 0; | |
6692 static int save_hkmap = 0; | |
6693 #endif | |
6694 buf_T *buf; | |
6695 | |
6696 if (p_paste) | |
6697 { | |
6698 /* | |
6699 * Paste switched from off to on. | |
6700 * Save the current values, so they can be restored later. | |
6701 */ | |
6702 if (!old_p_paste) | |
6703 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6704 // save options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6705 FOR_ALL_BUFFERS(buf) |
7 | 6706 { |
6707 buf->b_p_tw_nopaste = buf->b_p_tw; | |
6708 buf->b_p_wm_nopaste = buf->b_p_wm; | |
6709 buf->b_p_sts_nopaste = buf->b_p_sts; | |
6710 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
|
6711 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
|
6712 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6713 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
|
6714 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
|
6715 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
|
6716 ? 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
|
6717 #endif |
7 | 6718 } |
6719 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6720 // save global options |
7 | 6721 save_sm = p_sm; |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6722 save_sta = p_sta; |
7 | 6723 #ifdef FEAT_CMDL_INFO |
6724 save_ru = p_ru; | |
6725 #endif | |
6726 #ifdef FEAT_RIGHTLEFT | |
6727 save_ri = p_ri; | |
6728 save_hkmap = p_hkmap; | |
6729 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6730 // 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
|
6731 p_ai_nopaste = p_ai; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6732 p_et_nopaste = p_et; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6733 p_sts_nopaste = p_sts; |
7 | 6734 p_tw_nopaste = p_tw; |
6735 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
|
6736 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6737 if (p_vsts_nopaste) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6738 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
|
6739 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
|
6740 #endif |
7 | 6741 } |
6742 | |
6743 /* | |
6744 * Always set the option values, also when 'paste' is set when it is | |
6745 * already on. | |
6746 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6747 // set options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6748 FOR_ALL_BUFFERS(buf) |
7 | 6749 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6750 buf->b_p_tw = 0; // textwidth is 0 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6751 buf->b_p_wm = 0; // wrapmargin is 0 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6752 buf->b_p_sts = 0; // softtabstop is 0 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6753 buf->b_p_ai = 0; // no auto-indent |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6754 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
|
6755 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6756 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
|
6757 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
|
6758 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
|
6759 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
|
6760 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
|
6761 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
|
6762 #endif |
7 | 6763 } |
6764 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6765 // set global options |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6766 p_sm = 0; // no showmatch |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6767 p_sta = 0; // no smarttab |
7 | 6768 #ifdef FEAT_CMDL_INFO |
6769 if (p_ru) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6770 status_redraw_all(); // redraw to remove the ruler |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6771 p_ru = 0; // no ruler |
7 | 6772 #endif |
6773 #ifdef FEAT_RIGHTLEFT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6774 p_ri = 0; // no reverse insert |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6775 p_hkmap = 0; // no Hebrew keyboard |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6776 #endif |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6777 // set global values for local buffer options |
7 | 6778 p_tw = 0; |
6779 p_wm = 0; | |
6780 p_sts = 0; | |
6781 p_ai = 0; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6782 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6783 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6784 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
|
6785 p_vsts = empty_option; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6786 #endif |
7 | 6787 } |
6788 | |
6789 /* | |
6790 * Paste switched from on to off: Restore saved values. | |
6791 */ | |
6792 else if (old_p_paste) | |
6793 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6794 // restore options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6795 FOR_ALL_BUFFERS(buf) |
7 | 6796 { |
6797 buf->b_p_tw = buf->b_p_tw_nopaste; | |
6798 buf->b_p_wm = buf->b_p_wm_nopaste; | |
6799 buf->b_p_sts = buf->b_p_sts_nopaste; | |
6800 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
|
6801 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
|
6802 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6803 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
|
6804 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
|
6805 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
|
6806 ? 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
|
6807 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
|
6808 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
|
6809 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
|
6810 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
|
6811 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6812 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
|
6813 #endif |
7 | 6814 } |
6815 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6816 // restore global options |
7 | 6817 p_sm = save_sm; |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6818 p_sta = save_sta; |
7 | 6819 #ifdef FEAT_CMDL_INFO |
6820 if (p_ru != save_ru) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6821 status_redraw_all(); // redraw to draw the ruler |
7 | 6822 p_ru = save_ru; |
6823 #endif | |
6824 #ifdef FEAT_RIGHTLEFT | |
6825 p_ri = save_ri; | |
6826 p_hkmap = save_hkmap; | |
6827 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6828 // 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
|
6829 p_ai = p_ai_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6830 p_et = p_et_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6831 p_sts = p_sts_nopaste; |
7 | 6832 p_tw = p_tw_nopaste; |
6833 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
|
6834 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6835 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6836 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
|
6837 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
|
6838 #endif |
7 | 6839 } |
6840 | |
6841 old_p_paste = p_paste; | |
6842 } | |
6843 | |
6844 /* | |
6845 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found. | |
6846 * | |
6847 * Reset 'compatible' and set the values for options that didn't get set yet | |
6848 * to the Vim defaults. | |
6849 * Don't do this if the 'compatible' option has been set or reset before. | |
819 | 6850 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet. |
7 | 6851 */ |
6852 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6853 vimrc_found(char_u *fname, char_u *envname) |
819 | 6854 { |
6855 int opt_idx; | |
826 | 6856 int dofree = FALSE; |
819 | 6857 char_u *p; |
7 | 6858 |
6859 if (!option_was_set((char_u *)"cp")) | |
6860 { | |
6861 p_cp = FALSE; | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6862 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 6863 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF))) |
6864 set_option_default(opt_idx, OPT_FREE, FALSE); | |
6865 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
6866 didset_options2(); |
7 | 6867 } |
819 | 6868 |
6869 if (fname != NULL) | |
6870 { | |
6871 p = vim_getenv(envname, &dofree); | |
6872 if (p == NULL) | |
6873 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6874 // Set $MYVIMRC to the first vimrc file found. |
819 | 6875 p = FullName_save(fname, FALSE); |
6876 if (p != NULL) | |
6877 { | |
6878 vim_setenv(envname, p); | |
6879 vim_free(p); | |
6880 } | |
6881 } | |
6882 else if (dofree) | |
6883 vim_free(p); | |
6884 } | |
7 | 6885 } |
6886 | |
6887 /* | |
6888 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg. | |
6889 */ | |
6890 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6891 change_compatible(int on) |
7 | 6892 { |
838 | 6893 int opt_idx; |
6894 | |
7 | 6895 if (p_cp != on) |
6896 { | |
6897 p_cp = on; | |
6898 compatible_set(); | |
6899 } | |
838 | 6900 opt_idx = findoption((char_u *)"cp"); |
6901 if (opt_idx >= 0) | |
6902 options[opt_idx].flags |= P_WAS_SET; | |
7 | 6903 } |
6904 | |
6905 /* | |
6906 * 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
|
6907 * Only works correctly for global options. |
7 | 6908 */ |
6909 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6910 option_was_set(char_u *name) |
7 | 6911 { |
6912 int idx; | |
6913 | |
6914 idx = findoption(name); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6915 if (idx < 0) // unknown option |
7 | 6916 return FALSE; |
6917 if (options[idx].flags & P_WAS_SET) | |
6918 return TRUE; | |
6919 return FALSE; | |
6920 } | |
6921 | |
6922 /* | |
3980 | 6923 * Reset the flag indicating option "name" was set. |
6924 */ | |
14748
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6925 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6926 reset_option_was_set(char_u *name) |
3980 | 6927 { |
6928 int idx = findoption(name); | |
6929 | |
6930 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
|
6931 { |
3980 | 6932 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
|
6933 return OK; |
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6934 } |
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6935 return FAIL; |
3980 | 6936 } |
6937 | |
6938 /* | |
7 | 6939 * compatible_set() - Called when 'compatible' has been set or unset. |
6940 * | |
6941 * When 'compatible' set: Set all relevant options (those that have the P_VIM) | |
6942 * flag) to a Vi compatible value. | |
6943 * When 'compatible' is unset: Set all options that have a different default | |
6944 * for Vim (without the P_VI_DEF flag) to that default. | |
6945 */ | |
6946 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6947 compatible_set(void) |
7 | 6948 { |
6949 int opt_idx; | |
6950 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6951 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 6952 if ( ((options[opt_idx].flags & P_VIM) && p_cp) |
6953 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp)) | |
6954 set_option_default(opt_idx, OPT_FREE, p_cp); | |
6955 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
6956 didset_options2(); |
7 | 6957 } |
6958 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6959 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
7 | 6960 |
6961 /* | |
6962 * fill_breakat_flags() -- called when 'breakat' changes value. | |
6963 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6964 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6965 fill_breakat_flags(void) |
7 | 6966 { |
500 | 6967 char_u *p; |
7 | 6968 int i; |
6969 | |
6970 for (i = 0; i < 256; i++) | |
6971 breakat_flags[i] = FALSE; | |
6972 | |
6973 if (p_breakat != NULL) | |
500 | 6974 for (p = p_breakat; *p; p++) |
6975 breakat_flags[*p] = TRUE; | |
7 | 6976 } |
6977 #endif | |
6978 | |
6979 /* | |
6980 * Check if backspacing over something is allowed. | |
6981 */ | |
6982 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6983 can_bs( |
20069
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
6984 int what) // BS_INDENT, BS_EOL, BS_START or BS_NOSTOP |
7 | 6985 { |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
6986 #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
|
6987 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
|
6988 return FALSE; |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
6989 #endif |
7 | 6990 switch (*p_bs) |
6991 { | |
20069
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
6992 case '3': return TRUE; |
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
6993 case '2': return (what != BS_NOSTOP); |
7 | 6994 case '1': return (what != BS_START); |
6995 case '0': return FALSE; | |
6996 } | |
6997 return vim_strchr(p_bs, what) != NULL; | |
6998 } | |
6999 | |
7000 /* | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7001 * 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
|
7002 * 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
|
7003 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7004 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7005 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
|
7006 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7007 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
|
7008 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7009 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7010 /* |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7011 * 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
|
7012 * 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
|
7013 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7014 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7015 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
|
7016 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7017 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
|
7018 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7019 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7020 /* |
6243 | 7021 * Get the local or global value of 'backupcopy'. |
7022 */ | |
7023 unsigned int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7024 get_bkc_value(buf_T *buf) |
6243 | 7025 { |
7026 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags; | |
7027 } | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7028 |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7029 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7030 /* |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7031 * Get the local or global value of 'showbreak'. |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7032 */ |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7033 char_u * |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7034 get_showbreak_value(win_T *win) |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7035 { |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7036 if (win->w_p_sbr == NULL || *win->w_p_sbr == NUL) |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7037 return p_sbr; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7038 if (STRCMP(win->w_p_sbr, "NONE") == 0) |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7039 return empty_option; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7040 return win->w_p_sbr; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7041 } |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7042 #endif |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7043 |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7044 #if defined(FEAT_EVAL) || defined(PROTO) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7045 /* |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7046 * Get window or buffer local options. |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7047 */ |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7048 dict_T * |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7049 get_winbuf_options(int bufopt) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7050 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7051 dict_T *d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7052 int opt_idx; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7053 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7054 d = dict_alloc(); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7055 if (d == NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7056 return NULL; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7057 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7058 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7059 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7060 struct vimoption *opt = &options[opt_idx]; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7061 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7062 if ((bufopt && (opt->indir & PV_BUF)) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7063 || (!bufopt && (opt->indir & PV_WIN))) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7064 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7065 char_u *varp = get_varp(opt); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7066 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7067 if (varp != NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7068 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7069 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
|
7070 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
|
7071 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
|
7072 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
|
7073 else |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14243
diff
changeset
|
7074 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
|
7075 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7076 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7077 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7078 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7079 return d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7080 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7081 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7082 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7083 #if defined(FEAT_SYN_HL) || defined(PROTO) |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7084 /* |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7085 * 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
|
7086 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7087 int |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7088 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
|
7089 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7090 char_u *p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7091 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
|
7092 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7093 if (val == NULL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7094 p = wp->w_p_culopt; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7095 else |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7096 p = val; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7097 while (*p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7098 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7099 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
|
7100 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7101 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7102 culopt_flags_new |= CULOPT_LINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7103 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7104 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
|
7105 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7106 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7107 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
|
7108 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7109 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
|
7110 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7111 p += 6; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7112 culopt_flags_new |= CULOPT_NBR; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7113 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7114 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
|
7115 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7116 p += 10; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7117 culopt_flags_new |= CULOPT_SCRLINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7118 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7119 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7120 if (*p != ',' && *p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7121 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7122 if (*p == ',') |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7123 ++p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7124 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7125 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7126 // 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
|
7127 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
|
7128 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7129 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
|
7130 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7131 return OK; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7132 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7133 #endif |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7134 |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7135 /* |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7136 * Get the value of 'magic' adjusted for Vim9 script. |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7137 */ |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7138 int |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7139 magic_isset(void) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7140 { |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7141 switch (magic_overruled) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7142 { |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23467
diff
changeset
|
7143 case OPTION_MAGIC_ON: return TRUE; |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23467
diff
changeset
|
7144 case OPTION_MAGIC_OFF: return FALSE; |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23467
diff
changeset
|
7145 case OPTION_MAGIC_NOT_SET: break; |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7146 } |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7147 #ifdef FEAT_EVAL |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7148 if (in_vim9script()) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7149 return TRUE; |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7150 #endif |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7151 return p_magic; |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7152 } |