Mercurial > vim
annotate src/option.c @ 19176:be81baeb69f8 v8.2.0147
patch 8.2.0147: block Visual mode operators not correct when 'linebreak' set
Commit: https://github.com/vim/vim/commit/03c3bd9fd094c1aede2e8fe3ad8fd25b9f033053
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 23 20:58:09 2020 +0100
patch 8.2.0147: block Visual mode operators not correct when 'linebreak' set
Problem: Block Visual mode operators not correct when 'linebreak' set.
Solution: Set w_p_lbr to lbr_saved more often. (Ken Takata, closes https://github.com/vim/vim/issues/5524)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 23 Jan 2020 21:00:03 +0100 |
parents | 69f0e9b5c107 |
children | 2ef19eed524a |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9959
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * Code to handle user-settable options. This is all pretty much table- | |
12 * driven. Checklist for adding a new option: | |
13 * - Put it in the options array below (copy an existing entry). | |
14 * - For a global option: Add a variable for it in option.h. | |
15 * - For a buffer or window local option: | |
16 * - Add a PV_XX entry to the enum below. | |
17 * - Add a variable to the window or buffer struct in structs.h. | |
18 * - For a window option, add some code to copy_winopt(). | |
19 * - For a buffer option, add some code to buf_copy_options(). | |
20 * - For a buffer string option, add code to check_buf_options(). | |
21 * - If it's a numeric option, add any necessary bounds checks to do_set(). | |
22 * - If it's a list of flags, add some code in do_set(), search for WW_ALL. | |
23 * - When adding an option with expansion (P_EXPAND), but with a different | |
24 * default for Vi and Vim (no P_VI_DEF), add some code at VIMEXP. | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10205
diff
changeset
|
25 * - Add documentation! One line in doc/quickref.txt, full description in |
7 | 26 * options.txt, and any other related places. |
27 * - Add an entry in runtime/optwin.vim. | |
28 * When making changes: | |
29 * - Adjust the help for the option in doc/option.txt. | |
30 * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a | |
31 * comment at the help for the 'compatible' option. | |
32 */ | |
33 | |
34 #define IN_OPTION_C | |
35 #include "vim.h" | |
18054
88b5c2b4e3d2
patch 8.1.2022: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18047
diff
changeset
|
36 #include "optiondefs.h" |
7 | 37 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
38 static void set_options_default(int opt_flags); |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
39 static void set_string_default_esc(char *name, char_u *val, int escape); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
40 static char_u *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
|
41 static void didset_options(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
42 static void didset_options2(void); |
681 | 43 #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
|
44 static long_u *insecure_flag(int opt_idx, int opt_flags); |
681 | 45 #else |
46 # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags) | |
47 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 static void paste_option_changed(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
65 static void compatible_set(void); |
7 | 66 |
67 /* | |
68 * Initialize the options, first part. | |
69 * | |
70 * 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
|
71 * If "clean_arg" is TRUE Vim was started with --clean. |
7 | 72 */ |
73 void | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
74 set_init_1(int clean_arg) |
7 | 75 { |
76 char_u *p; | |
77 int opt_idx; | |
835 | 78 long_u n; |
7 | 79 |
80 #ifdef FEAT_LANGMAP | |
81 langmap_init(); | |
82 #endif | |
83 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
84 // Be Vi compatible by default |
7 | 85 p_cp = TRUE; |
86 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
87 // Use POSIX compatibility when $VIM_POSIX is set. |
164 | 88 if (mch_getenv((char_u *)"VIM_POSIX") != NULL) |
168 | 89 { |
164 | 90 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
|
91 set_string_default("shm", (char_u *)SHM_POSIX); |
168 | 92 } |
164 | 93 |
7 | 94 /* |
95 * Find default value for 'shell' option. | |
161 | 96 * Don't use it if it is empty. |
7 | 97 */ |
161 | 98 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
|
99 #if defined(MSWIN) |
161 | 100 || ((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
|
101 || ((p = (char_u *)default_shell()) != NULL && *p != NUL) |
7 | 102 #endif |
161 | 103 ) |
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
|
104 #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
|
105 { |
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 // 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
|
107 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
|
108 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
|
109 |
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 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
|
111 { |
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 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
|
113 cmd = alloc(len); |
18243
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
114 if (cmd != NULL) |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
115 { |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
116 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
|
117 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
|
118 vim_free(cmd); |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
119 } |
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
|
120 } |
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 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
|
122 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
|
123 } |
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 #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
|
125 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
|
126 #endif |
7 | 127 |
128 #ifdef FEAT_WILDIGN | |
129 /* | |
130 * Set the default for 'backupskip' to include environment variables for | |
131 * temp files. | |
132 */ | |
133 { | |
134 # ifdef UNIX | |
135 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"}; | |
136 # else | |
137 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"}; | |
138 # endif | |
170 | 139 int len; |
140 garray_T ga; | |
141 int mustfree; | |
7 | 142 |
143 ga_init2(&ga, 1, 100); | |
144 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n) | |
145 { | |
170 | 146 mustfree = FALSE; |
7 | 147 # ifdef UNIX |
148 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
|
149 # ifdef MACOS_X |
f64c5e636c9f
patch 8.0.1704: 'backupskip' default doesn't work for Mac
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
150 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
|
151 # else |
7 | 152 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
|
153 # endif |
7 | 154 else |
155 # endif | |
170 | 156 p = vim_getenv((char_u *)names[n], &mustfree); |
7 | 157 if (p != NULL && *p != NUL) |
158 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
159 // First time count the NUL, otherwise count the ','. |
835 | 160 len = (int)STRLEN(p) + 3; |
7 | 161 if (ga_grow(&ga, len) == OK) |
162 { | |
163 if (ga.ga_len > 0) | |
164 STRCAT(ga.ga_data, ","); | |
165 STRCAT(ga.ga_data, p); | |
166 add_pathsep(ga.ga_data); | |
167 STRCAT(ga.ga_data, "*"); | |
168 ga.ga_len += len; | |
169 } | |
170 } | |
170 | 171 if (mustfree) |
172 vim_free(p); | |
7 | 173 } |
174 if (ga.ga_data != NULL) | |
175 { | |
176 set_string_default("bsk", ga.ga_data); | |
177 vim_free(ga.ga_data); | |
178 } | |
179 } | |
180 #endif | |
181 | |
182 /* | |
183 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory | |
184 */ | |
185 opt_idx = findoption((char_u *)"maxmemtot"); | |
838 | 186 if (opt_idx >= 0) |
187 { | |
7 | 188 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
838 | 189 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) |
190 #endif | |
191 { | |
7 | 192 #ifdef HAVE_AVAIL_MEM |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
193 // Use amount of memory available at this moment. |
3634 | 194 n = (mch_avail_mem(FALSE) >> 1); |
7 | 195 #else |
196 # ifdef HAVE_TOTAL_MEM | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
197 // Use amount of memory available to Vim. |
1110 | 198 n = (mch_total_mem(FALSE) >> 1); |
7 | 199 # else |
838 | 200 n = (0x7fffffff >> 11); |
7 | 201 # endif |
202 #endif | |
203 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; | |
838 | 204 opt_idx = findoption((char_u *)"maxmem"); |
205 if (opt_idx >= 0) | |
206 { | |
207 #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
|
208 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
|
209 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L) |
838 | 210 #endif |
211 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; | |
212 } | |
213 } | |
7 | 214 } |
215 | |
216 #ifdef FEAT_SEARCHPATH | |
217 { | |
218 char_u *cdpath; | |
219 char_u *buf; | |
220 int i; | |
221 int j; | |
170 | 222 int mustfree = FALSE; |
7 | 223 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
224 // Initialize the 'cdpath' option's default value. |
170 | 225 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree); |
7 | 226 if (cdpath != NULL) |
227 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16730
diff
changeset
|
228 buf = alloc((STRLEN(cdpath) << 1) + 2); |
7 | 229 if (buf != NULL) |
230 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
231 buf[0] = ','; // start with ",", current dir first |
7 | 232 j = 1; |
233 for (i = 0; cdpath[i] != NUL; ++i) | |
234 { | |
235 if (vim_ispathlistsep(cdpath[i])) | |
236 buf[j++] = ','; | |
237 else | |
238 { | |
239 if (cdpath[i] == ' ' || cdpath[i] == ',') | |
240 buf[j++] = '\\'; | |
241 buf[j++] = cdpath[i]; | |
242 } | |
243 } | |
244 buf[j] = NUL; | |
245 opt_idx = findoption((char_u *)"cdpath"); | |
838 | 246 if (opt_idx >= 0) |
247 { | |
248 options[opt_idx].def_val[VI_DEFAULT] = buf; | |
249 options[opt_idx].flags |= P_DEF_ALLOCED; | |
250 } | |
2445
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
251 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
252 vim_free(buf); // cannot happen |
7 | 253 } |
170 | 254 if (mustfree) |
255 vim_free(cdpath); | |
7 | 256 } |
257 } | |
258 #endif | |
259 | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
260 #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
|
261 // Set print encoding on platforms that don't default to latin1 |
7 | 262 set_string_default("penc", |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
263 # if defined(MSWIN) |
7 | 264 (char_u *)"cp1252" |
265 # else | |
266 # ifdef VMS | |
267 (char_u *)"dec-mcs" | |
268 # else | |
269 # ifdef EBCDIC | |
270 (char_u *)"ebcdic-uk" | |
271 # else | |
272 # ifdef MAC | |
273 (char_u *)"mac-roman" | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
274 # else // HPUX |
7 | 275 (char_u *)"hp-roman8" |
276 # endif | |
277 # endif | |
278 # endif | |
279 # endif | |
280 ); | |
281 #endif | |
282 | |
283 #ifdef FEAT_POSTSCRIPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
284 // 'printexpr' must be allocated to be able to evaluate it. |
7 | 285 set_string_default("pexpr", |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
286 # if defined(MSWIN) |
8 | 287 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)" |
7 | 288 # else |
289 # ifdef VMS | |
290 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)" | |
291 | |
292 # else | |
293 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error" | |
294 # endif | |
295 # endif | |
296 ); | |
297 #endif | |
298 | |
299 /* | |
300 * Set all the options (except the terminal options) to their default | |
301 * value. Also set the global value for local options. | |
302 */ | |
303 set_options_default(0); | |
304 | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
305 #ifdef CLEAN_RUNTIMEPATH |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
306 if (clean_arg) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
307 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
308 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
|
309 if (opt_idx >= 0) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
310 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
311 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
|
312 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
|
313 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
314 opt_idx = findoption((char_u *)"packpath"); |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
315 if (opt_idx >= 0) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
316 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
317 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH; |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
318 p_pp = (char_u *)CLEAN_RUNTIMEPATH; |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
319 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
320 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
321 #endif |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
322 |
7 | 323 #ifdef FEAT_GUI |
324 if (found_reverse_arg) | |
325 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0); | |
326 #endif | |
327 | |
328 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
|
329 curbuf->b_p_ar = -1; // no local 'autoread' value |
5446 | 330 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
7 | 331 check_buf_options(curbuf); |
332 check_win_options(curwin); | |
333 check_options(); | |
334 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
335 // Must be before option_expand(), because that one needs vim_isIDc() |
7 | 336 didset_options(); |
337 | |
744 | 338 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
339 // 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
|
340 // didset_options() because it only depends on 'encoding'. |
227 | 341 init_spell_chartab(); |
342 #endif | |
343 | |
7 | 344 /* |
345 * Expand environment variables and things like "~" for the defaults. | |
346 * If option_expand() returns non-NULL the variable is expanded. This can | |
347 * only happen for non-indirect options. | |
348 * Also set the default to the expanded value, so ":set" does not list | |
349 * them. | |
350 * Don't set the P_ALLOCED flag, because we don't want to free the | |
351 * default. | |
352 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
353 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 354 { |
355 if ((options[opt_idx].flags & P_GETTEXT) | |
356 && options[opt_idx].var != NULL) | |
357 p = (char_u *)_(*(char **)options[opt_idx].var); | |
358 else | |
359 p = option_expand(opt_idx, NULL); | |
360 if (p != NULL && (p = vim_strsave(p)) != NULL) | |
361 { | |
362 *(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
|
363 // VIMEXP |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
364 // 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
|
365 // 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
|
366 // split P_DEF_ALLOCED in two. |
7 | 367 if (options[opt_idx].flags & P_DEF_ALLOCED) |
368 vim_free(options[opt_idx].def_val[VI_DEFAULT]); | |
369 options[opt_idx].def_val[VI_DEFAULT] = p; | |
370 options[opt_idx].flags |= P_DEF_ALLOCED; | |
371 } | |
372 } | |
373 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
374 save_file_ff(curbuf); // Buffer is unchanged |
7 | 375 |
376 #if defined(FEAT_ARABIC) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
377 // Detect use of mlterm. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
378 // 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
|
379 // abilities (bidi namely). |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
380 // 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
|
381 // instead of an environment variable due to inheritance. |
7 | 382 if (mch_getenv((char_u *)"MLTERM") != NULL) |
383 set_option_value((char_u *)"tbidi", 1L, NULL, 0); | |
384 #endif | |
385 | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
386 didset_options2(); |
7 | 387 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
388 # if defined(MSWIN) && defined(FEAT_GETTEXT) |
7 | 389 /* |
390 * If $LANG isn't set, try to get a good value for it. This makes the | |
391 * right language be used automatically. Don't do this for English. | |
392 */ | |
393 if (mch_getenv((char_u *)"LANG") == NULL) | |
394 { | |
395 char buf[20]; | |
396 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
397 // 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
|
398 // 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
|
399 // only the first two. |
7 | 400 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, |
401 (LPTSTR)buf, 20); | |
402 if (n >= 2 && STRNICMP(buf, "en", 2) != 0) | |
403 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
404 // There are a few exceptions (probably more) |
7 | 405 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0) |
406 STRCPY(buf, "zh_TW"); | |
407 else if (STRNICMP(buf, "chs", 3) == 0 | |
408 || STRNICMP(buf, "zhc", 3) == 0) | |
409 STRCPY(buf, "zh_CN"); | |
410 else if (STRNICMP(buf, "jp", 2) == 0) | |
411 STRCPY(buf, "ja"); | |
412 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
413 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
|
414 vim_setenv((char_u *)"LANG", (char_u *)buf); |
7 | 415 } |
416 } | |
168 | 417 # else |
767 | 418 # ifdef MACOS_CONVERT |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
419 // Moved to os_mac_conv.c to avoid dependency problems. |
1622 | 420 mac_lang_init(); |
168 | 421 # endif |
7 | 422 # endif |
423 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
424 // enc_locale() will try to find the encoding of the current locale. |
7 | 425 p = enc_locale(); |
426 if (p != NULL) | |
427 { | |
428 char_u *save_enc; | |
429 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
430 // Try setting 'encoding' and check if the value is valid. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
431 // If not, go back to the default "latin1". |
7 | 432 save_enc = p_enc; |
433 p_enc = p; | |
1080 | 434 if (STRCMP(p_enc, "gb18030") == 0) |
435 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
436 // 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
|
437 // 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
|
438 // still support conversion between gb18030 and utf-8. |
1080 | 439 p_enc = vim_strsave((char_u *)"cp936"); |
440 vim_free(p); | |
441 } | |
7 | 442 if (mb_init() == NULL) |
443 { | |
444 opt_idx = findoption((char_u *)"encoding"); | |
838 | 445 if (opt_idx >= 0) |
446 { | |
447 options[opt_idx].def_val[VI_DEFAULT] = p_enc; | |
448 options[opt_idx].flags |= P_DEF_ALLOCED; | |
449 } | |
7 | 450 |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12636
diff
changeset
|
451 #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
|
452 if (STRCMP(p_enc, "latin1") == 0 || enc_utf8) |
24 | 453 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
454 // 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
|
455 // 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
|
456 // set. |
24 | 457 set_string_option_direct((char_u *)"isp", -1, |
719 | 458 ISP_LATIN1, OPT_FREE, SID_NONE); |
714 | 459 set_string_option_direct((char_u *)"isk", -1, |
460 ISK_LATIN1, OPT_FREE, SID_NONE); | |
461 opt_idx = findoption((char_u *)"isp"); | |
838 | 462 if (opt_idx >= 0) |
463 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1; | |
714 | 464 opt_idx = findoption((char_u *)"isk"); |
838 | 465 if (opt_idx >= 0) |
466 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1; | |
24 | 467 (void)init_chartab(); |
468 } | |
469 #endif | |
470 | |
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
|
471 #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
|
472 // 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
|
473 // 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
|
474 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
|
475 # 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
|
476 (!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
|
477 # 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
|
478 GetACP() != GetConsoleCP()) |
7 | 479 { |
480 char buf[50]; | |
481 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
482 // 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
|
483 // 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
|
484 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
|
485 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
|
486 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
|
487 sprintf(buf, "cp%ld", (long)GetConsoleCP()); |
7 | 488 p_tenc = vim_strsave((char_u *)buf); |
489 if (p_tenc != NULL) | |
490 { | |
491 opt_idx = findoption((char_u *)"termencoding"); | |
838 | 492 if (opt_idx >= 0) |
493 { | |
494 options[opt_idx].def_val[VI_DEFAULT] = p_tenc; | |
495 options[opt_idx].flags |= P_DEF_ALLOCED; | |
496 } | |
7 | 497 convert_setup(&input_conv, p_tenc, p_enc); |
498 convert_setup(&output_conv, p_enc, p_tenc); | |
499 } | |
500 else | |
501 p_tenc = empty_option; | |
502 } | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
503 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
504 #if defined(MSWIN) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
505 // $HOME may have characters in active code page. |
170 | 506 init_homedir(); |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
507 #endif |
7 | 508 } |
509 else | |
510 { | |
511 vim_free(p_enc); | |
512 p_enc = save_enc; | |
513 } | |
514 } | |
515 | |
516 #ifdef FEAT_MULTI_LANG | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
517 // Set the default for 'helplang'. |
7 | 518 set_helplang_default(get_mess_lang()); |
519 #endif | |
520 } | |
521 | |
522 /* | |
523 * Set an option to its default value. | |
524 * This does not take care of side effects! | |
525 */ | |
526 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
527 set_option_default( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
528 int opt_idx, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
529 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
|
530 int compatible) // use Vi default value |
7 | 531 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
532 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
|
533 int dvi; // index in def_val[] |
7 | 534 long_u flags; |
681 | 535 long_u *flagsp; |
7 | 536 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
537 | |
538 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); | |
539 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
|
540 if (varp != NULL) // skip hidden option, nothing to do for it |
7 | 541 { |
542 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; | |
543 if (flags & P_STRING) | |
544 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
545 // 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
|
546 // freeing and allocating the value. |
13845
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
547 if (options[opt_idx].indir != PV_NONE) |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
548 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
|
549 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
|
550 else |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
551 { |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
552 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
|
553 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
|
554 *(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
|
555 options[opt_idx].flags &= ~P_ALLOCED; |
7 | 556 } |
557 } | |
558 else if (flags & P_NUM) | |
559 { | |
1017 | 560 if (options[opt_idx].indir == PV_SCROLL) |
7 | 561 win_comp_scroll(curwin); |
562 else | |
563 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
564 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
|
565 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
566 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
|
567 || (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
|
568 // '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
|
569 // 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
|
570 *(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
|
571 else |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
572 *(long *)varp = def_val; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
573 // May also set global value for local option. |
7 | 574 if (both) |
575 *(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
|
576 def_val; |
7 | 577 } |
578 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
579 else // P_BOOL |
7 | 580 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
581 // 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
|
582 // MSVC |
840 | 583 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; |
1111 | 584 #ifdef UNIX |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
585 // 'modeline' defaults to off for root |
1111 | 586 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) |
587 *(int *)varp = FALSE; | |
588 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
589 // May also set global value for local option. |
7 | 590 if (both) |
591 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | |
592 *(int *)varp; | |
593 } | |
634 | 594 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
595 // The default value is not insecure. |
681 | 596 flagsp = insecure_flag(opt_idx, opt_flags); |
597 *flagsp = *flagsp & ~P_INSECURE; | |
7 | 598 } |
599 | |
600 #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
|
601 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 602 #endif |
603 } | |
604 | |
605 /* | |
606 * 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
|
607 * When "opt_flags" is non-zero skip 'encoding'. |
7 | 608 */ |
609 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
610 set_options_default( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
611 int opt_flags) // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL |
7 | 612 { |
613 int i; | |
614 win_T *wp; | |
671 | 615 tabpage_T *tp; |
7 | 616 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
617 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
|
618 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
|
619 && (opt_flags == 0 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
620 || (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
|
621 # if defined(FEAT_CRYPT) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
622 && 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
|
623 && 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
|
624 # endif |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
625 ))) |
7 | 626 set_option_default(i, opt_flags, p_cp); |
627 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
628 // The 'scroll' option must be computed for all windows. |
671 | 629 FOR_ALL_TAB_WINDOWS(tp, wp) |
7 | 630 win_comp_scroll(wp); |
6205 | 631 #ifdef FEAT_CINDENT |
632 parse_cino(curbuf); | |
633 #endif | |
7 | 634 } |
635 | |
636 /* | |
637 * Set the Vi-default value of a string option. | |
638 * 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
|
639 * 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
|
640 */ |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
641 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
|
642 set_string_default_esc(char *name, char_u *val, int escape) |
7 | 643 { |
644 char_u *p; | |
645 int opt_idx; | |
646 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
647 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
|
648 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
|
649 else |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
650 p = vim_strsave(val); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
651 if (p != NULL) // we don't want a NULL |
7 | 652 { |
653 opt_idx = findoption((char_u *)name); | |
838 | 654 if (opt_idx >= 0) |
655 { | |
656 if (options[opt_idx].flags & P_DEF_ALLOCED) | |
657 vim_free(options[opt_idx].def_val[VI_DEFAULT]); | |
658 options[opt_idx].def_val[VI_DEFAULT] = p; | |
659 options[opt_idx].flags |= P_DEF_ALLOCED; | |
660 } | |
7 | 661 } |
662 } | |
663 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
664 void |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
665 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
|
666 { |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
667 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
|
668 } |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
669 |
7 | 670 /* |
671 * Set the Vi-default value of a number option. | |
672 * Used for 'lines' and 'columns'. | |
673 */ | |
674 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
675 set_number_default(char *name, long val) |
7 | 676 { |
838 | 677 int opt_idx; |
678 | |
679 opt_idx = findoption((char_u *)name); | |
680 if (opt_idx >= 0) | |
840 | 681 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 682 } |
683 | |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
684 /* |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
685 * 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
|
686 * 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
|
687 * 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
|
688 */ |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
689 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
|
690 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
|
691 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
692 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
|
693 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
|
694 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
695 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
|
696 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
|
697 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
|
698 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
699 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
|
700 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
701 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
|
702 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
|
703 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
704 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
|
705 && (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
|
706 && !(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
|
707 && !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
|
708 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
|
709 } |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
710 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
711 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
|
712 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
|
713 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
|
714 } |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
715 |
359 | 716 #if defined(EXITFREE) || defined(PROTO) |
717 /* | |
718 * Free all options. | |
719 */ | |
720 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
721 free_all_options(void) |
359 | 722 { |
723 int i; | |
724 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
725 for (i = 0; !istermoption_idx(i); i++) |
359 | 726 { |
727 if (options[i].indir == PV_NONE) | |
728 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
729 // 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
|
730 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL) |
359 | 731 free_string_option(*(char_u **)options[i].var); |
732 if (options[i].flags & P_DEF_ALLOCED) | |
733 free_string_option(options[i].def_val[VI_DEFAULT]); | |
734 } | |
735 else if (options[i].var != VAR_WIN | |
736 && (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
|
737 // buffer-local option: free global value |
359 | 738 free_string_option(*(char_u **)options[i].var); |
739 } | |
740 } | |
741 #endif | |
742 | |
743 | |
7 | 744 /* |
745 * Initialize the options, part two: After getting Rows and Columns and | |
746 * setting 'term'. | |
747 */ | |
748 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
749 set_init_2(void) |
7 | 750 { |
164 | 751 int idx; |
752 | |
7 | 753 /* |
12718
f8f505ffc0a6
patch 8.0.1237: ":set scroll&" often gives an error
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
754 * '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
|
755 * which results in the actual value computed from the window height. |
7 | 756 */ |
168 | 757 idx = findoption((char_u *)"scroll"); |
838 | 758 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
168 | 759 set_option_default(idx, OPT_LOCAL, p_cp); |
7 | 760 comp_col(); |
761 | |
164 | 762 /* |
763 * 'window' is only for backwards compatibility with Vi. | |
764 * Default is Rows - 1. | |
765 */ | |
857 | 766 if (!option_was_set((char_u *)"window")) |
164 | 767 p_window = Rows - 1; |
768 set_number_default("window", Rows - 1); | |
769 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
770 // 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
|
771 #if !((defined(MSWIN)) && !defined(FEAT_GUI)) |
671 | 772 /* |
773 * If 'background' wasn't set by the user, try guessing the value, | |
774 * depending on the terminal name. Only need to check for terminals | |
775 * with a dark background, that can handle color. | |
776 */ | |
777 idx = findoption((char_u *)"bg"); | |
838 | 778 if (idx >= 0 && !(options[idx].flags & P_WAS_SET) |
779 && *term_bg_default() == 'd') | |
671 | 780 { |
694 | 781 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
|
782 // 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
|
783 // changed again |
671 | 784 options[idx].flags &= ~P_WAS_SET; |
7 | 785 } |
786 #endif | |
440 | 787 |
788 #ifdef CURSOR_SHAPE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
789 parse_shape_opt(SHAPE_CURSOR); // set cursor shapes from 'guicursor' |
440 | 790 #endif |
791 #ifdef FEAT_MOUSESHAPE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
792 parse_shape_opt(SHAPE_MOUSE); // set mouse shapes from 'mouseshape' |
440 | 793 #endif |
794 #ifdef FEAT_PRINTER | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
795 (void)parse_printoptions(); // parse 'printoptions' default value |
440 | 796 #endif |
7 | 797 } |
798 | |
799 /* | |
800 * Initialize the options, part three: After reading the .vimrc | |
801 */ | |
802 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
803 set_init_3(void) |
7 | 804 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
805 #if defined(UNIX) || defined(MSWIN) |
7 | 806 /* |
807 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. | |
808 * This is done after other initializations, where 'shell' might have been | |
809 * set, but only if they have not been set before. | |
810 */ | |
811 char_u *p; | |
812 int idx_srr; | |
813 int do_srr; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
814 # ifdef FEAT_QUICKFIX |
7 | 815 int idx_sp; |
816 int do_sp; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
817 # endif |
7 | 818 |
819 idx_srr = findoption((char_u *)"srr"); | |
838 | 820 if (idx_srr < 0) |
821 do_srr = FALSE; | |
822 else | |
823 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
|
824 # ifdef FEAT_QUICKFIX |
7 | 825 idx_sp = findoption((char_u *)"sp"); |
838 | 826 if (idx_sp < 0) |
827 do_sp = FALSE; | |
828 else | |
829 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
|
830 # endif |
5867 | 831 p = get_isolated_shell_name(); |
7 | 832 if (p != NULL) |
833 { | |
834 /* | |
835 * Default for p_sp is "| tee", for p_srr is ">". | |
836 * For known shells it is changed here to include stderr. | |
837 */ | |
838 if ( fnamecmp(p, "csh") == 0 | |
839 || 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
|
840 # if defined(MSWIN) // also check with .exe extension |
7 | 841 || fnamecmp(p, "csh.exe") == 0 |
842 || fnamecmp(p, "tcsh.exe") == 0 | |
843 # endif | |
844 ) | |
845 { | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
846 # if defined(FEAT_QUICKFIX) |
7 | 847 if (do_sp) |
848 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
849 # ifdef MSWIN |
7 | 850 p_sp = (char_u *)">&"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
851 # else |
7 | 852 p_sp = (char_u *)"|& tee"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
853 # endif |
7 | 854 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
855 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
856 # endif |
7 | 857 if (do_srr) |
858 { | |
859 p_srr = (char_u *)">&"; | |
860 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
861 } | |
862 } | |
863 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
864 // Always use bourne shell style redirection if we reach this |
7 | 865 if ( fnamecmp(p, "sh") == 0 |
866 || fnamecmp(p, "ksh") == 0 | |
2774 | 867 || fnamecmp(p, "mksh") == 0 |
868 || fnamecmp(p, "pdksh") == 0 | |
7 | 869 || fnamecmp(p, "zsh") == 0 |
836 | 870 || fnamecmp(p, "zsh-beta") == 0 |
7 | 871 || fnamecmp(p, "bash") == 0 |
5867 | 872 || fnamecmp(p, "fish") == 0 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
873 # ifdef MSWIN |
7 | 874 || fnamecmp(p, "cmd") == 0 |
875 || fnamecmp(p, "sh.exe") == 0 | |
876 || fnamecmp(p, "ksh.exe") == 0 | |
2774 | 877 || fnamecmp(p, "mksh.exe") == 0 |
878 || fnamecmp(p, "pdksh.exe") == 0 | |
7 | 879 || fnamecmp(p, "zsh.exe") == 0 |
836 | 880 || fnamecmp(p, "zsh-beta.exe") == 0 |
7 | 881 || fnamecmp(p, "bash.exe") == 0 |
882 || fnamecmp(p, "cmd.exe") == 0 | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
883 # endif |
7 | 884 ) |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
885 { |
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
886 # if defined(FEAT_QUICKFIX) |
7 | 887 if (do_sp) |
888 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
889 # ifdef MSWIN |
7 | 890 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
|
891 # else |
7 | 892 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
|
893 # endif |
7 | 894 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
895 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
896 # endif |
7 | 897 if (do_srr) |
898 { | |
899 p_srr = (char_u *)">%s 2>&1"; | |
900 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
901 } | |
902 } | |
903 vim_free(p); | |
904 } | |
905 #endif | |
906 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
907 #if defined(MSWIN) |
7 | 908 /* |
3352 | 909 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the |
910 * 'shell' option. | |
7 | 911 * This is done after other initializations, where 'shell' might have been |
912 * set, but only if they have not been set before. Default for p_shcf is | |
913 * "/c", for p_shq is "". For "sh" like shells it is changed here to | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
914 * "-c" and "\"". And for Win32 we need to set p_sxq instead. |
7 | 915 */ |
10 | 916 if (strstr((char *)gettail(p_sh), "sh") != NULL) |
7 | 917 { |
918 int idx3; | |
919 | |
920 idx3 = findoption((char_u *)"shcf"); | |
838 | 921 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 922 { |
923 p_shcf = (char_u *)"-c"; | |
924 options[idx3].def_val[VI_DEFAULT] = p_shcf; | |
925 } | |
926 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
927 // Somehow Win32 requires the quotes around the redirection too |
7 | 928 idx3 = findoption((char_u *)"sxq"); |
838 | 929 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 930 { |
931 p_sxq = (char_u *)"\""; | |
932 options[idx3].def_val[VI_DEFAULT] = p_sxq; | |
933 } | |
934 } | |
3352 | 935 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL) |
936 { | |
937 int idx3; | |
938 | |
939 /* | |
940 * cmd.exe on Windows will strip the first and last double quote given | |
941 * on the command line, e.g. most of the time things like: | |
942 * cmd /c "my path/to/echo" "my args to echo" | |
943 * become: | |
944 * my path/to/echo" "my args to echo | |
945 * when executed. | |
946 * | |
3357 | 947 * To avoid this, set shellxquote to surround the command in |
948 * parenthesis. This appears to make most commands work, without | |
949 * breaking commands that worked previously, such as | |
950 * '"path with spaces/cmd" "a&b"'. | |
3352 | 951 */ |
952 idx3 = findoption((char_u *)"sxq"); | |
953 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
954 { | |
3357 | 955 p_sxq = (char_u *)"("; |
3352 | 956 options[idx3].def_val[VI_DEFAULT] = p_sxq; |
957 } | |
958 | |
959 idx3 = findoption((char_u *)"shcf"); | |
960 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
961 { | |
3357 | 962 p_shcf = (char_u *)"/c"; |
3352 | 963 options[idx3].def_val[VI_DEFAULT] = p_shcf; |
964 } | |
965 } | |
7 | 966 #endif |
967 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11107
diff
changeset
|
968 if (BUFEMPTY()) |
8659
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
969 { |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
970 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
|
971 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
972 // 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
|
973 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
|
974 set_fileformat(default_fileformat(), OPT_LOCAL); |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
975 } |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
976 |
7 | 977 #ifdef FEAT_TITLE |
978 set_title_defaults(); | |
979 #endif | |
980 } | |
981 | |
982 #if defined(FEAT_MULTI_LANG) || defined(PROTO) | |
983 /* | |
984 * When 'helplang' is still at its default value, set it to "lang". | |
985 * Only the first two characters of "lang" are used. | |
986 */ | |
987 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
988 set_helplang_default(char_u *lang) |
7 | 989 { |
990 int idx; | |
991 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
992 if (lang == NULL || STRLEN(lang) < 2) // safety check |
7 | 993 return; |
994 idx = findoption((char_u *)"hlg"); | |
838 | 995 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
7 | 996 { |
997 if (options[idx].flags & P_ALLOCED) | |
998 free_string_option(p_hlg); | |
999 p_hlg = vim_strsave(lang); | |
1000 if (p_hlg == NULL) | |
1001 p_hlg = empty_option; | |
1002 else | |
18 | 1003 { |
14997
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1004 // zh_CN becomes "cn", zh_TW becomes "tw" |
18 | 1005 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) |
1006 { | |
1007 p_hlg[0] = TOLOWER_ASC(p_hlg[3]); | |
1008 p_hlg[1] = TOLOWER_ASC(p_hlg[4]); | |
1009 } | |
14997
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1010 // 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
|
1011 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
|
1012 { |
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1013 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
|
1014 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
|
1015 } |
7 | 1016 p_hlg[2] = NUL; |
18 | 1017 } |
7 | 1018 options[idx].flags |= P_ALLOCED; |
1019 } | |
1020 } | |
1021 #endif | |
1022 | |
1023 #ifdef FEAT_TITLE | |
1024 /* | |
1025 * 'title' and 'icon' only default to true if they have not been set or reset | |
1026 * in .vimrc and we can read the old value. | |
1027 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if | |
1028 * they can be reset. This reduces startup time when using X on a remote | |
1029 * machine. | |
1030 */ | |
1031 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1032 set_title_defaults(void) |
7 | 1033 { |
1034 int idx1; | |
1035 long val; | |
1036 | |
1037 /* | |
1038 * If GUI is (going to be) used, we can always set the window title and | |
1039 * icon name. Saves a bit of time, because the X11 display server does | |
1040 * not need to be contacted. | |
1041 */ | |
1042 idx1 = findoption((char_u *)"title"); | |
838 | 1043 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 1044 { |
1045 #ifdef FEAT_GUI | |
1046 if (gui.starting || gui.in_use) | |
1047 val = TRUE; | |
1048 else | |
1049 #endif | |
1050 val = mch_can_restore_title(); | |
840 | 1051 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 1052 p_title = val; |
1053 } | |
1054 idx1 = findoption((char_u *)"icon"); | |
838 | 1055 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 1056 { |
1057 #ifdef FEAT_GUI | |
1058 if (gui.starting || gui.in_use) | |
1059 val = TRUE; | |
1060 else | |
1061 #endif | |
1062 val = mch_can_restore_icon(); | |
840 | 1063 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 1064 p_icon = val; |
1065 } | |
1066 } | |
1067 #endif | |
1068 | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1069 void |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1070 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
|
1071 { |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1072 int flags = 0; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1073 |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1074 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
|
1075 flags = OPT_LOCAL; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1076 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
|
1077 flags = OPT_GLOBAL; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1078 #if defined(FEAT_EVAL) && defined(FEAT_BROWSE) |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1079 if (cmdmod.browse && flags == 0) |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1080 ex_options(eap); |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1081 else |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1082 #endif |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1083 { |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1084 if (eap->forceit) |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1085 flags |= OPT_ONECOLUMN; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1086 (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
|
1087 } |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1088 } |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1089 |
7 | 1090 /* |
1091 * Parse 'arg' for option settings. | |
1092 * | |
1093 * 'arg' may be IObuff, but only when no errors can be present and option | |
1094 * does not need to be expanded with option_expand(). | |
1095 * "opt_flags": | |
1096 * 0 for ":set" | |
717 | 1097 * OPT_GLOBAL for ":setglobal" |
1098 * OPT_LOCAL for ":setlocal" and a modeline | |
7 | 1099 * OPT_MODELINE for a modeline |
717 | 1100 * OPT_WINONLY to only set window-local options |
1101 * OPT_NOWIN to skip setting window-local options | |
7 | 1102 * |
1103 * returns FAIL if an error is detected, OK otherwise | |
1104 */ | |
1105 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1106 do_set( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1107 char_u *arg, // 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
|
1108 int opt_flags) |
7 | 1109 { |
1110 int opt_idx; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1111 char *errmsg; |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1112 char errbuf[80]; |
7 | 1113 char_u *startarg; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1114 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
|
1115 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
|
1116 int afterchar; // character just after option name |
7 | 1117 int len; |
1118 int i; | |
9389
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
1119 varnumber_T value; |
7 | 1120 int key; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1121 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
|
1122 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
|
1123 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
|
1124 int adding; // "opt+=arg" |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1125 int prepending; // "opt^=arg" |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1126 int removing; // "opt-=arg" |
7 | 1127 int cp_val = 0; |
1128 char_u key_name[2]; | |
1129 | |
1130 if (*arg == NUL) | |
1131 { | |
1132 showoptions(0, opt_flags); | |
168 | 1133 did_show = TRUE; |
1134 goto theend; | |
7 | 1135 } |
1136 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1137 while (*arg != NUL) // loop to process all options |
7 | 1138 { |
1139 errmsg = NULL; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1140 startarg = arg; // remember for error message |
7 | 1141 |
36 | 1142 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3]) |
1143 && !(opt_flags & OPT_MODELINE)) | |
7 | 1144 { |
1145 /* | |
1146 * ":set all" show all options. | |
1147 * ":set all&" set all options to their default value. | |
1148 */ | |
1149 arg += 3; | |
1150 if (*arg == '&') | |
1151 { | |
1152 ++arg; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1153 // Only for :set command set global value of local options. |
7 | 1154 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
|
1155 didset_options(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
1156 didset_options2(); |
7034
e668b160ac68
commit https://github.com/vim/vim/commit/b341dda575899458f7075614dcedf0a80ee9d080
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
1157 redraw_all_later(CLEAR); |
7 | 1158 } |
1159 else | |
168 | 1160 { |
7 | 1161 showoptions(1, opt_flags); |
168 | 1162 did_show = TRUE; |
1163 } | |
7 | 1164 } |
36 | 1165 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) |
7 | 1166 { |
1167 showoptions(2, opt_flags); | |
1168 show_termcodes(); | |
168 | 1169 did_show = TRUE; |
7 | 1170 arg += 7; |
1171 } | |
1172 else | |
1173 { | |
1174 prefix = 1; | |
1911 | 1175 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0) |
7 | 1176 { |
1177 prefix = 0; | |
1178 arg += 2; | |
1179 } | |
1180 else if (STRNCMP(arg, "inv", 3) == 0) | |
1181 { | |
1182 prefix = 2; | |
1183 arg += 3; | |
1184 } | |
1185 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1186 // find end of name |
7 | 1187 key = 0; |
1188 if (*arg == '<') | |
1189 { | |
1190 opt_idx = -1; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1191 // look out for <t_>;> |
7 | 1192 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) |
1193 len = 5; | |
1194 else | |
1195 { | |
1196 len = 1; | |
1197 while (arg[len] != NUL && arg[len] != '>') | |
1198 ++len; | |
1199 } | |
1200 if (arg[len] != '>') | |
1201 { | |
1202 errmsg = e_invarg; | |
1203 goto skip; | |
1204 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1205 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
|
1206 if (arg[1] == 't' && arg[2] == '_') // could be term code |
7 | 1207 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
|
1208 arg[len++] = '>'; // restore '>' |
7 | 1209 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
|
1210 key = find_key_option(arg + 1, TRUE); |
7 | 1211 } |
1212 else | |
1213 { | |
1214 len = 0; | |
1215 /* | |
1216 * The two characters after "t_" may not be alphanumeric. | |
1217 */ | |
1218 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
1219 len = 4; | |
1220 else | |
1221 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') | |
1222 ++len; | |
1223 nextchar = arg[len]; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1224 arg[len] = NUL; // put NUL after name |
7 | 1225 opt_idx = findoption(arg); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1226 arg[len] = nextchar; // restore nextchar |
7 | 1227 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
|
1228 key = find_key_option(arg, FALSE); |
7 | 1229 } |
1230 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1231 // remember character after option name |
7 | 1232 afterchar = arg[len]; |
1233 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1234 // skip white space, allow ":set ai ?" |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1235 while (VIM_ISWHITE(arg[len])) |
7 | 1236 ++len; |
1237 | |
1238 adding = FALSE; | |
1239 prepending = FALSE; | |
1240 removing = FALSE; | |
1241 if (arg[len] != NUL && arg[len + 1] == '=') | |
1242 { | |
1243 if (arg[len] == '+') | |
1244 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1245 adding = TRUE; // "+=" |
7 | 1246 ++len; |
1247 } | |
1248 else if (arg[len] == '^') | |
1249 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1250 prepending = TRUE; // "^=" |
7 | 1251 ++len; |
1252 } | |
1253 else if (arg[len] == '-') | |
1254 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1255 removing = TRUE; // "-=" |
7 | 1256 ++len; |
1257 } | |
1258 } | |
1259 nextchar = arg[len]; | |
1260 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1261 if (opt_idx == -1 && key == 0) // found a mismatch: skip |
7 | 1262 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1263 errmsg = N_("E518: Unknown option"); |
7 | 1264 goto skip; |
1265 } | |
1266 | |
1267 if (opt_idx >= 0) | |
1268 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1269 if (options[opt_idx].var == NULL) // hidden option: skip |
7 | 1270 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1271 // 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
|
1272 // a hidden option, ignore setting it. |
7 | 1273 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL |
1274 && (!(options[opt_idx].flags & P_BOOL) | |
1275 || nextchar == '?')) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1276 errmsg = N_("E519: Option not supported"); |
7 | 1277 goto skip; |
1278 } | |
1279 | |
1280 flags = options[opt_idx].flags; | |
1281 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | |
1282 } | |
1283 else | |
1284 { | |
1285 flags = P_STRING; | |
1286 if (key < 0) | |
1287 { | |
1288 key_name[0] = KEY2TERMCAP0(key); | |
1289 key_name[1] = KEY2TERMCAP1(key); | |
1290 } | |
1291 else | |
1292 { | |
1293 key_name[0] = KS_KEY; | |
1294 key_name[1] = (key & 0xff); | |
1295 } | |
1296 } | |
1297 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1298 // 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
|
1299 // an already loaded buffer in a window). |
634 | 1300 if ((opt_flags & OPT_WINONLY) |
1301 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) | |
1302 goto skip; | |
1303 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1304 // Skip all options that are window-local (used for :vimgrep). |
717 | 1305 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0 |
1306 && options[opt_idx].var == VAR_WIN) | |
1307 goto skip; | |
1308 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1309 // Disallow changing some options from modelines. |
1807 | 1310 if (opt_flags & OPT_MODELINE) |
7 | 1311 { |
2317
2b2cd34569eb
Disallow setting 'enc' in a modeline. (Patrick Texier)
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
1312 if (flags & (P_SECURE | P_NO_ML)) |
1807 | 1313 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1314 errmsg = _("E520: Not allowed in a modeline"); |
1807 | 1315 goto skip; |
1316 } | |
16728
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1317 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
|
1318 { |
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1319 errmsg = _("E992: Not allowed in a modeline when 'modelineexpr' is off"); |
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1320 goto skip; |
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1321 } |
1810 | 1322 #ifdef FEAT_DIFF |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1323 // 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
|
1324 // '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
|
1325 // "wrap" gets set. |
1807 | 1326 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
|
1327 && 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
|
1328 && ( |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1329 #ifdef FEAT_FOLDING |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1330 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
|
1331 #endif |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1332 options[opt_idx].indir == PV_WRAP)) |
1807 | 1333 goto skip; |
1810 | 1334 #endif |
7 | 1335 } |
1336 | |
1337 #ifdef HAVE_SANDBOX | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1338 // Disallow changing some options in the sandbox |
634 | 1339 if (sandbox != 0 && (flags & P_SECURE)) |
7 | 1340 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1341 errmsg = _(e_sandbox); |
7 | 1342 goto skip; |
1343 } | |
1344 #endif | |
1345 | |
1346 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) | |
1347 { | |
1348 arg += len; | |
1349 cp_val = p_cp; | |
1350 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') | |
1351 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1352 if (arg[3] == 'm') // "opt&vim": set to Vim default |
7 | 1353 { |
1354 cp_val = FALSE; | |
1355 arg += 3; | |
1356 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1357 else // "opt&vi": set to Vi default |
7 | 1358 { |
1359 cp_val = TRUE; | |
1360 arg += 2; | |
1361 } | |
1362 } | |
1363 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
|
1364 && arg[1] != NUL && !VIM_ISWHITE(arg[1])) |
7 | 1365 { |
1366 errmsg = e_trailing; | |
1367 goto skip; | |
1368 } | |
1369 } | |
1370 | |
1371 /* | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
1372 * allow '=' and ':' for hystorical reasons (MSDOS command.com |
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
1373 * allows only one '=' character per "set" command line. grrr. (jw) |
7 | 1374 */ |
1375 if (nextchar == '?' | |
1376 || (prefix == 1 | |
1377 && vim_strchr((char_u *)"=:&<", nextchar) == NULL | |
1378 && !(flags & P_BOOL))) | |
1379 { | |
1380 /* | |
1381 * print value | |
1382 */ | |
1383 if (did_show) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1384 msg_putchar('\n'); // cursor below last one |
7 | 1385 else |
1386 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1387 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
|
1388 did_show = TRUE; // remember that we did a line |
7 | 1389 } |
1390 if (opt_idx >= 0) | |
1391 { | |
1392 showoneopt(&options[opt_idx], opt_flags); | |
1393 #ifdef FEAT_EVAL | |
1394 if (p_verbose > 0) | |
694 | 1395 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1396 // Mention where the option was last set. |
694 | 1397 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
|
1398 last_set_msg(options[opt_idx].script_ctx); |
694 | 1399 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
|
1400 last_set_msg(curwin->w_p_script_ctx[ |
694 | 1401 (int)options[opt_idx].indir & PV_MASK]); |
1402 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
|
1403 last_set_msg(curbuf->b_p_script_ctx[ |
694 | 1404 (int)options[opt_idx].indir & PV_MASK]); |
1405 } | |
7 | 1406 #endif |
1407 } | |
1408 else | |
1409 { | |
1410 char_u *p; | |
1411 | |
1412 p = find_termcode(key_name); | |
1413 if (p == NULL) | |
1414 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1415 errmsg = N_("E846: Key code not set"); |
7 | 1416 goto skip; |
1417 } | |
1418 else | |
1419 (void)show_one_termcode(key_name, p, TRUE); | |
1420 } | |
1421 if (nextchar != '?' | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1422 && nextchar != NUL && !VIM_ISWHITE(afterchar)) |
7 | 1423 errmsg = e_trailing; |
1424 } | |
1425 else | |
1426 { | |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1427 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
|
1428 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
|
1429 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1430 if (flags & P_BOOL) // boolean |
7 | 1431 { |
1432 if (nextchar == '=' || nextchar == ':') | |
1433 { | |
1434 errmsg = e_invarg; | |
1435 goto skip; | |
1436 } | |
1437 | |
1438 /* | |
1439 * ":set opt!": invert | |
1440 * ":set opt&": reset to default value | |
1441 * ":set opt<": reset to global value | |
1442 */ | |
1443 if (nextchar == '!') | |
1444 value = *(int *)(varp) ^ 1; | |
1445 else if (nextchar == '&') | |
840 | 1446 value = (int)(long)(long_i)options[opt_idx].def_val[ |
7 | 1447 ((flags & P_VI_DEF) || cp_val) |
1448 ? VI_DEFAULT : VIM_DEFAULT]; | |
1449 else if (nextchar == '<') | |
1450 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1451 // For 'autoread' -1 means to use global value. |
7 | 1452 if ((int *)varp == &curbuf->b_p_ar |
1453 && opt_flags == OPT_LOCAL) | |
1454 value = -1; | |
1455 else | |
1456 value = *(int *)get_varp_scope(&(options[opt_idx]), | |
1457 OPT_GLOBAL); | |
1458 } | |
1459 else | |
1460 { | |
1461 /* | |
1462 * ":set invopt": invert | |
1463 * ":set opt" or ":set noopt": set or reset | |
1464 */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1465 if (nextchar != NUL && !VIM_ISWHITE(afterchar)) |
7 | 1466 { |
1467 errmsg = e_trailing; | |
1468 goto skip; | |
1469 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1470 if (prefix == 2) // inv |
7 | 1471 value = *(int *)(varp) ^ 1; |
1472 else | |
1473 value = prefix; | |
1474 } | |
1475 | |
1476 errmsg = set_bool_option(opt_idx, varp, (int)value, | |
1477 opt_flags); | |
1478 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1479 else // numeric or string |
7 | 1480 { |
1481 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL | |
1482 || prefix != 1) | |
1483 { | |
1484 errmsg = e_invarg; | |
1485 goto skip; | |
1486 } | |
1487 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1488 if (flags & P_NUM) // numeric |
7 | 1489 { |
1490 /* | |
1491 * Different ways to set a number option: | |
1492 * & set to default value | |
1493 * < set to global value | |
1494 * <xx> accept special key codes for 'wildchar' | |
1495 * c accept any non-digit for 'wildchar' | |
1496 * [-]0-9 set number | |
1497 * other error | |
1498 */ | |
1499 ++arg; | |
1500 if (nextchar == '&') | |
840 | 1501 value = (long)(long_i)options[opt_idx].def_val[ |
7 | 1502 ((flags & P_VI_DEF) || cp_val) |
1503 ? VI_DEFAULT : VIM_DEFAULT]; | |
1504 else if (nextchar == '<') | |
5446 | 1505 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1506 // 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
|
1507 // use the global value. |
5446 | 1508 if ((long *)varp == &curbuf->b_p_ul |
1509 && opt_flags == OPT_LOCAL) | |
1510 value = NO_LOCAL_UNDOLEVEL; | |
1511 else | |
1512 value = *(long *)get_varp_scope( | |
1513 &(options[opt_idx]), OPT_GLOBAL); | |
1514 } | |
7 | 1515 else if (((long *)varp == &p_wc |
1516 || (long *)varp == &p_wcm) | |
1517 && (*arg == '<' | |
1518 || *arg == '^' | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1519 || (*arg != NUL |
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1520 && (!arg[1] || VIM_ISWHITE(arg[1])) |
7 | 1521 && !VIM_ISDIGIT(*arg)))) |
1522 { | |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1523 value = string_to_key(arg, FALSE); |
7 | 1524 if (value == 0 && (long *)varp != &p_wcm) |
1525 { | |
1526 errmsg = e_invarg; | |
1527 goto skip; | |
1528 } | |
1529 } | |
1530 else if (*arg == '-' || VIM_ISDIGIT(*arg)) | |
1531 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1532 // 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
|
1533 // hex numbers. |
7447
ad432f8f68fb
commit https://github.com/vim/vim/commit/887c1fea4a114e7170091942d0446c8882701b5b
Christian Brabandt <cb@256bit.org>
parents:
7426
diff
changeset
|
1534 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
|
1535 &value, NULL, 0, TRUE); |
17039
d726d8cce996
patch 8.1.1519: 'backupskip' may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
16843
diff
changeset
|
1536 if (i == 0 || (arg[i] != NUL |
d726d8cce996
patch 8.1.1519: 'backupskip' may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
16843
diff
changeset
|
1537 && !VIM_ISWHITE(arg[i]))) |
7 | 1538 { |
16706
77bcb5055fec
patch 8.1.1355: obvious mistakes are accepted as valid expressions
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
1539 errmsg = N_("E521: Number required after ="); |
7 | 1540 goto skip; |
1541 } | |
1542 } | |
1543 else | |
1544 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1545 errmsg = N_("E521: Number required after ="); |
7 | 1546 goto skip; |
1547 } | |
1548 | |
1549 if (adding) | |
1550 value = *(long *)varp + value; | |
1551 if (prepending) | |
1552 value = *(long *)varp * value; | |
1553 if (removing) | |
1554 value = *(long *)varp - value; | |
1555 errmsg = set_num_option(opt_idx, varp, value, | |
274 | 1556 errbuf, sizeof(errbuf), opt_flags); |
7 | 1557 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1558 else if (opt_idx >= 0) // string |
7 | 1559 { |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1560 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
|
1561 char_u *s = NULL; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1562 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
|
1563 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
|
1564 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
|
1565 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
|
1566 char_u *origval_g = NULL; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
1567 #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
|
1568 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
|
1569 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
|
1570 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
|
1571 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
|
1572 #endif |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1573 unsigned newlen; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1574 int comma; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1575 int bs; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1576 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
|
1577 // was allocated |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1578 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1579 // 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
|
1580 // 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
|
1581 // reset, use the global value here. |
7 | 1582 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
692 | 1583 && ((int)options[opt_idx].indir & PV_BOTH)) |
7 | 1584 varp = options[opt_idx].var; |
1585 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1586 // 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
|
1587 // new value is valid. |
7 | 1588 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
|
1589 |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1590 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
|
1591 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1592 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
|
1593 &(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
|
1594 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
|
1595 &(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
|
1596 |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1597 // 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
|
1598 // 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
|
1599 // 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
|
1600 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
|
1601 && 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
|
1602 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
|
1603 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1604 |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1605 // 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
|
1606 // 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
|
1607 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
|
1608 && (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
|
1609 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
|
1610 &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
|
1611 else |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1612 origval = oldval; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1613 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1614 if (nextchar == '&') // set to default val |
7 | 1615 { |
1616 newval = options[opt_idx].def_val[ | |
1617 ((flags & P_VI_DEF) || cp_val) | |
1618 ? VI_DEFAULT : VIM_DEFAULT]; | |
1619 if ((char_u **)varp == &p_bg) | |
1620 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1621 // guess the value of 'background' |
7 | 1622 #ifdef FEAT_GUI |
1623 if (gui.in_use) | |
1624 newval = gui_bg_default(); | |
1625 else | |
1626 #endif | |
671 | 1627 newval = term_bg_default(); |
7 | 1628 } |
1629 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1630 // 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
|
1631 // 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
|
1632 // 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
|
1633 // later |
7 | 1634 if (newval == NULL) |
1635 newval = empty_option; | |
1636 else | |
1637 { | |
1638 s = option_expand(opt_idx, newval); | |
1639 if (s == NULL) | |
1640 s = newval; | |
1641 newval = vim_strsave(s); | |
1642 } | |
1643 new_value_alloced = TRUE; | |
1644 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1645 else if (nextchar == '<') // set to global val |
7 | 1646 { |
1647 newval = vim_strsave(*(char_u **)get_varp_scope( | |
1648 &(options[opt_idx]), OPT_GLOBAL)); | |
1649 new_value_alloced = TRUE; | |
1650 } | |
1651 else | |
1652 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1653 ++arg; // jump to after the '=' or ':' |
7 | 1654 |
1655 /* | |
1656 * Set 'keywordprg' to ":help" if an empty | |
1657 * value was passed to :set by the user. | |
1658 * Misuse errbuf[] for the resulting string. | |
1659 */ | |
1660 if (varp == (char_u *)&p_kp | |
1661 && (*arg == NUL || *arg == ' ')) | |
1662 { | |
1663 STRCPY(errbuf, ":help"); | |
1664 save_arg = arg; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1665 arg = (char_u *)errbuf; |
7 | 1666 } |
1667 /* | |
3168 | 1668 * Convert 'backspace' number to string, for |
1669 * adding, prepending and removing string. | |
1670 */ | |
1671 else if (varp == (char_u *)&p_bs | |
1672 && VIM_ISDIGIT(**(char_u **)varp)) | |
1673 { | |
1674 i = getdigits((char_u **)varp); | |
1675 switch (i) | |
1676 { | |
1677 case 0: | |
1678 *(char_u **)varp = empty_option; | |
1679 break; | |
1680 case 1: | |
1681 *(char_u **)varp = vim_strsave( | |
1682 (char_u *)"indent,eol"); | |
1683 break; | |
1684 case 2: | |
1685 *(char_u **)varp = vim_strsave( | |
1686 (char_u *)"indent,eol,start"); | |
1687 break; | |
1688 } | |
1689 vim_free(oldval); | |
12190
497b78526358
patch 8.0.0975: using freed memory when setting 'backspace'
Christian Brabandt <cb@256bit.org>
parents:
12188
diff
changeset
|
1690 if (origval == oldval) |
497b78526358
patch 8.0.0975: using freed memory when setting 'backspace'
Christian Brabandt <cb@256bit.org>
parents:
12188
diff
changeset
|
1691 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
|
1692 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
|
1693 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
|
1694 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
|
1695 origval_g = *(char_u **)varp; |
3168 | 1696 oldval = *(char_u **)varp; |
1697 } | |
1698 /* | |
7 | 1699 * Convert 'whichwrap' number to string, for |
1700 * backwards compatibility with Vim 3.0. | |
1701 * Misuse errbuf[] for the resulting string. | |
1702 */ | |
1703 else if (varp == (char_u *)&p_ww | |
1704 && VIM_ISDIGIT(*arg)) | |
1705 { | |
1706 *errbuf = NUL; | |
1707 i = getdigits(&arg); | |
1708 if (i & 1) | |
1709 STRCAT(errbuf, "b,"); | |
1710 if (i & 2) | |
1711 STRCAT(errbuf, "s,"); | |
1712 if (i & 4) | |
1713 STRCAT(errbuf, "h,l,"); | |
1714 if (i & 8) | |
1715 STRCAT(errbuf, "<,>,"); | |
1716 if (i & 16) | |
1717 STRCAT(errbuf, "[,],"); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1718 if (*errbuf != NUL) // remove trailing , |
7 | 1719 errbuf[STRLEN(errbuf) - 1] = NUL; |
1720 save_arg = arg; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1721 arg = (char_u *)errbuf; |
7 | 1722 } |
1723 /* | |
1724 * Remove '>' before 'dir' and 'bdir', for | |
1725 * backwards compatibility with version 3.0 | |
1726 */ | |
1727 else if ( *arg == '>' | |
1728 && (varp == (char_u *)&p_dir | |
1729 || varp == (char_u *)&p_bdir)) | |
1730 { | |
1731 ++arg; | |
1732 } | |
1733 | |
1734 /* | |
1735 * Copy the new string into allocated memory. | |
1736 * Can't use set_string_option_direct(), because | |
1737 * we need to remove the backslashes. | |
1738 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1739 // get a bit too much |
7 | 1740 newlen = (unsigned)STRLEN(arg) + 1; |
1741 if (adding || prepending || removing) | |
1742 newlen += (unsigned)STRLEN(origval) + 1; | |
1743 newval = alloc(newlen); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1744 if (newval == NULL) // out of mem, don't change |
7 | 1745 break; |
1746 s = newval; | |
1747 | |
1748 /* | |
1749 * Copy the string, skip over escaped chars. | |
1750 * For MS-DOS and WIN32 backslashes before normal | |
1751 * file name characters are not removed, and keep | |
1752 * backslash at start, for "\\machine\path", but | |
1753 * do remove it for "\\\\machine\\path". | |
1754 * The reverse is found in ExpandOldSetting(). | |
1755 */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1756 while (*arg && !VIM_ISWHITE(*arg)) |
7 | 1757 { |
1758 if (*arg == '\\' && arg[1] != NUL | |
1759 #ifdef BACKSLASH_IN_FILENAME | |
1760 && !((flags & P_EXPAND) | |
1761 && vim_isfilec(arg[1]) | |
1762 && (arg[1] != '\\' | |
1763 || (s == newval | |
1764 && arg[2] != '\\'))) | |
1765 #endif | |
1766 ) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1767 ++arg; // remove backslash |
7 | 1768 if (has_mbyte |
474 | 1769 && (i = (*mb_ptr2len)(arg)) > 1) |
7 | 1770 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1771 // copy multibyte char |
7 | 1772 mch_memmove(s, arg, (size_t)i); |
1773 arg += i; | |
1774 s += i; | |
1775 } | |
1776 else | |
1777 *s++ = *arg++; | |
1778 } | |
1779 *s = NUL; | |
1780 | |
1781 /* | |
1782 * Expand environment variables and ~. | |
1783 * Don't do it when adding without inserting a | |
1784 * comma. | |
1785 */ | |
1786 if (!(adding || prepending || removing) | |
1787 || (flags & P_COMMA)) | |
1788 { | |
1789 s = option_expand(opt_idx, newval); | |
1790 if (s != NULL) | |
1791 { | |
1792 vim_free(newval); | |
1793 newlen = (unsigned)STRLEN(s) + 1; | |
1794 if (adding || prepending || removing) | |
1795 newlen += (unsigned)STRLEN(origval) + 1; | |
1796 newval = alloc(newlen); | |
1797 if (newval == NULL) | |
1798 break; | |
1799 STRCPY(newval, s); | |
1800 } | |
1801 } | |
1802 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1803 // 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
|
1804 // 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
|
1805 i = 0; // init for GCC |
7 | 1806 if (removing || (flags & P_NODUP)) |
1807 { | |
1808 i = (int)STRLEN(newval); | |
1809 bs = 0; | |
1810 for (s = origval; *s; ++s) | |
1811 { | |
1812 if ((!(flags & P_COMMA) | |
1813 || s == origval | |
1814 || (s[-1] == ',' && !(bs & 1))) | |
1815 && STRNCMP(s, newval, i) == 0 | |
1816 && (!(flags & P_COMMA) | |
1817 || s[i] == ',' | |
1818 || s[i] == NUL)) | |
1819 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1820 // Count backslashes. Only a comma with an |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1821 // even number of backslashes or a single |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1822 // backslash preceded by a comma before it |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1823 // is recognized as a separator |
7426
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1824 if ((s > origval + 1 |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1825 && s[-1] == '\\' |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1826 && s[-2] != ',') |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1827 || (s == origval + 1 |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1828 && s[-1] == '\\')) |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1829 |
7 | 1830 ++bs; |
1831 else | |
1832 bs = 0; | |
1833 } | |
1834 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1835 // do not add if already there |
7 | 1836 if ((adding || prepending) && *s) |
1837 { | |
1838 prepending = FALSE; | |
1839 adding = FALSE; | |
1840 STRCPY(newval, origval); | |
1841 } | |
1842 } | |
1843 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1844 // 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
|
1845 // needed |
7 | 1846 if (adding || prepending) |
1847 { | |
1848 comma = ((flags & P_COMMA) && *origval != NUL | |
1849 && *newval != NUL); | |
1850 if (adding) | |
1851 { | |
1852 i = (int)STRLEN(origval); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1853 // 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
|
1854 if (comma && i > 1 |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1855 && (flags & P_ONECOMMA) == P_ONECOMMA |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1856 && origval[i - 1] == ',' |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1857 && origval[i - 2] != '\\') |
6841 | 1858 i--; |
7 | 1859 mch_memmove(newval + i + comma, newval, |
1860 STRLEN(newval) + 1); | |
1861 mch_memmove(newval, origval, (size_t)i); | |
1862 } | |
1863 else | |
1864 { | |
1865 i = (int)STRLEN(newval); | |
1622 | 1866 STRMOVE(newval + i + comma, origval); |
7 | 1867 } |
1868 if (comma) | |
1869 newval[i] = ','; | |
1870 } | |
1871 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1872 // 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
|
1873 // been set above and is used here). |
7 | 1874 if (removing) |
1875 { | |
1876 STRCPY(newval, origval); | |
1877 if (*s) | |
1878 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1879 // may need to remove a comma |
7 | 1880 if (flags & P_COMMA) |
1881 { | |
1882 if (s == origval) | |
1883 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1884 // include comma after string |
7 | 1885 if (s[i] == ',') |
1886 ++i; | |
1887 } | |
1888 else | |
1889 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1890 // include comma before string |
7 | 1891 --s; |
1892 ++i; | |
1893 } | |
1894 } | |
1622 | 1895 STRMOVE(newval + (s - origval), s + i); |
7 | 1896 } |
1897 } | |
1898 | |
1899 if (flags & P_FLAGLIST) | |
1900 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1901 // 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
|
1902 for (s = newval; *s;) |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1903 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1904 // 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
|
1905 // P_ONECOMMA such as 'whichwrap' |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1906 if (flags & P_ONECOMMA) |
7 | 1907 { |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1908 if (*s != ',' && *(s + 1) == ',' |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1909 && vim_strchr(s + 2, *s) != NULL) |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1910 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1911 // Remove the duplicated value and |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1912 // the next comma. |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1913 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
|
1914 continue; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1915 } |
7 | 1916 } |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1917 else |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1918 { |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1919 if ((!(flags & P_COMMA) || *s != ',') |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1920 && vim_strchr(s + 1, *s) != NULL) |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1921 { |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1922 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
|
1923 continue; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1924 } |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1925 } |
10831
e926c5a7f9bf
patch 8.0.0305: invalid memory access when option has duplicate flag
Christian Brabandt <cb@256bit.org>
parents:
10825
diff
changeset
|
1926 ++s; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1927 } |
7 | 1928 } |
1929 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1930 if (save_arg != NULL) // number for 'whichwrap' |
7 | 1931 arg = save_arg; |
1932 new_value_alloced = TRUE; | |
1933 } | |
1934 | |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1935 /* |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1936 * 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
|
1937 */ |
7 | 1938 *(char_u **)(varp) = newval; |
1939 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
1940 #if defined(FEAT_EVAL) |
6939 | 1941 if (!starting |
1942 # ifdef FEAT_CRYPT | |
1943 && options[opt_idx].indir != PV_KEY | |
1944 # endif | |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1945 && 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
|
1946 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1947 // origval may be freed by |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1948 // did_set_string_option(), make a copy. |
6935 | 1949 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
|
1950 // 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
|
1951 // 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
|
1952 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
|
1953 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
|
1954 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
|
1955 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
|
1956 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
|
1957 } |
6935 | 1958 #endif |
1959 | |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1960 { |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1961 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
|
1962 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
|
1963 |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1964 // 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
|
1965 // 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
|
1966 // 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
|
1967 // 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
|
1968 // completely replaced. |
16082
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
1969 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
|
1970 #ifdef HAVE_SANDBOX |
16082
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
1971 || sandbox != 0 |
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
1972 #endif |
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
1973 || (!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
|
1974 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
|
1975 |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
1976 // 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
|
1977 // 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
|
1978 // '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
|
1979 // 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
|
1980 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
|
1981 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
|
1982 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
|
1983 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
|
1984 |
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
|
1985 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
|
1986 } |
7 | 1987 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
1988 #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
|
1989 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
|
1990 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
|
1991 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
|
1992 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
|
1993 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
|
1994 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
|
1995 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
|
1996 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
|
1997 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
|
1998 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1999 // If error detected, print the error message. |
7 | 2000 if (errmsg != NULL) |
2001 goto skip; | |
2002 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2003 else // key code option |
7 | 2004 { |
2005 char_u *p; | |
2006 | |
2007 if (nextchar == '&') | |
2008 { | |
2009 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
|
2010 errmsg = N_("E522: Not found in termcap"); |
7 | 2011 } |
2012 else | |
2013 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2014 ++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
|
2015 for (p = arg; *p && !VIM_ISWHITE(*p); ++p) |
7 | 2016 if (*p == '\\' && p[1] != NUL) |
2017 ++p; | |
2018 nextchar = *p; | |
2019 *p = NUL; | |
2020 add_termcode(key_name, arg, FALSE); | |
2021 *p = nextchar; | |
2022 } | |
2023 if (full_screen) | |
2024 ttest(FALSE); | |
2025 redraw_all_later(CLEAR); | |
2026 } | |
2027 } | |
634 | 2028 |
7 | 2029 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
|
2030 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
|
2031 opt_idx, opt_flags, value_is_replaced, value_checked); |
7 | 2032 } |
2033 | |
2034 skip: | |
2035 /* | |
2036 * Advance to next argument. | |
2037 * - skip until a blank found, taking care of backslashes | |
2038 * - skip blanks | |
2039 * - skip one "=val" argument (for hidden options ":set gfn =xx") | |
2040 */ | |
2041 for (i = 0; i < 2 ; ++i) | |
2042 { | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2043 while (*arg != NUL && !VIM_ISWHITE(*arg)) |
7 | 2044 if (*arg++ == '\\' && *arg != NUL) |
2045 ++arg; | |
2046 arg = skipwhite(arg); | |
2047 if (*arg != '=') | |
2048 break; | |
2049 } | |
2050 } | |
2051 | |
2052 if (errmsg != NULL) | |
2053 { | |
419 | 2054 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1); |
835 | 2055 i = (int)STRLEN(IObuff) + 2; |
7 | 2056 if (i + (arg - startarg) < IOSIZE) |
2057 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2058 // append the argument with the error |
7 | 2059 STRCAT(IObuff, ": "); |
2060 mch_memmove(IObuff + i, startarg, (arg - startarg)); | |
2061 IObuff[i + (arg - startarg)] = NUL; | |
2062 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2063 // make sure all characters are printable |
7 | 2064 trans_characters(IObuff, IOSIZE); |
2065 | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2066 ++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
|
2067 emsg((char *)IObuff); // show error highlighted |
7 | 2068 --no_wait_return; |
2069 | |
2070 return FAIL; | |
2071 } | |
2072 | |
2073 arg = skipwhite(arg); | |
2074 } | |
2075 | |
168 | 2076 theend: |
2077 if (silent_mode && did_show) | |
2078 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2079 // After displaying option values in silent mode. |
168 | 2080 silent_mode = FALSE; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2081 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
168 | 2082 msg_putchar('\n'); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2083 cursor_on(); // msg_start() switches it off |
168 | 2084 out_flush(); |
2085 silent_mode = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2086 info_message = FALSE; // use mch_msg(), not mch_errmsg() |
168 | 2087 } |
2088 | |
7 | 2089 return OK; |
2090 } | |
2091 | |
634 | 2092 /* |
2093 * Call this when an option has been given a new value through a user command. | |
2094 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag. | |
2095 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2096 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2097 did_set_option( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2098 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
|
2099 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
|
2100 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
|
2101 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
|
2102 // P_INSECURE flag. |
634 | 2103 { |
681 | 2104 long_u *p; |
2105 | |
634 | 2106 options[opt_idx].flags |= P_WAS_SET; |
2107 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2108 // 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
|
2109 // 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
|
2110 // flag. |
681 | 2111 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
|
2112 if (!value_checked && (secure |
634 | 2113 #ifdef HAVE_SANDBOX |
2114 || sandbox != 0 | |
2115 #endif | |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2116 || (opt_flags & OPT_MODELINE))) |
681 | 2117 *p = *p | P_INSECURE; |
2118 else if (new_value) | |
2119 *p = *p & ~P_INSECURE; | |
634 | 2120 } |
2121 | |
7 | 2122 /* |
2123 * Convert a key name or string into a key value. | |
2124 * 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
|
2125 * 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
|
2126 */ |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2127 int |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2128 string_to_key(char_u *arg, int multi_byte) |
7 | 2129 { |
2130 if (*arg == '<') | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
2131 return find_key_option(arg + 1, TRUE); |
7 | 2132 if (*arg == '^') |
2133 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
|
2134 if (multi_byte) |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2135 return PTR2CHAR(arg); |
7 | 2136 return *arg; |
2137 } | |
2138 | |
2139 #ifdef FEAT_TITLE | |
2140 /* | |
2141 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call | |
2142 * maketitle() to create and display it. | |
2143 * When switching the title or icon off, call mch_restore_title() to get | |
2144 * the old value back. | |
2145 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2146 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
|
2147 did_set_title(void) |
7 | 2148 { |
2149 if (starting != NO_SCREEN | |
2150 #ifdef FEAT_GUI | |
2151 && !gui.starting | |
2152 #endif | |
2153 ) | |
2154 maketitle(); | |
2155 } | |
2156 #endif | |
2157 | |
2158 /* | |
2159 * set_options_bin - called when 'bin' changes value. | |
2160 */ | |
2161 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2162 set_options_bin( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2163 int oldval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2164 int newval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2165 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 2166 { |
2167 /* | |
2168 * The option values that are changed when 'bin' changes are | |
2169 * copied when 'bin is set and restored when 'bin' is reset. | |
2170 */ | |
2171 if (newval) | |
2172 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2173 if (!oldval) // switched on |
7 | 2174 { |
2175 if (!(opt_flags & OPT_GLOBAL)) | |
2176 { | |
2177 curbuf->b_p_tw_nobin = curbuf->b_p_tw; | |
2178 curbuf->b_p_wm_nobin = curbuf->b_p_wm; | |
2179 curbuf->b_p_ml_nobin = curbuf->b_p_ml; | |
2180 curbuf->b_p_et_nobin = curbuf->b_p_et; | |
2181 } | |
2182 if (!(opt_flags & OPT_LOCAL)) | |
2183 { | |
2184 p_tw_nobin = p_tw; | |
2185 p_wm_nobin = p_wm; | |
2186 p_ml_nobin = p_ml; | |
2187 p_et_nobin = p_et; | |
2188 } | |
2189 } | |
2190 | |
2191 if (!(opt_flags & OPT_GLOBAL)) | |
2192 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2193 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
|
2194 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
|
2195 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
|
2196 curbuf->b_p_et = 0; // no expandtab |
7 | 2197 } |
2198 if (!(opt_flags & OPT_LOCAL)) | |
2199 { | |
2200 p_tw = 0; | |
2201 p_wm = 0; | |
2202 p_ml = FALSE; | |
2203 p_et = FALSE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2204 p_bin = TRUE; // needed when called for the "-b" argument |
7 | 2205 } |
2206 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2207 else if (oldval) // switched off |
7 | 2208 { |
2209 if (!(opt_flags & OPT_GLOBAL)) | |
2210 { | |
2211 curbuf->b_p_tw = curbuf->b_p_tw_nobin; | |
2212 curbuf->b_p_wm = curbuf->b_p_wm_nobin; | |
2213 curbuf->b_p_ml = curbuf->b_p_ml_nobin; | |
2214 curbuf->b_p_et = curbuf->b_p_et_nobin; | |
2215 } | |
2216 if (!(opt_flags & OPT_LOCAL)) | |
2217 { | |
2218 p_tw = p_tw_nobin; | |
2219 p_wm = p_wm_nobin; | |
2220 p_ml = p_ml_nobin; | |
2221 p_et = p_et_nobin; | |
2222 } | |
2223 } | |
2224 } | |
2225 | |
2226 /* | |
2227 * Expand environment variables for some string options. | |
2228 * These string options cannot be indirect! | |
2229 * If "val" is NULL expand the current value of the option. | |
2230 * Return pointer to NameBuff, or NULL when not expanded. | |
2231 */ | |
2232 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2233 option_expand(int opt_idx, char_u *val) |
7 | 2234 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2235 // if option doesn't need expansion nothing to do |
7 | 2236 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) |
2237 return NULL; | |
2238 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2239 // 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
|
2240 // expand_env() would truncate the string. |
7 | 2241 if (val != NULL && STRLEN(val) > MAXPATHL) |
2242 return NULL; | |
2243 | |
2244 if (val == NULL) | |
2245 val = *(char_u **)options[opt_idx].var; | |
2246 | |
2247 /* | |
2248 * Expanding this with NameBuff, expand_env() must not be passed IObuff. | |
2249 * Escape spaces when expanding 'tags', they are used to separate file | |
2250 * names. | |
374 | 2251 * For 'spellsuggest' expand after "file:". |
7 | 2252 */ |
2253 expand_env_esc(val, NameBuff, MAXPATHL, | |
1408 | 2254 (char_u **)options[opt_idx].var == &p_tags, FALSE, |
744 | 2255 #ifdef FEAT_SPELL |
374 | 2256 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : |
2257 #endif | |
2258 NULL); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2259 if (STRCMP(NameBuff, val) == 0) // they are the same |
7 | 2260 return NULL; |
2261 | |
2262 return NameBuff; | |
2263 } | |
2264 | |
2265 /* | |
2266 * After setting various option values: recompute variables that depend on | |
2267 * option values. | |
2268 */ | |
2269 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2270 didset_options(void) |
7 | 2271 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2272 // initialize the table for 'iskeyword' et.al. |
7 | 2273 (void)init_chartab(); |
2274 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2275 didset_string_options(); |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2276 |
744 | 2277 #ifdef FEAT_SPELL |
484 | 2278 (void)spell_check_msm(); |
374 | 2279 (void)spell_check_sps(); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
2280 (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
|
2281 (void)did_set_spell_option(TRUE); |
344 | 2282 #endif |
7 | 2283 #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
|
2284 // set cedit_key |
7 | 2285 (void)check_cedit(); |
2286 #endif | |
5995 | 2287 #ifdef FEAT_LINEBREAK |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2288 // initialize the table for 'breakat'. |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2289 fill_breakat_flags(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2290 #endif |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2291 after_copy_winopt(curwin); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2292 } |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2293 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2294 /* |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2295 * More side effects of setting options. |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2296 */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2297 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2298 didset_options2(void) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2299 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2300 // Initialize the highlight_attr[] table. |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2301 (void)highlight_changed(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2302 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2303 // Parse default for 'wildmode' |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2304 check_opt_wim(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2305 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2306 (void)set_chars_option(&p_lcs); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2307 // Parse default for 'fillchars'. |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2308 (void)set_chars_option(&p_fcs); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2309 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2310 #ifdef FEAT_CLIPBOARD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2311 // Parse default for 'clipboard' |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2312 (void)check_clipboard_option(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2313 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2314 #ifdef FEAT_VARTABS |
15858
3a45b89639fb
patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2315 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
|
2316 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
|
2317 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
|
2318 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
|
2319 #endif |
7 | 2320 } |
2321 | |
2322 /* | |
2323 * Check for string options that are NULL (normally only termcap options). | |
2324 */ | |
2325 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2326 check_options(void) |
7 | 2327 { |
2328 int opt_idx; | |
2329 | |
2330 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) | |
2331 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL) | |
2332 check_string_option((char_u **)get_varp(&(options[opt_idx]))); | |
2333 } | |
2334 | |
2335 /* | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2336 * 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
|
2337 * 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
|
2338 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2339 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2340 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
|
2341 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2342 int opt_idx; |
7 | 2343 |
2344 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) | |
2345 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
|
2346 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
|
2347 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
|
2348 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2349 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2350 /* |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2351 * 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
|
2352 * 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
|
2353 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2354 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2355 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
|
2356 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2357 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
|
2358 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2359 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
|
2360 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
|
2361 return opt_idx; |
7 | 2362 } |
2363 | |
634 | 2364 #if defined(FEAT_EVAL) || defined(PROTO) |
2365 /* | |
2366 * Return TRUE when option "opt" was set from a modeline or in secure mode. | |
2367 * Return FALSE when it wasn't. | |
2368 * Return -1 for an unknown option. | |
2369 */ | |
2370 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2371 was_set_insecurely(char_u *opt, int opt_flags) |
634 | 2372 { |
2373 int idx = findoption(opt); | |
681 | 2374 long_u *flagp; |
634 | 2375 |
2376 if (idx >= 0) | |
681 | 2377 { |
2378 flagp = insecure_flag(idx, opt_flags); | |
2379 return (*flagp & P_INSECURE) != 0; | |
2380 } | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
2381 internal_error("was_set_insecurely()"); |
634 | 2382 return -1; |
2383 } | |
681 | 2384 |
2385 /* | |
2386 * Get a pointer to the flags used for the P_INSECURE flag of option | |
2387 * "opt_idx". For some local options a local flags field is used. | |
2388 */ | |
2389 static long_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2390 insecure_flag(int opt_idx, int opt_flags) |
681 | 2391 { |
2392 if (opt_flags & OPT_LOCAL) | |
2393 switch ((int)options[opt_idx].indir) | |
2394 { | |
2395 #ifdef FEAT_STL_OPT | |
694 | 2396 case PV_STL: return &curwin->w_p_stl_flags; |
681 | 2397 #endif |
2398 #ifdef FEAT_EVAL | |
885 | 2399 # ifdef FEAT_FOLDING |
694 | 2400 case PV_FDE: return &curwin->w_p_fde_flags; |
2401 case PV_FDT: return &curwin->w_p_fdt_flags; | |
885 | 2402 # endif |
790 | 2403 # ifdef FEAT_BEVAL |
2404 case PV_BEXPR: return &curbuf->b_p_bexpr_flags; | |
2405 # endif | |
681 | 2406 # if defined(FEAT_CINDENT) |
694 | 2407 case PV_INDE: return &curbuf->b_p_inde_flags; |
681 | 2408 # endif |
694 | 2409 case PV_FEX: return &curbuf->b_p_fex_flags; |
681 | 2410 # ifdef FEAT_FIND_ID |
694 | 2411 case PV_INEX: return &curbuf->b_p_inex_flags; |
681 | 2412 # endif |
2413 #endif | |
2414 } | |
2415 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2416 // Nothing special, return global flags field. |
681 | 2417 return &options[opt_idx].flags; |
2418 } | |
634 | 2419 #endif |
2420 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2421 #if defined(FEAT_TITLE) || defined(PROTO) |
1805 | 2422 /* |
2423 * Redraw the window title and/or tab page text later. | |
2424 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2425 void redraw_titles(void) |
1805 | 2426 { |
2427 need_maketitle = TRUE; | |
2428 redraw_tabline = TRUE; | |
2429 } | |
2430 #endif | |
2431 | |
7 | 2432 /* |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2433 * 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
|
2434 * 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
|
2435 */ |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17845
diff
changeset
|
2436 int |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2437 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
|
2438 { |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2439 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
|
2440 |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2441 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
|
2442 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
|
2443 return FALSE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2444 return TRUE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2445 } |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2446 |
681 | 2447 #if defined(FEAT_EVAL) || defined(PROTO) |
2448 /* | |
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
|
2449 * Set the script_ctx for an option, taking care of setting the buffer- or |
694 | 2450 * window-local value. |
681 | 2451 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2452 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
|
2453 set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx) |
694 | 2454 { |
2455 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; | |
2456 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
|
2457 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
|
2458 |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18808
diff
changeset
|
2459 new_script_ctx.sc_lnum += SOURCING_LNUM; |
694 | 2460 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2461 // 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
|
2462 // in the buffer or window structure. |
694 | 2463 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
|
2464 options[opt_idx].script_ctx = new_script_ctx; |
694 | 2465 if (both || (opt_flags & OPT_LOCAL)) |
2466 { | |
2467 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
|
2468 curbuf->b_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
694 | 2469 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
|
2470 curwin->w_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
694 | 2471 } |
681 | 2472 } |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2473 |
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 * 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
|
2476 * "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
|
2477 * 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
|
2478 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2479 void |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2480 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
|
2481 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2482 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
|
2483 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
|
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 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
|
2486 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
|
2487 else |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2488 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2489 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
|
2490 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
|
2491 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
|
2492 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
|
2493 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
|
2494 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
|
2495 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2496 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
|
2497 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
|
2498 } |
681 | 2499 #endif |
2500 | |
7 | 2501 /* |
2502 * Set the value of a boolean option, and take care of side effects. | |
2503 * Returns NULL for success, or an error message for an error. | |
2504 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2505 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2506 set_bool_option( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2507 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
|
2508 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
|
2509 int value, // new value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2510 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 2511 { |
2512 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
|
2513 #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
|
2514 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
|
2515 #endif |
7 | 2516 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2517 // Disallow changing some options from secure mode |
7 | 2518 if ((secure |
2519 #ifdef HAVE_SANDBOX | |
2520 || sandbox != 0 | |
2521 #endif | |
2522 ) && (options[opt_idx].flags & P_SECURE)) | |
2523 return e_secure; | |
2524 | |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
2525 #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
|
2526 // 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
|
2527 // 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
|
2528 // 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
|
2529 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
|
2530 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
|
2531 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
|
2532 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2533 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2534 *(int *)varp = value; // set the new value |
7 | 2535 #ifdef FEAT_EVAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2536 // 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
|
2537 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 2538 #endif |
2539 | |
634 | 2540 #ifdef FEAT_GUI |
2541 need_mouse_correct = TRUE; | |
2542 #endif | |
2543 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2544 // May set global value for local option. |
7 | 2545 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
2546 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; | |
2547 | |
2548 /* | |
2549 * Handle side effects of changing a bool option. | |
2550 */ | |
2551 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2552 // 'compatible' |
7 | 2553 if ((int *)varp == &p_cp) |
2554 compatible_set(); | |
2555 | |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2556 #ifdef FEAT_LANGMAP |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2557 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
|
2558 // 'langremap' -> !'langnoremap' |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2559 p_lnr = !p_lrm; |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2560 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
|
2561 // 'langnoremap' -> !'langremap' |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2562 p_lrm = !p_lnr; |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2563 #endif |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2564 |
14846
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2565 #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
|
2566 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
|
2567 reset_cursorline(); |
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2568 #endif |
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2569 |
3246 | 2570 #ifdef FEAT_PERSISTENT_UNDO |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2571 // 'undofile' |
3246 | 2572 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) |
2573 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2574 // 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
|
2575 // 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
|
2576 // any changes in between. |
3894 | 2577 if (curbuf->b_p_udf || p_udf) |
2578 { | |
2579 char_u hash[UNDO_HASH_SIZE]; | |
2580 buf_T *save_curbuf = curbuf; | |
2581 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
2582 FOR_ALL_BUFFERS(curbuf) |
3894 | 2583 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2584 // 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
|
2585 // 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
|
2586 // 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
|
2587 // loaded |
3894 | 2588 if ((curbuf == save_curbuf |
3246 | 2589 || (opt_flags & OPT_GLOBAL) || opt_flags == 0) |
3894 | 2590 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) |
2591 { | |
2592 u_compute_hash(hash); | |
2593 u_read_undo(NULL, hash, curbuf->b_fname); | |
2594 } | |
2595 } | |
2596 curbuf = save_curbuf; | |
2597 } | |
3246 | 2598 } |
2599 #endif | |
2600 | |
7 | 2601 else if ((int *)varp == &curbuf->b_p_ro) |
2602 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2603 // when 'readonly' is reset globally, also reset readonlymode |
7 | 2604 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) |
2605 readonlymode = FALSE; | |
548 | 2606 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2607 // when 'readonly' is set may give W10 again |
548 | 2608 if (curbuf->b_p_ro) |
2609 curbuf->b_did_warn = FALSE; | |
2610 | |
7 | 2611 #ifdef FEAT_TITLE |
1805 | 2612 redraw_titles(); |
7 | 2613 #endif |
2614 } | |
2615 | |
2362
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2616 #ifdef FEAT_GUI |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2617 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
|
2618 { |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2619 if (!p_mh) |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2620 gui_mch_mousehide(FALSE); |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2621 } |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2622 #endif |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2623 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2624 // when 'modifiable' is changed, redraw the window title |
7 | 2625 else if ((int *)varp == &curbuf->b_p_ma) |
1805 | 2626 { |
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
|
2627 # ifdef FEAT_TERMINAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2628 // 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
|
2629 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
|
2630 && 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
|
2631 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2632 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
|
2633 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
|
2634 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2635 # 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
|
2636 # ifdef FEAT_TITLE |
1805 | 2637 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
|
2638 # 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
|
2639 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2640 #ifdef FEAT_TITLE |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2641 // when 'endofline' is changed, redraw the window title |
7 | 2642 else if ((int *)varp == &curbuf->b_p_eol) |
1805 | 2643 { |
2644 redraw_titles(); | |
2645 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2646 // when 'fixeol' is changed, redraw the window title |
6933 | 2647 else if ((int *)varp == &curbuf->b_p_fixeol) |
2648 { | |
2649 redraw_titles(); | |
2650 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2651 // when 'bomb' is changed, redraw the window title and tab page text |
1352 | 2652 else if ((int *)varp == &curbuf->b_p_bomb) |
1805 | 2653 { |
2654 redraw_titles(); | |
2655 } | |
7 | 2656 #endif |
2657 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2658 // when 'bin' is set also set some other options |
7 | 2659 else if ((int *)varp == &curbuf->b_p_bin) |
2660 { | |
2661 set_options_bin(old_value, curbuf->b_p_bin, opt_flags); | |
2662 #ifdef FEAT_TITLE | |
1805 | 2663 redraw_titles(); |
7 | 2664 #endif |
2665 } | |
2666 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2667 // when 'buflisted' changes, trigger autocommands |
7 | 2668 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) |
2669 { | |
2670 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, | |
2671 NULL, NULL, TRUE, curbuf); | |
2672 } | |
2673 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2674 // when 'swf' is set, create swapfile, when reset remove swapfile |
7 | 2675 else if ((int *)varp == &curbuf->b_p_swf) |
2676 { | |
2677 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
|
2678 ml_open_file(curbuf); // create the swap file |
7 | 2679 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2680 // 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
|
2681 // buf->b_p_swf |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2682 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
|
2683 } |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2684 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2685 // when 'terse' is set change 'shortmess' |
7 | 2686 else if ((int *)varp == &p_terse) |
2687 { | |
2688 char_u *p; | |
2689 | |
2690 p = vim_strchr(p_shm, SHM_SEARCH); | |
2691 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2692 // insert 's' in p_shm |
7 | 2693 if (p_terse && p == NULL) |
2694 { | |
2695 STRCPY(IObuff, p_shm); | |
2696 STRCAT(IObuff, "s"); | |
694 | 2697 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); |
7 | 2698 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2699 // remove 's' from p_shm |
7 | 2700 else if (!p_terse && p != NULL) |
1622 | 2701 STRMOVE(p, p + 1); |
7 | 2702 } |
2703 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2704 // when 'paste' is set or reset also change other options |
7 | 2705 else if ((int *)varp == &p_paste) |
2706 { | |
2707 paste_option_changed(); | |
2708 } | |
2709 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2710 // when 'insertmode' is set from an autocommand need to do work here |
7 | 2711 else if ((int *)varp == &p_im) |
2712 { | |
2713 if (p_im) | |
2714 { | |
2715 if ((State & INSERT) == 0) | |
2716 need_start_insertmode = TRUE; | |
2717 stop_insert_mode = FALSE; | |
2718 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2719 // 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
|
2720 else if (old_value) |
7 | 2721 { |
2722 need_start_insertmode = FALSE; | |
2723 stop_insert_mode = TRUE; | |
644 | 2724 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
|
2725 clear_cmdline = TRUE; // remove "(insert)" |
7 | 2726 restart_edit = 0; |
2727 } | |
2728 } | |
2729 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2730 // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw |
7 | 2731 else if ((int *)varp == &p_ic && p_hls) |
2732 { | |
744 | 2733 redraw_all_later(SOME_VALID); |
7 | 2734 } |
2735 | |
2736 #ifdef FEAT_SEARCH_EXTRA | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2737 // when 'hlsearch' is set or reset: reset no_hlsearch |
7 | 2738 else if ((int *)varp == &p_hls) |
2739 { | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13774
diff
changeset
|
2740 set_no_hlsearch(FALSE); |
7 | 2741 } |
2742 #endif | |
2743 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2744 // 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
|
2745 // at the end of normal_cmd() |
7 | 2746 else if ((int *)varp == &curwin->w_p_scb) |
2747 { | |
2748 if (curwin->w_p_scb) | |
5157
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2749 { |
7 | 2750 do_check_scrollbind(FALSE); |
5157
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2751 curwin->w_scbind_pos = curwin->w_topline; |
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2752 } |
7 | 2753 } |
2754 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
2755 #if defined(FEAT_QUICKFIX) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2756 // There can be only one window with 'previewwindow' set. |
7 | 2757 else if ((int *)varp == &curwin->w_p_pvw) |
2758 { | |
2759 if (curwin->w_p_pvw) | |
2760 { | |
2761 win_T *win; | |
2762 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
2763 FOR_ALL_WINDOWS(win) |
7 | 2764 if (win->w_p_pvw && win != curwin) |
2765 { | |
2766 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
|
2767 return N_("E590: A preview window already exists"); |
7 | 2768 } |
2769 } | |
2770 } | |
2771 #endif | |
2772 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2773 // when 'textmode' is set or reset also change 'fileformat' |
7 | 2774 else if ((int *)varp == &curbuf->b_p_tx) |
2775 { | |
2776 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); | |
2777 } | |
2778 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2779 // when 'textauto' is set or reset also change 'fileformats' |
7 | 2780 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
|
2781 { |
7 | 2782 set_string_option_direct((char_u *)"ffs", -1, |
2783 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", | |
694 | 2784 OPT_FREE | opt_flags, 0); |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
16082
diff
changeset
|
2785 } |
7 | 2786 |
2787 /* | |
2788 * When 'lisp' option changes include/exclude '-' in | |
2789 * keyword characters. | |
2790 */ | |
2791 #ifdef FEAT_LISP | |
2792 else if (varp == (char_u *)&(curbuf->b_p_lisp)) | |
2793 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2794 (void)buf_init_chartab(curbuf, FALSE); // ignore errors |
7 | 2795 } |
2796 #endif | |
2797 | |
2798 #ifdef FEAT_TITLE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2799 // 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
|
2800 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
|
2801 { |
1d25a3e8e03c
patch 8.1.0061: window title is wrong after resetting and setting 'title'
Christian Brabandt <cb@256bit.org>
parents:
14057
diff
changeset
|
2802 did_set_title(); |
7 | 2803 } |
2804 #endif | |
2805 | |
2806 else if ((int *)varp == &curbuf->b_changed) | |
2807 { | |
2808 if (!value) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2809 save_file_ff(curbuf); // Buffer is unchanged |
7 | 2810 #ifdef FEAT_TITLE |
1805 | 2811 redraw_titles(); |
7 | 2812 #endif |
2813 modified_was_set = value; | |
2814 } | |
2815 | |
2816 #ifdef BACKSLASH_IN_FILENAME | |
2817 else if ((int *)varp == &p_ssl) | |
2818 { | |
2819 if (p_ssl) | |
2820 { | |
2821 psepc = '/'; | |
2822 psepcN = '\\'; | |
2823 pseps[0] = '/'; | |
2824 } | |
2825 else | |
2826 { | |
2827 psepc = '\\'; | |
2828 psepcN = '/'; | |
2829 pseps[0] = '\\'; | |
2830 } | |
2831 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2832 // need to adjust the file name arguments and buffer names. |
7 | 2833 buflist_slash_adjust(); |
2834 alist_slash_adjust(); | |
2835 # ifdef FEAT_EVAL | |
2836 scriptnames_slash_adjust(); | |
2837 # endif | |
2838 } | |
2839 #endif | |
2840 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2841 // If 'wrap' is set, set w_leftcol to zero. |
7 | 2842 else if ((int *)varp == &curwin->w_p_wrap) |
2843 { | |
2844 if (curwin->w_p_wrap) | |
2845 curwin->w_leftcol = 0; | |
2846 } | |
2847 | |
2848 else if ((int *)varp == &p_ea) | |
2849 { | |
2850 if (p_ea && !old_value) | |
2851 win_equal(curwin, FALSE, 0); | |
2852 } | |
2853 | |
2854 else if ((int *)varp == &p_wiv) | |
2855 { | |
2856 /* | |
2857 * When 'weirdinvert' changed, set/reset 't_xs'. | |
2858 * Then set 'weirdinvert' according to value of 't_xs'. | |
2859 */ | |
2860 if (p_wiv && !old_value) | |
2861 T_XS = (char_u *)"y"; | |
2862 else if (!p_wiv && old_value) | |
2863 T_XS = empty_option; | |
2864 p_wiv = (*T_XS != NUL); | |
2865 } | |
2866 | |
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
|
2867 #ifdef FEAT_BEVAL_GUI |
7 | 2868 else if ((int *)varp == &p_beval) |
2869 { | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
2870 if (!balloonEvalForTerm) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
2871 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
2872 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
|
2873 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
|
2874 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
|
2875 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
|
2876 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
2877 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
2878 #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
|
2879 #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
|
2880 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
|
2881 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
2882 mch_bevalterm_changed(); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
2883 } |
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
|
2884 #endif |
820 | 2885 |
2886 #ifdef FEAT_AUTOCHDIR | |
7 | 2887 else if ((int *)varp == &p_acd) |
2888 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2889 // 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
|
2890 DO_AUTOCHDIR; |
7 | 2891 } |
2892 #endif | |
2893 | |
2894 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2895 // 'diff' |
7 | 2896 else if ((int *)varp == &curwin->w_p_diff) |
2897 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2898 // May add or remove the buffer from the list of diff buffers. |
16 | 2899 diff_buf_adjust(curwin); |
2900 # ifdef FEAT_FOLDING | |
7 | 2901 if (foldmethodIsDiff(curwin)) |
2902 foldUpdateAll(curwin); | |
16 | 2903 # endif |
7 | 2904 } |
2905 #endif | |
2906 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
2907 #ifdef HAVE_INPUT_METHOD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2908 // 'imdisable' |
7 | 2909 else if ((int *)varp == &p_imdisable) |
2910 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2911 // Only de-activate it here, it will be enabled when changing mode. |
7 | 2912 if (p_imdisable) |
2913 im_set_active(FALSE); | |
3129 | 2914 else if (State & INSERT) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2915 // 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
|
2916 // effect right away. |
3129 | 2917 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); |
7 | 2918 } |
2919 #endif | |
2920 | |
744 | 2921 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2922 // 'spell' |
258 | 2923 else if ((int *)varp == &curwin->w_p_spell) |
2924 { | |
2925 if (curwin->w_p_spell) | |
2926 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2927 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
|
2928 |
258 | 2929 if (errmsg != NULL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2930 emsg(_(errmsg)); |
258 | 2931 } |
2932 } | |
2933 #endif | |
2934 | |
7 | 2935 #ifdef FEAT_ARABIC |
2936 if ((int *)varp == &curwin->w_p_arab) | |
2937 { | |
2938 if (curwin->w_p_arab) | |
2939 { | |
2940 /* | |
2941 * 'arabic' is set, handle various sub-settings. | |
2942 */ | |
2943 if (!p_tbidi) | |
2944 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2945 // set rightleft mode |
7 | 2946 if (!curwin->w_p_rl) |
2947 { | |
2948 curwin->w_p_rl = TRUE; | |
2949 changed_window_setting(); | |
2950 } | |
2951 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2952 // Enable Arabic shaping (major part of what Arabic requires) |
7 | 2953 if (!p_arshape) |
2954 { | |
2955 p_arshape = TRUE; | |
2956 redraw_later_clear(); | |
2957 } | |
2958 } | |
2959 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2960 // 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
|
2961 // set. |
7 | 2962 if (STRCMP(p_enc, "utf-8") != 0) |
16 | 2963 { |
1848 | 2964 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); |
2965 | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
2966 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
|
2967 msg_attr(_(w_arabic), HL_ATTR(HLF_W)); |
1848 | 2968 #ifdef FEAT_EVAL |
2969 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); | |
2970 #endif | |
16 | 2971 } |
7 | 2972 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2973 // set 'delcombine' |
7 | 2974 p_deco = TRUE; |
2975 | |
2976 # ifdef FEAT_KEYMAP | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2977 // Force-set the necessary keymap for arabic |
7 | 2978 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", |
2979 OPT_LOCAL); | |
2980 # endif | |
2981 } | |
2982 else | |
2983 { | |
2984 /* | |
2985 * 'arabic' is reset, handle various sub-settings. | |
2986 */ | |
2987 if (!p_tbidi) | |
2988 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2989 // reset rightleft mode |
7 | 2990 if (curwin->w_p_rl) |
2991 { | |
2992 curwin->w_p_rl = FALSE; | |
2993 changed_window_setting(); | |
2994 } | |
2995 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2996 // '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
|
2997 // another window may still need it "on". |
7 | 2998 } |
2999 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3000 // '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
|
3001 // window may still want it "on". |
7 | 3002 |
3003 # ifdef FEAT_KEYMAP | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3004 // Revert to the default keymap |
7 | 3005 curbuf->b_p_iminsert = B_IMODE_NONE; |
3006 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; | |
3007 # endif | |
3008 } | |
3443 | 3009 } |
3010 | |
1958 | 3011 #endif |
3012 | |
17827
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3013 #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
|
3014 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
|
3015 || (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
|
3016 && gui.in_use |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3017 && (*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
|
3018 && curbuf->b_signlist != NULL) |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3019 { |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3020 // 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
|
3021 // '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
|
3022 // 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
|
3023 // 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
|
3024 // '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
|
3025 // (optimization). |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3026 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
|
3027 redraw_all_later(CLEAR); |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3028 } |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3029 #endif |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3030 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3031 #ifdef FEAT_TERMGUICOLORS |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3032 // 'termguicolors' |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3033 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
|
3034 { |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3035 # ifdef FEAT_VTP |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3036 // 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
|
3037 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
|
3038 # 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
|
3039 !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
|
3040 # 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
|
3041 !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
|
3042 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3043 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
|
3044 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
|
3045 } |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3046 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
|
3047 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
|
3048 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3049 # ifdef FEAT_GUI |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3050 if (!gui.in_use && !gui.starting) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3051 # endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3052 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
|
3053 # ifdef FEAT_VTP |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3054 // 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
|
3055 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
|
3056 { |
2bebc49116fd
patch 8.1.0123: MS-Windows: colors are wrong after setting 'notgc'
Christian Brabandt <cb@256bit.org>
parents:
14194
diff
changeset
|
3057 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
|
3058 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
|
3059 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
|
3060 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3061 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3062 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3063 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3064 |
7 | 3065 /* |
3066 * End of handling side effects for bool options. | |
3067 */ | |
3068 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3069 // after handling side effects, call autocommand |
6935 | 3070 |
7 | 3071 options[opt_idx].flags |= P_WAS_SET; |
3072 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3073 #if defined(FEAT_EVAL) |
14804
cca823b02a04
patch 8.1.0414: v:option_old is cleared when using :set in OptionSet autocmd
Christian Brabandt <cb@256bit.org>
parents:
14748
diff
changeset
|
3074 // Don't do this while starting up or recursively. |
cca823b02a04
patch 8.1.0414: v:option_old is cleared when using :set in OptionSet autocmd
Christian Brabandt <cb@256bit.org>
parents:
14748
diff
changeset
|
3075 if (!starting && *get_vim_var_str(VV_OPTION_TYPE) == NUL) |
6935 | 3076 { |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3077 char_u buf_old[2], buf_old_global[2], buf_new[2], buf_type[7]; |
14804
cca823b02a04
patch 8.1.0414: v:option_old is cleared when using :set in OptionSet autocmd
Christian Brabandt <cb@256bit.org>
parents:
14748
diff
changeset
|
3078 |
6937 | 3079 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE); |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3080 vim_snprintf((char *)buf_old_global, 2, "%d", |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3081 old_global_value ? TRUE: FALSE); |
6937 | 3082 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE); |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3083 vim_snprintf((char *)buf_type, 7, "%s", |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3084 (opt_flags & OPT_LOCAL) ? "local" : "global"); |
6935 | 3085 set_vim_var_string(VV_OPTION_NEW, buf_new, -1); |
3086 set_vim_var_string(VV_OPTION_OLD, buf_old, -1); | |
3087 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); | |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3088 if (opt_flags & OPT_LOCAL) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3089 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3090 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3091 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3092 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3093 if (opt_flags & OPT_GLOBAL) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3094 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3095 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3096 set_vim_var_string(VV_OPTION_OLDGLOBAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3097 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3098 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
|
3099 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3100 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3101 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3102 set_vim_var_string(VV_OPTION_OLDGLOBAL, buf_old_global, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3103 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3104 if (opt_flags & OPT_MODELINE) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3105 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3106 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3107 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3108 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3109 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3110 NULL, FALSE, NULL); |
6935 | 3111 reset_v_option_vars(); |
3112 } | |
3113 #endif | |
3114 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3115 comp_col(); // in case 'ruler' or 'showcmd' changed |
3443 | 3116 if (curwin->w_curswant != MAXCOL |
6669 | 3117 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 3118 curwin->w_set_curswant = TRUE; |
7 | 3119 check_redraw(options[opt_idx].flags); |
3120 | |
3121 return NULL; | |
3122 } | |
3123 | |
3124 /* | |
3125 * Set the value of a number option, and take care of side effects. | |
3126 * Returns NULL for success, or an error message for an error. | |
3127 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3128 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3129 set_num_option( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3130 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
|
3131 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
|
3132 long value, // new value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3133 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
|
3134 size_t errbuflen, // length of "errbuf" |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3135 int opt_flags) // OPT_LOCAL, OPT_GLOBAL and |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3136 // OPT_MODELINE |
7 | 3137 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3138 char *errmsg = NULL; |
7 | 3139 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
|
3140 #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
|
3141 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
|
3142 // 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
|
3143 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3144 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
|
3145 long old_Columns = Columns; // remember old Columns |
7 | 3146 long *pp = (long *)varp; |
3147 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3148 // Disallow changing some options from secure mode. |
634 | 3149 if ((secure |
3150 #ifdef HAVE_SANDBOX | |
3151 || sandbox != 0 | |
3152 #endif | |
3153 ) && (options[opt_idx].flags & P_SECURE)) | |
3154 return e_secure; | |
7 | 3155 |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3156 #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
|
3157 // 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
|
3158 // a global-only option setting the "local value" infact sets the global |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3159 // 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
|
3160 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
|
3161 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
|
3162 OPT_GLOBAL); |
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3163 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3164 |
7 | 3165 *pp = value; |
3166 #ifdef FEAT_EVAL | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3167 // 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
|
3168 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 3169 #endif |
634 | 3170 #ifdef FEAT_GUI |
3171 need_mouse_correct = TRUE; | |
3172 #endif | |
7 | 3173 |
3740 | 3174 if (curbuf->b_p_sw < 0) |
7 | 3175 { |
3176 errmsg = e_positive; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3177 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3178 // 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
|
3179 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
|
3180 ? 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
|
3181 : curbuf->b_p_ts; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3182 #else |
7 | 3183 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
|
3184 #endif |
7 | 3185 } |
3186 | |
3187 /* | |
3188 * Number options that need some action when changed | |
3189 */ | |
3190 if (pp == &p_wh || pp == &p_hh) | |
3191 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3192 // 'winheight' and 'helpheight' |
7 | 3193 if (p_wh < 1) |
3194 { | |
3195 errmsg = e_positive; | |
3196 p_wh = 1; | |
3197 } | |
3198 if (p_wmh > p_wh) | |
3199 { | |
3200 errmsg = e_winheight; | |
3201 p_wh = p_wmh; | |
3202 } | |
3203 if (p_hh < 0) | |
3204 { | |
3205 errmsg = e_positive; | |
3206 p_hh = 0; | |
3207 } | |
3208 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3209 // Change window height NOW |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10340
diff
changeset
|
3210 if (!ONE_WINDOW) |
7 | 3211 { |
3212 if (pp == &p_wh && curwin->w_height < p_wh) | |
3213 win_setheight((int)p_wh); | |
3214 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) | |
3215 win_setheight((int)p_hh); | |
3216 } | |
3217 } | |
3218 else if (pp == &p_wmh) | |
3219 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3220 // 'winminheight' |
7 | 3221 if (p_wmh < 0) |
3222 { | |
3223 errmsg = e_positive; | |
3224 p_wmh = 0; | |
3225 } | |
3226 if (p_wmh > p_wh) | |
3227 { | |
3228 errmsg = e_winheight; | |
3229 p_wmh = p_wh; | |
3230 } | |
3231 win_setminheight(); | |
3232 } | |
13 | 3233 else if (pp == &p_wiw) |
7 | 3234 { |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3235 // 'winwidth' |
7 | 3236 if (p_wiw < 1) |
3237 { | |
3238 errmsg = e_positive; | |
3239 p_wiw = 1; | |
3240 } | |
3241 if (p_wmw > p_wiw) | |
3242 { | |
3243 errmsg = e_winwidth; | |
3244 p_wiw = p_wmw; | |
3245 } | |
3246 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3247 // Change window width NOW |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10340
diff
changeset
|
3248 if (!ONE_WINDOW && curwin->w_width < p_wiw) |
7 | 3249 win_setwidth((int)p_wiw); |
3250 } | |
3251 else if (pp == &p_wmw) | |
3252 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3253 // 'winminwidth' |
7 | 3254 if (p_wmw < 0) |
3255 { | |
3256 errmsg = e_positive; | |
3257 p_wmw = 0; | |
3258 } | |
3259 if (p_wmw > p_wiw) | |
3260 { | |
3261 errmsg = e_winwidth; | |
3262 p_wmw = p_wiw; | |
3263 } | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3264 win_setminwidth(); |
7 | 3265 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
3266 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3267 // (re)set last window status line |
7 | 3268 else if (pp == &p_ls) |
3269 { | |
3270 last_status(FALSE); | |
3271 } | |
670 | 3272 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3273 // (re)set tab page line |
677 | 3274 else if (pp == &p_stal) |
670 | 3275 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3276 shell_new_rows(); // recompute window positions and heights |
670 | 3277 } |
7 | 3278 |
3279 #ifdef FEAT_GUI | |
3280 else if (pp == &p_linespace) | |
3281 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3282 // 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
|
3283 // same number of lines. |
444 | 3284 if (gui.in_use && gui_mch_adjust_charheight() == OK) |
813 | 3285 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); |
7 | 3286 } |
3287 #endif | |
3288 | |
3289 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3290 // 'foldlevel' |
7 | 3291 else if (pp == &curwin->w_p_fdl) |
3292 { | |
3293 if (curwin->w_p_fdl < 0) | |
3294 curwin->w_p_fdl = 0; | |
3295 newFoldLevel(); | |
3296 } | |
3297 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3298 // 'foldminlines' |
7 | 3299 else if (pp == &curwin->w_p_fml) |
3300 { | |
3301 foldUpdateAll(curwin); | |
3302 } | |
3303 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3304 // 'foldnestmax' |
7 | 3305 else if (pp == &curwin->w_p_fdn) |
3306 { | |
3307 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) | |
3308 foldUpdateAll(curwin); | |
3309 } | |
3310 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3311 // 'foldcolumn' |
7 | 3312 else if (pp == &curwin->w_p_fdc) |
3313 { | |
3314 if (curwin->w_p_fdc < 0) | |
3315 { | |
3316 errmsg = e_positive; | |
3317 curwin->w_p_fdc = 0; | |
3318 } | |
3319 else if (curwin->w_p_fdc > 12) | |
3320 { | |
3321 errmsg = e_invarg; | |
3322 curwin->w_p_fdc = 12; | |
3323 } | |
3324 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3325 #endif // FEAT_FOLDING |
5438 | 3326 |
3327 #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
|
3328 // 'shiftwidth' or 'tabstop' |
7 | 3329 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) |
3330 { | |
5438 | 3331 # ifdef FEAT_FOLDING |
7 | 3332 if (foldmethodIsIndent(curwin)) |
3333 foldUpdateAll(curwin); | |
5438 | 3334 # endif |
3335 # ifdef FEAT_CINDENT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3336 // 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
|
3337 // parse 'cinoptions'. |
5438 | 3338 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) |
3339 parse_cino(curbuf); | |
3340 # endif | |
3341 } | |
3342 #endif | |
7 | 3343 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3344 // 'maxcombine' |
714 | 3345 else if (pp == &p_mco) |
3346 { | |
3347 if (p_mco > MAX_MCO) | |
3348 p_mco = MAX_MCO; | |
3349 else if (p_mco < 0) | |
3350 p_mco = 0; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3351 screenclear(); // will re-allocate the screen |
714 | 3352 } |
3353 | |
7 | 3354 else if (pp == &curbuf->b_p_iminsert) |
3355 { | |
3356 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) | |
3357 { | |
3358 errmsg = e_invarg; | |
3359 curbuf->b_p_iminsert = B_IMODE_NONE; | |
3360 } | |
3361 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
|
3362 if (termcap_active) // don't do this in the alternate screen |
7 | 3363 showmode(); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
3364 #if defined(FEAT_KEYMAP) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3365 // Show/unshow value of 'keymap' in status lines. |
7 | 3366 status_redraw_curbuf(); |
3367 #endif | |
3368 } | |
3369 | |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3370 #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
|
3371 // 'imstyle' |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3372 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
|
3373 { |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3374 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
|
3375 errmsg = e_invarg; |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3376 } |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3377 #endif |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3378 |
164 | 3379 else if (pp == &p_window) |
3380 { | |
3381 if (p_window < 1) | |
3382 p_window = 1; | |
3383 else if (p_window >= Rows) | |
3384 p_window = Rows - 1; | |
3385 } | |
3386 | |
7 | 3387 else if (pp == &curbuf->b_p_imsearch) |
3388 { | |
3389 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) | |
3390 { | |
3391 errmsg = e_invarg; | |
3392 curbuf->b_p_imsearch = B_IMODE_NONE; | |
3393 } | |
3394 p_imsearch = curbuf->b_p_imsearch; | |
3395 } | |
3396 | |
3397 #ifdef FEAT_TITLE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3398 // if 'titlelen' has changed, redraw the title |
7 | 3399 else if (pp == &p_titlelen) |
3400 { | |
3401 if (p_titlelen < 0) | |
3402 { | |
3403 errmsg = e_positive; | |
3404 p_titlelen = 85; | |
3405 } | |
3406 if (starting != NO_SCREEN && old_value != p_titlelen) | |
3407 need_maketitle = TRUE; | |
3408 } | |
3409 #endif | |
3410 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3411 // if p_ch changed value, change the command line height |
7 | 3412 else if (pp == &p_ch) |
3413 { | |
3414 if (p_ch < 1) | |
3415 { | |
3416 errmsg = e_positive; | |
3417 p_ch = 1; | |
3418 } | |
1404 | 3419 if (p_ch > Rows - min_rows() + 1) |
3420 p_ch = Rows - min_rows() + 1; | |
7 | 3421 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3422 // 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
|
3423 // completed. Otherwise the frame sizes may be wrong. |
7 | 3424 if (p_ch != old_value && full_screen |
3425 #ifdef FEAT_GUI | |
3426 && !gui.starting | |
3427 #endif | |
3428 ) | |
824 | 3429 command_height(); |
7 | 3430 } |
3431 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3432 // when 'updatecount' changes from zero to non-zero, open swap files |
7 | 3433 else if (pp == &p_uc) |
3434 { | |
3435 if (p_uc < 0) | |
3436 { | |
3437 errmsg = e_positive; | |
3438 p_uc = 100; | |
3439 } | |
3440 if (p_uc && !old_value) | |
3441 ml_open_files(); | |
3442 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3443 #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
|
3444 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
|
3445 { |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3446 if (curwin->w_p_cole < 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3447 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3448 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
|
3449 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
|
3450 } |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3451 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
|
3452 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3453 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
|
3454 curwin->w_p_cole = 3; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3455 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3456 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3457 #endif |
16 | 3458 #ifdef MZSCHEME_GUI_THREADS |
14 | 3459 else if (pp == &p_mzq) |
3460 mzvim_reset_timer(); | |
3461 #endif | |
7 | 3462 |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3463 #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
|
3464 // 'pyxversion' |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3465 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
|
3466 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3467 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
|
3468 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
|
3469 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3470 #endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3471 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3472 // sync undo before 'undolevels' changes |
7 | 3473 else if (pp == &p_ul) |
3474 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3475 // use the old value, otherwise u_sync() may not work properly |
7 | 3476 p_ul = old_value; |
825 | 3477 u_sync(TRUE); |
7 | 3478 p_ul = value; |
3479 } | |
5446 | 3480 else if (pp == &curbuf->b_p_ul) |
3481 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3482 // use the old value, otherwise u_sync() may not work properly |
5446 | 3483 curbuf->b_p_ul = old_value; |
3484 u_sync(TRUE); | |
3485 curbuf->b_p_ul = value; | |
3486 } | |
7 | 3487 |
13 | 3488 #ifdef FEAT_LINEBREAK |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3489 // 'numberwidth' must be positive |
13 | 3490 else if (pp == &curwin->w_p_nuw) |
3491 { | |
3492 if (curwin->w_p_nuw < 1) | |
3493 { | |
3494 errmsg = e_positive; | |
3495 curwin->w_p_nuw = 1; | |
3496 } | |
17229
f1c7b7a4d9e4
patch 8.1.1614: 'numberwidth' can only go up to 10
Bram Moolenaar <Bram@vim.org>
parents:
17176
diff
changeset
|
3497 if (curwin->w_p_nuw > 20) |
13 | 3498 { |
3499 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
|
3500 curwin->w_p_nuw = 20; |
13 | 3501 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3502 curwin->w_nrwidth_line_count = 0; // trigger a redraw |
13 | 3503 } |
3504 #endif | |
3505 | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3506 else if (pp == &curbuf->b_p_tw) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3507 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3508 if (curbuf->b_p_tw < 0) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3509 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3510 errmsg = e_positive; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3511 curbuf->b_p_tw = 0; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3512 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3513 #ifdef FEAT_SYN_HL |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3514 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3515 win_T *wp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3516 tabpage_T *tp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3517 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3518 FOR_ALL_TAB_WINDOWS(tp, wp) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3519 check_colorcolumn(wp); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3520 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3521 #endif |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3522 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3523 |
7 | 3524 /* |
3525 * Check the bounds for numeric options here | |
3526 */ | |
3527 if (Rows < min_rows() && full_screen) | |
3528 { | |
3529 if (errbuf != NULL) | |
3530 { | |
274 | 3531 vim_snprintf((char *)errbuf, errbuflen, |
3532 _("E593: Need at least %d lines"), min_rows()); | |
7 | 3533 errmsg = errbuf; |
3534 } | |
3535 Rows = min_rows(); | |
3536 } | |
3537 if (Columns < MIN_COLUMNS && full_screen) | |
3538 { | |
3539 if (errbuf != NULL) | |
3540 { | |
274 | 3541 vim_snprintf((char *)errbuf, errbuflen, |
3542 _("E594: Need at least %d columns"), MIN_COLUMNS); | |
7 | 3543 errmsg = errbuf; |
3544 } | |
3545 Columns = MIN_COLUMNS; | |
3546 } | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
5039
diff
changeset
|
3547 limit_screen_size(); |
7 | 3548 |
3549 /* | |
3550 * If the screen (shell) height has been changed, assume it is the | |
3551 * physical screenheight. | |
3552 */ | |
3553 if (old_Rows != Rows || old_Columns != Columns) | |
3554 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3555 // Changing the screen size is not allowed while updating the screen. |
7 | 3556 if (updating_screen) |
3557 *pp = old_value; | |
3558 else if (full_screen | |
3559 #ifdef FEAT_GUI | |
3560 && !gui.starting | |
3561 #endif | |
3562 ) | |
3563 set_shellsize((int)Columns, (int)Rows, TRUE); | |
3564 else | |
3565 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3566 // 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
|
3567 // messages. |
7 | 3568 check_shellsize(); |
3569 if (cmdline_row > Rows - p_ch && Rows > p_ch) | |
3570 cmdline_row = Rows - p_ch; | |
3571 } | |
857 | 3572 if (p_window >= Rows || !option_was_set((char_u *)"window")) |
164 | 3573 p_window = Rows - 1; |
7 | 3574 } |
3575 | |
3576 if (curbuf->b_p_ts <= 0) | |
3577 { | |
3578 errmsg = e_positive; | |
3579 curbuf->b_p_ts = 8; | |
3580 } | |
3581 if (p_tm < 0) | |
3582 { | |
3583 errmsg = e_positive; | |
3584 p_tm = 0; | |
3585 } | |
3586 if ((curwin->w_p_scr <= 0 | |
3587 || (curwin->w_p_scr > curwin->w_height | |
3588 && curwin->w_height > 0)) | |
3589 && full_screen) | |
3590 { | |
3591 if (pp == &(curwin->w_p_scr)) | |
3592 { | |
3593 if (curwin->w_p_scr != 0) | |
3594 errmsg = e_scroll; | |
3595 win_comp_scroll(curwin); | |
3596 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3597 // 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
|
3598 // it. |
7 | 3599 else if (curwin->w_p_scr <= 0) |
3600 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
|
3601 else // curwin->w_p_scr > curwin->w_height |
7 | 3602 curwin->w_p_scr = curwin->w_height; |
3603 } | |
1726 | 3604 if (p_hi < 0) |
3605 { | |
3606 errmsg = e_positive; | |
3607 p_hi = 0; | |
3608 } | |
5991 | 3609 else if (p_hi > 10000) |
3610 { | |
3611 errmsg = e_invarg; | |
3612 p_hi = 10000; | |
3613 } | |
4444 | 3614 if (p_re < 0 || p_re > 2) |
3615 { | |
3616 errmsg = e_invarg; | |
3617 p_re = 0; | |
3618 } | |
7 | 3619 if (p_report < 0) |
3620 { | |
3621 errmsg = e_positive; | |
3622 p_report = 1; | |
3623 } | |
532 | 3624 if ((p_sj < -100 || p_sj >= Rows) && full_screen) |
7 | 3625 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3626 if (Rows != old_Rows) // Rows changed, just adjust p_sj |
7 | 3627 p_sj = Rows / 2; |
3628 else | |
3629 { | |
3630 errmsg = e_scroll; | |
3631 p_sj = 1; | |
3632 } | |
3633 } | |
3634 if (p_so < 0 && full_screen) | |
3635 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
3636 errmsg = e_positive; |
7 | 3637 p_so = 0; |
3638 } | |
3639 if (p_siso < 0 && full_screen) | |
3640 { | |
3641 errmsg = e_positive; | |
3642 p_siso = 0; | |
3643 } | |
3644 #ifdef FEAT_CMDWIN | |
3645 if (p_cwh < 1) | |
3646 { | |
3647 errmsg = e_positive; | |
3648 p_cwh = 1; | |
3649 } | |
3650 #endif | |
3651 if (p_ut < 0) | |
3652 { | |
3653 errmsg = e_positive; | |
3654 p_ut = 2000; | |
3655 } | |
3656 if (p_ss < 0) | |
3657 { | |
3658 errmsg = e_positive; | |
3659 p_ss = 0; | |
3660 } | |
3661 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3662 // May set global value for local option. |
7 | 3663 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
3664 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; | |
3665 | |
3666 options[opt_idx].flags |= P_WAS_SET; | |
3667 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3668 #if defined(FEAT_EVAL) |
14804
cca823b02a04
patch 8.1.0414: v:option_old is cleared when using :set in OptionSet autocmd
Christian Brabandt <cb@256bit.org>
parents:
14748
diff
changeset
|
3669 // Don't do this while starting up, failure or recursively. |
cca823b02a04
patch 8.1.0414: v:option_old is cleared when using :set in OptionSet autocmd
Christian Brabandt <cb@256bit.org>
parents:
14748
diff
changeset
|
3670 if (!starting && errmsg == NULL && *get_vim_var_str(VV_OPTION_TYPE) == NUL) |
6935 | 3671 { |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3672 char_u buf_old[11], buf_old_global[11], buf_new[11], buf_type[7]; |
6937 | 3673 vim_snprintf((char *)buf_old, 10, "%ld", old_value); |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3674 vim_snprintf((char *)buf_old_global, 10, "%ld", old_global_value); |
6937 | 3675 vim_snprintf((char *)buf_new, 10, "%ld", value); |
3676 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); | |
6935 | 3677 set_vim_var_string(VV_OPTION_NEW, buf_new, -1); |
3678 set_vim_var_string(VV_OPTION_OLD, buf_old, -1); | |
3679 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); | |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3680 if (opt_flags & OPT_LOCAL) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3681 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3682 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3683 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3684 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3685 if (opt_flags & OPT_GLOBAL) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3686 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3687 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3688 set_vim_var_string(VV_OPTION_OLDGLOBAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3689 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3690 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
|
3691 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3692 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3693 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3694 set_vim_var_string(VV_OPTION_OLDGLOBAL, buf_old_global, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3695 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3696 if (opt_flags & OPT_MODELINE) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3697 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3698 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3699 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3700 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3701 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3702 NULL, FALSE, NULL); |
6935 | 3703 reset_v_option_vars(); |
3704 } | |
3705 #endif | |
3706 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3707 comp_col(); // in case 'columns' or 'ls' changed |
3443 | 3708 if (curwin->w_curswant != MAXCOL |
6669 | 3709 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 3710 curwin->w_set_curswant = TRUE; |
7 | 3711 check_redraw(options[opt_idx].flags); |
3712 | |
3713 return errmsg; | |
3714 } | |
3715 | |
3716 /* | |
3717 * Called after an option changed: check if something needs to be redrawn. | |
3718 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
3719 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3720 check_redraw(long_u flags) |
7 | 3721 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3722 // Careful: P_RCLR and P_RALL are a combination of other P_ flags |
3263 | 3723 int doclear = (flags & P_RCLR) == P_RCLR; |
3724 int all = ((flags & P_RALL) == P_RALL || doclear); | |
7 | 3725 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3726 if ((flags & P_RSTAT) || all) // mark all status lines dirty |
7 | 3727 status_redraw_all(); |
3728 | |
3729 if ((flags & P_RBUF) || (flags & P_RWIN) || all) | |
3730 changed_window_setting(); | |
3731 if (flags & P_RBUF) | |
3732 redraw_curbuf_later(NOT_VALID); | |
10456
536a7d49249c
commit https://github.com/vim/vim/commit/a2477fd3490c1166522631eee53c57d34321086a
Christian Brabandt <cb@256bit.org>
parents:
10424
diff
changeset
|
3733 if (flags & P_RWINONLY) |
536a7d49249c
commit https://github.com/vim/vim/commit/a2477fd3490c1166522631eee53c57d34321086a
Christian Brabandt <cb@256bit.org>
parents:
10424
diff
changeset
|
3734 redraw_later(NOT_VALID); |
3263 | 3735 if (doclear) |
7 | 3736 redraw_all_later(CLEAR); |
3737 else if (all) | |
3738 redraw_all_later(NOT_VALID); | |
3739 } | |
3740 | |
3741 /* | |
3742 * Find index for option 'arg'. | |
3743 * Return -1 if not found. | |
3744 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
3745 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3746 findoption(char_u *arg) |
7 | 3747 { |
3748 int opt_idx; | |
3749 char *s, *p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3750 static short quick_tab[27] = {0, 0}; // quick access table |
7 | 3751 int is_term_opt; |
3752 | |
3753 /* | |
3754 * For first call: Initialize the quick-access table. | |
3755 * It contains the index for the first option that starts with a certain | |
3756 * letter. There are 26 letters, plus the first "t_" option. | |
3757 */ | |
3758 if (quick_tab[1] == 0) | |
3759 { | |
3760 p = options[0].fullname; | |
3761 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
3762 { | |
3763 if (s[0] != p[0]) | |
3764 { | |
3765 if (s[0] == 't' && s[1] == '_') | |
3766 quick_tab[26] = opt_idx; | |
3767 else | |
3768 quick_tab[CharOrdLow(s[0])] = opt_idx; | |
3769 } | |
3770 p = s; | |
3771 } | |
3772 } | |
3773 | |
3774 /* | |
3775 * Check for name starting with an illegal character. | |
3776 */ | |
3777 #ifdef EBCDIC | |
3778 if (!islower(arg[0])) | |
3779 #else | |
3780 if (arg[0] < 'a' || arg[0] > 'z') | |
3781 #endif | |
3782 return -1; | |
3783 | |
3784 is_term_opt = (arg[0] == 't' && arg[1] == '_'); | |
3785 if (is_term_opt) | |
3786 opt_idx = quick_tab[26]; | |
3787 else | |
3788 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
3789 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
3790 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3791 if (STRCMP(arg, s) == 0) // match full name |
7 | 3792 break; |
3793 } | |
3794 if (s == NULL && !is_term_opt) | |
3795 { | |
3796 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
3797 for ( ; options[opt_idx].fullname != NULL; opt_idx++) | |
3798 { | |
3799 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
|
3800 if (s != NULL && STRCMP(arg, s) == 0) // match short name |
7 | 3801 break; |
3802 s = NULL; | |
3803 } | |
3804 } | |
3805 if (s == NULL) | |
3806 opt_idx = -1; | |
3807 return opt_idx; | |
3808 } | |
3809 | |
14 | 3810 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME) |
7 | 3811 /* |
3812 * Get the value for an option. | |
3813 * | |
3814 * Returns: | |
3815 * Number or Toggle option: 1, *numval gets value. | |
3816 * String option: 0, *stringval gets allocated string. | |
3817 * Hidden Number or Toggle option: -1. | |
3818 * hidden String option: -2. | |
3819 * unknown option: -3. | |
3820 */ | |
3821 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3822 get_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3823 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3824 long *numval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3825 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
|
3826 int opt_flags) |
7 | 3827 { |
3828 int opt_idx; | |
3829 char_u *varp; | |
3830 | |
3831 opt_idx = findoption(name); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3832 if (opt_idx < 0) // unknown option |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3833 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3834 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3835 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3836 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
|
3837 && (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
|
3838 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3839 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
|
3840 char_u *p; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3841 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3842 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3843 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3844 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
|
3845 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
|
3846 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3847 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3848 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3849 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
|
3850 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
|
3851 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3852 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
|
3853 if (p != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3854 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3855 if (stringval != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3856 *stringval = vim_strsave(p); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3857 return 0; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3858 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3859 } |
7 | 3860 return -3; |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3861 } |
7 | 3862 |
3863 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | |
3864 | |
3865 if (options[opt_idx].flags & P_STRING) | |
3866 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3867 if (varp == NULL) // hidden option |
7 | 3868 return -2; |
3869 if (stringval != NULL) | |
3870 { | |
3871 #ifdef FEAT_CRYPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3872 // never return the value of the crypt key |
1622 | 3873 if ((char_u **)varp == &curbuf->b_p_key |
3874 && **(char_u **)(varp) != NUL) | |
7 | 3875 *stringval = vim_strsave((char_u *)"*****"); |
3876 else | |
3877 #endif | |
3878 *stringval = vim_strsave(*(char_u **)(varp)); | |
3879 } | |
3880 return 0; | |
3881 } | |
3882 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3883 if (varp == NULL) // hidden option |
7 | 3884 return -1; |
3885 if (options[opt_idx].flags & P_NUM) | |
3886 *numval = *(long *)varp; | |
3887 else | |
3888 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3889 // 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
|
3890 // it set when 'ff' or 'fenc' changed. |
7 | 3891 if ((int *)varp == &curbuf->b_changed) |
3892 *numval = curbufIsChanged(); | |
3893 else | |
9395
beab399e3883
commit https://github.com/vim/vim/commit/2acfbed9dbea990f129535de7ff3df360365130b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
3894 *numval = (long) *(int *)varp; |
7 | 3895 } |
3896 return 1; | |
3897 } | |
3898 #endif | |
3899 | |
5610 | 3900 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
4350 | 3901 /* |
3902 * Returns the option attributes and its value. Unlike the above function it | |
3903 * will return either global value or local value of the option depending on | |
3904 * what was requested, but it will never return global value if it was | |
3905 * requested to return local one and vice versa. Neither it will return | |
3906 * buffer-local value if it was requested to return window-local one. | |
3907 * | |
3908 * Pretends that option is absent if it is not present in the requested scope | |
3909 * (i.e. has no global, window-local or buffer-local value depending on | |
3910 * opt_type). Uses | |
3911 * | |
3912 * Returned flags: | |
5867 | 3913 * 0 hidden or unknown option, also option that does not have requested |
3914 * type (see SREQ_* in vim.h) | |
4350 | 3915 * see SOPT_* in vim.h for other flags |
3916 * | |
3917 * Possible opt_type values: see SREQ_* in vim.h | |
3918 */ | |
3919 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3920 get_option_value_strict( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3921 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3922 long *numval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3923 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
|
3924 int opt_type, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3925 void *from) |
4350 | 3926 { |
3927 int opt_idx; | |
4367 | 3928 char_u *varp = NULL; |
4350 | 3929 struct vimoption *p; |
3930 int r = 0; | |
3931 | |
3932 opt_idx = findoption(name); | |
3933 if (opt_idx < 0) | |
3934 return 0; | |
3935 | |
3936 p = &(options[opt_idx]); | |
3937 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3938 // Hidden option |
4350 | 3939 if (p->var == NULL) |
3940 return 0; | |
3941 | |
3942 if (p->flags & P_BOOL) | |
3943 r |= SOPT_BOOL; | |
3944 else if (p->flags & P_NUM) | |
3945 r |= SOPT_NUM; | |
3946 else if (p->flags & P_STRING) | |
3947 r |= SOPT_STRING; | |
3948 | |
3949 if (p->indir == PV_NONE) | |
3950 { | |
3951 if (opt_type == SREQ_GLOBAL) | |
3952 r |= SOPT_GLOBAL; | |
3953 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3954 return 0; // Did not request global-only option |
4350 | 3955 } |
3956 else | |
3957 { | |
3958 if (p->indir & PV_BOTH) | |
3959 r |= SOPT_GLOBAL; | |
3960 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
|
3961 return 0; // Requested global option |
4350 | 3962 |
3963 if (p->indir & PV_WIN) | |
3964 { | |
3965 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
|
3966 return 0; // Did not request window-local option |
4350 | 3967 else |
3968 r |= SOPT_WIN; | |
3969 } | |
3970 else if (p->indir & PV_BUF) | |
3971 { | |
3972 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
|
3973 return 0; // Did not request buffer-local option |
4350 | 3974 else |
3975 r |= SOPT_BUF; | |
3976 } | |
3977 } | |
3978 | |
3979 if (stringval == NULL) | |
3980 return r; | |
3981 | |
3982 if (opt_type == SREQ_GLOBAL) | |
3983 varp = p->var; | |
3984 else | |
3985 { | |
3986 if (opt_type == SREQ_BUF) | |
3987 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3988 // 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
|
3989 // consider it set when 'ff' or 'fenc' changed. |
4350 | 3990 if (p->indir == PV_MOD) |
3991 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
3992 *numval = bufIsChanged((buf_T *)from); |
4350 | 3993 varp = NULL; |
3994 } | |
3995 #ifdef FEAT_CRYPT | |
3996 else if (p->indir == PV_KEY) | |
3997 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3998 // never return the value of the crypt key |
4350 | 3999 *stringval = NULL; |
4000 varp = NULL; | |
4001 } | |
4002 #endif | |
4003 else | |
4004 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4005 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
|
4006 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4007 // 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
|
4008 curbuf = (buf_T *)from; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4009 curwin->w_buffer = curbuf; |
4350 | 4010 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
|
4011 curbuf = save_curbuf; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4012 curwin->w_buffer = curbuf; |
4350 | 4013 } |
4014 } | |
4015 else if (opt_type == SREQ_WIN) | |
4016 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4017 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
|
4018 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4019 curwin = (win_T *)from; |
4350 | 4020 curbuf = curwin->w_buffer; |
4021 varp = get_varp(p); | |
4022 curwin = save_curwin; | |
4023 curbuf = curwin->w_buffer; | |
4024 } | |
4025 if (varp == p->var) | |
4026 return (r | SOPT_UNSET); | |
4027 } | |
4028 | |
4029 if (varp != NULL) | |
4030 { | |
4031 if (p->flags & P_STRING) | |
4032 *stringval = vim_strsave(*(char_u **)(varp)); | |
4033 else if (p->flags & P_NUM) | |
4034 *numval = *(long *) varp; | |
4035 else | |
4036 *numval = *(int *)varp; | |
4037 } | |
4038 | |
4039 return r; | |
4040 } | |
5610 | 4041 |
4042 /* | |
6243 | 4043 * Iterate over options. First argument is a pointer to a pointer to a |
4044 * structure inside options[] array, second is option type like in the above | |
4045 * function. | |
5610 | 4046 * |
6243 | 4047 * If first argument points to NULL it is assumed that iteration just started |
5610 | 4048 * and caller needs the very first value. |
6243 | 4049 * If first argument points to the end marker function returns NULL and sets |
5610 | 4050 * first argument to NULL. |
4051 * | |
4052 * Returns full option name for current option on each call. | |
4053 */ | |
4054 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4055 option_iter_next(void **option, int opt_type) |
5610 | 4056 { |
4057 struct vimoption *ret = NULL; | |
4058 do | |
4059 { | |
4060 if (*option == NULL) | |
4061 *option = (void *) options; | |
4062 else if (((struct vimoption *) (*option))->fullname == NULL) | |
4063 { | |
4064 *option = NULL; | |
4065 return NULL; | |
4066 } | |
4067 else | |
4068 *option = (void *) (((struct vimoption *) (*option)) + 1); | |
4069 | |
4070 ret = ((struct vimoption *) (*option)); | |
4071 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4072 // Hidden option |
5610 | 4073 if (ret->var == NULL) |
4074 { | |
4075 ret = NULL; | |
4076 continue; | |
4077 } | |
4078 | |
4079 switch (opt_type) | |
4080 { | |
4081 case SREQ_GLOBAL: | |
4082 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH)) | |
4083 ret = NULL; | |
4084 break; | |
4085 case SREQ_BUF: | |
4086 if (!(ret->indir & PV_BUF)) | |
4087 ret = NULL; | |
4088 break; | |
4089 case SREQ_WIN: | |
4090 if (!(ret->indir & PV_WIN)) | |
4091 ret = NULL; | |
4092 break; | |
4093 default: | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
4094 internal_error("option_iter_next()"); |
5610 | 4095 return NULL; |
4096 } | |
4097 } | |
4098 while (ret == NULL); | |
4099 | |
4100 return (char_u *)ret->fullname; | |
4101 } | |
4350 | 4102 #endif |
4103 | |
7 | 4104 /* |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4105 * 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
|
4106 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4107 long_u |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4108 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
|
4109 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4110 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
|
4111 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4112 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4113 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4114 * 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
|
4115 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4116 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4117 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
|
4118 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4119 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
|
4120 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4121 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4122 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4123 * 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
|
4124 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4125 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4126 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
|
4127 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4128 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
|
4129 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4130 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4131 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4132 * 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
|
4133 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4134 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4135 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
|
4136 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4137 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
|
4138 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4139 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4140 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4141 * 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
|
4142 * local value. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4143 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4144 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4145 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
|
4146 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4147 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
|
4148 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4149 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4150 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4151 * 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
|
4152 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4153 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4154 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
|
4155 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4156 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
|
4157 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4158 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4159 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4160 * 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
|
4161 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4162 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4163 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
|
4164 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4165 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
|
4166 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4167 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4168 #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
|
4169 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4170 * 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
|
4171 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4172 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4173 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
|
4174 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4175 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
|
4176 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4177 #endif |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4178 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4179 /* |
7 | 4180 * Set the value of option "name". |
4181 * 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
|
4182 * |
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4183 * 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
|
4184 */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4185 char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4186 set_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4187 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4188 long number, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4189 char_u *string, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4190 int opt_flags) // OPT_LOCAL or 0 (both) |
7 | 4191 { |
4192 int opt_idx; | |
4193 char_u *varp; | |
835 | 4194 long_u flags; |
7 | 4195 |
4196 opt_idx = findoption(name); | |
838 | 4197 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
|
4198 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4199 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4200 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4201 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
|
4202 && (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
|
4203 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4204 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
|
4205 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4206 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4207 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4208 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
|
4209 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
|
4210 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4211 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4212 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4213 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
|
4214 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
|
4215 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4216 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
|
4217 if (full_screen) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4218 ttest(FALSE); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4219 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
|
4220 return NULL; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4221 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4222 |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4223 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
|
4224 } |
7 | 4225 else |
4226 { | |
4227 flags = options[opt_idx].flags; | |
4228 #ifdef HAVE_SANDBOX | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4229 // Disallow changing some options in the sandbox |
7 | 4230 if (sandbox > 0 && (flags & P_SECURE)) |
634 | 4231 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4232 emsg(_(e_sandbox)); |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4233 return NULL; |
634 | 4234 } |
4235 #endif | |
4236 if (flags & P_STRING) | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4237 return set_string_option(opt_idx, string, opt_flags); |
7 | 4238 else |
4239 { | |
1667 | 4240 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
|
4241 if (varp != NULL) // hidden option is not changed |
7 | 4242 { |
1298 | 4243 if (number == 0 && string != NULL) |
4244 { | |
1757 | 4245 int idx; |
1298 | 4246 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4247 // 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
|
4248 // to zero. |
1757 | 4249 for (idx = 0; string[idx] == '0'; ++idx) |
1298 | 4250 ; |
1757 | 4251 if (string[idx] != NUL || idx == 0) |
1298 | 4252 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4253 // 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
|
4254 // 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
|
4255 // 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
|
4256 semsg(_("E521: Number required: &%s = '%s'"), |
1298 | 4257 name, string); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4258 return NULL; // do nothing as we hit an error |
1298 | 4259 |
4260 } | |
4261 } | |
7 | 4262 if (flags & P_NUM) |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4263 return set_num_option(opt_idx, varp, number, |
274 | 4264 NULL, 0, opt_flags); |
7 | 4265 else |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4266 return set_bool_option(opt_idx, varp, (int)number, |
634 | 4267 opt_flags); |
7 | 4268 } |
4269 } | |
4270 } | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4271 return NULL; |
7 | 4272 } |
4273 | |
4274 /* | |
4275 * Get the terminal code for a terminal option. | |
4276 * Returns NULL when not found. | |
4277 */ | |
4278 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4279 get_term_code(char_u *tname) |
7 | 4280 { |
4281 int opt_idx; | |
4282 char_u *varp; | |
4283 | |
4284 if (tname[0] != 't' || tname[1] != '_' || | |
4285 tname[2] == NUL || tname[3] == NUL) | |
4286 return NULL; | |
4287 if ((opt_idx = findoption(tname)) >= 0) | |
4288 { | |
4289 varp = get_varp(&(options[opt_idx])); | |
4290 if (varp != NULL) | |
4291 varp = *(char_u **)(varp); | |
4292 return varp; | |
4293 } | |
4294 return find_termcode(tname + 2); | |
4295 } | |
4296 | |
4297 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4298 get_highlight_default(void) |
7 | 4299 { |
4300 int i; | |
4301 | |
4302 i = findoption((char_u *)"hl"); | |
4303 if (i >= 0) | |
4304 return options[i].def_val[VI_DEFAULT]; | |
4305 return (char_u *)NULL; | |
4306 } | |
4307 | |
39 | 4308 char_u * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4309 get_encoding_default(void) |
39 | 4310 { |
4311 int i; | |
4312 | |
4313 i = findoption((char_u *)"enc"); | |
4314 if (i >= 0) | |
4315 return options[i].def_val[VI_DEFAULT]; | |
4316 return (char_u *)NULL; | |
4317 } | |
4318 | |
7 | 4319 /* |
4320 * 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
|
4321 * 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
|
4322 * Returns 0 when the key is not recognized. |
7 | 4323 */ |
4324 static int | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4325 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
|
4326 { |
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4327 int key = 0; |
7 | 4328 int modifiers; |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4329 char_u *arg = arg_arg; |
7 | 4330 |
4331 /* | |
4332 * Don't use get_special_key_code() for t_xx, we don't want it to call | |
4333 * add_termcap_entry(). | |
4334 */ | |
4335 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
4336 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
|
4337 else if (has_lt) |
7 | 4338 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4339 --arg; // put arg at the '<' |
7 | 4340 modifiers = 0; |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18243
diff
changeset
|
4341 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE, TRUE, NULL); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4342 if (modifiers) // can't handle modifiers here |
7 | 4343 key = 0; |
4344 } | |
4345 return key; | |
4346 } | |
4347 | |
4348 /* | |
4349 * if 'all' == 0: show changed options | |
4350 * if 'all' == 1: show all normal options | |
4351 * if 'all' == 2: show all terminal options | |
4352 */ | |
4353 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4354 showoptions( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4355 int all, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4356 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 4357 { |
4358 struct vimoption *p; | |
4359 int col; | |
4360 int isterm; | |
4361 char_u *varp; | |
4362 struct vimoption **items; | |
4363 int item_count; | |
4364 int run; | |
4365 int row, rows; | |
4366 int cols; | |
4367 int i; | |
4368 int len; | |
4369 | |
4370 #define INC 20 | |
4371 #define GAP 3 | |
4372 | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4373 items = ALLOC_MULT(struct vimoption *, OPTION_COUNT); |
7 | 4374 if (items == NULL) |
4375 return; | |
4376 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4377 // Highlight title |
7 | 4378 if (all == 2) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4379 msg_puts_title(_("\n--- Terminal codes ---")); |
7 | 4380 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
|
4381 msg_puts_title(_("\n--- Global option values ---")); |
7 | 4382 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
|
4383 msg_puts_title(_("\n--- Local option values ---")); |
7 | 4384 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4385 msg_puts_title(_("\n--- Options ---")); |
7 | 4386 |
4387 /* | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4388 * Do the loop two times: |
7 | 4389 * 1. display the short items |
4390 * 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
|
4391 * When "opt_flags" has OPT_ONECOLUMN do everything in run 2. |
7 | 4392 */ |
4393 for (run = 1; run <= 2 && !got_int; ++run) | |
4394 { | |
4395 /* | |
4396 * collect the items in items[] | |
4397 */ | |
4398 item_count = 0; | |
4399 for (p = &options[0]; p->fullname != NULL; p++) | |
4400 { | |
14968
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4401 // apply :filter /pat/ |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4402 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
|
4403 continue; |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4404 |
7 | 4405 varp = NULL; |
4406 isterm = istermoption(p); | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4407 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) != 0) |
7 | 4408 { |
4409 if (p->indir != PV_NONE && !isterm) | |
4410 varp = get_varp_scope(p, opt_flags); | |
4411 } | |
4412 else | |
4413 varp = get_varp(p); | |
4414 if (varp != NULL | |
4415 && ((all == 2 && isterm) | |
4416 || (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
|
4417 || (all == 0 && !optval_default(p, varp, p_cp)))) |
7 | 4418 { |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4419 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
|
4420 len = Columns; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4421 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
|
4422 len = 1; // a toggle option fits always |
7 | 4423 else |
4424 { | |
4425 option_value2string(p, opt_flags); | |
4426 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; | |
4427 } | |
4428 if ((len <= INC - GAP && run == 1) || | |
4429 (len > INC - GAP && run == 2)) | |
4430 items[item_count++] = p; | |
4431 } | |
4432 } | |
4433 | |
4434 /* | |
4435 * display the items | |
4436 */ | |
4437 if (run == 1) | |
4438 { | |
4439 cols = (Columns + GAP - 3) / INC; | |
4440 if (cols == 0) | |
4441 cols = 1; | |
4442 rows = (item_count + cols - 1) / cols; | |
4443 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4444 else // run == 2 |
7 | 4445 rows = item_count; |
4446 for (row = 0; row < rows && !got_int; ++row) | |
4447 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4448 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
|
4449 if (got_int) // 'q' typed in more |
7 | 4450 break; |
4451 col = 0; | |
4452 for (i = row; i < item_count; i += rows) | |
4453 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4454 msg_col = col; // make columns |
7 | 4455 showoneopt(items[i], opt_flags); |
4456 col += INC; | |
4457 } | |
4458 out_flush(); | |
4459 ui_breakcheck(); | |
4460 } | |
4461 } | |
4462 vim_free(items); | |
4463 } | |
4464 | |
4465 /* | |
4466 * Return TRUE if option "p" has its default value. | |
4467 */ | |
4468 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
|
4469 optval_default(struct vimoption *p, char_u *varp, int compatible) |
7 | 4470 { |
4471 int dvi; | |
4472 | |
4473 if (varp == NULL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4474 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
|
4475 dvi = ((p->flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; |
7 | 4476 if (p->flags & P_NUM) |
840 | 4477 return (*(long *)varp == (long)(long_i)p->def_val[dvi]); |
7 | 4478 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
|
4479 // 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
|
4480 // needed for MSVC |
840 | 4481 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
|
4482 // P_STRING |
7 | 4483 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); |
4484 } | |
4485 | |
4486 /* | |
4487 * showoneopt: show the value of one option | |
4488 * must not be called with a hidden option! | |
4489 */ | |
4490 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4491 showoneopt( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4492 struct vimoption *p, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4493 int opt_flags) // OPT_LOCAL or OPT_GLOBAL |
7 | 4494 { |
168 | 4495 char_u *varp; |
4496 int save_silent = silent_mode; | |
4497 | |
4498 silent_mode = FALSE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4499 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
7 | 4500 |
4501 varp = get_varp_scope(p, opt_flags); | |
4502 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4503 // for 'modified' we also need to check if 'ff' or 'fenc' changed. |
7 | 4504 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed |
4505 ? !curbufIsChanged() : !*(int *)varp)) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4506 msg_puts("no"); |
7 | 4507 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
|
4508 msg_puts("--"); |
7 | 4509 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4510 msg_puts(" "); |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4511 msg_puts(p->fullname); |
7 | 4512 if (!(p->flags & P_BOOL)) |
4513 { | |
4514 msg_putchar('='); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4515 // put value string in NameBuff |
7 | 4516 option_value2string(p, opt_flags); |
4517 msg_outtrans(NameBuff); | |
4518 } | |
168 | 4519 |
4520 silent_mode = save_silent; | |
4521 info_message = FALSE; | |
7 | 4522 } |
4523 | |
4524 /* | |
4525 * Write modified options as ":set" commands to a file. | |
4526 * | |
4527 * There are three values for "opt_flags": | |
4528 * OPT_GLOBAL: Write global option values and fresh values of | |
4529 * buffer-local options (used for start of a session | |
4530 * file). | |
4531 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for | |
4532 * curwin (used for a vimrc file). | |
4533 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh | |
4534 * and local values for window-local options of | |
4535 * curwin. Local values are also written when at the | |
4536 * default value, because a modeline or autocommand | |
4537 * may have set them when doing ":edit file" and the | |
4538 * user has set them back at the default or fresh | |
4539 * value. | |
4540 * When "local_only" is TRUE, don't write fresh | |
4541 * values, only local values (for ":mkview"). | |
4542 * (fresh value = value used for a new buffer or window for a local option). | |
4543 * | |
4544 * Return FAIL on error, OK otherwise. | |
4545 */ | |
4546 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4547 makeset(FILE *fd, int opt_flags, int local_only) |
7 | 4548 { |
4549 struct vimoption *p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4550 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
|
4551 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
|
4552 char_u *varp_local = NULL; // fresh value |
7 | 4553 char *cmd; |
4554 int round; | |
1384 | 4555 int pri; |
7 | 4556 |
4557 /* | |
4558 * The options that don't have a default (terminal name, columns, lines) | |
4559 * are never written. Terminal options are also not written. | |
1384 | 4560 * Do the loop over "options[]" twice: once for options with the |
4561 * P_PRI_MKRC flag and once without. | |
7 | 4562 */ |
1384 | 4563 for (pri = 1; pri >= 0; --pri) |
4564 { | |
4565 for (p = &options[0]; !istermoption(p); p++) | |
4566 if (!(p->flags & P_NO_MKRC) | |
4567 && !istermoption(p) | |
4568 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) | |
7 | 4569 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4570 // skip global option when only doing locals |
7 | 4571 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) |
4572 continue; | |
4573 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4574 // 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
|
4575 // file, they are always buffer-specific. |
7 | 4576 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) |
4577 continue; | |
4578 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4579 // Global values are only written when not at the default value. |
7 | 4580 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
|
4581 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp, p_cp)) |
7 | 4582 continue; |
4583 | |
4584 round = 2; | |
4585 if (p->indir != PV_NONE) | |
4586 { | |
4587 if (p->var == VAR_WIN) | |
4588 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4589 // skip window-local option when only doing globals |
7 | 4590 if (!(opt_flags & OPT_LOCAL)) |
4591 continue; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4592 // 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
|
4593 // default, need to write it too. |
7 | 4594 if (!(opt_flags & OPT_GLOBAL) && !local_only) |
4595 { | |
4596 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
|
4597 if (!optval_default(p, varp_fresh, p_cp)) |
7 | 4598 { |
4599 round = 1; | |
4600 varp_local = varp; | |
4601 varp = varp_fresh; | |
4602 } | |
4603 } | |
4604 } | |
4605 } | |
4606 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4607 // 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
|
4608 // Round 2: other values |
7 | 4609 for ( ; round <= 2; varp = varp_local, ++round) |
4610 { | |
4611 if (round == 1 || (opt_flags & OPT_GLOBAL)) | |
4612 cmd = "set"; | |
4613 else | |
4614 cmd = "setlocal"; | |
4615 | |
4616 if (p->flags & P_BOOL) | |
4617 { | |
4618 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) | |
4619 return FAIL; | |
4620 } | |
4621 else if (p->flags & P_NUM) | |
4622 { | |
4623 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) | |
4624 return FAIL; | |
4625 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4626 else // P_STRING |
7 | 4627 { |
694 | 4628 int do_endif = FALSE; |
4629 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4630 // 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
|
4631 // already right, avoids reloading the syntax file. |
694 | 4632 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4633 #if defined(FEAT_SYN_HL) |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4634 p->indir == PV_SYN || |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4635 #endif |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4636 p->indir == PV_FT) |
7 | 4637 { |
4638 if (fprintf(fd, "if &%s != '%s'", p->fullname, | |
4639 *(char_u **)(varp)) < 0 | |
4640 || put_eol(fd) < 0) | |
4641 return FAIL; | |
694 | 4642 do_endif = TRUE; |
7 | 4643 } |
4644 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
|
4645 p->flags) == FAIL) |
7 | 4646 return FAIL; |
694 | 4647 if (do_endif) |
7 | 4648 { |
4649 if (put_line(fd, "endif") == FAIL) | |
4650 return FAIL; | |
4651 } | |
4652 } | |
4653 } | |
4654 } | |
1384 | 4655 } |
7 | 4656 return OK; |
4657 } | |
4658 | |
4659 #if defined(FEAT_FOLDING) || defined(PROTO) | |
4660 /* | |
4661 * Generate set commands for the local fold options only. Used when | |
4662 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options". | |
4663 */ | |
4664 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4665 makefoldset(FILE *fd) |
7 | 4666 { |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4667 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, 0) == FAIL |
7 | 4668 # 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
|
4669 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, 0) |
7 | 4670 == FAIL |
4671 # endif | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4672 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, 0) |
7 | 4673 == FAIL |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4674 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, 0) |
7 | 4675 == FAIL |
4676 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL | |
4677 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL | |
4678 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL | |
4679 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL | |
4680 ) | |
4681 return FAIL; | |
4682 | |
4683 return OK; | |
4684 } | |
4685 #endif | |
4686 | |
4687 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4688 put_setstring( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4689 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4690 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4691 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4692 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
|
4693 long_u flags) |
7 | 4694 { |
4695 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
|
4696 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
|
4697 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
|
4698 char_u *p; |
7 | 4699 |
4700 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
4701 return FAIL; | |
4702 if (*valuep != NULL) | |
4703 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4704 // 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
|
4705 // 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
|
4706 // CTRL-V or backslash |
7 | 4707 if (valuep == &p_pt) |
4708 { | |
4709 s = *valuep; | |
4710 while (*s != NUL) | |
1601 | 4711 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL) |
7 | 4712 return FAIL; |
4713 } | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4714 // 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
|
4715 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
|
4716 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4717 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
|
4718 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4719 // 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
|
4720 buf = alloc(size); |
2780 | 4721 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
|
4722 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4723 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
|
4724 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4725 // 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
|
4726 // 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
|
4727 // 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
|
4728 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
|
4729 && 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
|
4730 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4731 part = alloc(size); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4732 if (part == NULL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4733 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4734 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4735 // 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
|
4736 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
|
4737 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4738 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4739 p = buf; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4740 while (*p != NUL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4741 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4742 // 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
|
4743 // 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
|
4744 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
|
4745 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4746 (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
|
4747 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
|
4748 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4749 } |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4750 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4751 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4752 return OK; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4753 } |
7 | 4754 if (put_escstr(fd, buf, 2) == FAIL) |
2780 | 4755 { |
4756 vim_free(buf); | |
7 | 4757 return FAIL; |
2780 | 4758 } |
4759 vim_free(buf); | |
7 | 4760 } |
4761 else if (put_escstr(fd, *valuep, 2) == FAIL) | |
4762 return FAIL; | |
4763 } | |
4764 if (put_eol(fd) < 0) | |
4765 return FAIL; | |
4766 return OK; | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4767 fail: |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4768 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4769 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4770 return FAIL; |
7 | 4771 } |
4772 | |
4773 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4774 put_setnum( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4775 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4776 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4777 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4778 long *valuep) |
7 | 4779 { |
4780 long wc; | |
4781 | |
4782 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
4783 return FAIL; | |
4784 if (wc_use_keyname((char_u *)valuep, &wc)) | |
4785 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4786 // print 'wildchar' and 'wildcharm' as a key name |
7 | 4787 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) |
4788 return FAIL; | |
4789 } | |
4790 else if (fprintf(fd, "%ld", *valuep) < 0) | |
4791 return FAIL; | |
4792 if (put_eol(fd) < 0) | |
4793 return FAIL; | |
4794 return OK; | |
4795 } | |
4796 | |
4797 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4798 put_setbool( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4799 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4800 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4801 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4802 int value) |
7 | 4803 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4804 if (value < 0) // global/local option using global value |
1416 | 4805 return OK; |
7 | 4806 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 |
4807 || put_eol(fd) < 0) | |
4808 return FAIL; | |
4809 return OK; | |
4810 } | |
4811 | |
4812 /* | |
4813 * Clear all the terminal options. | |
4814 * If the option has been allocated, free the memory. | |
4815 * Terminal options are never hidden or indirect. | |
4816 */ | |
4817 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4818 clear_termoptions(void) |
7 | 4819 { |
4820 /* | |
4821 * Reset a few things before clearing the old options. This may cause | |
4822 * outputting a few things that the terminal doesn't understand, but the | |
4823 * screen will be cleared later, so this is OK. | |
4824 */ | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
4825 mch_setmouse(FALSE); // switch mouse off |
7 | 4826 #ifdef FEAT_TITLE |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4827 mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles |
7 | 4828 #endif |
4829 #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
|
4830 // 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
|
4831 // After restoring the title, because that will need the display. |
7 | 4832 if (gui.starting) |
4833 clear_xterm_clip(); | |
4834 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4835 stoptermcap(); // stop termcap mode |
7 | 4836 |
359 | 4837 free_termoptions(); |
4838 } | |
4839 | |
4840 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4841 free_termoptions(void) |
359 | 4842 { |
4843 struct vimoption *p; | |
4844 | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4845 for (p = options; p->fullname != NULL; p++) |
7 | 4846 if (istermoption(p)) |
4847 { | |
4848 if (p->flags & P_ALLOCED) | |
4849 free_string_option(*(char_u **)(p->var)); | |
4850 if (p->flags & P_DEF_ALLOCED) | |
4851 free_string_option(p->def_val[VI_DEFAULT]); | |
4852 *(char_u **)(p->var) = empty_option; | |
4853 p->def_val[VI_DEFAULT] = empty_option; | |
4854 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
|
4855 #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
|
4856 // 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
|
4857 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
|
4858 #endif |
7 | 4859 } |
4860 clear_termcodes(); | |
4861 } | |
4862 | |
4863 /* | |
1941 | 4864 * Free the string for one term option, if it was allocated. |
4865 * Set the string to empty_option and clear allocated flag. | |
4866 * "var" points to the option value. | |
4867 */ | |
4868 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4869 free_one_termoption(char_u *var) |
1941 | 4870 { |
4871 struct vimoption *p; | |
4872 | |
4873 for (p = &options[0]; p->fullname != NULL; p++) | |
4874 if (p->var == var) | |
4875 { | |
4876 if (p->flags & P_ALLOCED) | |
4877 free_string_option(*(char_u **)(p->var)); | |
4878 *(char_u **)(p->var) = empty_option; | |
4879 p->flags &= ~P_ALLOCED; | |
4880 break; | |
4881 } | |
4882 } | |
4883 | |
4884 /* | |
7 | 4885 * Set the terminal option defaults to the current value. |
4886 * Used after setting the terminal name. | |
4887 */ | |
4888 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4889 set_term_defaults(void) |
7 | 4890 { |
4891 struct vimoption *p; | |
4892 | |
4893 for (p = &options[0]; p->fullname != NULL; p++) | |
4894 { | |
4895 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) | |
4896 { | |
4897 if (p->flags & P_DEF_ALLOCED) | |
4898 { | |
4899 free_string_option(p->def_val[VI_DEFAULT]); | |
4900 p->flags &= ~P_DEF_ALLOCED; | |
4901 } | |
4902 p->def_val[VI_DEFAULT] = *(char_u **)(p->var); | |
4903 if (p->flags & P_ALLOCED) | |
4904 { | |
4905 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
|
4906 p->flags &= ~P_ALLOCED; // don't free the value now |
7 | 4907 } |
4908 } | |
4909 } | |
4910 } | |
4911 | |
4912 /* | |
4913 * return TRUE if 'p' starts with 't_' | |
4914 */ | |
4915 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4916 istermoption(struct vimoption *p) |
7 | 4917 { |
4918 return (p->fullname[0] == 't' && p->fullname[1] == '_'); | |
4919 } | |
4920 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4921 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4922 * 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
|
4923 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4924 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4925 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
|
4926 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4927 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
|
4928 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4929 |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
4930 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
7 | 4931 /* |
4350 | 4932 * Unset local option value, similar to ":set opt<". |
4933 */ | |
4934 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4935 unset_global_local_option(char_u *name, void *from) |
4350 | 4936 { |
4937 struct vimoption *p; | |
4938 int opt_idx; | |
4361 | 4939 buf_T *buf = (buf_T *)from; |
4350 | 4940 |
4941 opt_idx = findoption(name); | |
7007 | 4942 if (opt_idx < 0) |
4943 return; | |
4350 | 4944 p = &(options[opt_idx]); |
4945 | |
4946 switch ((int)p->indir) | |
4947 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4948 // global option with local value: use local value if it's been set |
4350 | 4949 case PV_EP: |
4361 | 4950 clear_string_option(&buf->b_p_ep); |
4350 | 4951 break; |
4952 case PV_KP: | |
4361 | 4953 clear_string_option(&buf->b_p_kp); |
4350 | 4954 break; |
4955 case PV_PATH: | |
4361 | 4956 clear_string_option(&buf->b_p_path); |
4350 | 4957 break; |
4958 case PV_AR: | |
4959 buf->b_p_ar = -1; | |
4960 break; | |
6243 | 4961 case PV_BKC: |
4962 clear_string_option(&buf->b_p_bkc); | |
4963 buf->b_bkc_flags = 0; | |
4964 break; | |
4350 | 4965 case PV_TAGS: |
4361 | 4966 clear_string_option(&buf->b_p_tags); |
4350 | 4967 break; |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4968 case PV_TC: |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4969 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
|
4970 buf->b_tc_flags = 0; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
4971 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
|
4972 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
|
4973 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
|
4974 break; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
4975 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
|
4976 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
|
4977 break; |
4350 | 4978 #ifdef FEAT_FIND_ID |
4979 case PV_DEF: | |
4361 | 4980 clear_string_option(&buf->b_p_def); |
4350 | 4981 break; |
4982 case PV_INC: | |
4361 | 4983 clear_string_option(&buf->b_p_inc); |
4350 | 4984 break; |
4985 #endif | |
4986 case PV_DICT: | |
4361 | 4987 clear_string_option(&buf->b_p_dict); |
4350 | 4988 break; |
4989 case PV_TSR: | |
4361 | 4990 clear_string_option(&buf->b_p_tsr); |
4350 | 4991 break; |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
4992 case PV_FP: |
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
4993 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
|
4994 break; |
4350 | 4995 #ifdef FEAT_QUICKFIX |
4996 case PV_EFM: | |
4361 | 4997 clear_string_option(&buf->b_p_efm); |
4350 | 4998 break; |
4999 case PV_GP: | |
4361 | 5000 clear_string_option(&buf->b_p_gp); |
4350 | 5001 break; |
5002 case PV_MP: | |
4361 | 5003 clear_string_option(&buf->b_p_mp); |
4350 | 5004 break; |
5005 #endif | |
5006 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) | |
5007 case PV_BEXPR: | |
4361 | 5008 clear_string_option(&buf->b_p_bexpr); |
4350 | 5009 break; |
5010 #endif | |
5011 #if defined(FEAT_CRYPT) | |
5012 case PV_CM: | |
4361 | 5013 clear_string_option(&buf->b_p_cm); |
4350 | 5014 break; |
5015 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5016 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5017 case PV_SBR: |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5018 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
|
5019 break; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5020 #endif |
4350 | 5021 #ifdef FEAT_STL_OPT |
5022 case PV_STL: | |
4361 | 5023 clear_string_option(&((win_T *)from)->w_p_stl); |
4350 | 5024 break; |
5025 #endif | |
5446 | 5026 case PV_UL: |
5027 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; | |
5028 break; | |
5712 | 5029 #ifdef FEAT_LISP |
5030 case PV_LW: | |
5031 clear_string_option(&buf->b_p_lw); | |
5032 break; | |
5033 #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
|
5034 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
|
5035 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
|
5036 break; |
4350 | 5037 } |
5038 } | |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
5039 #endif |
4350 | 5040 |
5041 /* | |
7 | 5042 * Get pointer to option variable, depending on local or global scope. |
5043 */ | |
5044 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5045 get_varp_scope(struct vimoption *p, int opt_flags) |
7 | 5046 { |
5047 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE) | |
5048 { | |
5049 if (p->var == VAR_WIN) | |
5050 return (char_u *)GLOBAL_WO(get_varp(p)); | |
5051 return p->var; | |
5052 } | |
692 | 5053 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) |
7 | 5054 { |
5055 switch ((int)p->indir) | |
5056 { | |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5057 case PV_FP: return (char_u *)&(curbuf->b_p_fp); |
7 | 5058 #ifdef FEAT_QUICKFIX |
694 | 5059 case PV_EFM: return (char_u *)&(curbuf->b_p_efm); |
5060 case PV_GP: return (char_u *)&(curbuf->b_p_gp); | |
5061 case PV_MP: return (char_u *)&(curbuf->b_p_mp); | |
5062 #endif | |
5063 case PV_EP: return (char_u *)&(curbuf->b_p_ep); | |
5064 case PV_KP: return (char_u *)&(curbuf->b_p_kp); | |
5065 case PV_PATH: return (char_u *)&(curbuf->b_p_path); | |
692 | 5066 case PV_AR: return (char_u *)&(curbuf->b_p_ar); |
694 | 5067 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
|
5068 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
|
5069 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
|
5070 case PV_SO: return (char_u *)&(curwin->w_p_so); |
7 | 5071 #ifdef FEAT_FIND_ID |
694 | 5072 case PV_DEF: return (char_u *)&(curbuf->b_p_def); |
5073 case PV_INC: return (char_u *)&(curbuf->b_p_inc); | |
7 | 5074 #endif |
694 | 5075 case PV_DICT: return (char_u *)&(curbuf->b_p_dict); |
5076 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr); | |
790 | 5077 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5078 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr); | |
5079 #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
|
5080 #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
|
5081 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
|
5082 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5083 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5084 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
|
5085 #endif |
40 | 5086 #ifdef FEAT_STL_OPT |
694 | 5087 case PV_STL: return (char_u *)&(curwin->w_p_stl); |
40 | 5088 #endif |
5446 | 5089 case PV_UL: return (char_u *)&(curbuf->b_p_ul); |
5712 | 5090 #ifdef FEAT_LISP |
5091 case PV_LW: return (char_u *)&(curbuf->b_p_lw); | |
5092 #endif | |
6243 | 5093 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
|
5094 case PV_MENC: return (char_u *)&(curbuf->b_p_menc); |
7 | 5095 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5096 return NULL; // "cannot happen" |
7 | 5097 } |
5098 return get_varp(p); | |
5099 } | |
5100 | |
5101 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5102 * 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
|
5103 * scope. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5104 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5105 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5106 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
|
5107 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5108 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
|
5109 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5110 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5111 /* |
7 | 5112 * Get pointer to option variable. |
5113 */ | |
5114 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5115 get_varp(struct vimoption *p) |
7 | 5116 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5117 // hidden option, always return NULL |
7 | 5118 if (p->var == NULL) |
5119 return NULL; | |
5120 | |
5121 switch ((int)p->indir) | |
5122 { | |
5123 case PV_NONE: return p->var; | |
5124 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5125 // global option with local value: use local value if it's been set |
694 | 5126 case PV_EP: return *curbuf->b_p_ep != NUL |
7 | 5127 ? (char_u *)&curbuf->b_p_ep : p->var; |
694 | 5128 case PV_KP: return *curbuf->b_p_kp != NUL |
7 | 5129 ? (char_u *)&curbuf->b_p_kp : p->var; |
694 | 5130 case PV_PATH: return *curbuf->b_p_path != NUL |
7 | 5131 ? (char_u *)&(curbuf->b_p_path) : p->var; |
692 | 5132 case PV_AR: return curbuf->b_p_ar >= 0 |
7 | 5133 ? (char_u *)&(curbuf->b_p_ar) : p->var; |
694 | 5134 case PV_TAGS: return *curbuf->b_p_tags != NUL |
7 | 5135 ? (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
|
5136 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
|
5137 ? (char_u *)&(curbuf->b_p_tc) : p->var; |
6243 | 5138 case PV_BKC: return *curbuf->b_p_bkc != NUL |
5139 ? (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
|
5140 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
|
5141 ? (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
|
5142 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
|
5143 ? (char_u *)&(curwin->w_p_so) : p->var; |
7 | 5144 #ifdef FEAT_FIND_ID |
694 | 5145 case PV_DEF: return *curbuf->b_p_def != NUL |
7 | 5146 ? (char_u *)&(curbuf->b_p_def) : p->var; |
694 | 5147 case PV_INC: return *curbuf->b_p_inc != NUL |
7 | 5148 ? (char_u *)&(curbuf->b_p_inc) : p->var; |
5149 #endif | |
694 | 5150 case PV_DICT: return *curbuf->b_p_dict != NUL |
7 | 5151 ? (char_u *)&(curbuf->b_p_dict) : p->var; |
694 | 5152 case PV_TSR: return *curbuf->b_p_tsr != NUL |
7 | 5153 ? (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
|
5154 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
|
5155 ? (char_u *)&(curbuf->b_p_fp) : p->var; |
7 | 5156 #ifdef FEAT_QUICKFIX |
694 | 5157 case PV_EFM: return *curbuf->b_p_efm != NUL |
5158 ? (char_u *)&(curbuf->b_p_efm) : p->var; | |
5159 case PV_GP: return *curbuf->b_p_gp != NUL | |
7 | 5160 ? (char_u *)&(curbuf->b_p_gp) : p->var; |
694 | 5161 case PV_MP: return *curbuf->b_p_mp != NUL |
7 | 5162 ? (char_u *)&(curbuf->b_p_mp) : p->var; |
5163 #endif | |
790 | 5164 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5165 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL | |
5166 ? (char_u *)&(curbuf->b_p_bexpr) : p->var; | |
5167 #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
|
5168 #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
|
5169 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
|
5170 ? (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
|
5171 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5172 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5173 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
|
5174 ? (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
|
5175 #endif |
40 | 5176 #ifdef FEAT_STL_OPT |
694 | 5177 case PV_STL: return *curwin->w_p_stl != NUL |
40 | 5178 ? (char_u *)&(curwin->w_p_stl) : p->var; |
5179 #endif | |
5446 | 5180 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL |
5181 ? (char_u *)&(curbuf->b_p_ul) : p->var; | |
5712 | 5182 #ifdef FEAT_LISP |
5183 case PV_LW: return *curbuf->b_p_lw != NUL | |
5184 ? (char_u *)&(curbuf->b_p_lw) : p->var; | |
5185 #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
|
5186 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
|
5187 ? (char_u *)&(curbuf->b_p_menc) : p->var; |
7 | 5188 #ifdef FEAT_ARABIC |
5189 case PV_ARAB: return (char_u *)&(curwin->w_p_arab); | |
5190 #endif | |
5191 case PV_LIST: return (char_u *)&(curwin->w_p_list); | |
744 | 5192 #ifdef FEAT_SPELL |
5193 case PV_SPELL: return (char_u *)&(curwin->w_p_spell); | |
5194 #endif | |
221 | 5195 #ifdef FEAT_SYN_HL |
744 | 5196 case PV_CUC: return (char_u *)&(curwin->w_p_cuc); |
5197 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
|
5198 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
|
5199 case PV_CC: return (char_u *)&(curwin->w_p_cc); |
221 | 5200 #endif |
7 | 5201 #ifdef FEAT_DIFF |
5202 case PV_DIFF: return (char_u *)&(curwin->w_p_diff); | |
5203 #endif | |
5204 #ifdef FEAT_FOLDING | |
5205 case PV_FDC: return (char_u *)&(curwin->w_p_fdc); | |
5206 case PV_FEN: return (char_u *)&(curwin->w_p_fen); | |
5207 case PV_FDI: return (char_u *)&(curwin->w_p_fdi); | |
5208 case PV_FDL: return (char_u *)&(curwin->w_p_fdl); | |
5209 case PV_FDM: return (char_u *)&(curwin->w_p_fdm); | |
5210 case PV_FML: return (char_u *)&(curwin->w_p_fml); | |
5211 case PV_FDN: return (char_u *)&(curwin->w_p_fdn); | |
5212 # ifdef FEAT_EVAL | |
5213 case PV_FDE: return (char_u *)&(curwin->w_p_fde); | |
5214 case PV_FDT: return (char_u *)&(curwin->w_p_fdt); | |
5215 # endif | |
5216 case PV_FMR: return (char_u *)&(curwin->w_p_fmr); | |
5217 #endif | |
5218 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
|
5219 case PV_RNU: return (char_u *)&(curwin->w_p_rnu); |
13 | 5220 #ifdef FEAT_LINEBREAK |
5221 case PV_NUW: return (char_u *)&(curwin->w_p_nuw); | |
5222 #endif | |
7 | 5223 case PV_WFH: return (char_u *)&(curwin->w_p_wfh); |
782 | 5224 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
|
5225 #if defined(FEAT_QUICKFIX) |
7 | 5226 case PV_PVW: return (char_u *)&(curwin->w_p_pvw); |
5227 #endif | |
5228 #ifdef FEAT_RIGHTLEFT | |
5229 case PV_RL: return (char_u *)&(curwin->w_p_rl); | |
5230 case PV_RLC: return (char_u *)&(curwin->w_p_rlc); | |
5231 #endif | |
5232 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr); | |
5233 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); | |
5234 #ifdef FEAT_LINEBREAK | |
5235 case PV_LBR: return (char_u *)&(curwin->w_p_lbr); | |
5995 | 5236 case PV_BRI: return (char_u *)&(curwin->w_p_bri); |
5237 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt); | |
7 | 5238 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5239 case PV_WCR: return (char_u *)&(curwin->w_p_wcr); |
7 | 5240 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
|
5241 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
|
5242 #ifdef FEAT_CONCEAL |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5243 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
|
5244 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
|
5245 #endif |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5246 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5247 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
|
5248 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
|
5249 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
|
5250 #endif |
7 | 5251 |
5252 case PV_AI: return (char_u *)&(curbuf->b_p_ai); | |
5253 case PV_BIN: return (char_u *)&(curbuf->b_p_bin); | |
5254 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); | |
5255 case PV_BH: return (char_u *)&(curbuf->b_p_bh); | |
5256 case PV_BT: return (char_u *)&(curbuf->b_p_bt); | |
5257 case PV_BL: return (char_u *)&(curbuf->b_p_bl); | |
5258 case PV_CI: return (char_u *)&(curbuf->b_p_ci); | |
5259 #ifdef FEAT_CINDENT | |
5260 case PV_CIN: return (char_u *)&(curbuf->b_p_cin); | |
5261 case PV_CINK: return (char_u *)&(curbuf->b_p_cink); | |
5262 case PV_CINO: return (char_u *)&(curbuf->b_p_cino); | |
5263 #endif | |
5264 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) | |
5265 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); | |
5266 #endif | |
5267 case PV_COM: return (char_u *)&(curbuf->b_p_com); | |
5268 #ifdef FEAT_FOLDING | |
5269 case PV_CMS: return (char_u *)&(curbuf->b_p_cms); | |
5270 #endif | |
5271 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
|
5272 #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
|
5273 case PV_CSL: return (char_u *)&(curbuf->b_p_csl); |
7 | 5274 #endif |
12 | 5275 #ifdef FEAT_COMPL_FUNC |
5276 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); | |
502 | 5277 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); |
12 | 5278 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5279 #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
|
5280 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
|
5281 #endif |
7 | 5282 case PV_EOL: return (char_u *)&(curbuf->b_p_eol); |
6933 | 5283 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol); |
7 | 5284 case PV_ET: return (char_u *)&(curbuf->b_p_et); |
5285 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); | |
5286 case PV_FF: return (char_u *)&(curbuf->b_p_ff); | |
5287 case PV_FT: return (char_u *)&(curbuf->b_p_ft); | |
5288 case PV_FO: return (char_u *)&(curbuf->b_p_fo); | |
41 | 5289 case PV_FLP: return (char_u *)&(curbuf->b_p_flp); |
7 | 5290 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); |
5291 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); | |
5292 case PV_INF: return (char_u *)&(curbuf->b_p_inf); | |
5293 case PV_ISK: return (char_u *)&(curbuf->b_p_isk); | |
5294 #ifdef FEAT_FIND_ID | |
5295 # ifdef FEAT_EVAL | |
5296 case PV_INEX: return (char_u *)&(curbuf->b_p_inex); | |
5297 # endif | |
5298 #endif | |
5299 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
5300 case PV_INDE: return (char_u *)&(curbuf->b_p_inde); | |
5301 case PV_INDK: return (char_u *)&(curbuf->b_p_indk); | |
5302 #endif | |
694 | 5303 #ifdef FEAT_EVAL |
667 | 5304 case PV_FEX: return (char_u *)&(curbuf->b_p_fex); |
5305 #endif | |
7 | 5306 #ifdef FEAT_CRYPT |
5307 case PV_KEY: return (char_u *)&(curbuf->b_p_key); | |
5308 #endif | |
5309 #ifdef FEAT_LISP | |
5310 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp); | |
5311 #endif | |
5312 case PV_ML: return (char_u *)&(curbuf->b_p_ml); | |
5313 case PV_MPS: return (char_u *)&(curbuf->b_p_mps); | |
5314 case PV_MA: return (char_u *)&(curbuf->b_p_ma); | |
5315 case PV_MOD: return (char_u *)&(curbuf->b_changed); | |
5316 case PV_NF: return (char_u *)&(curbuf->b_p_nf); | |
5317 case PV_PI: return (char_u *)&(curbuf->b_p_pi); | |
12 | 5318 #ifdef FEAT_TEXTOBJ |
5319 case PV_QE: return (char_u *)&(curbuf->b_p_qe); | |
5320 #endif | |
7 | 5321 case PV_RO: return (char_u *)&(curbuf->b_p_ro); |
5322 #ifdef FEAT_SMARTINDENT | |
5323 case PV_SI: return (char_u *)&(curbuf->b_p_si); | |
5324 #endif | |
5325 case PV_SN: return (char_u *)&(curbuf->b_p_sn); | |
5326 case PV_STS: return (char_u *)&(curbuf->b_p_sts); | |
5327 #ifdef FEAT_SEARCHPATH | |
5328 case PV_SUA: return (char_u *)&(curbuf->b_p_sua); | |
5329 #endif | |
5330 case PV_SWF: return (char_u *)&(curbuf->b_p_swf); | |
5331 #ifdef FEAT_SYN_HL | |
410 | 5332 case PV_SMC: return (char_u *)&(curbuf->b_p_smc); |
744 | 5333 case PV_SYN: return (char_u *)&(curbuf->b_p_syn); |
5334 #endif | |
5335 #ifdef FEAT_SPELL | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5336 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
|
5337 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
|
5338 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl); |
7 | 5339 #endif |
5340 case PV_SW: return (char_u *)&(curbuf->b_p_sw); | |
5341 case PV_TS: return (char_u *)&(curbuf->b_p_ts); | |
5342 case PV_TW: return (char_u *)&(curbuf->b_p_tw); | |
5343 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
|
5344 #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
|
5345 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
|
5346 #endif |
7 | 5347 case PV_WM: return (char_u *)&(curbuf->b_p_wm); |
5348 #ifdef FEAT_KEYMAP | |
5349 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); | |
5350 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5351 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5352 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
|
5353 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5354 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5355 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
|
5356 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
|
5357 #endif |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
5358 default: iemsg(_("E356: get_varp ERROR")); |
7 | 5359 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5360 // always return a valid pointer to avoid a crash! |
7 | 5361 return (char_u *)&(curbuf->b_p_wm); |
5362 } | |
5363 | |
5364 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5365 * 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
|
5366 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5367 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5368 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
|
5369 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5370 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
|
5371 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5372 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5373 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5374 * 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
|
5375 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5376 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5377 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
|
5378 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5379 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
|
5380 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5381 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5382 /* |
7 | 5383 * Get the value of 'equalprg', either the buffer-local one or the global one. |
5384 */ | |
5385 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5386 get_equalprg(void) |
7 | 5387 { |
5388 if (*curbuf->b_p_ep == NUL) | |
5389 return p_ep; | |
5390 return curbuf->b_p_ep; | |
5391 } | |
5392 | |
5393 /* | |
5394 * Copy options from one window to another. | |
5395 * Used when splitting a window. | |
5396 */ | |
5397 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5398 win_copy_options(win_T *wp_from, win_T *wp_to) |
7 | 5399 { |
5400 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); | |
5401 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
|
5402 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
|
5403 } |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5404 |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5405 /* |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5406 * 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
|
5407 */ |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5408 void |
18199
e2be5a6485f5
patch 8.1.2094: the fileio.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18156
diff
changeset
|
5409 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
|
5410 { |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5411 #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
|
5412 briopt_check(wp); |
6162 | 5413 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
5414 #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
|
5415 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
|
5416 check_colorcolumn(wp); |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
5417 #endif |
7 | 5418 } |
5419 | |
5420 /* | |
5421 * Copy the options from one winopt_T to another. | |
5422 * Doesn't free the old option values in "to", use clear_winopt() for that. | |
5423 * The 'scroll' option is not copied, because it depends on the window height. | |
5424 * The 'previewwindow' option is reset, there can be only one preview window. | |
5425 */ | |
5426 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5427 copy_winopt(winopt_T *from, winopt_T *to) |
7 | 5428 { |
5429 #ifdef FEAT_ARABIC | |
5430 to->wo_arab = from->wo_arab; | |
5431 #endif | |
5432 to->wo_list = from->wo_list; | |
5433 to->wo_nu = from->wo_nu; | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
5434 to->wo_rnu = from->wo_rnu; |
13 | 5435 #ifdef FEAT_LINEBREAK |
5436 to->wo_nuw = from->wo_nuw; | |
5437 #endif | |
7 | 5438 #ifdef FEAT_RIGHTLEFT |
5439 to->wo_rl = from->wo_rl; | |
5440 to->wo_rlc = vim_strsave(from->wo_rlc); | |
5441 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5442 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5443 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
|
5444 #endif |
40 | 5445 #ifdef FEAT_STL_OPT |
5446 to->wo_stl = vim_strsave(from->wo_stl); | |
5447 #endif | |
7 | 5448 to->wo_wrap = from->wo_wrap; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5449 #ifdef FEAT_DIFF |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5450 to->wo_wrap_save = from->wo_wrap_save; |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5451 #endif |
7 | 5452 #ifdef FEAT_LINEBREAK |
5453 to->wo_lbr = from->wo_lbr; | |
5995 | 5454 to->wo_bri = from->wo_bri; |
5455 to->wo_briopt = vim_strsave(from->wo_briopt); | |
7 | 5456 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5457 to->wo_wcr = vim_strsave(from->wo_wcr); |
7 | 5458 to->wo_scb = from->wo_scb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5459 to->wo_scb_save = from->wo_scb_save; |
2651 | 5460 to->wo_crb = from->wo_crb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5461 to->wo_crb_save = from->wo_crb_save; |
744 | 5462 #ifdef FEAT_SPELL |
5463 to->wo_spell = from->wo_spell; | |
5464 #endif | |
221 | 5465 #ifdef FEAT_SYN_HL |
744 | 5466 to->wo_cuc = from->wo_cuc; |
5467 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
|
5468 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
|
5469 to->wo_cc = vim_strsave(from->wo_cc); |
221 | 5470 #endif |
7 | 5471 #ifdef FEAT_DIFF |
5472 to->wo_diff = from->wo_diff; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5473 to->wo_diff_saved = from->wo_diff_saved; |
7 | 5474 #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
|
5475 #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
|
5476 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
|
5477 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
|
5478 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5479 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5480 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
|
5481 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
|
5482 #endif |
7 | 5483 #ifdef FEAT_FOLDING |
5484 to->wo_fdc = from->wo_fdc; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5485 to->wo_fdc_save = from->wo_fdc_save; |
7 | 5486 to->wo_fen = from->wo_fen; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5487 to->wo_fen_save = from->wo_fen_save; |
7 | 5488 to->wo_fdi = vim_strsave(from->wo_fdi); |
5489 to->wo_fml = from->wo_fml; | |
5490 to->wo_fdl = from->wo_fdl; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5491 to->wo_fdl_save = from->wo_fdl_save; |
7 | 5492 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
|
5493 to->wo_fdm_save = from->wo_diff_saved |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5494 ? vim_strsave(from->wo_fdm_save) : empty_option; |
7 | 5495 to->wo_fdn = from->wo_fdn; |
5496 # ifdef FEAT_EVAL | |
5497 to->wo_fde = vim_strsave(from->wo_fde); | |
5498 to->wo_fdt = vim_strsave(from->wo_fdt); | |
5499 # endif | |
5500 to->wo_fmr = vim_strsave(from->wo_fmr); | |
5501 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5502 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5503 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
|
5504 #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
|
5505 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5506 #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
|
5507 // 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
|
5508 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
|
5509 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
|
5510 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5511 check_winopt(to); // don't want NULL pointers |
7 | 5512 } |
5513 | |
5514 /* | |
5515 * Check string options in a window for a NULL value. | |
5516 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
5517 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5518 check_win_options(win_T *win) |
7 | 5519 { |
5520 check_winopt(&win->w_onebuf_opt); | |
5521 check_winopt(&win->w_allbuf_opt); | |
5522 } | |
5523 | |
5524 /* | |
5525 * Check for NULL pointers in a winopt_T and replace them with empty_option. | |
5526 */ | |
5997 | 5527 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5528 check_winopt(winopt_T *wop UNUSED) |
7 | 5529 { |
5530 #ifdef FEAT_FOLDING | |
5531 check_string_option(&wop->wo_fdi); | |
5532 check_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5533 check_string_option(&wop->wo_fdm_save); |
7 | 5534 # ifdef FEAT_EVAL |
5535 check_string_option(&wop->wo_fde); | |
5536 check_string_option(&wop->wo_fdt); | |
5537 # endif | |
5538 check_string_option(&wop->wo_fmr); | |
5539 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5540 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5541 check_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5542 #endif |
7 | 5543 #ifdef FEAT_RIGHTLEFT |
5544 check_string_option(&wop->wo_rlc); | |
5545 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5546 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5547 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
|
5548 #endif |
40 | 5549 #ifdef FEAT_STL_OPT |
5550 check_string_option(&wop->wo_stl); | |
5551 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5552 #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
|
5553 check_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5554 check_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5555 #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
|
5556 #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
|
5557 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
|
5558 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5559 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5560 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
|
5561 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
|
5562 #endif |
5995 | 5563 #ifdef FEAT_LINEBREAK |
5564 check_string_option(&wop->wo_briopt); | |
5565 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5566 check_string_option(&wop->wo_wcr); |
7 | 5567 } |
5568 | |
5569 /* | |
5570 * Free the allocated memory inside a winopt_T. | |
5571 */ | |
5572 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5573 clear_winopt(winopt_T *wop UNUSED) |
7 | 5574 { |
5575 #ifdef FEAT_FOLDING | |
5576 clear_string_option(&wop->wo_fdi); | |
5577 clear_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5578 clear_string_option(&wop->wo_fdm_save); |
7 | 5579 # ifdef FEAT_EVAL |
5580 clear_string_option(&wop->wo_fde); | |
5581 clear_string_option(&wop->wo_fdt); | |
5582 # endif | |
5583 clear_string_option(&wop->wo_fmr); | |
5584 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5585 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5586 clear_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5587 #endif |
5995 | 5588 #ifdef FEAT_LINEBREAK |
5589 clear_string_option(&wop->wo_briopt); | |
5590 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5591 clear_string_option(&wop->wo_wcr); |
7 | 5592 #ifdef FEAT_RIGHTLEFT |
5593 clear_string_option(&wop->wo_rlc); | |
5594 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5595 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5596 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
|
5597 #endif |
40 | 5598 #ifdef FEAT_STL_OPT |
5599 clear_string_option(&wop->wo_stl); | |
5600 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5601 #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
|
5602 clear_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5603 clear_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5604 #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
|
5605 #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
|
5606 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
|
5607 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5608 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5609 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
|
5610 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
|
5611 #endif |
7 | 5612 } |
5613 | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5614 #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
|
5615 // 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
|
5616 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
|
5617 # 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
|
5618 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5619 /* |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5620 * 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
|
5621 */ |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5622 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
|
5623 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
|
5624 { |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5625 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
|
5626 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
|
5627 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5628 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
|
5629 return; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5630 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
|
5631 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
|
5632 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
|
5633 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
|
5634 } |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5635 #else |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5636 # 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
|
5637 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5638 |
7 | 5639 /* |
5640 * Copy global option values to local options for one buffer. | |
5641 * Used when creating a new buffer and sometimes when entering a buffer. | |
5642 * 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
|
5643 * BCO_ENTER We will enter the buffer "buf". |
7 | 5644 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when |
5645 * appropriate. | |
5646 * BCO_NOHELP Don't copy the values to a help buffer. | |
5647 */ | |
5648 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5649 buf_copy_options(buf_T *buf, int flags) |
7 | 5650 { |
5651 int should_copy = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5652 char_u *save_p_isk = NULL; // init for GCC |
7 | 5653 int dont_do_help; |
5654 int did_isk = FALSE; | |
5655 | |
5656 /* | |
5657 * Skip this when the option defaults have not been set yet. Happens when | |
5658 * main() allocates the first buffer. | |
5659 */ | |
5660 if (p_cpo != NULL) | |
5661 { | |
5662 /* | |
5663 * Always copy when entering and 'cpo' contains 'S'. | |
5664 * Don't copy when already initialized. | |
5665 * Don't copy when 'cpo' contains 's' and not entering. | |
5666 * 'S' BCO_ENTER initialized 's' should_copy | |
5667 * yes yes X X TRUE | |
5668 * yes no yes X FALSE | |
5669 * no X yes X FALSE | |
5670 * X no no yes FALSE | |
5671 * X no no no TRUE | |
5672 * no yes no X TRUE | |
5673 */ | |
5674 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) | |
5675 && (buf->b_p_initialized | |
5676 || (!(flags & BCO_ENTER) | |
5677 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
5678 should_copy = FALSE; | |
5679 | |
5680 if (should_copy || (flags & BCO_ALWAYS)) | |
5681 { | |
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
|
5682 #ifdef FEAT_EVAL |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5683 vim_memset(buf->b_p_script_ctx, 0, sizeof(buf->b_p_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
|
5684 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
|
5685 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5686 // 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
|
5687 // 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
|
5688 // (jumping back to a help file with CTRL-T or CTRL-O) |
7 | 5689 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) |
5690 || 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
|
5691 if (dont_do_help) // don't free b_p_isk |
7 | 5692 { |
5693 save_p_isk = buf->b_p_isk; | |
5694 buf->b_p_isk = NULL; | |
5695 } | |
5696 /* | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14381
diff
changeset
|
5697 * 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
|
5698 * reset 'readonly' and copy 'fileformat'. |
7 | 5699 */ |
5700 if (!buf->b_p_initialized) | |
5701 { | |
5702 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
|
5703 buf->b_p_ro = FALSE; // don't copy readonly |
7 | 5704 buf->b_p_tx = p_tx; |
5705 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
|
5706 switch (*p_ffs) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5707 { |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5708 case 'm': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5709 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
|
5710 case 'd': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5711 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
|
5712 case 'u': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5713 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
|
5714 default: |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5715 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
|
5716 } |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5717 if (buf->b_p_ff != NULL) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5718 buf->b_start_ffc = *buf->b_p_ff; |
7 | 5719 buf->b_p_bh = empty_option; |
5720 buf->b_p_bt = empty_option; | |
5721 } | |
5722 else | |
5723 free_buf_options(buf, FALSE); | |
5724 | |
5725 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
|
5726 COPY_OPT_SCTX(buf, BV_AI); |
7 | 5727 buf->b_p_ai_nopaste = p_ai_nopaste; |
5728 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
|
5729 COPY_OPT_SCTX(buf, BV_SW); |
7 | 5730 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
|
5731 COPY_OPT_SCTX(buf, BV_TW); |
7 | 5732 buf->b_p_tw_nopaste = p_tw_nopaste; |
5733 buf->b_p_tw_nobin = p_tw_nobin; | |
5734 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
|
5735 COPY_OPT_SCTX(buf, BV_WM); |
7 | 5736 buf->b_p_wm_nopaste = p_wm_nopaste; |
5737 buf->b_p_wm_nobin = p_wm_nobin; | |
5738 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
|
5739 COPY_OPT_SCTX(buf, BV_BIN); |
402 | 5740 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
|
5741 COPY_OPT_SCTX(buf, BV_BOMB); |
6954 | 5742 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
|
5743 COPY_OPT_SCTX(buf, BV_FIXEOL); |
7 | 5744 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
|
5745 COPY_OPT_SCTX(buf, BV_ET); |
7 | 5746 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
|
5747 buf->b_p_et_nopaste = p_et_nopaste; |
7 | 5748 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
|
5749 COPY_OPT_SCTX(buf, BV_ML); |
7 | 5750 buf->b_p_ml_nobin = p_ml_nobin; |
5751 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
|
5752 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
|
5753 if (cmdmod.noswapfile) |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5754 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
|
5755 else |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5756 { |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5757 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
|
5758 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
|
5759 } |
7 | 5760 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
|
5761 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
|
5762 #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
|
5763 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
|
5764 COPY_OPT_SCTX(buf, BV_CSL); |
7 | 5765 #endif |
12 | 5766 #ifdef FEAT_COMPL_FUNC |
5767 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
|
5768 COPY_OPT_SCTX(buf, BV_CFU); |
502 | 5769 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
|
5770 COPY_OPT_SCTX(buf, BV_OFU); |
12 | 5771 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5772 #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
|
5773 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
|
5774 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
|
5775 #endif |
7 | 5776 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
|
5777 COPY_OPT_SCTX(buf, BV_STS); |
7 | 5778 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
|
5779 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5780 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
|
5781 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
|
5782 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
|
5783 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
|
5784 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5785 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
|
5786 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
|
5787 ? 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
|
5788 #endif |
7 | 5789 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
|
5790 COPY_OPT_SCTX(buf, BV_SN); |
7 | 5791 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
|
5792 COPY_OPT_SCTX(buf, BV_COM); |
7 | 5793 #ifdef FEAT_FOLDING |
5794 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
|
5795 COPY_OPT_SCTX(buf, BV_CMS); |
7 | 5796 #endif |
5797 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
|
5798 COPY_OPT_SCTX(buf, BV_FO); |
41 | 5799 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
|
5800 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
|
5801 // 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
|
5802 // when it is set to 8 bytes in defaults.vim. |
7 | 5803 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
|
5804 COPY_OPT_SCTX(buf, BV_NF); |
7 | 5805 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
|
5806 COPY_OPT_SCTX(buf, BV_MPS); |
7 | 5807 #ifdef FEAT_SMARTINDENT |
5808 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
|
5809 COPY_OPT_SCTX(buf, BV_SI); |
7 | 5810 #endif |
5811 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
|
5812 COPY_OPT_SCTX(buf, BV_CI); |
7 | 5813 #ifdef FEAT_CINDENT |
5814 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
|
5815 COPY_OPT_SCTX(buf, BV_CIN); |
7 | 5816 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
|
5817 COPY_OPT_SCTX(buf, BV_CINK); |
7 | 5818 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
|
5819 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
|
5820 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5821 // Don't copy 'filetype', it must be detected |
7 | 5822 buf->b_p_ft = empty_option; |
5823 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
|
5824 COPY_OPT_SCTX(buf, BV_PI); |
7 | 5825 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) |
5826 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
|
5827 COPY_OPT_SCTX(buf, BV_CINW); |
7 | 5828 #endif |
5829 #ifdef FEAT_LISP | |
5830 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
|
5831 COPY_OPT_SCTX(buf, BV_LISP); |
7 | 5832 #endif |
5833 #ifdef FEAT_SYN_HL | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5834 // Don't copy 'syntax', it must be set |
7 | 5835 buf->b_p_syn = empty_option; |
410 | 5836 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
|
5837 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
|
5838 buf->b_s.b_syn_isk = empty_option; |
744 | 5839 #endif |
5840 #ifdef FEAT_SPELL | |
2599 | 5841 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
|
5842 COPY_OPT_SCTX(buf, BV_SPC); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5843 (void)compile_cap_prog(&buf->b_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5844 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
|
5845 COPY_OPT_SCTX(buf, BV_SPF); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5846 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
|
5847 COPY_OPT_SCTX(buf, BV_SPL); |
7 | 5848 #endif |
5849 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
5850 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
|
5851 COPY_OPT_SCTX(buf, BV_INDE); |
7 | 5852 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
|
5853 COPY_OPT_SCTX(buf, BV_INDK); |
7 | 5854 #endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5855 buf->b_p_fp = empty_option; |
667 | 5856 #if defined(FEAT_EVAL) |
5857 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
|
5858 COPY_OPT_SCTX(buf, BV_FEX); |
667 | 5859 #endif |
7 | 5860 #ifdef FEAT_CRYPT |
5861 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
|
5862 COPY_OPT_SCTX(buf, BV_KEY); |
7 | 5863 #endif |
5864 #ifdef FEAT_SEARCHPATH | |
5865 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
|
5866 COPY_OPT_SCTX(buf, BV_SUA); |
7 | 5867 #endif |
5868 #ifdef FEAT_KEYMAP | |
5869 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
|
5870 COPY_OPT_SCTX(buf, BV_KMAP); |
7 | 5871 buf->b_kmap_state |= KEYMAP_INIT; |
5872 #endif | |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5873 #ifdef FEAT_TERMINAL |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5874 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
|
5875 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
|
5876 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5877 // 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
|
5878 // state from the current buffer is better than resetting it. |
7 | 5879 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
|
5880 COPY_OPT_SCTX(buf, BV_IMI); |
7 | 5881 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
|
5882 COPY_OPT_SCTX(buf, BV_IMS); |
7 | 5883 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5884 // 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
|
5885 // are not copied, start using the global value |
7 | 5886 buf->b_p_ar = -1; |
5446 | 5887 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
6243 | 5888 buf->b_p_bkc = empty_option; |
5889 buf->b_bkc_flags = 0; | |
7 | 5890 #ifdef FEAT_QUICKFIX |
5891 buf->b_p_gp = empty_option; | |
5892 buf->b_p_mp = empty_option; | |
5893 buf->b_p_efm = empty_option; | |
5894 #endif | |
5895 buf->b_p_ep = empty_option; | |
5896 buf->b_p_kp = empty_option; | |
5897 buf->b_p_path = empty_option; | |
5898 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
|
5899 buf->b_p_tc = empty_option; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5900 buf->b_tc_flags = 0; |
7 | 5901 #ifdef FEAT_FIND_ID |
5902 buf->b_p_def = empty_option; | |
5903 buf->b_p_inc = empty_option; | |
5904 # ifdef FEAT_EVAL | |
5905 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
|
5906 COPY_OPT_SCTX(buf, BV_INEX); |
7 | 5907 # endif |
5908 #endif | |
5909 buf->b_p_dict = empty_option; | |
5910 buf->b_p_tsr = empty_option; | |
12 | 5911 #ifdef FEAT_TEXTOBJ |
5912 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
|
5913 COPY_OPT_SCTX(buf, BV_QE); |
12 | 5914 #endif |
790 | 5915 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5916 buf->b_p_bexpr = empty_option; | |
5917 #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
|
5918 #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
|
5919 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
|
5920 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
5921 #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
|
5922 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
|
5923 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
|
5924 #endif |
5712 | 5925 #ifdef FEAT_LISP |
5926 buf->b_p_lw = empty_option; | |
5927 #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
|
5928 buf->b_p_menc = empty_option; |
7 | 5929 |
5930 /* | |
5931 * Don't copy the options set by ex_help(), use the saved values, | |
5932 * when going from a help buffer to a non-help buffer. | |
5933 * Don't touch these at all when BCO_NOHELP is used and going from | |
5934 * or to a help buffer. | |
5935 */ | |
5936 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
|
5937 { |
7 | 5938 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
|
5939 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5940 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
|
5941 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
|
5942 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5943 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
|
5944 #endif |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5945 } |
7 | 5946 else |
5947 { | |
5948 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
|
5949 COPY_OPT_SCTX(buf, BV_ISK); |
7 | 5950 did_isk = TRUE; |
5951 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
|
5952 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5953 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
|
5954 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
|
5955 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
|
5956 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
|
5957 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5958 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
|
5959 #endif |
7 | 5960 buf->b_help = FALSE; |
5961 if (buf->b_p_bt[0] == 'h') | |
5962 clear_string_option(&buf->b_p_bt); | |
5963 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
|
5964 COPY_OPT_SCTX(buf, BV_MA); |
7 | 5965 } |
5966 } | |
5967 | |
5968 /* | |
5969 * When the options should be copied (ignoring BCO_ALWAYS), set the | |
5970 * flag that indicates that the options have been initialized. | |
5971 */ | |
5972 if (should_copy) | |
5973 buf->b_p_initialized = TRUE; | |
5974 } | |
5975 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5976 check_buf_options(buf); // make sure we don't have NULLs |
7 | 5977 if (did_isk) |
5978 (void)buf_init_chartab(buf, FALSE); | |
5979 } | |
5980 | |
5981 /* | |
5982 * Reset the 'modifiable' option and its default value. | |
5983 */ | |
5984 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5985 reset_modifiable(void) |
7 | 5986 { |
5987 int opt_idx; | |
5988 | |
5989 curbuf->b_p_ma = FALSE; | |
5990 p_ma = FALSE; | |
5991 opt_idx = findoption((char_u *)"ma"); | |
838 | 5992 if (opt_idx >= 0) |
5993 options[opt_idx].def_val[VI_DEFAULT] = FALSE; | |
7 | 5994 } |
5995 | |
5996 /* | |
5997 * Set the global value for 'iminsert' to the local value. | |
5998 */ | |
5999 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6000 set_iminsert_global(void) |
7 | 6001 { |
6002 p_iminsert = curbuf->b_p_iminsert; | |
6003 } | |
6004 | |
6005 /* | |
6006 * Set the global value for 'imsearch' to the local value. | |
6007 */ | |
6008 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6009 set_imsearch_global(void) |
7 | 6010 { |
6011 p_imsearch = curbuf->b_p_imsearch; | |
6012 } | |
6013 | |
6014 static int expand_option_idx = -1; | |
6015 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; | |
6016 static int expand_option_flags = 0; | |
6017 | |
6018 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6019 set_context_in_set_cmd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6020 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6021 char_u *arg, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6022 int opt_flags) // OPT_GLOBAL and/or OPT_LOCAL |
7 | 6023 { |
6024 int nextchar; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6025 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
|
6026 int opt_idx = 0; // init for GCC |
7 | 6027 char_u *p; |
6028 char_u *s; | |
6029 int is_term_option = FALSE; | |
6030 int key; | |
6031 | |
6032 expand_option_flags = opt_flags; | |
6033 | |
6034 xp->xp_context = EXPAND_SETTINGS; | |
6035 if (*arg == NUL) | |
6036 { | |
6037 xp->xp_pattern = arg; | |
6038 return; | |
6039 } | |
6040 p = arg + STRLEN(arg) - 1; | |
6041 if (*p == ' ' && *(p - 1) != '\\') | |
6042 { | |
6043 xp->xp_pattern = p + 1; | |
6044 return; | |
6045 } | |
6046 while (p > arg) | |
6047 { | |
6048 s = p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6049 // count number of backslashes before ' ' or ',' |
7 | 6050 if (*p == ' ' || *p == ',') |
6051 { | |
6052 while (s > arg && *(s - 1) == '\\') | |
6053 --s; | |
6054 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6055 // break at a space with an even number of backslashes |
7 | 6056 if (*p == ' ' && ((p - s) & 1) == 0) |
6057 { | |
6058 ++p; | |
6059 break; | |
6060 } | |
6061 --p; | |
6062 } | |
1911 | 6063 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0) |
7 | 6064 { |
6065 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
6066 p += 2; | |
6067 } | |
6068 if (STRNCMP(p, "inv", 3) == 0) | |
6069 { | |
6070 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
6071 p += 3; | |
6072 } | |
6073 xp->xp_pattern = arg = p; | |
6074 if (*arg == '<') | |
6075 { | |
6076 while (*p != '>') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6077 if (*p++ == NUL) // expand terminal option name |
7 | 6078 return; |
6079 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
|
6080 if (key == 0) // unknown name |
7 | 6081 { |
6082 xp->xp_context = EXPAND_NOTHING; | |
6083 return; | |
6084 } | |
6085 nextchar = *++p; | |
6086 is_term_option = TRUE; | |
6087 expand_option_name[2] = KEY2TERMCAP0(key); | |
6088 expand_option_name[3] = KEY2TERMCAP1(key); | |
6089 } | |
6090 else | |
6091 { | |
6092 if (p[0] == 't' && p[1] == '_') | |
6093 { | |
6094 p += 2; | |
6095 if (*p != NUL) | |
6096 ++p; | |
6097 if (*p == NUL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6098 return; // expand option name |
7 | 6099 nextchar = *++p; |
6100 is_term_option = TRUE; | |
6101 expand_option_name[2] = p[-2]; | |
6102 expand_option_name[3] = p[-1]; | |
6103 } | |
6104 else | |
6105 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6106 // Allow * wildcard |
7 | 6107 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') |
6108 p++; | |
6109 if (*p == NUL) | |
6110 return; | |
6111 nextchar = *p; | |
6112 *p = NUL; | |
6113 opt_idx = findoption(arg); | |
6114 *p = nextchar; | |
6115 if (opt_idx == -1 || options[opt_idx].var == NULL) | |
6116 { | |
6117 xp->xp_context = EXPAND_NOTHING; | |
6118 return; | |
6119 } | |
6120 flags = options[opt_idx].flags; | |
6121 if (flags & P_BOOL) | |
6122 { | |
6123 xp->xp_context = EXPAND_NOTHING; | |
6124 return; | |
6125 } | |
6126 } | |
6127 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6128 // handle "-=" and "+=" |
7 | 6129 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') |
6130 { | |
6131 ++p; | |
6132 nextchar = '='; | |
6133 } | |
6134 if ((nextchar != '=' && nextchar != ':') | |
6135 || xp->xp_context == EXPAND_BOOL_SETTINGS) | |
6136 { | |
6137 xp->xp_context = EXPAND_UNSUCCESSFUL; | |
6138 return; | |
6139 } | |
6140 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) | |
6141 { | |
6142 xp->xp_context = EXPAND_OLD_SETTING; | |
6143 if (is_term_option) | |
6144 expand_option_idx = -1; | |
6145 else | |
6146 expand_option_idx = opt_idx; | |
6147 xp->xp_pattern = p + 1; | |
6148 return; | |
6149 } | |
6150 xp->xp_context = EXPAND_NOTHING; | |
6151 if (is_term_option || (flags & P_NUM)) | |
6152 return; | |
6153 | |
6154 xp->xp_pattern = p + 1; | |
6155 | |
6156 if (flags & P_EXPAND) | |
6157 { | |
6158 p = options[opt_idx].var; | |
6159 if (p == (char_u *)&p_bdir | |
6160 || p == (char_u *)&p_dir | |
6161 || p == (char_u *)&p_path | |
8182
95d59081580f
commit https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
6162 || p == (char_u *)&p_pp |
7 | 6163 || p == (char_u *)&p_rtp |
6164 #ifdef FEAT_SEARCHPATH | |
6165 || p == (char_u *)&p_cdpath | |
6166 #endif | |
6167 #ifdef FEAT_SESSION | |
6168 || p == (char_u *)&p_vdir | |
6169 #endif | |
6170 ) | |
6171 { | |
6172 xp->xp_context = EXPAND_DIRECTORIES; | |
6173 if (p == (char_u *)&p_path | |
6174 #ifdef FEAT_SEARCHPATH | |
6175 || p == (char_u *)&p_cdpath | |
6176 #endif | |
6177 ) | |
6178 xp->xp_backslash = XP_BS_THREE; | |
6179 else | |
6180 xp->xp_backslash = XP_BS_ONE; | |
6181 } | |
6182 else | |
6183 { | |
6184 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
|
6185 // for 'tags' need three backslashes for a space |
7 | 6186 if (p == (char_u *)&p_tags) |
6187 xp->xp_backslash = XP_BS_THREE; | |
6188 else | |
6189 xp->xp_backslash = XP_BS_ONE; | |
6190 } | |
6191 } | |
6192 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6193 // 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
|
6194 // last file name. |
7 | 6195 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) |
6196 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6197 // count number of backslashes before ' ' or ',' |
7 | 6198 if (*p == ' ' || *p == ',') |
6199 { | |
6200 s = p; | |
6201 while (s > xp->xp_pattern && *(s - 1) == '\\') | |
6202 --s; | |
6203 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) | |
6204 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) | |
6205 { | |
6206 xp->xp_pattern = p + 1; | |
6207 break; | |
6208 } | |
6209 } | |
374 | 6210 |
744 | 6211 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6212 // for 'spellsuggest' start at "file:" |
374 | 6213 if (options[opt_idx].var == (char_u *)&p_sps |
6214 && STRNCMP(p, "file:", 5) == 0) | |
6215 { | |
6216 xp->xp_pattern = p + 5; | |
6217 break; | |
6218 } | |
6219 #endif | |
7 | 6220 } |
6221 | |
6222 return; | |
6223 } | |
6224 | |
6225 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6226 ExpandSettings( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6227 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6228 regmatch_T *regmatch, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6229 int *num_file, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6230 char_u ***file) |
7 | 6231 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6232 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
|
6233 int num_term = 0; // Nr of matching terminal code settings |
7 | 6234 int opt_idx; |
6235 int match; | |
6236 int count = 0; | |
6237 char_u *str; | |
6238 int loop; | |
6239 int is_term_opt; | |
6240 char_u name_buf[MAX_KEY_NAME_LEN]; | |
6241 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
|
6242 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
|
6243 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6244 // do this loop twice: |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6245 // 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
|
6246 // loop == 1: copy the matching options into allocated memory |
7 | 6247 for (loop = 0; loop <= 1; ++loop) |
6248 { | |
6249 regmatch->rm_ic = ic; | |
6250 if (xp->xp_context != EXPAND_BOOL_SETTINGS) | |
6251 { | |
1883 | 6252 for (match = 0; match < (int)(sizeof(names) / sizeof(char *)); |
6253 ++match) | |
7 | 6254 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0)) |
6255 { | |
6256 if (loop == 0) | |
6257 num_normal++; | |
6258 else | |
6259 (*file)[count++] = vim_strsave((char_u *)names[match]); | |
6260 } | |
6261 } | |
6262 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; | |
6263 opt_idx++) | |
6264 { | |
6265 if (options[opt_idx].var == NULL) | |
6266 continue; | |
6267 if (xp->xp_context == EXPAND_BOOL_SETTINGS | |
6268 && !(options[opt_idx].flags & P_BOOL)) | |
6269 continue; | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6270 is_term_opt = istermoption_idx(opt_idx); |
7 | 6271 if (is_term_opt && num_normal > 0) |
6272 continue; | |
6273 match = FALSE; | |
6274 if (vim_regexec(regmatch, str, (colnr_T)0) | |
6275 || (options[opt_idx].shortname != NULL | |
6276 && vim_regexec(regmatch, | |
6277 (char_u *)options[opt_idx].shortname, (colnr_T)0))) | |
6278 match = TRUE; | |
6279 else if (is_term_opt) | |
6280 { | |
6281 name_buf[0] = '<'; | |
6282 name_buf[1] = 't'; | |
6283 name_buf[2] = '_'; | |
6284 name_buf[3] = str[2]; | |
6285 name_buf[4] = str[3]; | |
6286 name_buf[5] = '>'; | |
6287 name_buf[6] = NUL; | |
6288 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6289 { | |
6290 match = TRUE; | |
6291 str = name_buf; | |
6292 } | |
6293 } | |
6294 if (match) | |
6295 { | |
6296 if (loop == 0) | |
6297 { | |
6298 if (is_term_opt) | |
6299 num_term++; | |
6300 else | |
6301 num_normal++; | |
6302 } | |
6303 else | |
6304 (*file)[count++] = vim_strsave(str); | |
6305 } | |
6306 } | |
6307 /* | |
6308 * Check terminal key codes, these are not in the option table | |
6309 */ | |
6310 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) | |
6311 { | |
6312 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) | |
6313 { | |
6314 if (!isprint(str[0]) || !isprint(str[1])) | |
6315 continue; | |
6316 | |
6317 name_buf[0] = 't'; | |
6318 name_buf[1] = '_'; | |
6319 name_buf[2] = str[0]; | |
6320 name_buf[3] = str[1]; | |
6321 name_buf[4] = NUL; | |
6322 | |
6323 match = FALSE; | |
6324 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6325 match = TRUE; | |
6326 else | |
6327 { | |
6328 name_buf[0] = '<'; | |
6329 name_buf[1] = 't'; | |
6330 name_buf[2] = '_'; | |
6331 name_buf[3] = str[0]; | |
6332 name_buf[4] = str[1]; | |
6333 name_buf[5] = '>'; | |
6334 name_buf[6] = NUL; | |
6335 | |
6336 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6337 match = TRUE; | |
6338 } | |
6339 if (match) | |
6340 { | |
6341 if (loop == 0) | |
6342 num_term++; | |
6343 else | |
6344 (*file)[count++] = vim_strsave(name_buf); | |
6345 } | |
6346 } | |
6347 | |
6348 /* | |
6349 * Check special key names. | |
6350 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6351 regmatch->rm_ic = TRUE; // ignore case here |
7 | 6352 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) |
6353 { | |
6354 name_buf[0] = '<'; | |
6355 STRCPY(name_buf + 1, str); | |
6356 STRCAT(name_buf, ">"); | |
6357 | |
6358 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6359 { | |
6360 if (loop == 0) | |
6361 num_term++; | |
6362 else | |
6363 (*file)[count++] = vim_strsave(name_buf); | |
6364 } | |
6365 } | |
6366 } | |
6367 if (loop == 0) | |
6368 { | |
6369 if (num_normal > 0) | |
6370 *num_file = num_normal; | |
6371 else if (num_term > 0) | |
6372 *num_file = num_term; | |
6373 else | |
6374 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
|
6375 *file = ALLOC_MULT(char_u *, *num_file); |
7 | 6376 if (*file == NULL) |
6377 { | |
6378 *file = (char_u **)""; | |
6379 return FAIL; | |
6380 } | |
6381 } | |
6382 } | |
6383 return OK; | |
6384 } | |
6385 | |
6386 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6387 ExpandOldSetting(int *num_file, char_u ***file) |
7 | 6388 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6389 char_u *var = NULL; // init for GCC |
7 | 6390 char_u *buf; |
6391 | |
6392 *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
|
6393 *file = ALLOC_ONE(char_u *); |
7 | 6394 if (*file == NULL) |
6395 return FAIL; | |
6396 | |
6397 /* | |
6398 * For a terminal key code expand_option_idx is < 0. | |
6399 */ | |
6400 if (expand_option_idx < 0) | |
6401 { | |
6402 var = find_termcode(expand_option_name + 2); | |
6403 if (var == NULL) | |
6404 expand_option_idx = findoption(expand_option_name); | |
6405 } | |
6406 | |
6407 if (expand_option_idx >= 0) | |
6408 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6409 // put string of option value in NameBuff |
7 | 6410 option_value2string(&options[expand_option_idx], expand_option_flags); |
6411 var = NameBuff; | |
6412 } | |
6413 else if (var == NULL) | |
6414 var = (char_u *)""; | |
6415 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6416 // 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
|
6417 // what happens in do_set(). |
7 | 6418 buf = vim_strsave_escaped(var, escape_chars); |
6419 | |
6420 if (buf == NULL) | |
6421 { | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13242
diff
changeset
|
6422 VIM_CLEAR(*file); |
7 | 6423 return FAIL; |
6424 } | |
6425 | |
6426 #ifdef BACKSLASH_IN_FILENAME | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6427 // 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
|
6428 // 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
|
6429 for (var = buf; *var != NUL; MB_PTR_ADV(var)) |
7 | 6430 if (var[0] == '\\' && var[1] == '\\' |
6431 && expand_option_idx >= 0 | |
6432 && (options[expand_option_idx].flags & P_EXPAND) | |
6433 && vim_isfilec(var[2]) | |
6434 && (var[2] != '\\' || (var == buf && var[4] != '\\'))) | |
1622 | 6435 STRMOVE(var, var + 1); |
7 | 6436 #endif |
6437 | |
6438 *file[0] = buf; | |
6439 *num_file = 1; | |
6440 return OK; | |
6441 } | |
6442 | |
6443 /* | |
6444 * Get the value for the numeric or string option *opp in a nice format into | |
6445 * NameBuff[]. Must not be called with a hidden option! | |
6446 */ | |
6447 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6448 option_value2string( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6449 struct vimoption *opp, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6450 int opt_flags) // OPT_GLOBAL and/or OPT_LOCAL |
7 | 6451 { |
6452 char_u *varp; | |
6453 | |
6454 varp = get_varp_scope(opp, opt_flags); | |
6455 | |
6456 if (opp->flags & P_NUM) | |
6457 { | |
6458 long wc = 0; | |
6459 | |
6460 if (wc_use_keyname(varp, &wc)) | |
6461 STRCPY(NameBuff, get_special_key_name((int)wc, 0)); | |
6462 else if (wc != 0) | |
6463 STRCPY(NameBuff, transchar((int)wc)); | |
6464 else | |
6465 sprintf((char *)NameBuff, "%ld", *(long *)varp); | |
6466 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6467 else // P_STRING |
7 | 6468 { |
6469 varp = *(char_u **)(varp); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6470 if (varp == NULL) // just in case |
7 | 6471 NameBuff[0] = NUL; |
6472 #ifdef FEAT_CRYPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6473 // don't show the actual value of 'key', only that it's set |
840 | 6474 else if (opp->var == (char_u *)&p_key && *varp) |
7 | 6475 STRCPY(NameBuff, "*****"); |
6476 #endif | |
6477 else if (opp->flags & P_EXPAND) | |
6478 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
|
6479 // Translate 'pastetoggle' into special key names |
7 | 6480 else if ((char_u **)opp->var == &p_pt) |
6481 str2specialbuf(p_pt, NameBuff, MAXPATHL); | |
6482 else | |
419 | 6483 vim_strncpy(NameBuff, varp, MAXPATHL - 1); |
7 | 6484 } |
6485 } | |
6486 | |
6487 /* | |
6488 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be | |
6489 * printed as a keyname. | |
6490 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. | |
6491 */ | |
6492 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6493 wc_use_keyname(char_u *varp, long *wcp) |
7 | 6494 { |
6495 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) | |
6496 { | |
6497 *wcp = *(long *)varp; | |
6498 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0) | |
6499 return TRUE; | |
6500 } | |
6501 return FALSE; | |
6502 } | |
6503 | |
6504 /* | |
6505 * Return TRUE if format option 'x' is in effect. | |
6506 * Take care of no formatting when 'paste' is set. | |
6507 */ | |
6508 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6509 has_format_option(int x) |
7 | 6510 { |
6511 if (p_paste) | |
6512 return FALSE; | |
6513 return (vim_strchr(curbuf->b_p_fo, x) != NULL); | |
6514 } | |
6515 | |
6516 /* | |
6517 * Return TRUE if "x" is present in 'shortmess' option, or | |
6518 * 'shortmess' contains 'a' and "x" is present in SHM_A. | |
6519 */ | |
6520 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6521 shortmess(int x) |
7 | 6522 { |
3384 | 6523 return p_shm != NULL && |
6524 ( vim_strchr(p_shm, x) != NULL | |
7 | 6525 || (vim_strchr(p_shm, 'a') != NULL |
6526 && vim_strchr((char_u *)SHM_A, x) != NULL)); | |
6527 } | |
6528 | |
6529 /* | |
6530 * paste_option_changed() - Called after p_paste was set or reset. | |
6531 */ | |
6532 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6533 paste_option_changed(void) |
7 | 6534 { |
6535 static int old_p_paste = FALSE; | |
6536 static int save_sm = 0; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6537 static int save_sta = 0; |
7 | 6538 #ifdef FEAT_CMDL_INFO |
6539 static int save_ru = 0; | |
6540 #endif | |
6541 #ifdef FEAT_RIGHTLEFT | |
6542 static int save_ri = 0; | |
6543 static int save_hkmap = 0; | |
6544 #endif | |
6545 buf_T *buf; | |
6546 | |
6547 if (p_paste) | |
6548 { | |
6549 /* | |
6550 * Paste switched from off to on. | |
6551 * Save the current values, so they can be restored later. | |
6552 */ | |
6553 if (!old_p_paste) | |
6554 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6555 // save options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6556 FOR_ALL_BUFFERS(buf) |
7 | 6557 { |
6558 buf->b_p_tw_nopaste = buf->b_p_tw; | |
6559 buf->b_p_wm_nopaste = buf->b_p_wm; | |
6560 buf->b_p_sts_nopaste = buf->b_p_sts; | |
6561 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
|
6562 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
|
6563 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6564 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
|
6565 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
|
6566 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
|
6567 ? 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
|
6568 #endif |
7 | 6569 } |
6570 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6571 // save global options |
7 | 6572 save_sm = p_sm; |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6573 save_sta = p_sta; |
7 | 6574 #ifdef FEAT_CMDL_INFO |
6575 save_ru = p_ru; | |
6576 #endif | |
6577 #ifdef FEAT_RIGHTLEFT | |
6578 save_ri = p_ri; | |
6579 save_hkmap = p_hkmap; | |
6580 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6581 // 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
|
6582 p_ai_nopaste = p_ai; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6583 p_et_nopaste = p_et; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6584 p_sts_nopaste = p_sts; |
7 | 6585 p_tw_nopaste = p_tw; |
6586 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
|
6587 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6588 if (p_vsts_nopaste) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6589 vim_free(p_vsts_nopaste); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6590 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
|
6591 #endif |
7 | 6592 } |
6593 | |
6594 /* | |
6595 * Always set the option values, also when 'paste' is set when it is | |
6596 * already on. | |
6597 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6598 // set options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6599 FOR_ALL_BUFFERS(buf) |
7 | 6600 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6601 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
|
6602 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
|
6603 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
|
6604 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
|
6605 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
|
6606 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6607 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
|
6608 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
|
6609 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
|
6610 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
|
6611 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
|
6612 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
|
6613 #endif |
7 | 6614 } |
6615 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6616 // set global options |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6617 p_sm = 0; // no showmatch |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6618 p_sta = 0; // no smarttab |
7 | 6619 #ifdef FEAT_CMDL_INFO |
6620 if (p_ru) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6621 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
|
6622 p_ru = 0; // no ruler |
7 | 6623 #endif |
6624 #ifdef FEAT_RIGHTLEFT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6625 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
|
6626 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
|
6627 #endif |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6628 // set global values for local buffer options |
7 | 6629 p_tw = 0; |
6630 p_wm = 0; | |
6631 p_sts = 0; | |
6632 p_ai = 0; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6633 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6634 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6635 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
|
6636 p_vsts = empty_option; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6637 #endif |
7 | 6638 } |
6639 | |
6640 /* | |
6641 * Paste switched from on to off: Restore saved values. | |
6642 */ | |
6643 else if (old_p_paste) | |
6644 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6645 // restore options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6646 FOR_ALL_BUFFERS(buf) |
7 | 6647 { |
6648 buf->b_p_tw = buf->b_p_tw_nopaste; | |
6649 buf->b_p_wm = buf->b_p_wm_nopaste; | |
6650 buf->b_p_sts = buf->b_p_sts_nopaste; | |
6651 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
|
6652 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
|
6653 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6654 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
|
6655 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
|
6656 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
|
6657 ? 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
|
6658 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
|
6659 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
|
6660 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
|
6661 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
|
6662 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6663 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
|
6664 #endif |
7 | 6665 } |
6666 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6667 // restore global options |
7 | 6668 p_sm = save_sm; |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6669 p_sta = save_sta; |
7 | 6670 #ifdef FEAT_CMDL_INFO |
6671 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
|
6672 status_redraw_all(); // redraw to draw the ruler |
7 | 6673 p_ru = save_ru; |
6674 #endif | |
6675 #ifdef FEAT_RIGHTLEFT | |
6676 p_ri = save_ri; | |
6677 p_hkmap = save_hkmap; | |
6678 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6679 // 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
|
6680 p_ai = p_ai_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6681 p_et = p_et_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6682 p_sts = p_sts_nopaste; |
7 | 6683 p_tw = p_tw_nopaste; |
6684 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
|
6685 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6686 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6687 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
|
6688 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
|
6689 #endif |
7 | 6690 } |
6691 | |
6692 old_p_paste = p_paste; | |
6693 } | |
6694 | |
6695 /* | |
6696 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found. | |
6697 * | |
6698 * Reset 'compatible' and set the values for options that didn't get set yet | |
6699 * to the Vim defaults. | |
6700 * Don't do this if the 'compatible' option has been set or reset before. | |
819 | 6701 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet. |
7 | 6702 */ |
6703 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6704 vimrc_found(char_u *fname, char_u *envname) |
819 | 6705 { |
6706 int opt_idx; | |
826 | 6707 int dofree = FALSE; |
819 | 6708 char_u *p; |
7 | 6709 |
6710 if (!option_was_set((char_u *)"cp")) | |
6711 { | |
6712 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
|
6713 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 6714 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF))) |
6715 set_option_default(opt_idx, OPT_FREE, FALSE); | |
6716 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
6717 didset_options2(); |
7 | 6718 } |
819 | 6719 |
6720 if (fname != NULL) | |
6721 { | |
6722 p = vim_getenv(envname, &dofree); | |
6723 if (p == NULL) | |
6724 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6725 // Set $MYVIMRC to the first vimrc file found. |
819 | 6726 p = FullName_save(fname, FALSE); |
6727 if (p != NULL) | |
6728 { | |
6729 vim_setenv(envname, p); | |
6730 vim_free(p); | |
6731 } | |
6732 } | |
6733 else if (dofree) | |
6734 vim_free(p); | |
6735 } | |
7 | 6736 } |
6737 | |
6738 /* | |
6739 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg. | |
6740 */ | |
6741 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6742 change_compatible(int on) |
7 | 6743 { |
838 | 6744 int opt_idx; |
6745 | |
7 | 6746 if (p_cp != on) |
6747 { | |
6748 p_cp = on; | |
6749 compatible_set(); | |
6750 } | |
838 | 6751 opt_idx = findoption((char_u *)"cp"); |
6752 if (opt_idx >= 0) | |
6753 options[opt_idx].flags |= P_WAS_SET; | |
7 | 6754 } |
6755 | |
6756 /* | |
6757 * 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
|
6758 * Only works correctly for global options. |
7 | 6759 */ |
6760 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6761 option_was_set(char_u *name) |
7 | 6762 { |
6763 int idx; | |
6764 | |
6765 idx = findoption(name); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6766 if (idx < 0) // unknown option |
7 | 6767 return FALSE; |
6768 if (options[idx].flags & P_WAS_SET) | |
6769 return TRUE; | |
6770 return FALSE; | |
6771 } | |
6772 | |
6773 /* | |
3980 | 6774 * Reset the flag indicating option "name" was set. |
6775 */ | |
14748
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6776 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6777 reset_option_was_set(char_u *name) |
3980 | 6778 { |
6779 int idx = findoption(name); | |
6780 | |
6781 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
|
6782 { |
3980 | 6783 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
|
6784 return OK; |
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6785 } |
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6786 return FAIL; |
3980 | 6787 } |
6788 | |
6789 /* | |
7 | 6790 * compatible_set() - Called when 'compatible' has been set or unset. |
6791 * | |
6792 * When 'compatible' set: Set all relevant options (those that have the P_VIM) | |
6793 * flag) to a Vi compatible value. | |
6794 * When 'compatible' is unset: Set all options that have a different default | |
6795 * for Vim (without the P_VI_DEF flag) to that default. | |
6796 */ | |
6797 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6798 compatible_set(void) |
7 | 6799 { |
6800 int opt_idx; | |
6801 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6802 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 6803 if ( ((options[opt_idx].flags & P_VIM) && p_cp) |
6804 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp)) | |
6805 set_option_default(opt_idx, OPT_FREE, p_cp); | |
6806 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
6807 didset_options2(); |
7 | 6808 } |
6809 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6810 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
7 | 6811 |
6812 /* | |
6813 * fill_breakat_flags() -- called when 'breakat' changes value. | |
6814 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6815 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6816 fill_breakat_flags(void) |
7 | 6817 { |
500 | 6818 char_u *p; |
7 | 6819 int i; |
6820 | |
6821 for (i = 0; i < 256; i++) | |
6822 breakat_flags[i] = FALSE; | |
6823 | |
6824 if (p_breakat != NULL) | |
500 | 6825 for (p = p_breakat; *p; p++) |
6826 breakat_flags[*p] = TRUE; | |
7 | 6827 } |
6828 #endif | |
6829 | |
6830 /* | |
6831 * Check if backspacing over something is allowed. | |
6832 */ | |
6833 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6834 can_bs( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6835 int what) // BS_INDENT, BS_EOL or BS_START |
7 | 6836 { |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
6837 #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
|
6838 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
|
6839 return FALSE; |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
6840 #endif |
7 | 6841 switch (*p_bs) |
6842 { | |
6843 case '2': return TRUE; | |
6844 case '1': return (what != BS_START); | |
6845 case '0': return FALSE; | |
6846 } | |
6847 return vim_strchr(p_bs, what) != NULL; | |
6848 } | |
6849 | |
6850 /* | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6851 * 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
|
6852 * 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
|
6853 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6854 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6855 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
|
6856 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6857 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
|
6858 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6859 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6860 /* |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6861 * 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
|
6862 * 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
|
6863 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6864 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6865 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
|
6866 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6867 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
|
6868 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6869 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6870 /* |
6243 | 6871 * Get the local or global value of 'backupcopy'. |
6872 */ | |
6873 unsigned int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6874 get_bkc_value(buf_T *buf) |
6243 | 6875 { |
6876 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags; | |
6877 } | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6878 |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6879 #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
|
6880 /* |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6881 * 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
|
6882 */ |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6883 char_u * |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6884 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
|
6885 { |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6886 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
|
6887 return p_sbr; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6888 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
|
6889 return empty_option; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6890 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
|
6891 } |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6892 #endif |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6893 |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6894 #if defined(FEAT_EVAL) || defined(PROTO) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6895 /* |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6896 * Get window or buffer local options. |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6897 */ |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6898 dict_T * |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6899 get_winbuf_options(int bufopt) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6900 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6901 dict_T *d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6902 int opt_idx; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6903 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6904 d = dict_alloc(); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6905 if (d == NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6906 return NULL; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6907 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6908 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
|
6909 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6910 struct vimoption *opt = &options[opt_idx]; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6911 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6912 if ((bufopt && (opt->indir & PV_BUF)) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6913 || (!bufopt && (opt->indir & PV_WIN))) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6914 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6915 char_u *varp = get_varp(opt); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6916 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6917 if (varp != NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6918 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6919 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
|
6920 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
|
6921 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
|
6922 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
|
6923 else |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14243
diff
changeset
|
6924 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
|
6925 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6926 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6927 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6928 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6929 return d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6930 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6931 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6932 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6933 #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
|
6934 /* |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6935 * 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
|
6936 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6937 int |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6938 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
|
6939 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6940 char_u *p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6941 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
|
6942 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6943 if (val == NULL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6944 p = wp->w_p_culopt; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6945 else |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6946 p = val; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6947 while (*p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6948 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6949 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
|
6950 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6951 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6952 culopt_flags_new |= CULOPT_LINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6953 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6954 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
|
6955 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6956 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6957 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
|
6958 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6959 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
|
6960 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6961 p += 6; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6962 culopt_flags_new |= CULOPT_NBR; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6963 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6964 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
|
6965 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6966 p += 10; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6967 culopt_flags_new |= CULOPT_SCRLINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6968 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6969 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6970 if (*p != ',' && *p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6971 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6972 if (*p == ',') |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6973 ++p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6974 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6975 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6976 // 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
|
6977 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
|
6978 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6979 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
|
6980 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6981 return OK; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6982 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6983 #endif |