Mercurial > vim
annotate src/option.c @ 31825:0d27ddce621d v9.0.1245
patch 9.0.1245: code is indented more than necessary
Commit: https://github.com/vim/vim/commit/032713f8299abd92fcfb1e490d1ae5c1ecadde41
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Wed Jan 25 21:05:38 2023 +0000
patch 9.0.1245: code is indented more than necessary
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11879)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 25 Jan 2023 22:15:03 +0100 |
parents | aec031683d61 |
children | b741e5243e58 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9959
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * Code to handle user-settable options. This is all pretty much table- | |
12 * driven. Checklist for adding a new option: | |
13 * - Put it in the options array below (copy an existing entry). | |
14 * - For a global option: Add a variable for it in option.h. | |
15 * - For a buffer or window local option: | |
16 * - Add a PV_XX entry to the enum below. | |
17 * - Add a variable to the window or buffer struct in structs.h. | |
18 * - For a window option, add some code to copy_winopt(). | |
19 * - For a buffer option, add some code to buf_copy_options(). | |
20 * - For a buffer string option, add code to check_buf_options(). | |
21 * - If it's a numeric option, add any necessary bounds checks to do_set(). | |
22 * - If it's a list of flags, add some code in do_set(), search for WW_ALL. | |
23 * - When adding an option with expansion (P_EXPAND), but with a different | |
24 * default for Vi and Vim (no P_VI_DEF), add some code at VIMEXP. | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10205
diff
changeset
|
25 * - Add documentation! One line in doc/quickref.txt, full description in |
7 | 26 * options.txt, and any other related places. |
27 * - Add an entry in runtime/optwin.vim. | |
28 * When making changes: | |
29 * - Adjust the help for the option in doc/option.txt. | |
30 * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a | |
31 * comment at the help for the 'compatible' option. | |
32 */ | |
33 | |
34 #define IN_OPTION_C | |
35 #include "vim.h" | |
18054
88b5c2b4e3d2
patch 8.1.2022: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18047
diff
changeset
|
36 #include "optiondefs.h" |
7 | 37 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
38 static void set_options_default(int opt_flags); |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
39 static void set_string_default_esc(char *name, char_u *val, int escape); |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
40 static char_u *find_dup_item(char_u *origval, char_u *newval, long_u flags); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
41 static char_u *option_expand(int opt_idx, char_u *val); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
42 static void didset_options(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
43 static void didset_options2(void); |
681 | 44 #if defined(FEAT_EVAL) || defined(PROTO) |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
45 static long_u *insecure_flag(int opt_idx, int opt_flags); |
681 | 46 #else |
47 # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags) | |
48 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
49 static char *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags); |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
50 static char *set_num_option(int opt_idx, char_u *varp, long value, char *errbuf, size_t errbuflen, int opt_flags); |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
51 static int find_key_option(char_u *arg_arg, int has_lt); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
52 static void showoptions(int all, int opt_flags); |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
53 static int optval_default(struct vimoption *, char_u *varp, int compatible); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
54 static void showoneopt(struct vimoption *, int opt_flags); |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
55 static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, long_u flags); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
56 static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
57 static int put_setbool(FILE *fd, char *cmd, char *name, int value); |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
58 static int istermoption(struct vimoption *p); |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
59 static char_u *get_varp_scope(struct vimoption *p, int scope); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
60 static char_u *get_varp(struct vimoption *); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
61 static void check_win_options(win_T *win); |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
62 static void option_value2string(struct vimoption *, int scope); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
63 static void check_winopt(winopt_T *wop); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
64 static int wc_use_keyname(char_u *varp, long *wcp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
65 static void paste_option_changed(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
66 static void compatible_set(void); |
7 | 67 |
68 /* | |
69 * Initialize the options, first part. | |
70 * | |
71 * Called only once from main(), just after creating the first buffer. | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
72 * If "clean_arg" is TRUE Vim was started with --clean. |
7 | 73 */ |
74 void | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
75 set_init_1(int clean_arg) |
7 | 76 { |
77 char_u *p; | |
78 int opt_idx; | |
835 | 79 long_u n; |
7 | 80 |
81 #ifdef FEAT_LANGMAP | |
82 langmap_init(); | |
83 #endif | |
84 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
85 // Be Vi compatible by default |
7 | 86 p_cp = TRUE; |
87 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
88 // Use POSIX compatibility when $VIM_POSIX is set. |
164 | 89 if (mch_getenv((char_u *)"VIM_POSIX") != NULL) |
168 | 90 { |
164 | 91 set_string_default("cpo", (char_u *)CPO_ALL); |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
92 set_string_default("shm", (char_u *)SHM_POSIX); |
168 | 93 } |
164 | 94 |
7 | 95 /* |
96 * Find default value for 'shell' option. | |
161 | 97 * Don't use it if it is empty. |
7 | 98 */ |
161 | 99 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL) |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
100 #if defined(MSWIN) |
161 | 101 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL) |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7829
diff
changeset
|
102 || ((p = (char_u *)default_shell()) != NULL && *p != NUL) |
7 | 103 #endif |
161 | 104 ) |
18241
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
105 #if defined(MSWIN) |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
106 { |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
107 // For MS-Windows put the path in quotes instead of escaping spaces. |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
108 char_u *cmd; |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
109 size_t len; |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
110 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
111 if (vim_strchr(p, ' ') != NULL) |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
112 { |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
113 len = STRLEN(p) + 3; // two quotes and a trailing NUL |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
114 cmd = alloc(len); |
18243
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
115 if (cmd != NULL) |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
116 { |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
117 vim_snprintf((char *)cmd, len, "\"%s\"", p); |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
118 set_string_default("sh", cmd); |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
119 vim_free(cmd); |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
120 } |
18241
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
121 } |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
122 else |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
123 set_string_default("sh", p); |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
124 } |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
125 #else |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
126 set_string_default_esc("sh", p, TRUE); |
18241
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
127 #endif |
7 | 128 |
129 /* | |
130 * Set the default for 'backupskip' to include environment variables for | |
131 * temp files. | |
132 */ | |
133 { | |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
134 #ifdef UNIX |
7 | 135 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"}; |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
136 #else |
7 | 137 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"}; |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
138 #endif |
170 | 139 int len; |
140 garray_T ga; | |
141 int mustfree; | |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
142 char_u *item; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
143 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
144 opt_idx = findoption((char_u *)"backupskip"); |
7 | 145 |
146 ga_init2(&ga, 1, 100); | |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
147 for (n = 0; n < (long)ARRAY_LENGTH(names); ++n) |
7 | 148 { |
170 | 149 mustfree = FALSE; |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
150 #ifdef UNIX |
7 | 151 if (*names[n] == NUL) |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
152 # ifdef MACOS_X |
13664
f64c5e636c9f
patch 8.0.1704: 'backupskip' default doesn't work for Mac
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
153 p = (char_u *)"/private/tmp"; |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
154 # else |
7 | 155 p = (char_u *)"/tmp"; |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
156 # endif |
7 | 157 else |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
158 #endif |
170 | 159 p = vim_getenv((char_u *)names[n], &mustfree); |
7 | 160 if (p != NULL && *p != NUL) |
161 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
162 // First time count the NUL, otherwise count the ','. |
835 | 163 len = (int)STRLEN(p) + 3; |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
164 item = alloc(len); |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
165 STRCPY(item, p); |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
166 add_pathsep(item); |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
167 STRCAT(item, "*"); |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
168 if (find_dup_item(ga.ga_data, item, options[opt_idx].flags) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
169 == NULL |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
170 && ga_grow(&ga, len) == OK) |
7 | 171 { |
172 if (ga.ga_len > 0) | |
173 STRCAT(ga.ga_data, ","); | |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
174 STRCAT(ga.ga_data, item); |
7 | 175 ga.ga_len += len; |
176 } | |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
177 vim_free(item); |
7 | 178 } |
170 | 179 if (mustfree) |
180 vim_free(p); | |
7 | 181 } |
182 if (ga.ga_data != NULL) | |
183 { | |
184 set_string_default("bsk", ga.ga_data); | |
185 vim_free(ga.ga_data); | |
186 } | |
187 } | |
188 | |
189 /* | |
190 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory | |
191 */ | |
192 opt_idx = findoption((char_u *)"maxmemtot"); | |
838 | 193 if (opt_idx >= 0) |
194 { | |
7 | 195 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
838 | 196 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) |
197 #endif | |
198 { | |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
199 #if defined(HAVE_AVAIL_MEM) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
200 // Use amount of memory available at this moment. |
3634 | 201 n = (mch_avail_mem(FALSE) >> 1); |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
202 #elif defined(HAVE_TOTAL_MEM) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
203 // Use amount of memory available to Vim. |
1110 | 204 n = (mch_total_mem(FALSE) >> 1); |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
205 #else |
838 | 206 n = (0x7fffffff >> 11); |
7 | 207 #endif |
208 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; | |
838 | 209 opt_idx = findoption((char_u *)"maxmem"); |
210 if (opt_idx >= 0) | |
211 { | |
212 #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
|
213 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
|
214 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L) |
838 | 215 #endif |
216 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; | |
217 } | |
218 } | |
7 | 219 } |
220 | |
221 { | |
222 char_u *cdpath; | |
223 char_u *buf; | |
224 int i; | |
225 int j; | |
170 | 226 int mustfree = FALSE; |
7 | 227 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
228 // Initialize the 'cdpath' option's default value. |
170 | 229 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree); |
7 | 230 if (cdpath != NULL) |
231 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16730
diff
changeset
|
232 buf = alloc((STRLEN(cdpath) << 1) + 2); |
7 | 233 if (buf != NULL) |
234 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
235 buf[0] = ','; // start with ",", current dir first |
7 | 236 j = 1; |
237 for (i = 0; cdpath[i] != NUL; ++i) | |
238 { | |
239 if (vim_ispathlistsep(cdpath[i])) | |
240 buf[j++] = ','; | |
241 else | |
242 { | |
243 if (cdpath[i] == ' ' || cdpath[i] == ',') | |
244 buf[j++] = '\\'; | |
245 buf[j++] = cdpath[i]; | |
246 } | |
247 } | |
248 buf[j] = NUL; | |
249 opt_idx = findoption((char_u *)"cdpath"); | |
838 | 250 if (opt_idx >= 0) |
251 { | |
252 options[opt_idx].def_val[VI_DEFAULT] = buf; | |
253 options[opt_idx].flags |= P_DEF_ALLOCED; | |
254 } | |
2445
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
255 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
256 vim_free(buf); // cannot happen |
7 | 257 } |
170 | 258 if (mustfree) |
259 vim_free(cdpath); | |
7 | 260 } |
261 } | |
262 | |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
263 #if defined(FEAT_POSTSCRIPT) && \ |
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
264 (defined(MSWIN) || defined(VMS) || defined(MAC) || defined(hpux)) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
265 // Set print encoding on platforms that don't default to latin1 |
7 | 266 set_string_default("penc", |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
267 # if defined(MSWIN) |
7 | 268 (char_u *)"cp1252" |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
269 # elif defined(VMS) |
7 | 270 (char_u *)"dec-mcs" |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
271 # elif defined(MAC) |
7 | 272 (char_u *)"mac-roman" |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
273 # else // HPUX |
7 | 274 (char_u *)"hp-roman8" |
275 # endif | |
276 ); | |
277 #endif | |
278 | |
279 #ifdef FEAT_POSTSCRIPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
280 // 'printexpr' must be allocated to be able to evaluate it. |
7 | 281 set_string_default("pexpr", |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
282 # if defined(MSWIN) |
8 | 283 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)" |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
284 # elif defined(VMS) |
7 | 285 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)" |
286 | |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
287 # else |
7 | 288 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error" |
289 # endif | |
290 ); | |
291 #endif | |
292 | |
293 /* | |
294 * Set all the options (except the terminal options) to their default | |
295 * value. Also set the global value for local options. | |
296 */ | |
297 set_options_default(0); | |
298 | |
27509
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
299 #ifdef UNIX |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
300 // Force restricted-mode on for "nologin" or "false" $SHELL |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
301 p = get_isolated_shell_name(); |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
302 if (p != NULL) |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
303 { |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
304 if (fnamecmp(p, "nologin") == 0 || fnamecmp(p, "false") == 0) |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
305 restricted = TRUE; |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
306 vim_free(p); |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
307 } |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
308 #endif |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
309 |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
310 #ifdef CLEAN_RUNTIMEPATH |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
311 if (clean_arg) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
312 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
313 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
|
314 if (opt_idx >= 0) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
315 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
316 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
|
317 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
|
318 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
319 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
|
320 if (opt_idx >= 0) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
321 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
322 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
|
323 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
|
324 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
325 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
326 #endif |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
327 |
7 | 328 #ifdef FEAT_GUI |
329 if (found_reverse_arg) | |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
330 set_option_value_give_err((char_u *)"bg", 0L, (char_u *)"dark", 0); |
7 | 331 #endif |
332 | |
333 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
|
334 curbuf->b_p_ar = -1; // no local 'autoread' value |
5446 | 335 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
7 | 336 check_buf_options(curbuf); |
337 check_win_options(curwin); | |
338 check_options(); | |
339 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
340 // Must be before option_expand(), because that one needs vim_isIDc() |
7 | 341 didset_options(); |
342 | |
744 | 343 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
344 // 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
|
345 // didset_options() because it only depends on 'encoding'. |
227 | 346 init_spell_chartab(); |
347 #endif | |
348 | |
7 | 349 /* |
350 * Expand environment variables and things like "~" for the defaults. | |
351 * If option_expand() returns non-NULL the variable is expanded. This can | |
352 * only happen for non-indirect options. | |
353 * Also set the default to the expanded value, so ":set" does not list | |
354 * them. | |
355 * Don't set the P_ALLOCED flag, because we don't want to free the | |
356 * default. | |
357 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
358 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 359 { |
360 if ((options[opt_idx].flags & P_GETTEXT) | |
361 && options[opt_idx].var != NULL) | |
362 p = (char_u *)_(*(char **)options[opt_idx].var); | |
363 else | |
364 p = option_expand(opt_idx, NULL); | |
365 if (p != NULL && (p = vim_strsave(p)) != NULL) | |
366 { | |
367 *(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
|
368 // VIMEXP |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
369 // 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
|
370 // 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
|
371 // split P_DEF_ALLOCED in two. |
7 | 372 if (options[opt_idx].flags & P_DEF_ALLOCED) |
373 vim_free(options[opt_idx].def_val[VI_DEFAULT]); | |
374 options[opt_idx].def_val[VI_DEFAULT] = p; | |
375 options[opt_idx].flags |= P_DEF_ALLOCED; | |
376 } | |
377 } | |
378 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
379 save_file_ff(curbuf); // Buffer is unchanged |
7 | 380 |
381 #if defined(FEAT_ARABIC) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
382 // Detect use of mlterm. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
383 // 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
|
384 // abilities (bidi namely). |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
385 // 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
|
386 // instead of an environment variable due to inheritance. |
7 | 387 if (mch_getenv((char_u *)"MLTERM") != NULL) |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
388 set_option_value_give_err((char_u *)"tbidi", 1L, NULL, 0); |
7 | 389 #endif |
390 | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
391 didset_options2(); |
7 | 392 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
393 # if defined(MSWIN) && defined(FEAT_GETTEXT) |
7 | 394 /* |
395 * If $LANG isn't set, try to get a good value for it. This makes the | |
396 * right language be used automatically. Don't do this for English. | |
397 */ | |
398 if (mch_getenv((char_u *)"LANG") == NULL) | |
399 { | |
400 char buf[20]; | |
401 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
402 // 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
|
403 // 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
|
404 // only the first two. |
7 | 405 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, |
406 (LPTSTR)buf, 20); | |
407 if (n >= 2 && STRNICMP(buf, "en", 2) != 0) | |
408 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
409 // There are a few exceptions (probably more) |
7 | 410 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0) |
411 STRCPY(buf, "zh_TW"); | |
412 else if (STRNICMP(buf, "chs", 3) == 0 | |
413 || STRNICMP(buf, "zhc", 3) == 0) | |
414 STRCPY(buf, "zh_CN"); | |
415 else if (STRNICMP(buf, "jp", 2) == 0) | |
416 STRCPY(buf, "ja"); | |
417 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
418 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
|
419 vim_setenv((char_u *)"LANG", (char_u *)buf); |
7 | 420 } |
421 } | |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
422 # elif defined(MACOS_CONVERT) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
423 // Moved to os_mac_conv.c to avoid dependency problems. |
1622 | 424 mac_lang_init(); |
7 | 425 # endif |
426 | |
24747
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
427 # ifdef MSWIN |
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
428 // MS-Windows has builtin support for conversion to and from Unicode, using |
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
429 // "utf-8" for 'encoding' should work best for most users. |
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
430 p = vim_strsave((char_u *)ENC_DFLT); |
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
431 # else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
432 // enc_locale() will try to find the encoding of the current locale. |
24747
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
433 // This works best for properly configured systems, old and new. |
7 | 434 p = enc_locale(); |
24747
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
435 # endif |
7 | 436 if (p != NULL) |
437 { | |
438 char_u *save_enc; | |
439 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
440 // Try setting 'encoding' and check if the value is valid. |
24747
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
441 // If not, go back to the default encoding. |
7 | 442 save_enc = p_enc; |
443 p_enc = p; | |
1080 | 444 if (STRCMP(p_enc, "gb18030") == 0) |
445 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
446 // 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
|
447 // 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
|
448 // still support conversion between gb18030 and utf-8. |
1080 | 449 p_enc = vim_strsave((char_u *)"cp936"); |
450 vim_free(p); | |
451 } | |
7 | 452 if (mb_init() == NULL) |
453 { | |
454 opt_idx = findoption((char_u *)"encoding"); | |
838 | 455 if (opt_idx >= 0) |
456 { | |
457 options[opt_idx].def_val[VI_DEFAULT] = p_enc; | |
458 options[opt_idx].flags |= P_DEF_ALLOCED; | |
459 } | |
7 | 460 |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12636
diff
changeset
|
461 #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
|
462 if (STRCMP(p_enc, "latin1") == 0 || enc_utf8) |
24 | 463 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
464 // 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
|
465 // 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
|
466 // set. |
24 | 467 set_string_option_direct((char_u *)"isp", -1, |
719 | 468 ISP_LATIN1, OPT_FREE, SID_NONE); |
714 | 469 set_string_option_direct((char_u *)"isk", -1, |
470 ISK_LATIN1, OPT_FREE, SID_NONE); | |
471 opt_idx = findoption((char_u *)"isp"); | |
838 | 472 if (opt_idx >= 0) |
473 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1; | |
714 | 474 opt_idx = findoption((char_u *)"isk"); |
838 | 475 if (opt_idx >= 0) |
476 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1; | |
24 | 477 (void)init_chartab(); |
478 } | |
479 #endif | |
480 | |
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
|
481 #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
|
482 // 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
|
483 // 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
|
484 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
|
485 # 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
|
486 (!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
|
487 # endif |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
488 GetACP() != GetConsoleCP()) |
7 | 489 { |
490 char buf[50]; | |
491 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
492 // 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
|
493 // 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
|
494 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
|
495 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
|
496 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
|
497 sprintf(buf, "cp%ld", (long)GetConsoleCP()); |
7 | 498 p_tenc = vim_strsave((char_u *)buf); |
499 if (p_tenc != NULL) | |
500 { | |
501 opt_idx = findoption((char_u *)"termencoding"); | |
838 | 502 if (opt_idx >= 0) |
503 { | |
504 options[opt_idx].def_val[VI_DEFAULT] = p_tenc; | |
505 options[opt_idx].flags |= P_DEF_ALLOCED; | |
506 } | |
7 | 507 convert_setup(&input_conv, p_tenc, p_enc); |
508 convert_setup(&output_conv, p_enc, p_tenc); | |
509 } | |
510 else | |
511 p_tenc = empty_option; | |
512 } | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
513 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
514 #if defined(MSWIN) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
515 // $HOME may have characters in active code page. |
170 | 516 init_homedir(); |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
517 #endif |
7 | 518 } |
519 else | |
520 { | |
521 vim_free(p_enc); | |
522 p_enc = save_enc; | |
523 } | |
524 } | |
525 | |
526 #ifdef FEAT_MULTI_LANG | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
527 // Set the default for 'helplang'. |
7 | 528 set_helplang_default(get_mess_lang()); |
529 #endif | |
530 } | |
531 | |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
532 static char_u *fencs_utf8_default = (char_u *)"ucs-bom,utf-8,default,latin1"; |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
533 |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
534 /* |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
535 * Set the "fileencodings" option to the default value for when 'encoding' is |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
536 * utf-8. |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
537 */ |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
538 void |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
539 set_fencs_unicode() |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
540 { |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
541 set_string_option_direct((char_u *)"fencs", -1, fencs_utf8_default, |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
542 OPT_FREE, 0); |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
543 } |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
544 |
7 | 545 /* |
546 * Set an option to its default value. | |
547 * This does not take care of side effects! | |
548 */ | |
549 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
550 set_option_default( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
551 int opt_idx, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
552 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
|
553 int compatible) // use Vi default value |
7 | 554 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
555 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
|
556 int dvi; // index in def_val[] |
7 | 557 long_u flags; |
681 | 558 long_u *flagsp; |
7 | 559 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
560 | |
561 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); | |
562 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
|
563 if (varp != NULL) // skip hidden option, nothing to do for it |
7 | 564 { |
565 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; | |
566 if (flags & P_STRING) | |
567 { | |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
568 // 'fencs' default value depends on 'encoding' |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
569 if (options[opt_idx].var == (char_u *)&p_fencs && enc_utf8) |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
570 set_fencs_unicode(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
571 // 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
|
572 // freeing and allocating the value. |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
573 else if (options[opt_idx].indir != PV_NONE) |
13845
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
574 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
|
575 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
|
576 else |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
577 { |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
578 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
|
579 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
|
580 *(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
|
581 options[opt_idx].flags &= ~P_ALLOCED; |
7 | 582 } |
583 } | |
584 else if (flags & P_NUM) | |
585 { | |
1017 | 586 if (options[opt_idx].indir == PV_SCROLL) |
7 | 587 win_comp_scroll(curwin); |
588 else | |
589 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
590 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
|
591 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
592 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
|
593 || (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
|
594 // '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
|
595 // 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
|
596 *(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
|
597 else |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
598 *(long *)varp = def_val; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
599 // May also set global value for local option. |
7 | 600 if (both) |
601 *(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
|
602 def_val; |
7 | 603 } |
604 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
605 else // P_BOOL |
7 | 606 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
607 // 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
|
608 // MSVC |
840 | 609 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; |
1111 | 610 #ifdef UNIX |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
611 // 'modeline' defaults to off for root |
1111 | 612 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) |
613 *(int *)varp = FALSE; | |
614 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
615 // May also set global value for local option. |
7 | 616 if (both) |
617 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | |
618 *(int *)varp; | |
619 } | |
634 | 620 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
621 // The default value is not insecure. |
681 | 622 flagsp = insecure_flag(opt_idx, opt_flags); |
623 *flagsp = *flagsp & ~P_INSECURE; | |
7 | 624 } |
625 | |
626 #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
|
627 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 628 #endif |
629 } | |
630 | |
631 /* | |
632 * 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
|
633 * When "opt_flags" is non-zero skip 'encoding'. |
7 | 634 */ |
635 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
636 set_options_default( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
637 int opt_flags) // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL |
7 | 638 { |
639 int i; | |
640 win_T *wp; | |
671 | 641 tabpage_T *tp; |
7 | 642 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
643 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
|
644 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
|
645 && (opt_flags == 0 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
646 || (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
|
647 # if defined(FEAT_CRYPT) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
648 && 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
|
649 && 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
|
650 # endif |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
651 ))) |
7 | 652 set_option_default(i, opt_flags, p_cp); |
653 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
654 // The 'scroll' option must be computed for all windows. |
671 | 655 FOR_ALL_TAB_WINDOWS(tp, wp) |
7 | 656 win_comp_scroll(wp); |
6205 | 657 parse_cino(curbuf); |
7 | 658 } |
659 | |
660 /* | |
661 * Set the Vi-default value of a string option. | |
662 * 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
|
663 * 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
|
664 */ |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
665 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
|
666 set_string_default_esc(char *name, char_u *val, int escape) |
7 | 667 { |
668 char_u *p; | |
669 int opt_idx; | |
670 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
671 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
|
672 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
|
673 else |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
674 p = vim_strsave(val); |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
675 if (p == NULL) // we don't want a NULL |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
676 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
677 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
678 opt_idx = findoption((char_u *)name); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
679 if (opt_idx < 0) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
680 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
681 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
682 if (options[opt_idx].flags & P_DEF_ALLOCED) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
683 vim_free(options[opt_idx].def_val[VI_DEFAULT]); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
684 options[opt_idx].def_val[VI_DEFAULT] = p; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
685 options[opt_idx].flags |= P_DEF_ALLOCED; |
7 | 686 } |
687 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
688 void |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
689 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
|
690 { |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
691 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
|
692 } |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
693 |
7 | 694 /* |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
695 * For an option value that contains comma separated items, find "newval" in |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
696 * "origval". Return NULL if not found. |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
697 */ |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
698 static char_u * |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
699 find_dup_item(char_u *origval, char_u *newval, long_u flags) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
700 { |
22242
f7871f02ddcd
patch 8.2.1670: a couple of gcc compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
22234
diff
changeset
|
701 int bs = 0; |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
702 size_t newlen; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
703 char_u *s; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
704 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
705 if (origval == NULL) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
706 return NULL; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
707 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
708 newlen = STRLEN(newval); |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
709 for (s = origval; *s != NUL; ++s) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
710 { |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
711 if ((!(flags & P_COMMA) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
712 || s == origval |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
713 || (s[-1] == ',' && !(bs & 1))) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
714 && STRNCMP(s, newval, newlen) == 0 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
715 && (!(flags & P_COMMA) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
716 || s[newlen] == ',' |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
717 || s[newlen] == NUL)) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
718 return s; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
719 // Count backslashes. Only a comma with an even number of backslashes |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
720 // or a single backslash preceded by a comma before it is recognized as |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
721 // a separator. |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
722 if ((s > origval + 1 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
723 && s[-1] == '\\' |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
724 && s[-2] != ',') |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
725 || (s == origval + 1 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
726 && s[-1] == '\\')) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
727 ++bs; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
728 else |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
729 bs = 0; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
730 } |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
731 return NULL; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
732 } |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
733 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
734 /* |
7 | 735 * Set the Vi-default value of a number option. |
736 * Used for 'lines' and 'columns'. | |
737 */ | |
738 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
739 set_number_default(char *name, long val) |
7 | 740 { |
838 | 741 int opt_idx; |
742 | |
743 opt_idx = findoption((char_u *)name); | |
744 if (opt_idx >= 0) | |
840 | 745 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 746 } |
747 | |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
748 #if defined(FEAT_PROP_POPUP) || defined(PROTO) |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
749 /* |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
750 * 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
|
751 * 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
|
752 * 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
|
753 */ |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
754 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
|
755 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
|
756 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
757 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
|
758 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
|
759 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
760 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
|
761 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
|
762 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
|
763 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
764 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
|
765 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
766 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
|
767 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
|
768 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
769 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
|
770 && (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
|
771 && !(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
|
772 && !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
|
773 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
|
774 } |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
775 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
776 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
|
777 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
|
778 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
|
779 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
780 #endif |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
781 |
359 | 782 #if defined(EXITFREE) || defined(PROTO) |
783 /* | |
784 * Free all options. | |
785 */ | |
786 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
787 free_all_options(void) |
359 | 788 { |
789 int i; | |
790 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
791 for (i = 0; !istermoption_idx(i); i++) |
359 | 792 { |
793 if (options[i].indir == PV_NONE) | |
794 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
795 // 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
|
796 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL) |
359 | 797 free_string_option(*(char_u **)options[i].var); |
798 if (options[i].flags & P_DEF_ALLOCED) | |
799 free_string_option(options[i].def_val[VI_DEFAULT]); | |
800 } | |
801 else if (options[i].var != VAR_WIN | |
802 && (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
|
803 // buffer-local option: free global value |
25419
8a0234862ce6
patch 8.2.3246: memory use after free
Bram Moolenaar <Bram@vim.org>
parents:
25380
diff
changeset
|
804 clear_string_option((char_u **)options[i].var); |
359 | 805 } |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
806 free_operatorfunc_option(); |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26193
diff
changeset
|
807 free_tagfunc_option(); |
359 | 808 } |
809 #endif | |
810 | |
811 | |
7 | 812 /* |
813 * Initialize the options, part two: After getting Rows and Columns and | |
814 * setting 'term'. | |
815 */ | |
816 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
817 set_init_2(void) |
7 | 818 { |
164 | 819 int idx; |
820 | |
7 | 821 /* |
12718
f8f505ffc0a6
patch 8.0.1237: ":set scroll&" often gives an error
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
822 * '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
|
823 * which results in the actual value computed from the window height. |
7 | 824 */ |
168 | 825 idx = findoption((char_u *)"scroll"); |
838 | 826 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
168 | 827 set_option_default(idx, OPT_LOCAL, p_cp); |
7 | 828 comp_col(); |
829 | |
164 | 830 /* |
831 * 'window' is only for backwards compatibility with Vi. | |
832 * Default is Rows - 1. | |
833 */ | |
857 | 834 if (!option_was_set((char_u *)"window")) |
164 | 835 p_window = Rows - 1; |
836 set_number_default("window", Rows - 1); | |
837 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
838 // 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
|
839 #if !((defined(MSWIN)) && !defined(FEAT_GUI)) |
671 | 840 /* |
841 * If 'background' wasn't set by the user, try guessing the value, | |
842 * depending on the terminal name. Only need to check for terminals | |
843 * with a dark background, that can handle color. | |
844 */ | |
845 idx = findoption((char_u *)"bg"); | |
838 | 846 if (idx >= 0 && !(options[idx].flags & P_WAS_SET) |
847 && *term_bg_default() == 'd') | |
671 | 848 { |
694 | 849 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
|
850 // 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
|
851 // changed again |
671 | 852 options[idx].flags &= ~P_WAS_SET; |
7 | 853 } |
854 #endif | |
440 | 855 |
856 #ifdef CURSOR_SHAPE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
857 parse_shape_opt(SHAPE_CURSOR); // set cursor shapes from 'guicursor' |
440 | 858 #endif |
859 #ifdef FEAT_MOUSESHAPE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
860 parse_shape_opt(SHAPE_MOUSE); // set mouse shapes from 'mouseshape' |
440 | 861 #endif |
862 #ifdef FEAT_PRINTER | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
863 (void)parse_printoptions(); // parse 'printoptions' default value |
440 | 864 #endif |
7 | 865 } |
866 | |
867 /* | |
868 * Initialize the options, part three: After reading the .vimrc | |
869 */ | |
870 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
871 set_init_3(void) |
7 | 872 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
873 #if defined(UNIX) || defined(MSWIN) |
7 | 874 /* |
875 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. | |
876 * This is done after other initializations, where 'shell' might have been | |
877 * set, but only if they have not been set before. | |
878 */ | |
879 char_u *p; | |
880 int idx_srr; | |
881 int do_srr; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
882 # ifdef FEAT_QUICKFIX |
7 | 883 int idx_sp; |
884 int do_sp; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
885 # endif |
7 | 886 |
887 idx_srr = findoption((char_u *)"srr"); | |
838 | 888 if (idx_srr < 0) |
889 do_srr = FALSE; | |
890 else | |
891 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
|
892 # ifdef FEAT_QUICKFIX |
7 | 893 idx_sp = findoption((char_u *)"sp"); |
838 | 894 if (idx_sp < 0) |
895 do_sp = FALSE; | |
896 else | |
897 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
|
898 # endif |
5867 | 899 p = get_isolated_shell_name(); |
7 | 900 if (p != NULL) |
901 { | |
902 /* | |
903 * Default for p_sp is "| tee", for p_srr is ">". | |
904 * For known shells it is changed here to include stderr. | |
905 */ | |
906 if ( fnamecmp(p, "csh") == 0 | |
907 || 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
|
908 # if defined(MSWIN) // also check with .exe extension |
7 | 909 || fnamecmp(p, "csh.exe") == 0 |
910 || fnamecmp(p, "tcsh.exe") == 0 | |
911 # endif | |
912 ) | |
913 { | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
914 # if defined(FEAT_QUICKFIX) |
7 | 915 if (do_sp) |
916 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
917 # ifdef MSWIN |
7 | 918 p_sp = (char_u *)">&"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
919 # else |
7 | 920 p_sp = (char_u *)"|& tee"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
921 # endif |
7 | 922 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
923 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
924 # endif |
7 | 925 if (do_srr) |
926 { | |
927 p_srr = (char_u *)">&"; | |
928 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
929 } | |
930 } | |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
931 # ifdef MSWIN |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
932 // Windows PowerShell output is UTF-16 with BOM so re-encode to the |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
933 // current codepage. |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
934 else if ( fnamecmp(p, "powershell") == 0 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
935 || fnamecmp(p, "powershell.exe") == 0 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
936 ) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
937 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
938 # if defined(FEAT_QUICKFIX) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
939 if (do_sp) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
940 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
941 p_sp = (char_u *)"2>&1 | Out-File -Encoding default"; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
942 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
943 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
944 # endif |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
945 if (do_srr) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
946 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
947 p_srr = (char_u *)"2>&1 | Out-File -Encoding default"; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
948 options[idx_srr].def_val[VI_DEFAULT] = p_srr; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
949 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
950 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
951 #endif |
7 | 952 else |
24600
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
953 // Always use POSIX shell style redirection if we reach this |
7 | 954 if ( fnamecmp(p, "sh") == 0 |
955 || fnamecmp(p, "ksh") == 0 | |
2774 | 956 || fnamecmp(p, "mksh") == 0 |
957 || fnamecmp(p, "pdksh") == 0 | |
7 | 958 || fnamecmp(p, "zsh") == 0 |
836 | 959 || fnamecmp(p, "zsh-beta") == 0 |
7 | 960 || fnamecmp(p, "bash") == 0 |
5867 | 961 || fnamecmp(p, "fish") == 0 |
24600
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
962 || fnamecmp(p, "ash") == 0 |
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
963 || fnamecmp(p, "dash") == 0 |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
964 || fnamecmp(p, "pwsh") == 0 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
965 # ifdef MSWIN |
7 | 966 || fnamecmp(p, "cmd") == 0 |
967 || fnamecmp(p, "sh.exe") == 0 | |
968 || fnamecmp(p, "ksh.exe") == 0 | |
2774 | 969 || fnamecmp(p, "mksh.exe") == 0 |
970 || fnamecmp(p, "pdksh.exe") == 0 | |
7 | 971 || fnamecmp(p, "zsh.exe") == 0 |
836 | 972 || fnamecmp(p, "zsh-beta.exe") == 0 |
7 | 973 || fnamecmp(p, "bash.exe") == 0 |
974 || fnamecmp(p, "cmd.exe") == 0 | |
24600
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
975 || fnamecmp(p, "dash.exe") == 0 |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
976 || fnamecmp(p, "pwsh.exe") == 0 |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
977 # endif |
7 | 978 ) |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
979 { |
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
980 # if defined(FEAT_QUICKFIX) |
7 | 981 if (do_sp) |
982 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
983 # ifdef MSWIN |
7 | 984 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
|
985 # else |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
986 if (fnamecmp(p, "pwsh") == 0) |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
987 p_sp = (char_u *)">%s 2>&1"; |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
988 else |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
989 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
|
990 # endif |
7 | 991 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
992 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
993 # endif |
7 | 994 if (do_srr) |
995 { | |
996 p_srr = (char_u *)">%s 2>&1"; | |
997 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
998 } | |
999 } | |
1000 vim_free(p); | |
1001 } | |
1002 #endif | |
1003 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
1004 #if defined(MSWIN) |
7 | 1005 /* |
3352 | 1006 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the |
1007 * 'shell' option. | |
7 | 1008 * This is done after other initializations, where 'shell' might have been |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1009 * set, but only if they have not been set before. |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1010 * Default values depend on shell (cmd.exe is default shell): |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1011 * |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1012 * p_shcf p_sxq |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
1013 * cmd.exe - "/c" "(" |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1014 * powershell.exe - "-Command" "\"" |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
1015 * pwsh.exe - "-c" "\"" |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1016 * "sh" like shells - "-c" "\"" |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1017 * |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1018 * For Win32 p_sxq is set instead of p_shq to include shell redirection. |
7 | 1019 */ |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1020 if (strstr((char *)gettail(p_sh), "powershell") != NULL) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1021 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1022 int idx_opt; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1023 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1024 idx_opt = findoption((char_u *)"shcf"); |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1025 if (idx_opt >= 0 && !(options[idx_opt].flags & P_WAS_SET)) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1026 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1027 p_shcf = (char_u*)"-Command"; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1028 options[idx_opt].def_val[VI_DEFAULT] = p_shcf; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1029 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1030 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1031 idx_opt = findoption((char_u *)"sxq"); |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1032 if (idx_opt >= 0 && !(options[idx_opt].flags & P_WAS_SET)) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1033 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1034 p_sxq = (char_u*)"\""; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1035 options[idx_opt].def_val[VI_DEFAULT] = p_sxq; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1036 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1037 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1038 else if (strstr((char *)gettail(p_sh), "sh") != NULL) |
7 | 1039 { |
1040 int idx3; | |
1041 | |
1042 idx3 = findoption((char_u *)"shcf"); | |
838 | 1043 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 1044 { |
1045 p_shcf = (char_u *)"-c"; | |
1046 options[idx3].def_val[VI_DEFAULT] = p_shcf; | |
1047 } | |
1048 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1049 // Somehow Win32 requires the quotes around the redirection too |
7 | 1050 idx3 = findoption((char_u *)"sxq"); |
838 | 1051 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 1052 { |
1053 p_sxq = (char_u *)"\""; | |
1054 options[idx3].def_val[VI_DEFAULT] = p_sxq; | |
1055 } | |
1056 } | |
3352 | 1057 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL) |
1058 { | |
1059 int idx3; | |
1060 | |
1061 /* | |
1062 * cmd.exe on Windows will strip the first and last double quote given | |
1063 * on the command line, e.g. most of the time things like: | |
1064 * cmd /c "my path/to/echo" "my args to echo" | |
1065 * become: | |
1066 * my path/to/echo" "my args to echo | |
1067 * when executed. | |
1068 * | |
3357 | 1069 * To avoid this, set shellxquote to surround the command in |
1070 * parenthesis. This appears to make most commands work, without | |
1071 * breaking commands that worked previously, such as | |
1072 * '"path with spaces/cmd" "a&b"'. | |
3352 | 1073 */ |
1074 idx3 = findoption((char_u *)"sxq"); | |
1075 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
1076 { | |
3357 | 1077 p_sxq = (char_u *)"("; |
3352 | 1078 options[idx3].def_val[VI_DEFAULT] = p_sxq; |
1079 } | |
1080 | |
1081 idx3 = findoption((char_u *)"shcf"); | |
1082 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
1083 { | |
3357 | 1084 p_shcf = (char_u *)"/c"; |
3352 | 1085 options[idx3].def_val[VI_DEFAULT] = p_shcf; |
1086 } | |
1087 } | |
7 | 1088 #endif |
1089 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11107
diff
changeset
|
1090 if (BUFEMPTY()) |
8659
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1091 { |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1092 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
|
1093 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1094 // 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
|
1095 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
|
1096 set_fileformat(default_fileformat(), OPT_LOCAL); |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1097 } |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1098 |
7 | 1099 set_title_defaults(); |
1100 } | |
1101 | |
1102 #if defined(FEAT_MULTI_LANG) || defined(PROTO) | |
1103 /* | |
1104 * When 'helplang' is still at its default value, set it to "lang". | |
1105 * Only the first two characters of "lang" are used. | |
1106 */ | |
1107 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1108 set_helplang_default(char_u *lang) |
7 | 1109 { |
1110 int idx; | |
1111 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1112 if (lang == NULL || STRLEN(lang) < 2) // safety check |
7 | 1113 return; |
1114 idx = findoption((char_u *)"hlg"); | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1115 if (idx < 0 || (options[idx].flags & P_WAS_SET)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1116 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1117 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1118 if (options[idx].flags & P_ALLOCED) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1119 free_string_option(p_hlg); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1120 p_hlg = vim_strsave(lang); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1121 if (p_hlg == NULL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1122 p_hlg = empty_option; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1123 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1124 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1125 // zh_CN becomes "cn", zh_TW becomes "tw" |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1126 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1127 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1128 p_hlg[0] = TOLOWER_ASC(p_hlg[3]); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1129 p_hlg[1] = TOLOWER_ASC(p_hlg[4]); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1130 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1131 // any C like setting, such as C.UTF-8, becomes "en" |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1132 else if (STRLEN(p_hlg) >= 1 && *p_hlg == 'C') |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1133 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1134 p_hlg[0] = 'e'; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1135 p_hlg[1] = 'n'; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1136 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1137 p_hlg[2] = NUL; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1138 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1139 options[idx].flags |= P_ALLOCED; |
7 | 1140 } |
1141 #endif | |
1142 | |
1143 /* | |
1144 * 'title' and 'icon' only default to true if they have not been set or reset | |
1145 * in .vimrc and we can read the old value. | |
1146 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if | |
1147 * they can be reset. This reduces startup time when using X on a remote | |
1148 * machine. | |
1149 */ | |
1150 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1151 set_title_defaults(void) |
7 | 1152 { |
1153 int idx1; | |
1154 long val; | |
1155 | |
1156 /* | |
1157 * If GUI is (going to be) used, we can always set the window title and | |
1158 * icon name. Saves a bit of time, because the X11 display server does | |
1159 * not need to be contacted. | |
1160 */ | |
1161 idx1 = findoption((char_u *)"title"); | |
838 | 1162 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 1163 { |
1164 #ifdef FEAT_GUI | |
1165 if (gui.starting || gui.in_use) | |
1166 val = TRUE; | |
1167 else | |
1168 #endif | |
1169 val = mch_can_restore_title(); | |
840 | 1170 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 1171 p_title = val; |
1172 } | |
1173 idx1 = findoption((char_u *)"icon"); | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1174 if (idx1 < 0 || (options[idx1].flags & P_WAS_SET)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1175 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1176 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1177 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1178 |
7 | 1179 #ifdef FEAT_GUI |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1180 if (gui.starting || gui.in_use) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1181 val = TRUE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1182 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1183 #endif |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1184 val = mch_can_restore_icon(); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1185 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1186 p_icon = val; |
7 | 1187 } |
1188 | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1189 void |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1190 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
|
1191 { |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1192 int flags = 0; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1193 |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1194 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
|
1195 flags = OPT_LOCAL; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1196 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
|
1197 flags = OPT_GLOBAL; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1198 #if defined(FEAT_EVAL) && defined(FEAT_BROWSE) |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22242
diff
changeset
|
1199 if ((cmdmod.cmod_flags & CMOD_BROWSE) && flags == 0) |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1200 ex_options(eap); |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1201 else |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1202 #endif |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1203 { |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1204 if (eap->forceit) |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1205 flags |= OPT_ONECOLUMN; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1206 (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
|
1207 } |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1208 } |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1209 |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1210 typedef enum { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1211 OP_NONE = 0, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1212 OP_ADDING, // "opt+=arg" |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1213 OP_PREPENDING, // "opt^=arg" |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1214 OP_REMOVING, // "opt-=arg" |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1215 } set_op_T; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1216 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1217 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1218 * Part of do_set() for string options. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1219 * Returns FAIL on failure, do not process further options. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1220 */ |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1221 static int |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1222 do_set_string( |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1223 int opt_idx, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1224 int opt_flags, |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1225 char_u **argp, |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1226 int nextchar, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1227 set_op_T op_arg, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1228 int flags, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1229 int cp_val, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1230 char_u *varp_arg, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1231 char *errbuf, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1232 int *value_checked, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1233 char **errmsg) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1234 { |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1235 char_u *arg = *argp; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1236 set_op_T op = op_arg; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1237 char_u *varp = varp_arg; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1238 char_u *save_arg = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1239 char_u *s = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1240 char_u *oldval = NULL; // previous value if *varp |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1241 char_u *newval; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1242 char_u *origval = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1243 char_u *origval_l = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1244 char_u *origval_g = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1245 #if defined(FEAT_EVAL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1246 char_u *saved_origval = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1247 char_u *saved_origval_l = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1248 char_u *saved_origval_g = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1249 char_u *saved_newval = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1250 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1251 unsigned newlen; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1252 int comma; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1253 char_u whichwrap[80]; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1254 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1255 // When using ":set opt=val" for a global option |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1256 // with a local value the local value will be |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1257 // reset, use the global value here. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1258 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1259 && ((int)options[opt_idx].indir & PV_BOTH)) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1260 varp = options[opt_idx].var; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1261 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1262 // The old value is kept until we are sure that the new value is valid. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1263 oldval = *(char_u **)varp; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1264 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1265 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1266 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1267 origval_l = *(char_u **)get_varp_scope( |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1268 &(options[opt_idx]), OPT_LOCAL); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1269 origval_g = *(char_u **)get_varp_scope( |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1270 &(options[opt_idx]), OPT_GLOBAL); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1271 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1272 // A global-local string option might have an empty option as value to |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1273 // indicate that the global value should be used. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1274 if (((int)options[opt_idx].indir & PV_BOTH) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1275 && origval_l == empty_option) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1276 origval_l = origval_g; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1277 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1278 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1279 // When setting the local value of a global option, the old value may be |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1280 // the global value. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1281 if (((int)options[opt_idx].indir & PV_BOTH) && (opt_flags & OPT_LOCAL)) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1282 origval = *(char_u **)get_varp(&options[opt_idx]); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1283 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1284 origval = oldval; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1285 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1286 if (nextchar == '&') // set to default val |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1287 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1288 newval = options[opt_idx].def_val[((flags & P_VI_DEF) || cp_val) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1289 ? VI_DEFAULT : VIM_DEFAULT]; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1290 if ((char_u **)varp == &p_bg) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1291 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1292 // guess the value of 'background' |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1293 #ifdef FEAT_GUI |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1294 if (gui.in_use) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1295 newval = gui_bg_default(); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1296 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1297 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1298 newval = term_bg_default(); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1299 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1300 else if ((char_u **)varp == &p_fencs && enc_utf8) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1301 newval = fencs_utf8_default; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1302 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1303 // expand environment variables and ~ since the default value was |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1304 // already expanded, only required when an environment variable was set |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1305 // later |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1306 if (newval == NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1307 newval = empty_option; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1308 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1309 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1310 s = option_expand(opt_idx, newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1311 if (s == NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1312 s = newval; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1313 newval = vim_strsave(s); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1314 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1315 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1316 else if (nextchar == '<') // set to global val |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1317 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1318 newval = vim_strsave(*(char_u **)get_varp_scope( |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1319 &(options[opt_idx]), OPT_GLOBAL)); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1320 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1321 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1322 { |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1323 ++arg; // jump to after the '=' or ':' |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1324 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1325 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1326 * Set 'keywordprg' to ":help" if an empty |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1327 * value was passed to :set by the user. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1328 */ |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1329 if (varp == (char_u *)&p_kp && (*arg == NUL || *arg == ' ')) |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1330 { |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1331 save_arg = arg; |
30417
6a1862bfb280
patch 9.0.0544: minor issues with setting a string option
Bram Moolenaar <Bram@vim.org>
parents:
30409
diff
changeset
|
1332 arg = (char_u *)":help"; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1333 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1334 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1335 * Convert 'backspace' number to string, for |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1336 * adding, prepending and removing string. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1337 */ |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1338 else if (varp == (char_u *)&p_bs && VIM_ISDIGIT(**(char_u **)varp)) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1339 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1340 int i = getdigits((char_u **)varp); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1341 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1342 switch (i) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1343 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1344 case 0: |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1345 *(char_u **)varp = empty_option; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1346 break; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1347 case 1: |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1348 *(char_u **)varp = vim_strsave((char_u *)"indent,eol"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1349 break; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1350 case 2: |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1351 *(char_u **)varp = vim_strsave( |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1352 (char_u *)"indent,eol,start"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1353 break; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1354 case 3: |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1355 *(char_u **)varp = vim_strsave( |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1356 (char_u *)"indent,eol,nostop"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1357 break; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1358 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1359 vim_free(oldval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1360 if (origval == oldval) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1361 origval = *(char_u **)varp; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1362 if (origval_l == oldval) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1363 origval_l = *(char_u **)varp; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1364 if (origval_g == oldval) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1365 origval_g = *(char_u **)varp; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1366 oldval = *(char_u **)varp; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1367 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1368 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1369 * Convert 'whichwrap' number to string, for backwards compatibility |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1370 * with Vim 3.0. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1371 */ |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1372 else if (varp == (char_u *)&p_ww && VIM_ISDIGIT(*arg)) |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1373 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1374 *whichwrap = NUL; |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1375 int i = getdigits(&arg); |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1376 if (i & 1) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1377 STRCAT(whichwrap, "b,"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1378 if (i & 2) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1379 STRCAT(whichwrap, "s,"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1380 if (i & 4) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1381 STRCAT(whichwrap, "h,l,"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1382 if (i & 8) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1383 STRCAT(whichwrap, "<,>,"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1384 if (i & 16) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1385 STRCAT(whichwrap, "[,],"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1386 if (*whichwrap != NUL) // remove trailing , |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1387 whichwrap[STRLEN(whichwrap) - 1] = NUL; |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1388 save_arg = arg; |
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1389 arg = (char_u *)whichwrap; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1390 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1391 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1392 * Remove '>' before 'dir' and 'bdir', for backwards compatibility with |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1393 * version 3.0 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1394 */ |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1395 else if (*arg == '>' && (varp == (char_u *)&p_dir |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1396 || varp == (char_u *)&p_bdir)) |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1397 ++arg; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1398 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1399 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1400 * Copy the new string into allocated memory. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1401 * Can't use set_string_option_direct(), because we need to remove the |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1402 * backslashes. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1403 */ |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1404 // get a bit too much |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1405 newlen = (unsigned)STRLEN(arg) + 1; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1406 if (op != OP_NONE) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1407 newlen += (unsigned)STRLEN(origval) + 1; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1408 newval = alloc(newlen); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1409 if (newval == NULL) // out of mem, don't change |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1410 return FAIL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1411 s = newval; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1412 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1413 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1414 * Copy the string, skip over escaped chars. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1415 * For MS-DOS and WIN32 backslashes before normal file name characters |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1416 * are not removed, and keep backslash at start, for "\\machine\path", |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1417 * but do remove it for "\\\\machine\\path". |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1418 * The reverse is found in ExpandOldSetting(). |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1419 */ |
30417
6a1862bfb280
patch 9.0.0544: minor issues with setting a string option
Bram Moolenaar <Bram@vim.org>
parents:
30409
diff
changeset
|
1420 while (*arg != NUL && !VIM_ISWHITE(*arg)) |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1421 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1422 int i; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1423 |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1424 if (*arg == '\\' && arg[1] != NUL |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1425 #ifdef BACKSLASH_IN_FILENAME |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1426 && !((flags & P_EXPAND) |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1427 && vim_isfilec(arg[1]) |
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1428 && !VIM_ISWHITE(arg[1]) |
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1429 && (arg[1] != '\\' |
30417
6a1862bfb280
patch 9.0.0544: minor issues with setting a string option
Bram Moolenaar <Bram@vim.org>
parents:
30409
diff
changeset
|
1430 || (s == newval && arg[2] != '\\'))) |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1431 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1432 ) |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1433 ++arg; // remove backslash |
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1434 if (has_mbyte && (i = (*mb_ptr2len)(arg)) > 1) |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1435 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1436 // copy multibyte char |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1437 mch_memmove(s, arg, (size_t)i); |
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1438 arg += i; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1439 s += i; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1440 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1441 else |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1442 *s++ = *arg++; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1443 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1444 *s = NUL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1445 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1446 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1447 * Expand environment variables and ~. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1448 * Don't do it when adding without inserting a comma. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1449 */ |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1450 if (op == OP_NONE || (flags & P_COMMA)) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1451 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1452 s = option_expand(opt_idx, newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1453 if (s != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1454 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1455 vim_free(newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1456 newlen = (unsigned)STRLEN(s) + 1; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1457 if (op != OP_NONE) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1458 newlen += (unsigned)STRLEN(origval) + 1; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1459 newval = alloc(newlen); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1460 if (newval == NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1461 return FAIL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1462 STRCPY(newval, s); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1463 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1464 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1465 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1466 // locate newval[] in origval[] when removing it |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1467 // and when adding to avoid duplicates |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1468 int len = 0; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1469 if (op == OP_REMOVING || (flags & P_NODUP)) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1470 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1471 len = (int)STRLEN(newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1472 s = find_dup_item(origval, newval, flags); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1473 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1474 // do not add if already there |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1475 if ((op == OP_ADDING || op == OP_PREPENDING) && s != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1476 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1477 op = OP_NONE; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1478 STRCPY(newval, origval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1479 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1480 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1481 // if no duplicate, move pointer to end of original value |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1482 if (s == NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1483 s = origval + (int)STRLEN(origval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1484 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1485 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1486 // concatenate the two strings; add a ',' if needed |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1487 if (op == OP_ADDING || op == OP_PREPENDING) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1488 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1489 comma = ((flags & P_COMMA) && *origval != NUL && *newval != NUL); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1490 if (op == OP_ADDING) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1491 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1492 len = (int)STRLEN(origval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1493 // strip a trailing comma, would get 2 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1494 if (comma && len > 1 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1495 && (flags & P_ONECOMMA) == P_ONECOMMA |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1496 && origval[len - 1] == ',' |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1497 && origval[len - 2] != '\\') |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1498 len--; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1499 mch_memmove(newval + len + comma, newval, STRLEN(newval) + 1); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1500 mch_memmove(newval, origval, (size_t)len); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1501 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1502 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1503 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1504 len = (int)STRLEN(newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1505 STRMOVE(newval + len + comma, origval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1506 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1507 if (comma) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1508 newval[len] = ','; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1509 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1510 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1511 // Remove newval[] from origval[]. (Note: "len" has been set above and |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1512 // is used here). |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1513 if (op == OP_REMOVING) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1514 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1515 STRCPY(newval, origval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1516 if (*s) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1517 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1518 // may need to remove a comma |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1519 if (flags & P_COMMA) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1520 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1521 if (s == origval) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1522 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1523 // include comma after string |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1524 if (s[len] == ',') |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1525 ++len; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1526 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1527 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1528 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1529 // include comma before string |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1530 --s; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1531 ++len; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1532 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1533 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1534 STRMOVE(newval + (s - origval), s + len); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1535 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1536 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1537 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1538 if (flags & P_FLAGLIST) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1539 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1540 // Remove flags that appear twice. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1541 for (s = newval; *s;) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1542 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1543 // if options have P_FLAGLIST and P_ONECOMMA such as |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1544 // 'whichwrap' |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1545 if (flags & P_ONECOMMA) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1546 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1547 if (*s != ',' && *(s + 1) == ',' |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1548 && vim_strchr(s + 2, *s) != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1549 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1550 // Remove the duplicated value and the next comma. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1551 STRMOVE(s, s + 2); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1552 continue; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1553 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1554 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1555 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1556 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1557 if ((!(flags & P_COMMA) || *s != ',') |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1558 && vim_strchr(s + 1, *s) != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1559 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1560 STRMOVE(s, s + 1); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1561 continue; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1562 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1563 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1564 ++s; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1565 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1566 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1567 |
30417
6a1862bfb280
patch 9.0.0544: minor issues with setting a string option
Bram Moolenaar <Bram@vim.org>
parents:
30409
diff
changeset
|
1568 if (save_arg != NULL) |
6a1862bfb280
patch 9.0.0544: minor issues with setting a string option
Bram Moolenaar <Bram@vim.org>
parents:
30409
diff
changeset
|
1569 arg = save_arg; // arg was temporarily changed, restore it |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1570 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1571 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1572 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1573 * Set the new value. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1574 */ |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1575 *(char_u **)(varp) = newval; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1576 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1577 #if defined(FEAT_EVAL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1578 if (!starting |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1579 # ifdef FEAT_CRYPT |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1580 && options[opt_idx].indir != PV_KEY |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1581 # endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1582 && origval != NULL && newval != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1583 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1584 // origval may be freed by did_set_string_option(), make a copy. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1585 saved_origval = vim_strsave(origval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1586 // newval (and varp) may become invalid if the buffer is closed by |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1587 // autocommands. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1588 saved_newval = vim_strsave(newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1589 if (origval_l != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1590 saved_origval_l = vim_strsave(origval_l); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1591 if (origval_g != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1592 saved_origval_g = vim_strsave(origval_g); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1593 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1594 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1595 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1596 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1597 long_u *p = insecure_flag(opt_idx, opt_flags); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1598 int secure_saved = secure; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1599 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1600 // When an option is set in the sandbox, from a modeline or in secure |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1601 // mode, then deal with side effects in secure mode. Also when the |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1602 // value was set with the P_INSECURE flag and is not completely |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1603 // replaced. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1604 if ((opt_flags & OPT_MODELINE) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1605 #ifdef HAVE_SANDBOX |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1606 || sandbox != 0 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1607 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1608 || (op != OP_NONE && (*p & P_INSECURE))) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1609 secure = 1; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1610 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1611 // Handle side effects, and set the global value for ":set" on local |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1612 // options. Note: when setting 'syntax' or 'filetype' autocommands may |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1613 // be triggered that can cause havoc. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1614 *errmsg = did_set_string_option( |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1615 opt_idx, (char_u **)varp, oldval, errbuf, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1616 opt_flags, value_checked); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1617 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1618 secure = secure_saved; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1619 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1620 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1621 #if defined(FEAT_EVAL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1622 if (*errmsg == NULL) |
31259
a7dba627a21b
patch 9.0.0963: function name does not match autocmd event name
Bram Moolenaar <Bram@vim.org>
parents:
31174
diff
changeset
|
1623 trigger_optionset_string(opt_idx, opt_flags, saved_origval, |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1624 saved_origval_l, saved_origval_g, saved_newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1625 vim_free(saved_origval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1626 vim_free(saved_origval_l); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1627 vim_free(saved_origval_g); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1628 vim_free(saved_newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1629 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1630 |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1631 *argp = arg; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1632 return *errmsg == NULL ? OK : FAIL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1633 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1634 |
7 | 1635 /* |
1636 * Parse 'arg' for option settings. | |
1637 * | |
1638 * 'arg' may be IObuff, but only when no errors can be present and option | |
1639 * does not need to be expanded with option_expand(). | |
1640 * "opt_flags": | |
1641 * 0 for ":set" | |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
1642 * OPT_GLOBAL for ":setglobal" |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
1643 * OPT_LOCAL for ":setlocal" and a modeline |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
1644 * OPT_MODELINE for a modeline |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
1645 * OPT_WINONLY to only set window-local options |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
1646 * OPT_NOWIN to skip setting window-local options |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
1647 * OPT_ONECOLUMN do not use multiple columns |
7 | 1648 * |
1649 * returns FAIL if an error is detected, OK otherwise | |
1650 */ | |
1651 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1652 do_set( |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
1653 char_u *arg_start, // option string (may be written to!) |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1654 int opt_flags) |
7 | 1655 { |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
1656 char_u *arg = arg_start; |
7 | 1657 int opt_idx; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1658 char *errmsg; |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1659 char errbuf[80]; |
7 | 1660 char_u *startarg; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1661 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
|
1662 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
|
1663 int afterchar; // character just after option name |
7 | 1664 int len; |
1665 int i; | |
9389
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
1666 varnumber_T value; |
7 | 1667 int key; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1668 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
|
1669 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
|
1670 int did_show = FALSE; // already showed one value |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1671 set_op_T op = 0; |
7 | 1672 int cp_val = 0; |
1673 char_u key_name[2]; | |
1674 | |
1675 if (*arg == NUL) | |
1676 { | |
1677 showoptions(0, opt_flags); | |
168 | 1678 did_show = TRUE; |
1679 goto theend; | |
7 | 1680 } |
1681 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1682 while (*arg != NUL) // loop to process all options |
7 | 1683 { |
1684 errmsg = NULL; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1685 startarg = arg; // remember for error message |
7 | 1686 |
31766
9f1504e36ae9
patch 9.0.1215: using isalpha() adds dependency on current locale
Bram Moolenaar <Bram@vim.org>
parents:
31752
diff
changeset
|
1687 if (STRNCMP(arg, "all", 3) == 0 && !ASCII_ISALPHA(arg[3]) |
36 | 1688 && !(opt_flags & OPT_MODELINE)) |
7 | 1689 { |
1690 /* | |
1691 * ":set all" show all options. | |
1692 * ":set all&" set all options to their default value. | |
1693 */ | |
1694 arg += 3; | |
1695 if (*arg == '&') | |
1696 { | |
1697 ++arg; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1698 // Only for :set command set global value of local options. |
7 | 1699 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
|
1700 didset_options(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
1701 didset_options2(); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1702 redraw_all_later(UPD_CLEAR); |
7 | 1703 } |
1704 else | |
168 | 1705 { |
7 | 1706 showoptions(1, opt_flags); |
168 | 1707 did_show = TRUE; |
1708 } | |
7 | 1709 } |
36 | 1710 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) |
7 | 1711 { |
1712 showoptions(2, opt_flags); | |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
1713 show_termcodes(opt_flags); |
168 | 1714 did_show = TRUE; |
7 | 1715 arg += 7; |
1716 } | |
1717 else | |
1718 { | |
1719 prefix = 1; | |
1911 | 1720 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0) |
7 | 1721 { |
1722 prefix = 0; | |
1723 arg += 2; | |
1724 } | |
1725 else if (STRNCMP(arg, "inv", 3) == 0) | |
1726 { | |
1727 prefix = 2; | |
1728 arg += 3; | |
1729 } | |
1730 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1731 // find end of name |
7 | 1732 key = 0; |
1733 if (*arg == '<') | |
1734 { | |
1735 opt_idx = -1; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1736 // look out for <t_>;> |
7 | 1737 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) |
1738 len = 5; | |
1739 else | |
1740 { | |
1741 len = 1; | |
1742 while (arg[len] != NUL && arg[len] != '>') | |
1743 ++len; | |
1744 } | |
1745 if (arg[len] != '>') | |
1746 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
1747 errmsg = e_invalid_argument; |
7 | 1748 goto skip; |
1749 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1750 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
|
1751 if (arg[1] == 't' && arg[2] == '_') // could be term code |
7 | 1752 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
|
1753 arg[len++] = '>'; // restore '>' |
7 | 1754 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
|
1755 key = find_key_option(arg + 1, TRUE); |
7 | 1756 } |
1757 else | |
1758 { | |
1759 len = 0; | |
1760 /* | |
1761 * The two characters after "t_" may not be alphanumeric. | |
1762 */ | |
1763 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
1764 len = 4; | |
1765 else | |
1766 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') | |
1767 ++len; | |
1768 nextchar = arg[len]; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1769 arg[len] = NUL; // put NUL after name |
7 | 1770 opt_idx = findoption(arg); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1771 arg[len] = nextchar; // restore nextchar |
7 | 1772 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
|
1773 key = find_key_option(arg, FALSE); |
7 | 1774 } |
1775 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1776 // remember character after option name |
7 | 1777 afterchar = arg[len]; |
1778 | |
25176
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1779 if (in_vim9script()) |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1780 { |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1781 char_u *p = skipwhite(arg + len); |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1782 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1783 // disallow white space before =val, +=val, -=val, ^=val |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1784 if (p > arg + len && (p[0] == '=' |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1785 || (vim_strchr((char_u *)"+-^", p[0]) != NULL |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1786 && p[1] == '='))) |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1787 { |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1788 errmsg = e_no_white_space_allowed_between_option_and; |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1789 arg = p; |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1790 startarg = p; |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1791 goto skip; |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1792 } |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1793 } |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
1794 else |
24968
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24912
diff
changeset
|
1795 // skip white space, allow ":set ai ?", ":set hlsearch !" |
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24912
diff
changeset
|
1796 while (VIM_ISWHITE(arg[len])) |
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24912
diff
changeset
|
1797 ++len; |
7 | 1798 |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1799 op = OP_NONE; |
7 | 1800 if (arg[len] != NUL && arg[len + 1] == '=') |
1801 { | |
1802 if (arg[len] == '+') | |
1803 { | |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1804 op = OP_ADDING; // "+=" |
7 | 1805 ++len; |
1806 } | |
1807 else if (arg[len] == '^') | |
1808 { | |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1809 op = OP_PREPENDING; // "^=" |
7 | 1810 ++len; |
1811 } | |
1812 else if (arg[len] == '-') | |
1813 { | |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1814 op = OP_REMOVING; // "-=" |
7 | 1815 ++len; |
1816 } | |
1817 } | |
1818 nextchar = arg[len]; | |
1819 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1820 if (opt_idx == -1 && key == 0) // found a mismatch: skip |
7 | 1821 { |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
1822 if (in_vim9script() && arg > arg_start |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
1823 && vim_strchr((char_u *)"!&<", *arg) != NULL) |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
1824 errmsg = e_no_white_space_allowed_between_option_and; |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
1825 else |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
1826 errmsg = e_unknown_option; |
7 | 1827 goto skip; |
1828 } | |
1829 | |
1830 if (opt_idx >= 0) | |
1831 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1832 if (options[opt_idx].var == NULL) // hidden option: skip |
7 | 1833 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1834 // 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
|
1835 // a hidden option, ignore setting it. |
7 | 1836 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL |
1837 && (!(options[opt_idx].flags & P_BOOL) | |
1838 || nextchar == '?')) | |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
1839 errmsg = e_option_not_supported; |
7 | 1840 goto skip; |
1841 } | |
1842 | |
1843 flags = options[opt_idx].flags; | |
1844 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | |
1845 } | |
1846 else | |
1847 { | |
1848 flags = P_STRING; | |
1849 if (key < 0) | |
1850 { | |
1851 key_name[0] = KEY2TERMCAP0(key); | |
1852 key_name[1] = KEY2TERMCAP1(key); | |
1853 } | |
1854 else | |
1855 { | |
1856 key_name[0] = KS_KEY; | |
1857 key_name[1] = (key & 0xff); | |
1858 } | |
1859 } | |
1860 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1861 // 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
|
1862 // an already loaded buffer in a window). |
634 | 1863 if ((opt_flags & OPT_WINONLY) |
1864 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) | |
1865 goto skip; | |
1866 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1867 // Skip all options that are window-local (used for :vimgrep). |
717 | 1868 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0 |
1869 && options[opt_idx].var == VAR_WIN) | |
1870 goto skip; | |
1871 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1872 // Disallow changing some options from modelines. |
1807 | 1873 if (opt_flags & OPT_MODELINE) |
7 | 1874 { |
2317
2b2cd34569eb
Disallow setting 'enc' in a modeline. (Patrick Texier)
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
1875 if (flags & (P_SECURE | P_NO_ML)) |
1807 | 1876 { |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
1877 errmsg = e_not_allowed_in_modeline; |
1807 | 1878 goto skip; |
1879 } | |
16728
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1880 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
|
1881 { |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
1882 errmsg = e_not_allowed_in_modeline_when_modelineexpr_is_off; |
16728
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1883 goto skip; |
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1884 } |
1810 | 1885 #ifdef FEAT_DIFF |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1886 // 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
|
1887 // '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
|
1888 // "wrap" gets set. |
1807 | 1889 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
|
1890 && 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
|
1891 && ( |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1892 #ifdef FEAT_FOLDING |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1893 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
|
1894 #endif |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1895 options[opt_idx].indir == PV_WRAP)) |
1807 | 1896 goto skip; |
1810 | 1897 #endif |
7 | 1898 } |
1899 | |
1900 #ifdef HAVE_SANDBOX | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1901 // Disallow changing some options in the sandbox |
634 | 1902 if (sandbox != 0 && (flags & P_SECURE)) |
7 | 1903 { |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25176
diff
changeset
|
1904 errmsg = e_not_allowed_in_sandbox; |
7 | 1905 goto skip; |
1906 } | |
1907 #endif | |
1908 | |
1909 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) | |
1910 { | |
1911 arg += len; | |
1912 cp_val = p_cp; | |
1913 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') | |
1914 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1915 if (arg[3] == 'm') // "opt&vim": set to Vim default |
7 | 1916 { |
1917 cp_val = FALSE; | |
1918 arg += 3; | |
1919 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1920 else // "opt&vi": set to Vi default |
7 | 1921 { |
1922 cp_val = TRUE; | |
1923 arg += 2; | |
1924 } | |
1925 } | |
1926 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
|
1927 && arg[1] != NUL && !VIM_ISWHITE(arg[1])) |
7 | 1928 { |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
1929 errmsg = e_trailing_characters; |
7 | 1930 goto skip; |
1931 } | |
1932 } | |
1933 | |
1934 /* | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
1935 * allow '=' and ':' for historical reasons (MSDOS command.com |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
1936 * allows only one '=' character per "set" command line. grrr. (jw) |
7 | 1937 */ |
1938 if (nextchar == '?' | |
1939 || (prefix == 1 | |
1940 && vim_strchr((char_u *)"=:&<", nextchar) == NULL | |
1941 && !(flags & P_BOOL))) | |
1942 { | |
1943 /* | |
1944 * print value | |
1945 */ | |
1946 if (did_show) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1947 msg_putchar('\n'); // cursor below last one |
7 | 1948 else |
1949 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1950 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
|
1951 did_show = TRUE; // remember that we did a line |
7 | 1952 } |
1953 if (opt_idx >= 0) | |
1954 { | |
1955 showoneopt(&options[opt_idx], opt_flags); | |
1956 #ifdef FEAT_EVAL | |
1957 if (p_verbose > 0) | |
694 | 1958 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1959 // Mention where the option was last set. |
694 | 1960 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
|
1961 last_set_msg(options[opt_idx].script_ctx); |
694 | 1962 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
|
1963 last_set_msg(curwin->w_p_script_ctx[ |
694 | 1964 (int)options[opt_idx].indir & PV_MASK]); |
1965 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
|
1966 last_set_msg(curbuf->b_p_script_ctx[ |
694 | 1967 (int)options[opt_idx].indir & PV_MASK]); |
1968 } | |
7 | 1969 #endif |
1970 } | |
1971 else | |
1972 { | |
1973 char_u *p; | |
1974 | |
1975 p = find_termcode(key_name); | |
1976 if (p == NULL) | |
1977 { | |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
1978 errmsg = e_key_code_not_set; |
7 | 1979 goto skip; |
1980 } | |
1981 else | |
1982 (void)show_one_termcode(key_name, p, TRUE); | |
1983 } | |
1984 if (nextchar != '?' | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1985 && nextchar != NUL && !VIM_ISWHITE(afterchar)) |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
1986 errmsg = e_trailing_characters; |
7 | 1987 } |
1988 else | |
1989 { | |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
1990 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
|
1991 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1992 if (flags & P_BOOL) // boolean |
7 | 1993 { |
1994 if (nextchar == '=' || nextchar == ':') | |
1995 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
1996 errmsg = e_invalid_argument; |
7 | 1997 goto skip; |
1998 } | |
1999 | |
2000 /* | |
2001 * ":set opt!": invert | |
2002 * ":set opt&": reset to default value | |
2003 * ":set opt<": reset to global value | |
2004 */ | |
2005 if (nextchar == '!') | |
2006 value = *(int *)(varp) ^ 1; | |
2007 else if (nextchar == '&') | |
840 | 2008 value = (int)(long)(long_i)options[opt_idx].def_val[ |
7 | 2009 ((flags & P_VI_DEF) || cp_val) |
2010 ? VI_DEFAULT : VIM_DEFAULT]; | |
2011 else if (nextchar == '<') | |
2012 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2013 // For 'autoread' -1 means to use global value. |
7 | 2014 if ((int *)varp == &curbuf->b_p_ar |
2015 && opt_flags == OPT_LOCAL) | |
2016 value = -1; | |
2017 else | |
2018 value = *(int *)get_varp_scope(&(options[opt_idx]), | |
2019 OPT_GLOBAL); | |
2020 } | |
2021 else | |
2022 { | |
2023 /* | |
2024 * ":set invopt": invert | |
2025 * ":set opt" or ":set noopt": set or reset | |
2026 */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2027 if (nextchar != NUL && !VIM_ISWHITE(afterchar)) |
7 | 2028 { |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
2029 errmsg = e_trailing_characters; |
7 | 2030 goto skip; |
2031 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2032 if (prefix == 2) // inv |
7 | 2033 value = *(int *)(varp) ^ 1; |
2034 else | |
2035 value = prefix; | |
2036 } | |
2037 | |
2038 errmsg = set_bool_option(opt_idx, varp, (int)value, | |
2039 opt_flags); | |
2040 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2041 else // numeric or string |
7 | 2042 { |
2043 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL | |
2044 || prefix != 1) | |
2045 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
2046 errmsg = e_invalid_argument; |
7 | 2047 goto skip; |
2048 } | |
2049 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2050 if (flags & P_NUM) // numeric |
7 | 2051 { |
2052 /* | |
2053 * Different ways to set a number option: | |
2054 * & set to default value | |
2055 * < set to global value | |
2056 * <xx> accept special key codes for 'wildchar' | |
2057 * c accept any non-digit for 'wildchar' | |
2058 * [-]0-9 set number | |
2059 * other error | |
2060 */ | |
2061 ++arg; | |
2062 if (nextchar == '&') | |
840 | 2063 value = (long)(long_i)options[opt_idx].def_val[ |
7 | 2064 ((flags & P_VI_DEF) || cp_val) |
2065 ? VI_DEFAULT : VIM_DEFAULT]; | |
2066 else if (nextchar == '<') | |
5446 | 2067 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2068 // 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
|
2069 // use the global value. |
5446 | 2070 if ((long *)varp == &curbuf->b_p_ul |
2071 && opt_flags == OPT_LOCAL) | |
2072 value = NO_LOCAL_UNDOLEVEL; | |
2073 else | |
2074 value = *(long *)get_varp_scope( | |
2075 &(options[opt_idx]), OPT_GLOBAL); | |
2076 } | |
7 | 2077 else if (((long *)varp == &p_wc |
2078 || (long *)varp == &p_wcm) | |
2079 && (*arg == '<' | |
2080 || *arg == '^' | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2081 || (*arg != NUL |
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2082 && (!arg[1] || VIM_ISWHITE(arg[1])) |
7 | 2083 && !VIM_ISDIGIT(*arg)))) |
2084 { | |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2085 value = string_to_key(arg, FALSE); |
7 | 2086 if (value == 0 && (long *)varp != &p_wcm) |
2087 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
2088 errmsg = e_invalid_argument; |
7 | 2089 goto skip; |
2090 } | |
2091 } | |
2092 else if (*arg == '-' || VIM_ISDIGIT(*arg)) | |
2093 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2094 // 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
|
2095 // hex numbers. |
7447
ad432f8f68fb
commit https://github.com/vim/vim/commit/887c1fea4a114e7170091942d0446c8882701b5b
Christian Brabandt <cb@256bit.org>
parents:
7426
diff
changeset
|
2096 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
|
2097 &value, NULL, 0, TRUE); |
17039
d726d8cce996
patch 8.1.1519: 'backupskip' may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
16843
diff
changeset
|
2098 if (i == 0 || (arg[i] != NUL |
d726d8cce996
patch 8.1.1519: 'backupskip' may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
16843
diff
changeset
|
2099 && !VIM_ISWHITE(arg[i]))) |
7 | 2100 { |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
2101 errmsg = e_number_required_after_equal; |
7 | 2102 goto skip; |
2103 } | |
2104 } | |
2105 else | |
2106 { | |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
2107 errmsg = e_number_required_after_equal; |
7 | 2108 goto skip; |
2109 } | |
2110 | |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2111 if (op == OP_ADDING) |
7 | 2112 value = *(long *)varp + value; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2113 else if (op == OP_PREPENDING) |
7 | 2114 value = *(long *)varp * value; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2115 else if (op == OP_REMOVING) |
7 | 2116 value = *(long *)varp - value; |
2117 errmsg = set_num_option(opt_idx, varp, value, | |
274 | 2118 errbuf, sizeof(errbuf), opt_flags); |
7 | 2119 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2120 else if (opt_idx >= 0) // string |
7 | 2121 { |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2122 if (do_set_string(opt_idx, opt_flags, &arg, nextchar, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2123 op, flags, cp_val, varp, errbuf, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2124 &value_checked, &errmsg) == FAIL) |
7 | 2125 { |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2126 if (errmsg != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2127 goto skip; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2128 break; |
7 | 2129 } |
2130 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2131 else // key code option |
7 | 2132 { |
2133 char_u *p; | |
2134 | |
2135 if (nextchar == '&') | |
2136 { | |
2137 if (add_termcap_entry(key_name, TRUE) == FAIL) | |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
2138 errmsg = e_not_found_in_termcap; |
7 | 2139 } |
2140 else | |
2141 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2142 ++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
|
2143 for (p = arg; *p && !VIM_ISWHITE(*p); ++p) |
7 | 2144 if (*p == '\\' && p[1] != NUL) |
2145 ++p; | |
2146 nextchar = *p; | |
2147 *p = NUL; | |
2148 add_termcode(key_name, arg, FALSE); | |
2149 *p = nextchar; | |
2150 } | |
2151 if (full_screen) | |
2152 ttest(FALSE); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
2153 redraw_all_later(UPD_CLEAR); |
7 | 2154 } |
2155 } | |
634 | 2156 |
7 | 2157 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
|
2158 did_set_option( |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2159 opt_idx, opt_flags, op == OP_NONE, value_checked); |
7 | 2160 } |
2161 | |
2162 skip: | |
2163 /* | |
2164 * Advance to next argument. | |
2165 * - skip until a blank found, taking care of backslashes | |
2166 * - skip blanks | |
2167 * - skip one "=val" argument (for hidden options ":set gfn =xx") | |
2168 */ | |
2169 for (i = 0; i < 2 ; ++i) | |
2170 { | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2171 while (*arg != NUL && !VIM_ISWHITE(*arg)) |
7 | 2172 if (*arg++ == '\\' && *arg != NUL) |
2173 ++arg; | |
2174 arg = skipwhite(arg); | |
2175 if (*arg != '=') | |
2176 break; | |
2177 } | |
2178 } | |
2179 | |
2180 if (errmsg != NULL) | |
2181 { | |
419 | 2182 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1); |
835 | 2183 i = (int)STRLEN(IObuff) + 2; |
7 | 2184 if (i + (arg - startarg) < IOSIZE) |
2185 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2186 // append the argument with the error |
7 | 2187 STRCAT(IObuff, ": "); |
2188 mch_memmove(IObuff + i, startarg, (arg - startarg)); | |
2189 IObuff[i + (arg - startarg)] = NUL; | |
2190 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2191 // make sure all characters are printable |
7 | 2192 trans_characters(IObuff, IOSIZE); |
2193 | |
29960
4fcf816aa806
patch 9.0.0318: clearing screen causes flicker
Bram Moolenaar <Bram@vim.org>
parents:
29879
diff
changeset
|
2194 ++no_wait_return; // wait_return() done later |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2195 emsg((char *)IObuff); // show error highlighted |
7 | 2196 --no_wait_return; |
2197 | |
2198 return FAIL; | |
2199 } | |
2200 | |
2201 arg = skipwhite(arg); | |
2202 } | |
2203 | |
168 | 2204 theend: |
2205 if (silent_mode && did_show) | |
2206 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2207 // After displaying option values in silent mode. |
168 | 2208 silent_mode = FALSE; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2209 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
168 | 2210 msg_putchar('\n'); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2211 cursor_on(); // msg_start() switches it off |
168 | 2212 out_flush(); |
2213 silent_mode = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2214 info_message = FALSE; // use mch_msg(), not mch_errmsg() |
168 | 2215 } |
2216 | |
7 | 2217 return OK; |
2218 } | |
2219 | |
634 | 2220 /* |
2221 * Call this when an option has been given a new value through a user command. | |
2222 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag. | |
2223 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2224 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2225 did_set_option( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2226 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
|
2227 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
|
2228 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
|
2229 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
|
2230 // P_INSECURE flag. |
634 | 2231 { |
681 | 2232 long_u *p; |
2233 | |
634 | 2234 options[opt_idx].flags |= P_WAS_SET; |
2235 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2236 // 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
|
2237 // 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
|
2238 // flag. |
681 | 2239 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
|
2240 if (!value_checked && (secure |
634 | 2241 #ifdef HAVE_SANDBOX |
2242 || sandbox != 0 | |
2243 #endif | |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2244 || (opt_flags & OPT_MODELINE))) |
681 | 2245 *p = *p | P_INSECURE; |
2246 else if (new_value) | |
2247 *p = *p & ~P_INSECURE; | |
634 | 2248 } |
2249 | |
7 | 2250 /* |
2251 * Convert a key name or string into a key value. | |
2252 * 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
|
2253 * 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
|
2254 */ |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2255 int |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2256 string_to_key(char_u *arg, int multi_byte) |
7 | 2257 { |
2258 if (*arg == '<') | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
2259 return find_key_option(arg + 1, TRUE); |
7 | 2260 if (*arg == '^') |
2261 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
|
2262 if (multi_byte) |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2263 return PTR2CHAR(arg); |
7 | 2264 return *arg; |
2265 } | |
2266 | |
2267 /* | |
2268 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call | |
2269 * maketitle() to create and display it. | |
2270 * When switching the title or icon off, call mch_restore_title() to get | |
2271 * the old value back. | |
2272 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2273 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
|
2274 did_set_title(void) |
7 | 2275 { |
2276 if (starting != NO_SCREEN | |
2277 #ifdef FEAT_GUI | |
2278 && !gui.starting | |
2279 #endif | |
2280 ) | |
2281 maketitle(); | |
2282 } | |
2283 | |
2284 /* | |
2285 * set_options_bin - called when 'bin' changes value. | |
2286 */ | |
2287 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2288 set_options_bin( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2289 int oldval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2290 int newval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2291 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 2292 { |
2293 /* | |
2294 * The option values that are changed when 'bin' changes are | |
2295 * copied when 'bin is set and restored when 'bin' is reset. | |
2296 */ | |
2297 if (newval) | |
2298 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2299 if (!oldval) // switched on |
7 | 2300 { |
2301 if (!(opt_flags & OPT_GLOBAL)) | |
2302 { | |
2303 curbuf->b_p_tw_nobin = curbuf->b_p_tw; | |
2304 curbuf->b_p_wm_nobin = curbuf->b_p_wm; | |
2305 curbuf->b_p_ml_nobin = curbuf->b_p_ml; | |
2306 curbuf->b_p_et_nobin = curbuf->b_p_et; | |
2307 } | |
2308 if (!(opt_flags & OPT_LOCAL)) | |
2309 { | |
2310 p_tw_nobin = p_tw; | |
2311 p_wm_nobin = p_wm; | |
2312 p_ml_nobin = p_ml; | |
2313 p_et_nobin = p_et; | |
2314 } | |
2315 } | |
2316 | |
2317 if (!(opt_flags & OPT_GLOBAL)) | |
2318 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2319 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
|
2320 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
|
2321 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
|
2322 curbuf->b_p_et = 0; // no expandtab |
7 | 2323 } |
2324 if (!(opt_flags & OPT_LOCAL)) | |
2325 { | |
2326 p_tw = 0; | |
2327 p_wm = 0; | |
2328 p_ml = FALSE; | |
2329 p_et = FALSE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2330 p_bin = TRUE; // needed when called for the "-b" argument |
7 | 2331 } |
2332 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2333 else if (oldval) // switched off |
7 | 2334 { |
2335 if (!(opt_flags & OPT_GLOBAL)) | |
2336 { | |
2337 curbuf->b_p_tw = curbuf->b_p_tw_nobin; | |
2338 curbuf->b_p_wm = curbuf->b_p_wm_nobin; | |
2339 curbuf->b_p_ml = curbuf->b_p_ml_nobin; | |
2340 curbuf->b_p_et = curbuf->b_p_et_nobin; | |
2341 } | |
2342 if (!(opt_flags & OPT_LOCAL)) | |
2343 { | |
2344 p_tw = p_tw_nobin; | |
2345 p_wm = p_wm_nobin; | |
2346 p_ml = p_ml_nobin; | |
2347 p_et = p_et_nobin; | |
2348 } | |
2349 } | |
2350 } | |
2351 | |
2352 /* | |
2353 * Expand environment variables for some string options. | |
2354 * These string options cannot be indirect! | |
2355 * If "val" is NULL expand the current value of the option. | |
2356 * Return pointer to NameBuff, or NULL when not expanded. | |
2357 */ | |
2358 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2359 option_expand(int opt_idx, char_u *val) |
7 | 2360 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2361 // if option doesn't need expansion nothing to do |
7 | 2362 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) |
2363 return NULL; | |
2364 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2365 // 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
|
2366 // expand_env() would truncate the string. |
7 | 2367 if (val != NULL && STRLEN(val) > MAXPATHL) |
2368 return NULL; | |
2369 | |
2370 if (val == NULL) | |
2371 val = *(char_u **)options[opt_idx].var; | |
2372 | |
2373 /* | |
2374 * Expanding this with NameBuff, expand_env() must not be passed IObuff. | |
2375 * Escape spaces when expanding 'tags', they are used to separate file | |
2376 * names. | |
374 | 2377 * For 'spellsuggest' expand after "file:". |
7 | 2378 */ |
2379 expand_env_esc(val, NameBuff, MAXPATHL, | |
1408 | 2380 (char_u **)options[opt_idx].var == &p_tags, FALSE, |
744 | 2381 #ifdef FEAT_SPELL |
374 | 2382 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : |
2383 #endif | |
2384 NULL); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2385 if (STRCMP(NameBuff, val) == 0) // they are the same |
7 | 2386 return NULL; |
2387 | |
2388 return NameBuff; | |
2389 } | |
2390 | |
2391 /* | |
2392 * After setting various option values: recompute variables that depend on | |
2393 * option values. | |
2394 */ | |
2395 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2396 didset_options(void) |
7 | 2397 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2398 // initialize the table for 'iskeyword' et.al. |
7 | 2399 (void)init_chartab(); |
2400 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2401 didset_string_options(); |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2402 |
744 | 2403 #ifdef FEAT_SPELL |
484 | 2404 (void)spell_check_msm(); |
374 | 2405 (void)spell_check_sps(); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
2406 (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
|
2407 (void)did_set_spell_option(TRUE); |
344 | 2408 #endif |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2409 // set cedit_key |
7 | 2410 (void)check_cedit(); |
5995 | 2411 #ifdef FEAT_LINEBREAK |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2412 // initialize the table for 'breakat'. |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2413 fill_breakat_flags(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2414 #endif |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2415 after_copy_winopt(curwin); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2416 } |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2417 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2418 /* |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2419 * More side effects of setting options. |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2420 */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2421 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2422 didset_options2(void) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2423 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2424 // Initialize the highlight_attr[] table. |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2425 (void)highlight_changed(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2426 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2427 // Parse default for 'wildmode' |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2428 check_opt_wim(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2429 |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2430 // Parse default for 'listchars'. |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2431 (void)set_chars_option(curwin, &curwin->w_p_lcs, TRUE); |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2432 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2433 // Parse default for 'fillchars'. |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2434 (void)set_chars_option(curwin, &curwin->w_p_fcs, TRUE); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2435 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2436 #ifdef FEAT_CLIPBOARD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2437 // Parse default for 'clipboard' |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2438 (void)check_clipboard_option(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2439 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2440 #ifdef FEAT_VARTABS |
15858
3a45b89639fb
patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2441 vim_free(curbuf->b_p_vsts_array); |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
2442 (void)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
|
2443 vim_free(curbuf->b_p_vts_array); |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
2444 (void)tabstop_set(curbuf->b_p_vts, &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
|
2445 #endif |
7 | 2446 } |
2447 | |
2448 /* | |
2449 * Check for string options that are NULL (normally only termcap options). | |
2450 */ | |
2451 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2452 check_options(void) |
7 | 2453 { |
2454 int opt_idx; | |
2455 | |
2456 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) | |
2457 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL) | |
2458 check_string_option((char_u **)get_varp(&(options[opt_idx]))); | |
2459 } | |
2460 | |
2461 /* | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2462 * 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
|
2463 * 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
|
2464 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2465 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2466 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
|
2467 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2468 int opt_idx; |
7 | 2469 |
2470 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) | |
2471 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
|
2472 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
|
2473 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
|
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 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2476 /* |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2477 * 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
|
2478 * 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
|
2479 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2480 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2481 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
|
2482 { |
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 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
|
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 (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
|
2486 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
|
2487 return opt_idx; |
7 | 2488 } |
2489 | |
634 | 2490 #if defined(FEAT_EVAL) || defined(PROTO) |
2491 /* | |
2492 * Return TRUE when option "opt" was set from a modeline or in secure mode. | |
2493 * Return FALSE when it wasn't. | |
2494 * Return -1 for an unknown option. | |
2495 */ | |
2496 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2497 was_set_insecurely(char_u *opt, int opt_flags) |
634 | 2498 { |
2499 int idx = findoption(opt); | |
681 | 2500 long_u *flagp; |
634 | 2501 |
2502 if (idx >= 0) | |
681 | 2503 { |
2504 flagp = insecure_flag(idx, opt_flags); | |
2505 return (*flagp & P_INSECURE) != 0; | |
2506 } | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
2507 internal_error("was_set_insecurely()"); |
634 | 2508 return -1; |
2509 } | |
681 | 2510 |
2511 /* | |
2512 * Get a pointer to the flags used for the P_INSECURE flag of option | |
2513 * "opt_idx". For some local options a local flags field is used. | |
23821
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
2514 * NOTE: Caller must make sure that "curwin" is set to the window from which |
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
2515 * the option is used. |
681 | 2516 */ |
2517 static long_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2518 insecure_flag(int opt_idx, int opt_flags) |
681 | 2519 { |
2520 if (opt_flags & OPT_LOCAL) | |
2521 switch ((int)options[opt_idx].indir) | |
2522 { | |
2523 #ifdef FEAT_STL_OPT | |
694 | 2524 case PV_STL: return &curwin->w_p_stl_flags; |
681 | 2525 #endif |
2526 #ifdef FEAT_EVAL | |
885 | 2527 # ifdef FEAT_FOLDING |
694 | 2528 case PV_FDE: return &curwin->w_p_fde_flags; |
2529 case PV_FDT: return &curwin->w_p_fdt_flags; | |
885 | 2530 # endif |
790 | 2531 # ifdef FEAT_BEVAL |
2532 case PV_BEXPR: return &curbuf->b_p_bexpr_flags; | |
2533 # endif | |
694 | 2534 case PV_INDE: return &curbuf->b_p_inde_flags; |
2535 case PV_FEX: return &curbuf->b_p_fex_flags; | |
681 | 2536 # ifdef FEAT_FIND_ID |
694 | 2537 case PV_INEX: return &curbuf->b_p_inex_flags; |
681 | 2538 # endif |
2539 #endif | |
2540 } | |
2541 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2542 // Nothing special, return global flags field. |
681 | 2543 return &options[opt_idx].flags; |
2544 } | |
634 | 2545 #endif |
2546 | |
1805 | 2547 /* |
2548 * Redraw the window title and/or tab page text later. | |
2549 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2550 void redraw_titles(void) |
1805 | 2551 { |
2552 need_maketitle = TRUE; | |
2553 redraw_tabline = TRUE; | |
2554 } | |
2555 | |
7 | 2556 /* |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2557 * 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
|
2558 * 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
|
2559 */ |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17845
diff
changeset
|
2560 int |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2561 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
|
2562 { |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2563 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
|
2564 |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2565 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
|
2566 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
|
2567 return FALSE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2568 return TRUE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2569 } |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2570 |
681 | 2571 #if defined(FEAT_EVAL) || defined(PROTO) |
2572 /* | |
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
|
2573 * Set the script_ctx for an option, taking care of setting the buffer- or |
694 | 2574 * window-local value. |
681 | 2575 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2576 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
|
2577 set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx) |
694 | 2578 { |
2579 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; | |
2580 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
|
2581 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
|
2582 |
20269
246101db63a4
patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents:
20237
diff
changeset
|
2583 // Modeline already has the line number set. |
246101db63a4
patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents:
20237
diff
changeset
|
2584 if (!(opt_flags & OPT_MODELINE)) |
246101db63a4
patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents:
20237
diff
changeset
|
2585 new_script_ctx.sc_lnum += SOURCING_LNUM; |
694 | 2586 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2587 // 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
|
2588 // in the buffer or window structure. |
694 | 2589 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
|
2590 options[opt_idx].script_ctx = new_script_ctx; |
694 | 2591 if (both || (opt_flags & OPT_LOCAL)) |
2592 { | |
2593 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
|
2594 curbuf->b_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
694 | 2595 else if (indir & PV_WIN) |
27289
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
2596 { |
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
|
2597 curwin->w_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
27289
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
2598 if (both) |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
2599 // also setting the "all buffers" value |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
2600 curwin->w_allbuf_opt.wo_script_ctx[indir & PV_MASK] = |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
2601 new_script_ctx; |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
2602 } |
694 | 2603 } |
681 | 2604 } |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2605 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2606 /* |
27303
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2607 * Get the script context of global option "name". |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2608 * |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2609 */ |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2610 sctx_T * |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2611 get_option_sctx(char *name) |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2612 { |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2613 int idx = findoption((char_u *)name); |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2614 |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2615 if (idx >= 0) |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2616 return &options[idx].script_ctx; |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2617 siemsg("no such option: %s", name); |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2618 return NULL; |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2619 } |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2620 |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2621 /* |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2622 * 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
|
2623 * "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
|
2624 * 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
|
2625 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2626 void |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2627 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
|
2628 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2629 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
|
2630 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
|
2631 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2632 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
|
2633 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
|
2634 else |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2635 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2636 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
|
2637 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
|
2638 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
|
2639 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
|
2640 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
|
2641 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
|
2642 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2643 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
|
2644 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
|
2645 } |
681 | 2646 #endif |
2647 | |
19405
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2648 #if defined(FEAT_EVAL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2649 /* |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2650 * Apply the OptionSet autocommand. |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2651 */ |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2652 static void |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2653 apply_optionset_autocmd( |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2654 int opt_idx, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2655 long opt_flags, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2656 long oldval, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2657 long oldval_g, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2658 long newval, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2659 char *errmsg) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2660 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2661 char_u buf_old[12], buf_old_global[12], buf_new[12], buf_type[12]; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2662 |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2663 // Don't do this while starting up, failure or recursively. |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2664 if (starting || errmsg != NULL || *get_vim_var_str(VV_OPTION_TYPE) != NUL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2665 return; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2666 |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2667 vim_snprintf((char *)buf_old, sizeof(buf_old), "%ld", oldval); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2668 vim_snprintf((char *)buf_old_global, sizeof(buf_old_global), "%ld", |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2669 oldval_g); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2670 vim_snprintf((char *)buf_new, sizeof(buf_new), "%ld", newval); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2671 vim_snprintf((char *)buf_type, sizeof(buf_type), "%s", |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2672 (opt_flags & OPT_LOCAL) ? "local" : "global"); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2673 set_vim_var_string(VV_OPTION_NEW, buf_new, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2674 set_vim_var_string(VV_OPTION_OLD, buf_old, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2675 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2676 if (opt_flags & OPT_LOCAL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2677 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2678 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2679 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2680 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2681 if (opt_flags & OPT_GLOBAL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2682 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2683 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2684 set_vim_var_string(VV_OPTION_OLDGLOBAL, buf_old, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2685 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2686 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2687 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2688 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2689 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2690 set_vim_var_string(VV_OPTION_OLDGLOBAL, buf_old_global, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2691 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2692 if (opt_flags & OPT_MODELINE) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2693 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2694 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2695 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2696 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2697 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2698 NULL, FALSE, NULL); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2699 reset_v_option_vars(); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2700 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2701 #endif |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2702 |
7 | 2703 /* |
2704 * Set the value of a boolean option, and take care of side effects. | |
2705 * Returns NULL for success, or an error message for an error. | |
2706 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2707 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2708 set_bool_option( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2709 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
|
2710 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
|
2711 int value, // new value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2712 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 2713 { |
2714 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
|
2715 #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
|
2716 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
|
2717 #endif |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
2718 char *errmsg = NULL; |
7 | 2719 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2720 // Disallow changing some options from secure mode |
7 | 2721 if ((secure |
2722 #ifdef HAVE_SANDBOX | |
2723 || sandbox != 0 | |
2724 #endif | |
2725 ) && (options[opt_idx].flags & P_SECURE)) | |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
2726 return e_not_allowed_here; |
7 | 2727 |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
2728 #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
|
2729 // 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
|
2730 // 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
|
2731 // 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
|
2732 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
|
2733 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
|
2734 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
|
2735 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2736 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2737 *(int *)varp = value; // set the new value |
7 | 2738 #ifdef FEAT_EVAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2739 // 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
|
2740 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 2741 #endif |
2742 | |
634 | 2743 #ifdef FEAT_GUI |
2744 need_mouse_correct = TRUE; | |
2745 #endif | |
2746 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2747 // May set global value for local option. |
7 | 2748 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
2749 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; | |
2750 | |
2751 /* | |
2752 * Handle side effects of changing a bool option. | |
2753 */ | |
2754 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2755 // 'compatible' |
7 | 2756 if ((int *)varp == &p_cp) |
2757 compatible_set(); | |
2758 | |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2759 #ifdef FEAT_LANGMAP |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2760 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
|
2761 // 'langremap' -> !'langnoremap' |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2762 p_lnr = !p_lrm; |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2763 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
|
2764 // 'langnoremap' -> !'langremap' |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2765 p_lrm = !p_lnr; |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2766 #endif |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2767 |
3246 | 2768 #ifdef FEAT_PERSISTENT_UNDO |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2769 // 'undofile' |
3246 | 2770 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) |
2771 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2772 // 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
|
2773 // 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
|
2774 // any changes in between. |
3894 | 2775 if (curbuf->b_p_udf || p_udf) |
2776 { | |
2777 char_u hash[UNDO_HASH_SIZE]; | |
2778 buf_T *save_curbuf = curbuf; | |
2779 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
2780 FOR_ALL_BUFFERS(curbuf) |
3894 | 2781 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2782 // 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
|
2783 // 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
|
2784 // 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
|
2785 // loaded |
3894 | 2786 if ((curbuf == save_curbuf |
3246 | 2787 || (opt_flags & OPT_GLOBAL) || opt_flags == 0) |
3894 | 2788 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) |
2789 { | |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2790 #ifdef FEAT_CRYPT |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2791 if (crypt_get_method_nr(curbuf) == CRYPT_M_SOD) |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2792 continue; |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2793 #endif |
3894 | 2794 u_compute_hash(hash); |
2795 u_read_undo(NULL, hash, curbuf->b_fname); | |
2796 } | |
2797 } | |
2798 curbuf = save_curbuf; | |
2799 } | |
3246 | 2800 } |
2801 #endif | |
2802 | |
7 | 2803 else if ((int *)varp == &curbuf->b_p_ro) |
2804 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2805 // when 'readonly' is reset globally, also reset readonlymode |
7 | 2806 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) |
2807 readonlymode = FALSE; | |
548 | 2808 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2809 // when 'readonly' is set may give W10 again |
548 | 2810 if (curbuf->b_p_ro) |
2811 curbuf->b_did_warn = FALSE; | |
2812 | |
1805 | 2813 redraw_titles(); |
7 | 2814 } |
2815 | |
2362
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2816 #ifdef FEAT_GUI |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2817 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
|
2818 { |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2819 if (!p_mh) |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2820 gui_mch_mousehide(FALSE); |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2821 } |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2822 #endif |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2823 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2824 // when 'modifiable' is changed, redraw the window title |
7 | 2825 else if ((int *)varp == &curbuf->b_p_ma) |
1805 | 2826 { |
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
|
2827 # ifdef FEAT_TERMINAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2828 // 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
|
2829 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
|
2830 && 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
|
2831 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2832 curbuf->b_p_ma = FALSE; |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
2833 return e_cannot_make_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
|
2834 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2835 # endif |
1805 | 2836 redraw_titles(); |
26336
a2e6da79274d
patch 8.2.3699: the +title feature adds a lot of #ifdef but little code
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
2837 } |
31000
2a1a4a13b396
patch 9.0.0835: the window title is not redrawn when 'endoffile' changes
Bram Moolenaar <Bram@vim.org>
parents:
30966
diff
changeset
|
2838 // redraw the window title and tab page text when 'endoffile', 'endofline', |
2a1a4a13b396
patch 9.0.0835: the window title is not redrawn when 'endoffile' changes
Bram Moolenaar <Bram@vim.org>
parents:
30966
diff
changeset
|
2839 // 'fixeol' or 'bomb' is changed |
2a1a4a13b396
patch 9.0.0835: the window title is not redrawn when 'endoffile' changes
Bram Moolenaar <Bram@vim.org>
parents:
30966
diff
changeset
|
2840 else if ((int *)varp == &curbuf->b_p_eof |
2a1a4a13b396
patch 9.0.0835: the window title is not redrawn when 'endoffile' changes
Bram Moolenaar <Bram@vim.org>
parents:
30966
diff
changeset
|
2841 || (int *)varp == &curbuf->b_p_eol |
2a1a4a13b396
patch 9.0.0835: the window title is not redrawn when 'endoffile' changes
Bram Moolenaar <Bram@vim.org>
parents:
30966
diff
changeset
|
2842 || (int *)varp == &curbuf->b_p_fixeol |
2a1a4a13b396
patch 9.0.0835: the window title is not redrawn when 'endoffile' changes
Bram Moolenaar <Bram@vim.org>
parents:
30966
diff
changeset
|
2843 || (int *)varp == &curbuf->b_p_bomb) |
1805 | 2844 { |
2845 redraw_titles(); | |
2846 } | |
7 | 2847 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2848 // when 'bin' is set also set some other options |
7 | 2849 else if ((int *)varp == &curbuf->b_p_bin) |
2850 { | |
2851 set_options_bin(old_value, curbuf->b_p_bin, opt_flags); | |
1805 | 2852 redraw_titles(); |
7 | 2853 } |
2854 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2855 // when 'buflisted' changes, trigger autocommands |
7 | 2856 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) |
2857 { | |
2858 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, | |
2859 NULL, NULL, TRUE, curbuf); | |
2860 } | |
2861 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2862 // when 'swf' is set, create swapfile, when reset remove swapfile |
7 | 2863 else if ((int *)varp == &curbuf->b_p_swf) |
2864 { | |
2865 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
|
2866 ml_open_file(curbuf); // create the swap file |
7 | 2867 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2868 // 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
|
2869 // buf->b_p_swf |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2870 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
|
2871 } |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2872 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2873 // when 'terse' is set change 'shortmess' |
7 | 2874 else if ((int *)varp == &p_terse) |
2875 { | |
2876 char_u *p; | |
2877 | |
2878 p = vim_strchr(p_shm, SHM_SEARCH); | |
2879 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2880 // insert 's' in p_shm |
7 | 2881 if (p_terse && p == NULL) |
2882 { | |
2883 STRCPY(IObuff, p_shm); | |
2884 STRCAT(IObuff, "s"); | |
694 | 2885 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); |
7 | 2886 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2887 // remove 's' from p_shm |
7 | 2888 else if (!p_terse && p != NULL) |
1622 | 2889 STRMOVE(p, p + 1); |
7 | 2890 } |
2891 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2892 // when 'paste' is set or reset also change other options |
7 | 2893 else if ((int *)varp == &p_paste) |
2894 { | |
2895 paste_option_changed(); | |
2896 } | |
2897 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2898 // when 'insertmode' is set from an autocommand need to do work here |
7 | 2899 else if ((int *)varp == &p_im) |
2900 { | |
2901 if (p_im) | |
2902 { | |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
2903 if ((State & MODE_INSERT) == 0) |
7 | 2904 need_start_insertmode = TRUE; |
2905 stop_insert_mode = FALSE; | |
2906 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2907 // 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
|
2908 else if (old_value) |
7 | 2909 { |
2910 need_start_insertmode = FALSE; | |
2911 stop_insert_mode = TRUE; | |
644 | 2912 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
|
2913 clear_cmdline = TRUE; // remove "(insert)" |
7 | 2914 restart_edit = 0; |
2915 } | |
2916 } | |
2917 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2918 // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw |
7 | 2919 else if ((int *)varp == &p_ic && p_hls) |
2920 { | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
2921 redraw_all_later(UPD_SOME_VALID); |
7 | 2922 } |
2923 | |
2924 #ifdef FEAT_SEARCH_EXTRA | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2925 // when 'hlsearch' is set or reset: reset no_hlsearch |
7 | 2926 else if ((int *)varp == &p_hls) |
2927 { | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13774
diff
changeset
|
2928 set_no_hlsearch(FALSE); |
7 | 2929 } |
2930 #endif | |
2931 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2932 // 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
|
2933 // at the end of normal_cmd() |
7 | 2934 else if ((int *)varp == &curwin->w_p_scb) |
2935 { | |
2936 if (curwin->w_p_scb) | |
5157
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2937 { |
7 | 2938 do_check_scrollbind(FALSE); |
5157
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2939 curwin->w_scbind_pos = curwin->w_topline; |
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2940 } |
7 | 2941 } |
2942 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
2943 #if defined(FEAT_QUICKFIX) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2944 // There can be only one window with 'previewwindow' set. |
7 | 2945 else if ((int *)varp == &curwin->w_p_pvw) |
2946 { | |
2947 if (curwin->w_p_pvw) | |
2948 { | |
2949 win_T *win; | |
2950 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
2951 FOR_ALL_WINDOWS(win) |
7 | 2952 if (win->w_p_pvw && win != curwin) |
2953 { | |
2954 curwin->w_p_pvw = FALSE; | |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
2955 return e_preview_window_already_exists; |
7 | 2956 } |
2957 } | |
2958 } | |
2959 #endif | |
2960 | |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
2961 else if ((int *)varp == &curwin->w_p_sms) |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
2962 { |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
2963 if (!curwin->w_p_sms) |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
2964 { |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
2965 curwin->w_skipcol = 0; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
2966 changed_line_abv_curs(); |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
2967 } |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
2968 } |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
2969 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2970 // when 'textmode' is set or reset also change 'fileformat' |
7 | 2971 else if ((int *)varp == &curbuf->b_p_tx) |
2972 { | |
2973 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); | |
2974 } | |
2975 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2976 // when 'textauto' is set or reset also change 'fileformats' |
7 | 2977 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
|
2978 { |
7 | 2979 set_string_option_direct((char_u *)"ffs", -1, |
2980 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", | |
694 | 2981 OPT_FREE | opt_flags, 0); |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
16082
diff
changeset
|
2982 } |
7 | 2983 |
2984 /* | |
2985 * When 'lisp' option changes include/exclude '-' in | |
2986 * keyword characters. | |
2987 */ | |
2988 else if (varp == (char_u *)&(curbuf->b_p_lisp)) | |
2989 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2990 (void)buf_init_chartab(curbuf, FALSE); // ignore errors |
7 | 2991 } |
2992 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2993 // 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
|
2994 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
|
2995 { |
1d25a3e8e03c
patch 8.1.0061: window title is wrong after resetting and setting 'title'
Christian Brabandt <cb@256bit.org>
parents:
14057
diff
changeset
|
2996 did_set_title(); |
7 | 2997 } |
2998 | |
2999 else if ((int *)varp == &curbuf->b_changed) | |
3000 { | |
3001 if (!value) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3002 save_file_ff(curbuf); // Buffer is unchanged |
1805 | 3003 redraw_titles(); |
7 | 3004 modified_was_set = value; |
3005 } | |
3006 | |
3007 #ifdef BACKSLASH_IN_FILENAME | |
3008 else if ((int *)varp == &p_ssl) | |
3009 { | |
3010 if (p_ssl) | |
3011 { | |
3012 psepc = '/'; | |
3013 psepcN = '\\'; | |
3014 pseps[0] = '/'; | |
3015 } | |
3016 else | |
3017 { | |
3018 psepc = '\\'; | |
3019 psepcN = '/'; | |
3020 pseps[0] = '\\'; | |
3021 } | |
3022 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3023 // need to adjust the file name arguments and buffer names. |
7 | 3024 buflist_slash_adjust(); |
3025 alist_slash_adjust(); | |
3026 # ifdef FEAT_EVAL | |
3027 scriptnames_slash_adjust(); | |
3028 # endif | |
3029 } | |
3030 #endif | |
3031 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3032 // If 'wrap' is set, set w_leftcol to zero. |
7 | 3033 else if ((int *)varp == &curwin->w_p_wrap) |
3034 { | |
3035 if (curwin->w_p_wrap) | |
3036 curwin->w_leftcol = 0; | |
3037 } | |
3038 | |
3039 else if ((int *)varp == &p_ea) | |
3040 { | |
3041 if (p_ea && !old_value) | |
3042 win_equal(curwin, FALSE, 0); | |
3043 } | |
3044 | |
3045 else if ((int *)varp == &p_wiv) | |
3046 { | |
3047 /* | |
3048 * When 'weirdinvert' changed, set/reset 't_xs'. | |
3049 * Then set 'weirdinvert' according to value of 't_xs'. | |
3050 */ | |
3051 if (p_wiv && !old_value) | |
3052 T_XS = (char_u *)"y"; | |
3053 else if (!p_wiv && old_value) | |
3054 T_XS = empty_option; | |
3055 p_wiv = (*T_XS != NUL); | |
3056 } | |
3057 | |
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
|
3058 #ifdef FEAT_BEVAL_GUI |
7 | 3059 else if ((int *)varp == &p_beval) |
3060 { | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3061 if (!balloonEvalForTerm) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3062 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3063 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
|
3064 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
|
3065 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
|
3066 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
|
3067 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3068 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3069 #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
|
3070 #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
|
3071 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
|
3072 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3073 mch_bevalterm_changed(); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3074 } |
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
|
3075 #endif |
820 | 3076 |
3077 #ifdef FEAT_AUTOCHDIR | |
7 | 3078 else if ((int *)varp == &p_acd) |
3079 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3080 // 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
|
3081 DO_AUTOCHDIR; |
7 | 3082 } |
3083 #endif | |
3084 | |
3085 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3086 // 'diff' |
7 | 3087 else if ((int *)varp == &curwin->w_p_diff) |
3088 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3089 // May add or remove the buffer from the list of diff buffers. |
16 | 3090 diff_buf_adjust(curwin); |
3091 # ifdef FEAT_FOLDING | |
7 | 3092 if (foldmethodIsDiff(curwin)) |
3093 foldUpdateAll(curwin); | |
16 | 3094 # endif |
7 | 3095 } |
3096 #endif | |
3097 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3098 #ifdef HAVE_INPUT_METHOD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3099 // 'imdisable' |
7 | 3100 else if ((int *)varp == &p_imdisable) |
3101 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3102 // Only de-activate it here, it will be enabled when changing mode. |
7 | 3103 if (p_imdisable) |
3104 im_set_active(FALSE); | |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
3105 else if (State & MODE_INSERT) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3106 // 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
|
3107 // effect right away. |
3129 | 3108 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); |
7 | 3109 } |
3110 #endif | |
3111 | |
744 | 3112 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3113 // 'spell' |
258 | 3114 else if ((int *)varp == &curwin->w_p_spell) |
3115 { | |
3116 if (curwin->w_p_spell) | |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
3117 errmsg = did_set_spelllang(curwin); |
258 | 3118 } |
3119 #endif | |
3120 | |
7 | 3121 #ifdef FEAT_ARABIC |
3122 if ((int *)varp == &curwin->w_p_arab) | |
3123 { | |
3124 if (curwin->w_p_arab) | |
3125 { | |
3126 /* | |
3127 * 'arabic' is set, handle various sub-settings. | |
3128 */ | |
3129 if (!p_tbidi) | |
3130 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3131 // set rightleft mode |
7 | 3132 if (!curwin->w_p_rl) |
3133 { | |
3134 curwin->w_p_rl = TRUE; | |
3135 changed_window_setting(); | |
3136 } | |
3137 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3138 // Enable Arabic shaping (major part of what Arabic requires) |
7 | 3139 if (!p_arshape) |
3140 { | |
3141 p_arshape = TRUE; | |
3142 redraw_later_clear(); | |
3143 } | |
3144 } | |
3145 | |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
26721
diff
changeset
|
3146 // Arabic requires a utf-8 encoding, inform the user if it's not |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3147 // set. |
7 | 3148 if (STRCMP(p_enc, "utf-8") != 0) |
16 | 3149 { |
1848 | 3150 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); |
3151 | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
3152 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
|
3153 msg_attr(_(w_arabic), HL_ATTR(HLF_W)); |
1848 | 3154 #ifdef FEAT_EVAL |
3155 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); | |
3156 #endif | |
16 | 3157 } |
7 | 3158 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3159 // set 'delcombine' |
7 | 3160 p_deco = TRUE; |
3161 | |
3162 # ifdef FEAT_KEYMAP | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3163 // Force-set the necessary keymap for arabic |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
3164 errmsg = set_option_value((char_u *)"keymap", |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
3165 0L, (char_u *)"arabic", OPT_LOCAL); |
7 | 3166 # endif |
3167 } | |
3168 else | |
3169 { | |
3170 /* | |
3171 * 'arabic' is reset, handle various sub-settings. | |
3172 */ | |
3173 if (!p_tbidi) | |
3174 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3175 // reset rightleft mode |
7 | 3176 if (curwin->w_p_rl) |
3177 { | |
3178 curwin->w_p_rl = FALSE; | |
3179 changed_window_setting(); | |
3180 } | |
3181 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3182 // '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
|
3183 // another window may still need it "on". |
7 | 3184 } |
3185 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3186 // '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
|
3187 // window may still want it "on". |
7 | 3188 |
3189 # ifdef FEAT_KEYMAP | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3190 // Revert to the default keymap |
7 | 3191 curbuf->b_p_iminsert = B_IMODE_NONE; |
3192 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; | |
3193 # endif | |
3194 } | |
3443 | 3195 } |
3196 | |
1958 | 3197 #endif |
3198 | |
17827
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3199 #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
|
3200 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
|
3201 || (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
|
3202 && gui.in_use |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3203 && (*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
|
3204 && curbuf->b_signlist != NULL) |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3205 { |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3206 // 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
|
3207 // '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
|
3208 // 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
|
3209 // 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
|
3210 // '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
|
3211 // (optimization). |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3212 if (!(curwin->w_p_nu && ((int *)varp == &curwin->w_p_rnu))) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
3213 redraw_all_later(UPD_CLEAR); |
17827
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3214 } |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3215 #endif |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3216 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3217 #ifdef FEAT_TERMGUICOLORS |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3218 // 'termguicolors' |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3219 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
|
3220 { |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3221 # ifdef FEAT_VTP |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3222 // 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
|
3223 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
|
3224 # 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
|
3225 !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
|
3226 # 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
|
3227 !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
|
3228 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3229 p_tgc = 0; |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
3230 return e_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
|
3231 } |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3232 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
|
3233 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
|
3234 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3235 # ifdef FEAT_GUI |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3236 if (!gui.in_use && !gui.starting) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3237 # endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3238 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
|
3239 # ifdef FEAT_VTP |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3240 // 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
|
3241 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
|
3242 { |
2bebc49116fd
patch 8.1.0123: MS-Windows: colors are wrong after setting 'notgc'
Christian Brabandt <cb@256bit.org>
parents:
14194
diff
changeset
|
3243 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
|
3244 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
|
3245 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
|
3246 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3247 # endif |
26193
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26175
diff
changeset
|
3248 # ifdef FEAT_TERMINAL |
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26175
diff
changeset
|
3249 term_update_colors_all(); |
28919
99c1356f4210
patch 8.2.4982: colors in terminal window are not 100% correct
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
3250 term_update_palette_all(); |
26193
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26175
diff
changeset
|
3251 term_update_wincolor_all(); |
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26175
diff
changeset
|
3252 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3253 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3254 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3255 |
7 | 3256 /* |
3257 * End of handling side effects for bool options. | |
3258 */ | |
3259 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3260 // after handling side effects, call autocommand |
6935 | 3261 |
7 | 3262 options[opt_idx].flags |= P_WAS_SET; |
3263 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3264 #if defined(FEAT_EVAL) |
19405
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3265 apply_optionset_autocmd(opt_idx, opt_flags, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3266 (long)(old_value ? TRUE : FALSE), |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3267 (long)(old_global_value ? TRUE : FALSE), |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3268 (long)(value ? TRUE : FALSE), NULL); |
6935 | 3269 #endif |
3270 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3271 comp_col(); // in case 'ruler' or 'showcmd' changed |
3443 | 3272 if (curwin->w_curswant != MAXCOL |
6669 | 3273 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 3274 curwin->w_set_curswant = TRUE; |
24079
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3275 |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3276 if ((opt_flags & OPT_NO_REDRAW) == 0) |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3277 check_redraw(options[opt_idx].flags); |
7 | 3278 |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
3279 return errmsg; |
7 | 3280 } |
3281 | |
3282 /* | |
3283 * Set the value of a number option, and take care of side effects. | |
3284 * Returns NULL for success, or an error message for an error. | |
3285 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3286 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3287 set_num_option( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3288 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
|
3289 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
|
3290 long value, // new value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3291 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
|
3292 size_t errbuflen, // length of "errbuf" |
24079
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3293 int opt_flags) // OPT_LOCAL, OPT_GLOBAL, |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3294 // OPT_MODELINE, etc. |
7 | 3295 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3296 char *errmsg = NULL; |
7 | 3297 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
|
3298 #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
|
3299 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
|
3300 // 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
|
3301 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3302 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
|
3303 long old_Columns = Columns; // remember old Columns |
7 | 3304 long *pp = (long *)varp; |
3305 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3306 // Disallow changing some options from secure mode. |
634 | 3307 if ((secure |
3308 #ifdef HAVE_SANDBOX | |
3309 || sandbox != 0 | |
3310 #endif | |
3311 ) && (options[opt_idx].flags & P_SECURE)) | |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3312 return e_not_allowed_here; |
7 | 3313 |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3314 #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
|
3315 // Save the global value before changing anything. This is needed as for |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3316 // a global-only option setting the "local value" in fact sets the global |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3317 // 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
|
3318 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
|
3319 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
|
3320 OPT_GLOBAL); |
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3321 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3322 |
7 | 3323 *pp = value; |
3324 #ifdef FEAT_EVAL | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3325 // 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
|
3326 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 3327 #endif |
634 | 3328 #ifdef FEAT_GUI |
3329 need_mouse_correct = TRUE; | |
3330 #endif | |
7 | 3331 |
3740 | 3332 if (curbuf->b_p_sw < 0) |
7 | 3333 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3334 errmsg = e_argument_must_be_positive; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3335 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3336 // 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
|
3337 curbuf->b_p_sw = tabstop_count(curbuf->b_p_vts_array) > 0 |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
3338 ? tabstop_first(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
|
3339 : curbuf->b_p_ts; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3340 #else |
7 | 3341 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
|
3342 #endif |
7 | 3343 } |
3344 | |
3345 /* | |
3346 * Number options that need some action when changed | |
3347 */ | |
3348 if (pp == &p_wh || pp == &p_hh) | |
3349 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3350 // 'winheight' and 'helpheight' |
7 | 3351 if (p_wh < 1) |
3352 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3353 errmsg = e_argument_must_be_positive; |
7 | 3354 p_wh = 1; |
3355 } | |
3356 if (p_wmh > p_wh) | |
3357 { | |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3358 errmsg = e_winheight_cannot_be_smaller_than_winminheight; |
7 | 3359 p_wh = p_wmh; |
3360 } | |
3361 if (p_hh < 0) | |
3362 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3363 errmsg = e_argument_must_be_positive; |
7 | 3364 p_hh = 0; |
3365 } | |
3366 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3367 // Change window height NOW |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10340
diff
changeset
|
3368 if (!ONE_WINDOW) |
7 | 3369 { |
3370 if (pp == &p_wh && curwin->w_height < p_wh) | |
3371 win_setheight((int)p_wh); | |
3372 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) | |
3373 win_setheight((int)p_hh); | |
3374 } | |
3375 } | |
3376 else if (pp == &p_wmh) | |
3377 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3378 // 'winminheight' |
7 | 3379 if (p_wmh < 0) |
3380 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3381 errmsg = e_argument_must_be_positive; |
7 | 3382 p_wmh = 0; |
3383 } | |
3384 if (p_wmh > p_wh) | |
3385 { | |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3386 errmsg = e_winheight_cannot_be_smaller_than_winminheight; |
7 | 3387 p_wmh = p_wh; |
3388 } | |
3389 win_setminheight(); | |
3390 } | |
13 | 3391 else if (pp == &p_wiw) |
7 | 3392 { |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3393 // 'winwidth' |
7 | 3394 if (p_wiw < 1) |
3395 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3396 errmsg = e_argument_must_be_positive; |
7 | 3397 p_wiw = 1; |
3398 } | |
3399 if (p_wmw > p_wiw) | |
3400 { | |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3401 errmsg = e_winwidth_cannot_be_smaller_than_winminwidth; |
7 | 3402 p_wiw = p_wmw; |
3403 } | |
3404 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3405 // Change window width NOW |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10340
diff
changeset
|
3406 if (!ONE_WINDOW && curwin->w_width < p_wiw) |
7 | 3407 win_setwidth((int)p_wiw); |
3408 } | |
3409 else if (pp == &p_wmw) | |
3410 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3411 // 'winminwidth' |
7 | 3412 if (p_wmw < 0) |
3413 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3414 errmsg = e_argument_must_be_positive; |
7 | 3415 p_wmw = 0; |
3416 } | |
3417 if (p_wmw > p_wiw) | |
3418 { | |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3419 errmsg = e_winwidth_cannot_be_smaller_than_winminwidth; |
7 | 3420 p_wmw = p_wiw; |
3421 } | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3422 win_setminwidth(); |
7 | 3423 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
3424 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3425 // (re)set last window status line |
7 | 3426 else if (pp == &p_ls) |
3427 { | |
3428 last_status(FALSE); | |
3429 } | |
670 | 3430 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3431 // (re)set tab page line |
677 | 3432 else if (pp == &p_stal) |
670 | 3433 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3434 shell_new_rows(); // recompute window positions and heights |
670 | 3435 } |
7 | 3436 |
3437 #ifdef FEAT_GUI | |
3438 else if (pp == &p_linespace) | |
3439 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3440 // 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
|
3441 // same number of lines. |
444 | 3442 if (gui.in_use && gui_mch_adjust_charheight() == OK) |
813 | 3443 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); |
7 | 3444 } |
3445 #endif | |
3446 | |
3447 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3448 // 'foldlevel' |
7 | 3449 else if (pp == &curwin->w_p_fdl) |
3450 { | |
3451 if (curwin->w_p_fdl < 0) | |
3452 curwin->w_p_fdl = 0; | |
3453 newFoldLevel(); | |
3454 } | |
3455 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3456 // 'foldminlines' |
7 | 3457 else if (pp == &curwin->w_p_fml) |
3458 { | |
3459 foldUpdateAll(curwin); | |
3460 } | |
3461 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3462 // 'foldnestmax' |
7 | 3463 else if (pp == &curwin->w_p_fdn) |
3464 { | |
3465 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) | |
3466 foldUpdateAll(curwin); | |
3467 } | |
3468 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3469 // 'foldcolumn' |
7 | 3470 else if (pp == &curwin->w_p_fdc) |
3471 { | |
3472 if (curwin->w_p_fdc < 0) | |
3473 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3474 errmsg = e_argument_must_be_positive; |
7 | 3475 curwin->w_p_fdc = 0; |
3476 } | |
3477 else if (curwin->w_p_fdc > 12) | |
3478 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3479 errmsg = e_invalid_argument; |
7 | 3480 curwin->w_p_fdc = 12; |
3481 } | |
3482 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3483 #endif // FEAT_FOLDING |
5438 | 3484 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3485 // 'shiftwidth' or 'tabstop' |
7 | 3486 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) |
3487 { | |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
3488 #ifdef FEAT_FOLDING |
7 | 3489 if (foldmethodIsIndent(curwin)) |
3490 foldUpdateAll(curwin); | |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
3491 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3492 // 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
|
3493 // parse 'cinoptions'. |
5438 | 3494 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) |
3495 parse_cino(curbuf); | |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
3496 } |
7 | 3497 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3498 // 'maxcombine' |
714 | 3499 else if (pp == &p_mco) |
3500 { | |
3501 if (p_mco > MAX_MCO) | |
3502 p_mco = MAX_MCO; | |
3503 else if (p_mco < 0) | |
3504 p_mco = 0; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3505 screenclear(); // will re-allocate the screen |
714 | 3506 } |
3507 | |
7 | 3508 else if (pp == &curbuf->b_p_iminsert) |
3509 { | |
3510 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) | |
3511 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3512 errmsg = e_invalid_argument; |
7 | 3513 curbuf->b_p_iminsert = B_IMODE_NONE; |
3514 } | |
3515 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
|
3516 if (termcap_active) // don't do this in the alternate screen |
7 | 3517 showmode(); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
3518 #if defined(FEAT_KEYMAP) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3519 // Show/unshow value of 'keymap' in status lines. |
7 | 3520 status_redraw_curbuf(); |
3521 #endif | |
3522 } | |
3523 | |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3524 #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
|
3525 // 'imstyle' |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3526 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
|
3527 { |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3528 if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3529 errmsg = e_invalid_argument; |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3530 } |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3531 #endif |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3532 |
164 | 3533 else if (pp == &p_window) |
3534 { | |
3535 if (p_window < 1) | |
3536 p_window = 1; | |
3537 else if (p_window >= Rows) | |
3538 p_window = Rows - 1; | |
3539 } | |
3540 | |
7 | 3541 else if (pp == &curbuf->b_p_imsearch) |
3542 { | |
3543 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) | |
3544 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3545 errmsg = e_invalid_argument; |
7 | 3546 curbuf->b_p_imsearch = B_IMODE_NONE; |
3547 } | |
3548 p_imsearch = curbuf->b_p_imsearch; | |
3549 } | |
3550 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3551 // if 'titlelen' has changed, redraw the title |
7 | 3552 else if (pp == &p_titlelen) |
3553 { | |
3554 if (p_titlelen < 0) | |
3555 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3556 errmsg = e_argument_must_be_positive; |
7 | 3557 p_titlelen = 85; |
3558 } | |
3559 if (starting != NO_SCREEN && old_value != p_titlelen) | |
3560 need_maketitle = TRUE; | |
3561 } | |
3562 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3563 // if p_ch changed value, change the command line height |
7 | 3564 else if (pp == &p_ch) |
3565 { | |
30005
bb0e525e1393
patch 9.0.0340: the 'cmdheight' zero support causes too much trouble
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
3566 if (p_ch < 1) |
7 | 3567 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3568 errmsg = e_argument_must_be_positive; |
7 | 3569 p_ch = 1; |
3570 } | |
1404 | 3571 if (p_ch > Rows - min_rows() + 1) |
3572 p_ch = Rows - min_rows() + 1; | |
7 | 3573 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3574 // 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
|
3575 // completed. Otherwise the frame sizes may be wrong. |
30671
15ac28c12c8f
patch 9.0.0670: no space for command line when there is a tabline
Bram Moolenaar <Bram@vim.org>
parents:
30661
diff
changeset
|
3576 if ((p_ch != old_value |
15ac28c12c8f
patch 9.0.0670: no space for command line when there is a tabline
Bram Moolenaar <Bram@vim.org>
parents:
30661
diff
changeset
|
3577 || tabline_height() + topframe->fr_height != Rows - p_ch) |
30661
57ebc2a4d2ca
patch 9.0.0665: setting 'cmdheight' has no effect if last window was resized
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
3578 && full_screen |
7 | 3579 #ifdef FEAT_GUI |
3580 && !gui.starting | |
3581 #endif | |
30661
57ebc2a4d2ca
patch 9.0.0665: setting 'cmdheight' has no effect if last window was resized
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
3582 ) |
824 | 3583 command_height(); |
7 | 3584 } |
3585 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3586 // when 'updatecount' changes from zero to non-zero, open swap files |
7 | 3587 else if (pp == &p_uc) |
3588 { | |
3589 if (p_uc < 0) | |
3590 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3591 errmsg = e_argument_must_be_positive; |
7 | 3592 p_uc = 100; |
3593 } | |
3594 if (p_uc && !old_value) | |
3595 ml_open_files(); | |
3596 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3597 #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
|
3598 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
|
3599 { |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3600 if (curwin->w_p_cole < 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3601 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3602 errmsg = e_argument_must_be_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
|
3603 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
|
3604 } |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3605 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
|
3606 { |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3607 errmsg = e_invalid_argument; |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3608 curwin->w_p_cole = 3; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3609 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3610 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3611 #endif |
16 | 3612 #ifdef MZSCHEME_GUI_THREADS |
14 | 3613 else if (pp == &p_mzq) |
3614 mzvim_reset_timer(); | |
3615 #endif | |
7 | 3616 |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3617 #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
|
3618 // 'pyxversion' |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3619 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
|
3620 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3621 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3622 errmsg = e_invalid_argument; |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3623 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3624 #endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3625 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3626 // sync undo before 'undolevels' changes |
7 | 3627 else if (pp == &p_ul) |
3628 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3629 // use the old value, otherwise u_sync() may not work properly |
7 | 3630 p_ul = old_value; |
825 | 3631 u_sync(TRUE); |
7 | 3632 p_ul = value; |
3633 } | |
5446 | 3634 else if (pp == &curbuf->b_p_ul) |
3635 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3636 // use the old value, otherwise u_sync() may not work properly |
5446 | 3637 curbuf->b_p_ul = old_value; |
3638 u_sync(TRUE); | |
3639 curbuf->b_p_ul = value; | |
3640 } | |
7 | 3641 |
13 | 3642 #ifdef FEAT_LINEBREAK |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3643 // 'numberwidth' must be positive |
13 | 3644 else if (pp == &curwin->w_p_nuw) |
3645 { | |
3646 if (curwin->w_p_nuw < 1) | |
3647 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3648 errmsg = e_argument_must_be_positive; |
13 | 3649 curwin->w_p_nuw = 1; |
3650 } | |
17229
f1c7b7a4d9e4
patch 8.1.1614: 'numberwidth' can only go up to 10
Bram Moolenaar <Bram@vim.org>
parents:
17176
diff
changeset
|
3651 if (curwin->w_p_nuw > 20) |
13 | 3652 { |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3653 errmsg = e_invalid_argument; |
17229
f1c7b7a4d9e4
patch 8.1.1614: 'numberwidth' can only go up to 10
Bram Moolenaar <Bram@vim.org>
parents:
17176
diff
changeset
|
3654 curwin->w_p_nuw = 20; |
13 | 3655 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3656 curwin->w_nrwidth_line_count = 0; // trigger a redraw |
13 | 3657 } |
3658 #endif | |
3659 | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3660 else if (pp == &curbuf->b_p_tw) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3661 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3662 if (curbuf->b_p_tw < 0) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3663 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3664 errmsg = e_argument_must_be_positive; |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3665 curbuf->b_p_tw = 0; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3666 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3667 #ifdef FEAT_SYN_HL |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3668 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3669 win_T *wp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3670 tabpage_T *tp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3671 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3672 FOR_ALL_TAB_WINDOWS(tp, wp) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3673 check_colorcolumn(wp); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3674 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3675 #endif |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3676 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3677 |
7 | 3678 /* |
3679 * Check the bounds for numeric options here | |
3680 */ | |
3681 if (Rows < min_rows() && full_screen) | |
3682 { | |
3683 if (errbuf != NULL) | |
3684 { | |
27426
41e0dcf38521
patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents:
27303
diff
changeset
|
3685 vim_snprintf(errbuf, errbuflen, |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
3686 _(e_need_at_least_nr_lines), min_rows()); |
7 | 3687 errmsg = errbuf; |
3688 } | |
3689 Rows = min_rows(); | |
3690 } | |
3691 if (Columns < MIN_COLUMNS && full_screen) | |
3692 { | |
3693 if (errbuf != NULL) | |
3694 { | |
27426
41e0dcf38521
patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents:
27303
diff
changeset
|
3695 vim_snprintf(errbuf, errbuflen, |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
3696 _(e_need_at_least_nr_columns), MIN_COLUMNS); |
7 | 3697 errmsg = errbuf; |
3698 } | |
3699 Columns = MIN_COLUMNS; | |
3700 } | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
5039
diff
changeset
|
3701 limit_screen_size(); |
7 | 3702 |
3703 /* | |
3704 * If the screen (shell) height has been changed, assume it is the | |
3705 * physical screenheight. | |
3706 */ | |
3707 if (old_Rows != Rows || old_Columns != Columns) | |
3708 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3709 // Changing the screen size is not allowed while updating the screen. |
7 | 3710 if (updating_screen) |
3711 *pp = old_value; | |
3712 else if (full_screen | |
3713 #ifdef FEAT_GUI | |
3714 && !gui.starting | |
3715 #endif | |
3716 ) | |
3717 set_shellsize((int)Columns, (int)Rows, TRUE); | |
3718 else | |
3719 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3720 // 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
|
3721 // messages. |
7 | 3722 check_shellsize(); |
3723 if (cmdline_row > Rows - p_ch && Rows > p_ch) | |
3724 cmdline_row = Rows - p_ch; | |
3725 } | |
857 | 3726 if (p_window >= Rows || !option_was_set((char_u *)"window")) |
164 | 3727 p_window = Rows - 1; |
7 | 3728 } |
3729 | |
3730 if (curbuf->b_p_ts <= 0) | |
3731 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3732 errmsg = e_argument_must_be_positive; |
7 | 3733 curbuf->b_p_ts = 8; |
3734 } | |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3735 else if (curbuf->b_p_ts > TABSTOP_MAX) |
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3736 { |
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3737 errmsg = e_invalid_argument; |
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3738 curbuf->b_p_ts = 8; |
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3739 } |
7 | 3740 if (p_tm < 0) |
3741 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3742 errmsg = e_argument_must_be_positive; |
7 | 3743 p_tm = 0; |
3744 } | |
3745 if ((curwin->w_p_scr <= 0 | |
3746 || (curwin->w_p_scr > curwin->w_height | |
3747 && curwin->w_height > 0)) | |
3748 && full_screen) | |
3749 { | |
3750 if (pp == &(curwin->w_p_scr)) | |
3751 { | |
3752 if (curwin->w_p_scr != 0) | |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25176
diff
changeset
|
3753 errmsg = e_invalid_scroll_size; |
7 | 3754 win_comp_scroll(curwin); |
3755 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3756 // 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
|
3757 // it. |
7 | 3758 else if (curwin->w_p_scr <= 0) |
3759 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
|
3760 else // curwin->w_p_scr > curwin->w_height |
7 | 3761 curwin->w_p_scr = curwin->w_height; |
3762 } | |
1726 | 3763 if (p_hi < 0) |
3764 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3765 errmsg = e_argument_must_be_positive; |
1726 | 3766 p_hi = 0; |
3767 } | |
5991 | 3768 else if (p_hi > 10000) |
3769 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3770 errmsg = e_invalid_argument; |
5991 | 3771 p_hi = 10000; |
3772 } | |
4444 | 3773 if (p_re < 0 || p_re > 2) |
3774 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3775 errmsg = e_invalid_argument; |
4444 | 3776 p_re = 0; |
3777 } | |
7 | 3778 if (p_report < 0) |
3779 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3780 errmsg = e_argument_must_be_positive; |
7 | 3781 p_report = 1; |
3782 } | |
532 | 3783 if ((p_sj < -100 || p_sj >= Rows) && full_screen) |
7 | 3784 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3785 if (Rows != old_Rows) // Rows changed, just adjust p_sj |
7 | 3786 p_sj = Rows / 2; |
3787 else | |
3788 { | |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25176
diff
changeset
|
3789 errmsg = e_invalid_scroll_size; |
7 | 3790 p_sj = 1; |
3791 } | |
3792 } | |
3793 if (p_so < 0 && full_screen) | |
3794 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3795 errmsg = e_argument_must_be_positive; |
7 | 3796 p_so = 0; |
3797 } | |
3798 if (p_siso < 0 && full_screen) | |
3799 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3800 errmsg = e_argument_must_be_positive; |
7 | 3801 p_siso = 0; |
3802 } | |
3803 if (p_cwh < 1) | |
3804 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3805 errmsg = e_argument_must_be_positive; |
7 | 3806 p_cwh = 1; |
3807 } | |
3808 if (p_ut < 0) | |
3809 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3810 errmsg = e_argument_must_be_positive; |
7 | 3811 p_ut = 2000; |
3812 } | |
3813 if (p_ss < 0) | |
3814 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3815 errmsg = e_argument_must_be_positive; |
7 | 3816 p_ss = 0; |
3817 } | |
3818 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3819 // May set global value for local option. |
7 | 3820 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
3821 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; | |
3822 | |
3823 options[opt_idx].flags |= P_WAS_SET; | |
3824 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3825 #if defined(FEAT_EVAL) |
19405
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3826 apply_optionset_autocmd(opt_idx, opt_flags, old_value, old_global_value, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3827 value, errmsg); |
6935 | 3828 #endif |
3829 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3830 comp_col(); // in case 'columns' or 'ls' changed |
3443 | 3831 if (curwin->w_curswant != MAXCOL |
6669 | 3832 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 3833 curwin->w_set_curswant = TRUE; |
24079
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3834 if ((opt_flags & OPT_NO_REDRAW) == 0) |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3835 check_redraw(options[opt_idx].flags); |
7 | 3836 |
3837 return errmsg; | |
3838 } | |
3839 | |
3840 /* | |
3841 * Called after an option changed: check if something needs to be redrawn. | |
3842 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
3843 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3844 check_redraw(long_u flags) |
7 | 3845 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3846 // Careful: P_RCLR and P_RALL are a combination of other P_ flags |
3263 | 3847 int doclear = (flags & P_RCLR) == P_RCLR; |
3848 int all = ((flags & P_RALL) == P_RALL || doclear); | |
7 | 3849 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3850 if ((flags & P_RSTAT) || all) // mark all status lines dirty |
7 | 3851 status_redraw_all(); |
3852 | |
3853 if ((flags & P_RBUF) || (flags & P_RWIN) || all) | |
3854 changed_window_setting(); | |
3855 if (flags & P_RBUF) | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
3856 redraw_curbuf_later(UPD_NOT_VALID); |
10456
536a7d49249c
commit https://github.com/vim/vim/commit/a2477fd3490c1166522631eee53c57d34321086a
Christian Brabandt <cb@256bit.org>
parents:
10424
diff
changeset
|
3857 if (flags & P_RWINONLY) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
3858 redraw_later(UPD_NOT_VALID); |
3263 | 3859 if (doclear) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
3860 redraw_all_later(UPD_CLEAR); |
7 | 3861 else if (all) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
3862 redraw_all_later(UPD_NOT_VALID); |
7 | 3863 } |
3864 | |
3865 /* | |
3866 * Find index for option 'arg'. | |
3867 * Return -1 if not found. | |
3868 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
3869 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3870 findoption(char_u *arg) |
7 | 3871 { |
3872 int opt_idx; | |
3873 char *s, *p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3874 static short quick_tab[27] = {0, 0}; // quick access table |
7 | 3875 int is_term_opt; |
3876 | |
3877 /* | |
3878 * For first call: Initialize the quick-access table. | |
3879 * It contains the index for the first option that starts with a certain | |
3880 * letter. There are 26 letters, plus the first "t_" option. | |
3881 */ | |
3882 if (quick_tab[1] == 0) | |
3883 { | |
3884 p = options[0].fullname; | |
3885 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
3886 { | |
3887 if (s[0] != p[0]) | |
3888 { | |
3889 if (s[0] == 't' && s[1] == '_') | |
3890 quick_tab[26] = opt_idx; | |
3891 else | |
3892 quick_tab[CharOrdLow(s[0])] = opt_idx; | |
3893 } | |
3894 p = s; | |
3895 } | |
3896 } | |
3897 | |
3898 /* | |
3899 * Check for name starting with an illegal character. | |
3900 */ | |
3901 if (arg[0] < 'a' || arg[0] > 'z') | |
3902 return -1; | |
3903 | |
3904 is_term_opt = (arg[0] == 't' && arg[1] == '_'); | |
3905 if (is_term_opt) | |
3906 opt_idx = quick_tab[26]; | |
3907 else | |
3908 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
3909 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
3910 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3911 if (STRCMP(arg, s) == 0) // match full name |
7 | 3912 break; |
3913 } | |
3914 if (s == NULL && !is_term_opt) | |
3915 { | |
3916 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
3917 for ( ; options[opt_idx].fullname != NULL; opt_idx++) | |
3918 { | |
3919 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
|
3920 if (s != NULL && STRCMP(arg, s) == 0) // match short name |
7 | 3921 break; |
3922 s = NULL; | |
3923 } | |
3924 } | |
3925 if (s == NULL) | |
3926 opt_idx = -1; | |
3927 return opt_idx; | |
3928 } | |
3929 | |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
3930 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME) \ |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
3931 || defined(FEAT_SPELL) || defined(PROTO) |
7 | 3932 /* |
3933 * Get the value for an option. | |
3934 * | |
3935 * Returns: | |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3936 * Number option: gov_number, *numval gets value. |
23467
826a6406ea7b
patch 8.2.2276: list of distributed files is outdated
Bram Moolenaar <Bram@vim.org>
parents:
23422
diff
changeset
|
3937 * Toggle option: gov_bool, *numval gets value. |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3938 * String option: gov_string, *stringval gets allocated string. |
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3939 * Hidden Number option: gov_hidden_number. |
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3940 * Hidden Toggle option: gov_hidden_bool. |
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3941 * Hidden String option: gov_hidden_string. |
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3942 * Unknown option: gov_unknown. |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
3943 * |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
3944 * "flagsp" (if not NULL) is set to the option flags (P_xxxx). |
7 | 3945 */ |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3946 getoption_T |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3947 get_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3948 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3949 long *numval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3950 char_u **stringval, // NULL when only checking existence |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
3951 int *flagsp, |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
3952 int scope) |
7 | 3953 { |
3954 int opt_idx; | |
3955 char_u *varp; | |
3956 | |
3957 opt_idx = findoption(name); | |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3958 if (opt_idx < 0) // option not in the table |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3959 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3960 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3961 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3962 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_' |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3963 && (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
|
3964 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3965 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
|
3966 char_u *p; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3967 |
26802
f6b10a501a0e
patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
3968 if (flagsp != NULL) |
f6b10a501a0e
patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
3969 *flagsp = 0; // terminal option has no flags |
f6b10a501a0e
patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
3970 |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3971 // check for a terminal option |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3972 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3973 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3974 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
|
3975 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
|
3976 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3977 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3978 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3979 key_name[0] = KS_KEY; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3980 key_name[1] = (key & 0xff); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3981 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3982 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
|
3983 if (p != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3984 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3985 if (stringval != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3986 *stringval = vim_strsave(p); |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3987 return gov_string; |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3988 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3989 } |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3990 return gov_unknown; |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3991 } |
7 | 3992 |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
3993 varp = get_varp_scope(&(options[opt_idx]), scope); |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
3994 |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
3995 if (flagsp != NULL) |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
3996 // Return the P_xxxx option flags. |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
3997 *flagsp = options[opt_idx].flags; |
7 | 3998 |
3999 if (options[opt_idx].flags & P_STRING) | |
4000 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4001 if (varp == NULL) // hidden option |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4002 return gov_hidden_string; |
7 | 4003 if (stringval != NULL) |
4004 { | |
28804
12bbd8a31cac
patch 8.2.4926: #ifdef for crypt feature around too many lines
Bram Moolenaar <Bram@vim.org>
parents:
28800
diff
changeset
|
4005 if ((char_u **)varp == &p_pt) // 'pastetoggle' |
30226
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
4006 *stringval = str2special_save(*(char_u **)(varp), FALSE, |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
4007 FALSE); |
7 | 4008 #ifdef FEAT_CRYPT |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4009 // never return the value of the crypt key |
28804
12bbd8a31cac
patch 8.2.4926: #ifdef for crypt feature around too many lines
Bram Moolenaar <Bram@vim.org>
parents:
28800
diff
changeset
|
4010 else if ((char_u **)varp == &curbuf->b_p_key |
1622 | 4011 && **(char_u **)(varp) != NUL) |
7 | 4012 *stringval = vim_strsave((char_u *)"*****"); |
28804
12bbd8a31cac
patch 8.2.4926: #ifdef for crypt feature around too many lines
Bram Moolenaar <Bram@vim.org>
parents:
28800
diff
changeset
|
4013 #endif |
7 | 4014 else |
4015 *stringval = vim_strsave(*(char_u **)(varp)); | |
4016 } | |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4017 return gov_string; |
7 | 4018 } |
4019 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4020 if (varp == NULL) // hidden option |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4021 return (options[opt_idx].flags & P_NUM) |
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4022 ? gov_hidden_number : gov_hidden_bool; |
7 | 4023 if (options[opt_idx].flags & P_NUM) |
4024 *numval = *(long *)varp; | |
4025 else | |
4026 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4027 // 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
|
4028 // it set when 'ff' or 'fenc' changed. |
7 | 4029 if ((int *)varp == &curbuf->b_changed) |
4030 *numval = curbufIsChanged(); | |
4031 else | |
9395
beab399e3883
commit https://github.com/vim/vim/commit/2acfbed9dbea990f129535de7ff3df360365130b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4032 *numval = (long) *(int *)varp; |
7 | 4033 } |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4034 return (options[opt_idx].flags & P_NUM) ? gov_number : gov_bool; |
7 | 4035 } |
4036 #endif | |
4037 | |
5610 | 4038 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
4350 | 4039 /* |
4040 * Returns the option attributes and its value. Unlike the above function it | |
4041 * will return either global value or local value of the option depending on | |
4042 * what was requested, but it will never return global value if it was | |
4043 * requested to return local one and vice versa. Neither it will return | |
4044 * buffer-local value if it was requested to return window-local one. | |
4045 * | |
4046 * Pretends that option is absent if it is not present in the requested scope | |
4047 * (i.e. has no global, window-local or buffer-local value depending on | |
4048 * opt_type). Uses | |
4049 * | |
4050 * Returned flags: | |
5867 | 4051 * 0 hidden or unknown option, also option that does not have requested |
4052 * type (see SREQ_* in vim.h) | |
4350 | 4053 * see SOPT_* in vim.h for other flags |
4054 * | |
4055 * Possible opt_type values: see SREQ_* in vim.h | |
4056 */ | |
4057 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4058 get_option_value_strict( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4059 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4060 long *numval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4061 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
|
4062 int opt_type, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4063 void *from) |
4350 | 4064 { |
4065 int opt_idx; | |
4367 | 4066 char_u *varp = NULL; |
4350 | 4067 struct vimoption *p; |
4068 int r = 0; | |
4069 | |
4070 opt_idx = findoption(name); | |
4071 if (opt_idx < 0) | |
4072 return 0; | |
4073 | |
4074 p = &(options[opt_idx]); | |
4075 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4076 // Hidden option |
4350 | 4077 if (p->var == NULL) |
4078 return 0; | |
4079 | |
4080 if (p->flags & P_BOOL) | |
4081 r |= SOPT_BOOL; | |
4082 else if (p->flags & P_NUM) | |
4083 r |= SOPT_NUM; | |
4084 else if (p->flags & P_STRING) | |
4085 r |= SOPT_STRING; | |
4086 | |
4087 if (p->indir == PV_NONE) | |
4088 { | |
4089 if (opt_type == SREQ_GLOBAL) | |
4090 r |= SOPT_GLOBAL; | |
4091 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4092 return 0; // Did not request global-only option |
4350 | 4093 } |
4094 else | |
4095 { | |
4096 if (p->indir & PV_BOTH) | |
4097 r |= SOPT_GLOBAL; | |
4098 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
|
4099 return 0; // Requested global option |
4350 | 4100 |
4101 if (p->indir & PV_WIN) | |
4102 { | |
4103 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
|
4104 return 0; // Did not request window-local option |
4350 | 4105 else |
4106 r |= SOPT_WIN; | |
4107 } | |
4108 else if (p->indir & PV_BUF) | |
4109 { | |
4110 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
|
4111 return 0; // Did not request buffer-local option |
4350 | 4112 else |
4113 r |= SOPT_BUF; | |
4114 } | |
4115 } | |
4116 | |
4117 if (stringval == NULL) | |
4118 return r; | |
4119 | |
4120 if (opt_type == SREQ_GLOBAL) | |
4121 varp = p->var; | |
4122 else | |
4123 { | |
4124 if (opt_type == SREQ_BUF) | |
4125 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4126 // 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
|
4127 // consider it set when 'ff' or 'fenc' changed. |
4350 | 4128 if (p->indir == PV_MOD) |
4129 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4130 *numval = bufIsChanged((buf_T *)from); |
4350 | 4131 varp = NULL; |
4132 } | |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
4133 # ifdef FEAT_CRYPT |
4350 | 4134 else if (p->indir == PV_KEY) |
4135 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4136 // never return the value of the crypt key |
4350 | 4137 *stringval = NULL; |
4138 varp = NULL; | |
4139 } | |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
4140 # endif |
4350 | 4141 else |
4142 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4143 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
|
4144 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4145 // 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
|
4146 curbuf = (buf_T *)from; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4147 curwin->w_buffer = curbuf; |
4350 | 4148 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
|
4149 curbuf = save_curbuf; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4150 curwin->w_buffer = curbuf; |
4350 | 4151 } |
4152 } | |
4153 else if (opt_type == SREQ_WIN) | |
4154 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4155 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
|
4156 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4157 curwin = (win_T *)from; |
4350 | 4158 curbuf = curwin->w_buffer; |
4159 varp = get_varp(p); | |
4160 curwin = save_curwin; | |
4161 curbuf = curwin->w_buffer; | |
4162 } | |
4163 if (varp == p->var) | |
4164 return (r | SOPT_UNSET); | |
4165 } | |
4166 | |
4167 if (varp != NULL) | |
4168 { | |
4169 if (p->flags & P_STRING) | |
4170 *stringval = vim_strsave(*(char_u **)(varp)); | |
4171 else if (p->flags & P_NUM) | |
4172 *numval = *(long *) varp; | |
4173 else | |
4174 *numval = *(int *)varp; | |
4175 } | |
4176 | |
4177 return r; | |
4178 } | |
5610 | 4179 |
4180 /* | |
6243 | 4181 * Iterate over options. First argument is a pointer to a pointer to a |
4182 * structure inside options[] array, second is option type like in the above | |
4183 * function. | |
5610 | 4184 * |
6243 | 4185 * If first argument points to NULL it is assumed that iteration just started |
5610 | 4186 * and caller needs the very first value. |
6243 | 4187 * If first argument points to the end marker function returns NULL and sets |
5610 | 4188 * first argument to NULL. |
4189 * | |
4190 * Returns full option name for current option on each call. | |
4191 */ | |
4192 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4193 option_iter_next(void **option, int opt_type) |
5610 | 4194 { |
4195 struct vimoption *ret = NULL; | |
4196 do | |
4197 { | |
4198 if (*option == NULL) | |
4199 *option = (void *) options; | |
4200 else if (((struct vimoption *) (*option))->fullname == NULL) | |
4201 { | |
4202 *option = NULL; | |
4203 return NULL; | |
4204 } | |
4205 else | |
4206 *option = (void *) (((struct vimoption *) (*option)) + 1); | |
4207 | |
4208 ret = ((struct vimoption *) (*option)); | |
4209 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4210 // Hidden option |
5610 | 4211 if (ret->var == NULL) |
4212 { | |
4213 ret = NULL; | |
4214 continue; | |
4215 } | |
4216 | |
4217 switch (opt_type) | |
4218 { | |
4219 case SREQ_GLOBAL: | |
4220 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH)) | |
4221 ret = NULL; | |
4222 break; | |
4223 case SREQ_BUF: | |
4224 if (!(ret->indir & PV_BUF)) | |
4225 ret = NULL; | |
4226 break; | |
4227 case SREQ_WIN: | |
4228 if (!(ret->indir & PV_WIN)) | |
4229 ret = NULL; | |
4230 break; | |
4231 default: | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
4232 internal_error("option_iter_next()"); |
5610 | 4233 return NULL; |
4234 } | |
4235 } | |
4236 while (ret == NULL); | |
4237 | |
4238 return (char_u *)ret->fullname; | |
4239 } | |
4350 | 4240 #endif |
4241 | |
7 | 4242 /* |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4243 * 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
|
4244 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4245 long_u |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4246 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
|
4247 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4248 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
|
4249 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4250 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4251 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4252 * 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
|
4253 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4254 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4255 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
|
4256 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4257 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
|
4258 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4259 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4260 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4261 * 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
|
4262 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4263 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4264 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
|
4265 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4266 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
|
4267 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4268 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4269 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4270 * 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
|
4271 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4272 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4273 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
|
4274 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4275 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
|
4276 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4277 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4278 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4279 * 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
|
4280 * local value. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4281 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4282 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4283 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
|
4284 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4285 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
|
4286 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4287 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4288 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4289 * 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
|
4290 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4291 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4292 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
|
4293 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4294 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
|
4295 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4296 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4297 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4298 * 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
|
4299 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4300 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4301 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
|
4302 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4303 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
|
4304 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4305 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4306 #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
|
4307 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4308 * 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
|
4309 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4310 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4311 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
|
4312 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4313 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
|
4314 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4315 #endif |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4316 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4317 /* |
7 | 4318 * Set the value of option "name". |
4319 * 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
|
4320 * |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4321 * Returns NULL on success or an untranslated error message on error. |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4322 */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4323 char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4324 set_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4325 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4326 long number, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4327 char_u *string, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4328 int opt_flags) // OPT_LOCAL or 0 (both) |
7 | 4329 { |
4330 int opt_idx; | |
4331 char_u *varp; | |
835 | 4332 long_u flags; |
7 | 4333 |
4334 opt_idx = findoption(name); | |
838 | 4335 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
|
4336 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4337 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4338 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4339 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
|
4340 && (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
|
4341 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4342 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
|
4343 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4344 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4345 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4346 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
|
4347 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
|
4348 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4349 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4350 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4351 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
|
4352 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
|
4353 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4354 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
|
4355 if (full_screen) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4356 ttest(FALSE); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
4357 redraw_all_later(UPD_CLEAR); |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4358 return NULL; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4359 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4360 |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
4361 semsg(_(e_unknown_option_str_2), name); |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4362 } |
7 | 4363 else |
4364 { | |
4365 flags = options[opt_idx].flags; | |
4366 #ifdef HAVE_SANDBOX | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4367 // Disallow changing some options in the sandbox |
7 | 4368 if (sandbox > 0 && (flags & P_SECURE)) |
634 | 4369 { |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25176
diff
changeset
|
4370 emsg(_(e_not_allowed_in_sandbox)); |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4371 return NULL; |
634 | 4372 } |
4373 #endif | |
4374 if (flags & P_STRING) | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4375 return set_string_option(opt_idx, string, opt_flags); |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4376 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4377 varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4378 if (varp != NULL) // hidden option is not changed |
7 | 4379 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4380 if (number == 0 && string != NULL) |
7 | 4381 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4382 int idx; |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4383 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4384 // Either we are given a string or we are setting option |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4385 // to zero. |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4386 for (idx = 0; string[idx] == '0'; ++idx) |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4387 ; |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4388 if (string[idx] != NUL || idx == 0) |
1298 | 4389 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4390 // There's another character after zeros or the string |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4391 // is empty. In both cases, we are trying to set a |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4392 // num option using a string. |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4393 semsg(_(e_number_required_after_str_equal_str), |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4394 name, string); |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4395 return NULL; // do nothing as we hit an error |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4396 |
1298 | 4397 } |
7 | 4398 } |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4399 if (flags & P_NUM) |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4400 return set_num_option(opt_idx, varp, number, |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4401 NULL, 0, opt_flags); |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4402 else |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4403 return set_bool_option(opt_idx, varp, (int)number, opt_flags); |
7 | 4404 } |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4405 |
7 | 4406 } |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4407 return NULL; |
7 | 4408 } |
4409 | |
4410 /* | |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4411 * Call set_option_value() and when an error is returned report it. |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4412 */ |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4413 void |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4414 set_option_value_give_err( |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4415 char_u *name, |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4416 long number, |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4417 char_u *string, |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4418 int opt_flags) // OPT_LOCAL or 0 (both) |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4419 { |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4420 char *errmsg = set_option_value(name, number, string, opt_flags); |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4421 |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4422 if (errmsg != NULL) |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4423 emsg(_(errmsg)); |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4424 } |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4425 |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4426 /* |
7 | 4427 * Get the terminal code for a terminal option. |
4428 * Returns NULL when not found. | |
4429 */ | |
4430 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4431 get_term_code(char_u *tname) |
7 | 4432 { |
4433 int opt_idx; | |
4434 char_u *varp; | |
4435 | |
4436 if (tname[0] != 't' || tname[1] != '_' || | |
4437 tname[2] == NUL || tname[3] == NUL) | |
4438 return NULL; | |
4439 if ((opt_idx = findoption(tname)) >= 0) | |
4440 { | |
4441 varp = get_varp(&(options[opt_idx])); | |
4442 if (varp != NULL) | |
4443 varp = *(char_u **)(varp); | |
4444 return varp; | |
4445 } | |
4446 return find_termcode(tname + 2); | |
4447 } | |
4448 | |
4449 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4450 get_highlight_default(void) |
7 | 4451 { |
4452 int i; | |
4453 | |
4454 i = findoption((char_u *)"hl"); | |
4455 if (i >= 0) | |
4456 return options[i].def_val[VI_DEFAULT]; | |
4457 return (char_u *)NULL; | |
4458 } | |
4459 | |
39 | 4460 char_u * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4461 get_encoding_default(void) |
39 | 4462 { |
4463 int i; | |
4464 | |
4465 i = findoption((char_u *)"enc"); | |
4466 if (i >= 0) | |
4467 return options[i].def_val[VI_DEFAULT]; | |
4468 return (char_u *)NULL; | |
4469 } | |
4470 | |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
4471 #if defined(FEAT_QUICKFIX) || defined(PROTO) |
27855
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4472 int |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4473 is_option_allocated(char *name) |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4474 { |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4475 int idx = findoption((char_u *)name); |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4476 |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4477 return idx >= 0 && (options[idx].flags & P_ALLOCED); |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4478 } |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
4479 #endif |
27855
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4480 |
29497
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4481 #if defined(FEAT_EVAL) || defined(PROTO) |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4482 /* |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4483 * Return TRUE if "name" is a string option. |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4484 * Returns FALSE if option "name" does not exist. |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4485 */ |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4486 int |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4487 is_string_option(char_u *name) |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4488 { |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4489 int idx = findoption(name); |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4490 |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4491 return idx >= 0 && (options[idx].flags & P_STRING); |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4492 } |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4493 #endif |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4494 |
7 | 4495 /* |
4496 * 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
|
4497 * 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
|
4498 * Returns 0 when the key is not recognized. |
7 | 4499 */ |
4500 static int | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4501 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
|
4502 { |
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4503 int key = 0; |
7 | 4504 int modifiers; |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4505 char_u *arg = arg_arg; |
7 | 4506 |
4507 /* | |
4508 * Don't use get_special_key_code() for t_xx, we don't want it to call | |
4509 * add_termcap_entry(). | |
4510 */ | |
4511 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
4512 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
|
4513 else if (has_lt) |
7 | 4514 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4515 --arg; // put arg at the '<' |
7 | 4516 modifiers = 0; |
20603
c2570baa2e4c
patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents:
20269
diff
changeset
|
4517 key = find_special_key(&arg, &modifiers, |
c2570baa2e4c
patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents:
20269
diff
changeset
|
4518 FSK_KEYCODE | FSK_KEEP_X_KEY | FSK_SIMPLIFY, NULL); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4519 if (modifiers) // can't handle modifiers here |
7 | 4520 key = 0; |
4521 } | |
4522 return key; | |
4523 } | |
4524 | |
4525 /* | |
4526 * if 'all' == 0: show changed options | |
4527 * if 'all' == 1: show all normal options | |
4528 * if 'all' == 2: show all terminal options | |
4529 */ | |
4530 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4531 showoptions( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4532 int all, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4533 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 4534 { |
4535 struct vimoption *p; | |
4536 int col; | |
4537 int isterm; | |
4538 char_u *varp; | |
4539 struct vimoption **items; | |
4540 int item_count; | |
4541 int run; | |
4542 int row, rows; | |
4543 int cols; | |
4544 int i; | |
4545 int len; | |
4546 | |
4547 #define INC 20 | |
4548 #define GAP 3 | |
4549 | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4550 items = ALLOC_MULT(struct vimoption *, OPTION_COUNT); |
7 | 4551 if (items == NULL) |
4552 return; | |
4553 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4554 // Highlight title |
7 | 4555 if (all == 2) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4556 msg_puts_title(_("\n--- Terminal codes ---")); |
7 | 4557 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
|
4558 msg_puts_title(_("\n--- Global option values ---")); |
7 | 4559 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
|
4560 msg_puts_title(_("\n--- Local option values ---")); |
7 | 4561 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4562 msg_puts_title(_("\n--- Options ---")); |
7 | 4563 |
4564 /* | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4565 * Do the loop two times: |
7 | 4566 * 1. display the short items |
4567 * 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
|
4568 * When "opt_flags" has OPT_ONECOLUMN do everything in run 2. |
7 | 4569 */ |
4570 for (run = 1; run <= 2 && !got_int; ++run) | |
4571 { | |
4572 /* | |
4573 * collect the items in items[] | |
4574 */ | |
4575 item_count = 0; | |
4576 for (p = &options[0]; p->fullname != NULL; p++) | |
4577 { | |
14968
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4578 // apply :filter /pat/ |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4579 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
|
4580 continue; |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4581 |
7 | 4582 varp = NULL; |
4583 isterm = istermoption(p); | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4584 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) != 0) |
7 | 4585 { |
4586 if (p->indir != PV_NONE && !isterm) | |
4587 varp = get_varp_scope(p, opt_flags); | |
4588 } | |
4589 else | |
4590 varp = get_varp(p); | |
4591 if (varp != NULL | |
4592 && ((all == 2 && isterm) | |
4593 || (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
|
4594 || (all == 0 && !optval_default(p, varp, p_cp)))) |
7 | 4595 { |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4596 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
|
4597 len = Columns; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4598 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
|
4599 len = 1; // a toggle option fits always |
7 | 4600 else |
4601 { | |
4602 option_value2string(p, opt_flags); | |
4603 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; | |
4604 } | |
4605 if ((len <= INC - GAP && run == 1) || | |
4606 (len > INC - GAP && run == 2)) | |
4607 items[item_count++] = p; | |
4608 } | |
4609 } | |
4610 | |
4611 /* | |
4612 * display the items | |
4613 */ | |
4614 if (run == 1) | |
4615 { | |
4616 cols = (Columns + GAP - 3) / INC; | |
4617 if (cols == 0) | |
4618 cols = 1; | |
4619 rows = (item_count + cols - 1) / cols; | |
4620 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4621 else // run == 2 |
7 | 4622 rows = item_count; |
4623 for (row = 0; row < rows && !got_int; ++row) | |
4624 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4625 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
|
4626 if (got_int) // 'q' typed in more |
7 | 4627 break; |
4628 col = 0; | |
4629 for (i = row; i < item_count; i += rows) | |
4630 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4631 msg_col = col; // make columns |
7 | 4632 showoneopt(items[i], opt_flags); |
4633 col += INC; | |
4634 } | |
4635 out_flush(); | |
4636 ui_breakcheck(); | |
4637 } | |
4638 } | |
4639 vim_free(items); | |
4640 } | |
4641 | |
4642 /* | |
4643 * Return TRUE if option "p" has its default value. | |
4644 */ | |
4645 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
|
4646 optval_default(struct vimoption *p, char_u *varp, int compatible) |
7 | 4647 { |
4648 int dvi; | |
4649 | |
4650 if (varp == NULL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4651 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
|
4652 dvi = ((p->flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; |
7 | 4653 if (p->flags & P_NUM) |
840 | 4654 return (*(long *)varp == (long)(long_i)p->def_val[dvi]); |
7 | 4655 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
|
4656 // 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
|
4657 // needed for MSVC |
840 | 4658 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
|
4659 // P_STRING |
7 | 4660 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); |
4661 } | |
4662 | |
4663 /* | |
4664 * showoneopt: show the value of one option | |
4665 * must not be called with a hidden option! | |
4666 */ | |
4667 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4668 showoneopt( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4669 struct vimoption *p, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4670 int opt_flags) // OPT_LOCAL or OPT_GLOBAL |
7 | 4671 { |
168 | 4672 char_u *varp; |
4673 int save_silent = silent_mode; | |
4674 | |
4675 silent_mode = FALSE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4676 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
7 | 4677 |
4678 varp = get_varp_scope(p, opt_flags); | |
4679 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4680 // for 'modified' we also need to check if 'ff' or 'fenc' changed. |
7 | 4681 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed |
4682 ? !curbufIsChanged() : !*(int *)varp)) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4683 msg_puts("no"); |
7 | 4684 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
|
4685 msg_puts("--"); |
7 | 4686 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4687 msg_puts(" "); |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4688 msg_puts(p->fullname); |
7 | 4689 if (!(p->flags & P_BOOL)) |
4690 { | |
4691 msg_putchar('='); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4692 // put value string in NameBuff |
7 | 4693 option_value2string(p, opt_flags); |
4694 msg_outtrans(NameBuff); | |
4695 } | |
168 | 4696 |
4697 silent_mode = save_silent; | |
4698 info_message = FALSE; | |
7 | 4699 } |
4700 | |
4701 /* | |
4702 * Write modified options as ":set" commands to a file. | |
4703 * | |
4704 * There are three values for "opt_flags": | |
4705 * OPT_GLOBAL: Write global option values and fresh values of | |
4706 * buffer-local options (used for start of a session | |
4707 * file). | |
4708 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for | |
4709 * curwin (used for a vimrc file). | |
4710 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh | |
4711 * and local values for window-local options of | |
4712 * curwin. Local values are also written when at the | |
4713 * default value, because a modeline or autocommand | |
4714 * may have set them when doing ":edit file" and the | |
4715 * user has set them back at the default or fresh | |
4716 * value. | |
4717 * When "local_only" is TRUE, don't write fresh | |
4718 * values, only local values (for ":mkview"). | |
4719 * (fresh value = value used for a new buffer or window for a local option). | |
4720 * | |
4721 * Return FAIL on error, OK otherwise. | |
4722 */ | |
4723 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4724 makeset(FILE *fd, int opt_flags, int local_only) |
7 | 4725 { |
4726 struct vimoption *p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4727 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
|
4728 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
|
4729 char_u *varp_local = NULL; // fresh value |
7 | 4730 char *cmd; |
4731 int round; | |
1384 | 4732 int pri; |
7 | 4733 |
4734 /* | |
4735 * The options that don't have a default (terminal name, columns, lines) | |
4736 * are never written. Terminal options are also not written. | |
1384 | 4737 * Do the loop over "options[]" twice: once for options with the |
4738 * P_PRI_MKRC flag and once without. | |
7 | 4739 */ |
1384 | 4740 for (pri = 1; pri >= 0; --pri) |
4741 { | |
4742 for (p = &options[0]; !istermoption(p); p++) | |
4743 if (!(p->flags & P_NO_MKRC) | |
4744 && !istermoption(p) | |
4745 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) | |
7 | 4746 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4747 // skip global option when only doing locals |
7 | 4748 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) |
4749 continue; | |
4750 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4751 // 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
|
4752 // file, they are always buffer-specific. |
7 | 4753 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) |
4754 continue; | |
4755 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4756 // Global values are only written when not at the default value. |
7 | 4757 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
|
4758 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp, p_cp)) |
7 | 4759 continue; |
4760 | |
24476
e79d1475fc89
patch 8.2.2778: problem restoring 'packpath' in session
Bram Moolenaar <Bram@vim.org>
parents:
24464
diff
changeset
|
4761 if ((opt_flags & OPT_SKIPRTP) && (p->var == (char_u *)&p_rtp |
e79d1475fc89
patch 8.2.2778: problem restoring 'packpath' in session
Bram Moolenaar <Bram@vim.org>
parents:
24464
diff
changeset
|
4762 || p->var == (char_u *)&p_pp)) |
24464
a56f9c2ba51c
patch 8.2.2772: problems when restoring 'runtimepath' from a session file
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4763 continue; |
a56f9c2ba51c
patch 8.2.2772: problems when restoring 'runtimepath' from a session file
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4764 |
7 | 4765 round = 2; |
4766 if (p->indir != PV_NONE) | |
4767 { | |
4768 if (p->var == VAR_WIN) | |
4769 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4770 // skip window-local option when only doing globals |
7 | 4771 if (!(opt_flags & OPT_LOCAL)) |
4772 continue; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4773 // 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
|
4774 // default, need to write it too. |
7 | 4775 if (!(opt_flags & OPT_GLOBAL) && !local_only) |
4776 { | |
4777 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
|
4778 if (!optval_default(p, varp_fresh, p_cp)) |
7 | 4779 { |
4780 round = 1; | |
4781 varp_local = varp; | |
4782 varp = varp_fresh; | |
4783 } | |
4784 } | |
4785 } | |
4786 } | |
4787 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4788 // 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
|
4789 // Round 2: other values |
7 | 4790 for ( ; round <= 2; varp = varp_local, ++round) |
4791 { | |
4792 if (round == 1 || (opt_flags & OPT_GLOBAL)) | |
4793 cmd = "set"; | |
4794 else | |
4795 cmd = "setlocal"; | |
4796 | |
4797 if (p->flags & P_BOOL) | |
4798 { | |
4799 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) | |
4800 return FAIL; | |
4801 } | |
4802 else if (p->flags & P_NUM) | |
4803 { | |
4804 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) | |
4805 return FAIL; | |
4806 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4807 else // P_STRING |
7 | 4808 { |
694 | 4809 int do_endif = FALSE; |
4810 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4811 // 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
|
4812 // already right, avoids reloading the syntax file. |
694 | 4813 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4814 #if defined(FEAT_SYN_HL) |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4815 p->indir == PV_SYN || |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4816 #endif |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4817 p->indir == PV_FT) |
7 | 4818 { |
4819 if (fprintf(fd, "if &%s != '%s'", p->fullname, | |
4820 *(char_u **)(varp)) < 0 | |
4821 || put_eol(fd) < 0) | |
4822 return FAIL; | |
694 | 4823 do_endif = TRUE; |
7 | 4824 } |
4825 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
|
4826 p->flags) == FAIL) |
7 | 4827 return FAIL; |
694 | 4828 if (do_endif) |
7 | 4829 { |
4830 if (put_line(fd, "endif") == FAIL) | |
4831 return FAIL; | |
4832 } | |
4833 } | |
4834 } | |
4835 } | |
1384 | 4836 } |
7 | 4837 return OK; |
4838 } | |
4839 | |
4840 #if defined(FEAT_FOLDING) || defined(PROTO) | |
4841 /* | |
4842 * Generate set commands for the local fold options only. Used when | |
4843 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options". | |
4844 */ | |
4845 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4846 makefoldset(FILE *fd) |
7 | 4847 { |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4848 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, 0) == FAIL |
7 | 4849 # 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
|
4850 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, 0) |
7 | 4851 == FAIL |
4852 # endif | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4853 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, 0) |
7 | 4854 == FAIL |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4855 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, 0) |
7 | 4856 == FAIL |
4857 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL | |
4858 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL | |
4859 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL | |
4860 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL | |
4861 ) | |
4862 return FAIL; | |
4863 | |
4864 return OK; | |
4865 } | |
4866 #endif | |
4867 | |
4868 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4869 put_setstring( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4870 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4871 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4872 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4873 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
|
4874 long_u flags) |
7 | 4875 { |
4876 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
|
4877 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
|
4878 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
|
4879 char_u *p; |
7 | 4880 |
4881 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
4882 return FAIL; | |
4883 if (*valuep != NULL) | |
4884 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4885 // 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
|
4886 // 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
|
4887 // CTRL-V or backslash |
7 | 4888 if (valuep == &p_pt) |
4889 { | |
4890 s = *valuep; | |
4891 while (*s != NUL) | |
30226
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
4892 if (put_escstr(fd, str2special(&s, FALSE, FALSE), 2) == FAIL) |
7 | 4893 return FAIL; |
4894 } | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4895 // 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
|
4896 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
|
4897 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4898 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
|
4899 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4900 // 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
|
4901 buf = alloc(size); |
2780 | 4902 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
|
4903 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4904 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
|
4905 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4906 // 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
|
4907 // 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
|
4908 // 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
|
4909 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
|
4910 && 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
|
4911 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4912 part = alloc(size); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4913 if (part == NULL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4914 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4915 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4916 // 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
|
4917 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
|
4918 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4919 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4920 p = buf; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4921 while (*p != NUL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4922 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4923 // 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
|
4924 // 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
|
4925 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
|
4926 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4927 (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
|
4928 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
|
4929 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4930 } |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4931 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4932 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4933 return OK; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4934 } |
7 | 4935 if (put_escstr(fd, buf, 2) == FAIL) |
2780 | 4936 { |
4937 vim_free(buf); | |
7 | 4938 return FAIL; |
2780 | 4939 } |
4940 vim_free(buf); | |
7 | 4941 } |
4942 else if (put_escstr(fd, *valuep, 2) == FAIL) | |
4943 return FAIL; | |
4944 } | |
4945 if (put_eol(fd) < 0) | |
4946 return FAIL; | |
4947 return OK; | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4948 fail: |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4949 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4950 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4951 return FAIL; |
7 | 4952 } |
4953 | |
4954 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4955 put_setnum( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4956 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4957 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4958 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4959 long *valuep) |
7 | 4960 { |
4961 long wc; | |
4962 | |
4963 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
4964 return FAIL; | |
4965 if (wc_use_keyname((char_u *)valuep, &wc)) | |
4966 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4967 // print 'wildchar' and 'wildcharm' as a key name |
7 | 4968 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) |
4969 return FAIL; | |
4970 } | |
4971 else if (fprintf(fd, "%ld", *valuep) < 0) | |
4972 return FAIL; | |
4973 if (put_eol(fd) < 0) | |
4974 return FAIL; | |
4975 return OK; | |
4976 } | |
4977 | |
4978 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4979 put_setbool( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4980 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4981 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4982 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4983 int value) |
7 | 4984 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4985 if (value < 0) // global/local option using global value |
1416 | 4986 return OK; |
7 | 4987 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 |
4988 || put_eol(fd) < 0) | |
4989 return FAIL; | |
4990 return OK; | |
4991 } | |
4992 | |
4993 /* | |
4994 * Clear all the terminal options. | |
4995 * If the option has been allocated, free the memory. | |
4996 * Terminal options are never hidden or indirect. | |
4997 */ | |
4998 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4999 clear_termoptions(void) |
7 | 5000 { |
5001 /* | |
5002 * Reset a few things before clearing the old options. This may cause | |
5003 * outputting a few things that the terminal doesn't understand, but the | |
5004 * screen will be cleared later, so this is OK. | |
5005 */ | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
5006 mch_setmouse(FALSE); // switch mouse off |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5007 mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles |
7 | 5008 #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
|
5009 // 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
|
5010 // After restoring the title, because that will need the display. |
7 | 5011 if (gui.starting) |
5012 clear_xterm_clip(); | |
5013 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5014 stoptermcap(); // stop termcap mode |
7 | 5015 |
359 | 5016 free_termoptions(); |
5017 } | |
5018 | |
5019 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5020 free_termoptions(void) |
359 | 5021 { |
5022 struct vimoption *p; | |
5023 | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
5024 for (p = options; p->fullname != NULL; p++) |
7 | 5025 if (istermoption(p)) |
5026 { | |
5027 if (p->flags & P_ALLOCED) | |
5028 free_string_option(*(char_u **)(p->var)); | |
5029 if (p->flags & P_DEF_ALLOCED) | |
5030 free_string_option(p->def_val[VI_DEFAULT]); | |
5031 *(char_u **)(p->var) = empty_option; | |
5032 p->def_val[VI_DEFAULT] = empty_option; | |
5033 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
|
5034 #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
|
5035 // 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
|
5036 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
|
5037 #endif |
7 | 5038 } |
5039 clear_termcodes(); | |
5040 } | |
5041 | |
5042 /* | |
1941 | 5043 * Free the string for one term option, if it was allocated. |
5044 * Set the string to empty_option and clear allocated flag. | |
5045 * "var" points to the option value. | |
5046 */ | |
5047 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5048 free_one_termoption(char_u *var) |
1941 | 5049 { |
5050 struct vimoption *p; | |
5051 | |
5052 for (p = &options[0]; p->fullname != NULL; p++) | |
5053 if (p->var == var) | |
5054 { | |
5055 if (p->flags & P_ALLOCED) | |
5056 free_string_option(*(char_u **)(p->var)); | |
5057 *(char_u **)(p->var) = empty_option; | |
5058 p->flags &= ~P_ALLOCED; | |
5059 break; | |
5060 } | |
5061 } | |
5062 | |
5063 /* | |
7 | 5064 * Set the terminal option defaults to the current value. |
5065 * Used after setting the terminal name. | |
5066 */ | |
5067 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5068 set_term_defaults(void) |
7 | 5069 { |
5070 struct vimoption *p; | |
5071 | |
5072 for (p = &options[0]; p->fullname != NULL; p++) | |
5073 { | |
5074 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) | |
5075 { | |
5076 if (p->flags & P_DEF_ALLOCED) | |
5077 { | |
5078 free_string_option(p->def_val[VI_DEFAULT]); | |
5079 p->flags &= ~P_DEF_ALLOCED; | |
5080 } | |
5081 p->def_val[VI_DEFAULT] = *(char_u **)(p->var); | |
5082 if (p->flags & P_ALLOCED) | |
5083 { | |
5084 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
|
5085 p->flags &= ~P_ALLOCED; // don't free the value now |
7 | 5086 } |
5087 } | |
5088 } | |
5089 } | |
5090 | |
5091 /* | |
5092 * return TRUE if 'p' starts with 't_' | |
5093 */ | |
5094 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5095 istermoption(struct vimoption *p) |
7 | 5096 { |
5097 return (p->fullname[0] == 't' && p->fullname[1] == '_'); | |
5098 } | |
5099 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5100 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5101 * 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
|
5102 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5103 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5104 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
|
5105 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5106 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
|
5107 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5108 |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
5109 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
7 | 5110 /* |
4350 | 5111 * Unset local option value, similar to ":set opt<". |
5112 */ | |
5113 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5114 unset_global_local_option(char_u *name, void *from) |
4350 | 5115 { |
5116 struct vimoption *p; | |
5117 int opt_idx; | |
4361 | 5118 buf_T *buf = (buf_T *)from; |
4350 | 5119 |
5120 opt_idx = findoption(name); | |
7007 | 5121 if (opt_idx < 0) |
5122 return; | |
4350 | 5123 p = &(options[opt_idx]); |
5124 | |
5125 switch ((int)p->indir) | |
5126 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5127 // global option with local value: use local value if it's been set |
4350 | 5128 case PV_EP: |
4361 | 5129 clear_string_option(&buf->b_p_ep); |
4350 | 5130 break; |
5131 case PV_KP: | |
4361 | 5132 clear_string_option(&buf->b_p_kp); |
4350 | 5133 break; |
5134 case PV_PATH: | |
4361 | 5135 clear_string_option(&buf->b_p_path); |
4350 | 5136 break; |
5137 case PV_AR: | |
5138 buf->b_p_ar = -1; | |
5139 break; | |
6243 | 5140 case PV_BKC: |
5141 clear_string_option(&buf->b_p_bkc); | |
5142 buf->b_bkc_flags = 0; | |
5143 break; | |
4350 | 5144 case PV_TAGS: |
4361 | 5145 clear_string_option(&buf->b_p_tags); |
4350 | 5146 break; |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5147 case PV_TC: |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5148 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
|
5149 buf->b_tc_flags = 0; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5150 break; |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5151 case PV_SISO: |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5152 curwin->w_p_siso = -1; |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5153 break; |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5154 case PV_SO: |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5155 curwin->w_p_so = -1; |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5156 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5157 # ifdef FEAT_FIND_ID |
4350 | 5158 case PV_DEF: |
4361 | 5159 clear_string_option(&buf->b_p_def); |
4350 | 5160 break; |
5161 case PV_INC: | |
4361 | 5162 clear_string_option(&buf->b_p_inc); |
4350 | 5163 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5164 # endif |
4350 | 5165 case PV_DICT: |
4361 | 5166 clear_string_option(&buf->b_p_dict); |
4350 | 5167 break; |
5168 case PV_TSR: | |
4361 | 5169 clear_string_option(&buf->b_p_tsr); |
4350 | 5170 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5171 # ifdef FEAT_COMPL_FUNC |
25990
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5172 case PV_TSRFU: |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5173 clear_string_option(&buf->b_p_tsrfu); |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5174 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5175 # endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5176 case PV_FP: |
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5177 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
|
5178 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5179 # ifdef FEAT_QUICKFIX |
4350 | 5180 case PV_EFM: |
4361 | 5181 clear_string_option(&buf->b_p_efm); |
4350 | 5182 break; |
5183 case PV_GP: | |
4361 | 5184 clear_string_option(&buf->b_p_gp); |
4350 | 5185 break; |
5186 case PV_MP: | |
4361 | 5187 clear_string_option(&buf->b_p_mp); |
4350 | 5188 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5189 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5190 # if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
4350 | 5191 case PV_BEXPR: |
4361 | 5192 clear_string_option(&buf->b_p_bexpr); |
4350 | 5193 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5194 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5195 # if defined(FEAT_CRYPT) |
4350 | 5196 case PV_CM: |
4361 | 5197 clear_string_option(&buf->b_p_cm); |
4350 | 5198 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5199 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5200 # ifdef FEAT_LINEBREAK |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5201 case PV_SBR: |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5202 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
|
5203 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5204 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5205 # ifdef FEAT_STL_OPT |
4350 | 5206 case PV_STL: |
4361 | 5207 clear_string_option(&((win_T *)from)->w_p_stl); |
4350 | 5208 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5209 # endif |
5446 | 5210 case PV_UL: |
5211 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; | |
5212 break; | |
5712 | 5213 case PV_LW: |
5214 clear_string_option(&buf->b_p_lw); | |
5215 break; | |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
5216 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
|
5217 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
|
5218 break; |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5219 case PV_LCS: |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5220 clear_string_option(&((win_T *)from)->w_p_lcs); |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
5221 set_chars_option((win_T *)from, &((win_T *)from)->w_p_lcs, TRUE); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
5222 redraw_later(UPD_NOT_VALID); |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5223 break; |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5224 case PV_FCS: |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5225 clear_string_option(&((win_T *)from)->w_p_fcs); |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
5226 set_chars_option((win_T *)from, &((win_T *)from)->w_p_fcs, TRUE); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
5227 redraw_later(UPD_NOT_VALID); |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5228 break; |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
5229 case PV_VE: |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5230 clear_string_option(&((win_T *)from)->w_p_ve); |
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5231 ((win_T *)from)->w_ve_flags = 0; |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
5232 break; |
4350 | 5233 } |
5234 } | |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
5235 #endif |
4350 | 5236 |
5237 /* | |
7 | 5238 * Get pointer to option variable, depending on local or global scope. |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
5239 * "scope" can be OPT_LOCAL, OPT_GLOBAL or a combination. |
7 | 5240 */ |
5241 static char_u * | |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
5242 get_varp_scope(struct vimoption *p, int scope) |
7 | 5243 { |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
5244 if ((scope & OPT_GLOBAL) && p->indir != PV_NONE) |
7 | 5245 { |
5246 if (p->var == VAR_WIN) | |
5247 return (char_u *)GLOBAL_WO(get_varp(p)); | |
5248 return p->var; | |
5249 } | |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
5250 if ((scope & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) |
7 | 5251 { |
5252 switch ((int)p->indir) | |
5253 { | |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5254 case PV_FP: return (char_u *)&(curbuf->b_p_fp); |
7 | 5255 #ifdef FEAT_QUICKFIX |
694 | 5256 case PV_EFM: return (char_u *)&(curbuf->b_p_efm); |
5257 case PV_GP: return (char_u *)&(curbuf->b_p_gp); | |
5258 case PV_MP: return (char_u *)&(curbuf->b_p_mp); | |
5259 #endif | |
5260 case PV_EP: return (char_u *)&(curbuf->b_p_ep); | |
5261 case PV_KP: return (char_u *)&(curbuf->b_p_kp); | |
5262 case PV_PATH: return (char_u *)&(curbuf->b_p_path); | |
692 | 5263 case PV_AR: return (char_u *)&(curbuf->b_p_ar); |
694 | 5264 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
|
5265 case PV_TC: return (char_u *)&(curbuf->b_p_tc); |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5266 case PV_SISO: return (char_u *)&(curwin->w_p_siso); |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5267 case PV_SO: return (char_u *)&(curwin->w_p_so); |
7 | 5268 #ifdef FEAT_FIND_ID |
694 | 5269 case PV_DEF: return (char_u *)&(curbuf->b_p_def); |
5270 case PV_INC: return (char_u *)&(curbuf->b_p_inc); | |
7 | 5271 #endif |
694 | 5272 case PV_DICT: return (char_u *)&(curbuf->b_p_dict); |
5273 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr); | |
25990
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5274 #ifdef FEAT_COMPL_FUNC |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5275 case PV_TSRFU: return (char_u *)&(curbuf->b_p_tsrfu); |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5276 #endif |
790 | 5277 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5278 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr); | |
5279 #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
|
5280 #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
|
5281 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
|
5282 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5283 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5284 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
|
5285 #endif |
40 | 5286 #ifdef FEAT_STL_OPT |
694 | 5287 case PV_STL: return (char_u *)&(curwin->w_p_stl); |
40 | 5288 #endif |
5446 | 5289 case PV_UL: return (char_u *)&(curbuf->b_p_ul); |
5712 | 5290 case PV_LW: return (char_u *)&(curbuf->b_p_lw); |
6243 | 5291 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
|
5292 case PV_MENC: return (char_u *)&(curbuf->b_p_menc); |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
5293 case PV_LCS: return (char_u *)&(curwin->w_p_lcs); |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5294 case PV_FCS: return (char_u *)&(curwin->w_p_fcs); |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5295 case PV_VE: return (char_u *)&(curwin->w_p_ve); |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5296 |
7 | 5297 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5298 return NULL; // "cannot happen" |
7 | 5299 } |
5300 return get_varp(p); | |
5301 } | |
5302 | |
5303 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5304 * 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
|
5305 * scope. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5306 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5307 char_u * |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
5308 get_option_varp_scope(int opt_idx, int scope) |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5309 { |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
5310 return get_varp_scope(&(options[opt_idx]), scope); |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5311 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5312 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5313 /* |
7 | 5314 * Get pointer to option variable. |
5315 */ | |
5316 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5317 get_varp(struct vimoption *p) |
7 | 5318 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5319 // hidden option, always return NULL |
7 | 5320 if (p->var == NULL) |
5321 return NULL; | |
5322 | |
5323 switch ((int)p->indir) | |
5324 { | |
5325 case PV_NONE: return p->var; | |
5326 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5327 // global option with local value: use local value if it's been set |
694 | 5328 case PV_EP: return *curbuf->b_p_ep != NUL |
7 | 5329 ? (char_u *)&curbuf->b_p_ep : p->var; |
694 | 5330 case PV_KP: return *curbuf->b_p_kp != NUL |
7 | 5331 ? (char_u *)&curbuf->b_p_kp : p->var; |
694 | 5332 case PV_PATH: return *curbuf->b_p_path != NUL |
7 | 5333 ? (char_u *)&(curbuf->b_p_path) : p->var; |
692 | 5334 case PV_AR: return curbuf->b_p_ar >= 0 |
7 | 5335 ? (char_u *)&(curbuf->b_p_ar) : p->var; |
694 | 5336 case PV_TAGS: return *curbuf->b_p_tags != NUL |
7 | 5337 ? (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
|
5338 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
|
5339 ? (char_u *)&(curbuf->b_p_tc) : p->var; |
6243 | 5340 case PV_BKC: return *curbuf->b_p_bkc != NUL |
5341 ? (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
|
5342 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
|
5343 ? (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
|
5344 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
|
5345 ? (char_u *)&(curwin->w_p_so) : p->var; |
7 | 5346 #ifdef FEAT_FIND_ID |
694 | 5347 case PV_DEF: return *curbuf->b_p_def != NUL |
7 | 5348 ? (char_u *)&(curbuf->b_p_def) : p->var; |
694 | 5349 case PV_INC: return *curbuf->b_p_inc != NUL |
7 | 5350 ? (char_u *)&(curbuf->b_p_inc) : p->var; |
5351 #endif | |
694 | 5352 case PV_DICT: return *curbuf->b_p_dict != NUL |
7 | 5353 ? (char_u *)&(curbuf->b_p_dict) : p->var; |
694 | 5354 case PV_TSR: return *curbuf->b_p_tsr != NUL |
7 | 5355 ? (char_u *)&(curbuf->b_p_tsr) : p->var; |
25990
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5356 #ifdef FEAT_COMPL_FUNC |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5357 case PV_TSRFU: return *curbuf->b_p_tsrfu != NUL |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5358 ? (char_u *)&(curbuf->b_p_tsrfu) : p->var; |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5359 #endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5360 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
|
5361 ? (char_u *)&(curbuf->b_p_fp) : p->var; |
7 | 5362 #ifdef FEAT_QUICKFIX |
694 | 5363 case PV_EFM: return *curbuf->b_p_efm != NUL |
5364 ? (char_u *)&(curbuf->b_p_efm) : p->var; | |
5365 case PV_GP: return *curbuf->b_p_gp != NUL | |
7 | 5366 ? (char_u *)&(curbuf->b_p_gp) : p->var; |
694 | 5367 case PV_MP: return *curbuf->b_p_mp != NUL |
7 | 5368 ? (char_u *)&(curbuf->b_p_mp) : p->var; |
5369 #endif | |
790 | 5370 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5371 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL | |
5372 ? (char_u *)&(curbuf->b_p_bexpr) : p->var; | |
5373 #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
|
5374 #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
|
5375 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
|
5376 ? (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
|
5377 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5378 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5379 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
|
5380 ? (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
|
5381 #endif |
40 | 5382 #ifdef FEAT_STL_OPT |
694 | 5383 case PV_STL: return *curwin->w_p_stl != NUL |
40 | 5384 ? (char_u *)&(curwin->w_p_stl) : p->var; |
5385 #endif | |
5446 | 5386 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL |
5387 ? (char_u *)&(curbuf->b_p_ul) : p->var; | |
5712 | 5388 case PV_LW: return *curbuf->b_p_lw != NUL |
5389 ? (char_u *)&(curbuf->b_p_lw) : p->var; | |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
5390 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
|
5391 ? (char_u *)&(curbuf->b_p_menc) : p->var; |
7 | 5392 #ifdef FEAT_ARABIC |
5393 case PV_ARAB: return (char_u *)&(curwin->w_p_arab); | |
5394 #endif | |
5395 case PV_LIST: return (char_u *)&(curwin->w_p_list); | |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5396 case PV_LCS: return *curwin->w_p_lcs != NUL |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5397 ? (char_u *)&(curwin->w_p_lcs) : p->var; |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5398 case PV_FCS: return *curwin->w_p_fcs != NUL |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5399 ? (char_u *)&(curwin->w_p_fcs) : p->var; |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5400 case PV_VE: return *curwin->w_p_ve != NUL |
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5401 ? (char_u *)&(curwin->w_p_ve) : p->var; |
744 | 5402 #ifdef FEAT_SPELL |
5403 case PV_SPELL: return (char_u *)&(curwin->w_p_spell); | |
5404 #endif | |
221 | 5405 #ifdef FEAT_SYN_HL |
744 | 5406 case PV_CUC: return (char_u *)&(curwin->w_p_cuc); |
5407 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
|
5408 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
|
5409 case PV_CC: return (char_u *)&(curwin->w_p_cc); |
221 | 5410 #endif |
7 | 5411 #ifdef FEAT_DIFF |
5412 case PV_DIFF: return (char_u *)&(curwin->w_p_diff); | |
5413 #endif | |
5414 #ifdef FEAT_FOLDING | |
5415 case PV_FDC: return (char_u *)&(curwin->w_p_fdc); | |
5416 case PV_FEN: return (char_u *)&(curwin->w_p_fen); | |
5417 case PV_FDI: return (char_u *)&(curwin->w_p_fdi); | |
5418 case PV_FDL: return (char_u *)&(curwin->w_p_fdl); | |
5419 case PV_FDM: return (char_u *)&(curwin->w_p_fdm); | |
5420 case PV_FML: return (char_u *)&(curwin->w_p_fml); | |
5421 case PV_FDN: return (char_u *)&(curwin->w_p_fdn); | |
5422 # ifdef FEAT_EVAL | |
5423 case PV_FDE: return (char_u *)&(curwin->w_p_fde); | |
5424 case PV_FDT: return (char_u *)&(curwin->w_p_fdt); | |
5425 # endif | |
5426 case PV_FMR: return (char_u *)&(curwin->w_p_fmr); | |
5427 #endif | |
5428 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
|
5429 case PV_RNU: return (char_u *)&(curwin->w_p_rnu); |
13 | 5430 #ifdef FEAT_LINEBREAK |
5431 case PV_NUW: return (char_u *)&(curwin->w_p_nuw); | |
5432 #endif | |
7 | 5433 case PV_WFH: return (char_u *)&(curwin->w_p_wfh); |
782 | 5434 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
|
5435 #if defined(FEAT_QUICKFIX) |
7 | 5436 case PV_PVW: return (char_u *)&(curwin->w_p_pvw); |
5437 #endif | |
5438 #ifdef FEAT_RIGHTLEFT | |
5439 case PV_RL: return (char_u *)&(curwin->w_p_rl); | |
5440 case PV_RLC: return (char_u *)&(curwin->w_p_rlc); | |
5441 #endif | |
5442 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr); | |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
5443 case PV_SMS: return (char_u *)&(curwin->w_p_sms); |
7 | 5444 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); |
5445 #ifdef FEAT_LINEBREAK | |
5446 case PV_LBR: return (char_u *)&(curwin->w_p_lbr); | |
5995 | 5447 case PV_BRI: return (char_u *)&(curwin->w_p_bri); |
5448 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt); | |
7 | 5449 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5450 case PV_WCR: return (char_u *)&(curwin->w_p_wcr); |
7 | 5451 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
|
5452 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
|
5453 #ifdef FEAT_CONCEAL |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5454 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
|
5455 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
|
5456 #endif |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5457 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5458 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
|
5459 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
|
5460 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
|
5461 #endif |
7 | 5462 |
5463 case PV_AI: return (char_u *)&(curbuf->b_p_ai); | |
5464 case PV_BIN: return (char_u *)&(curbuf->b_p_bin); | |
5465 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); | |
5466 case PV_BH: return (char_u *)&(curbuf->b_p_bh); | |
5467 case PV_BT: return (char_u *)&(curbuf->b_p_bt); | |
5468 case PV_BL: return (char_u *)&(curbuf->b_p_bl); | |
5469 case PV_CI: return (char_u *)&(curbuf->b_p_ci); | |
5470 case PV_CIN: return (char_u *)&(curbuf->b_p_cin); | |
5471 case PV_CINK: return (char_u *)&(curbuf->b_p_cink); | |
5472 case PV_CINO: return (char_u *)&(curbuf->b_p_cino); | |
28353
8bc8071928ed
patch 8.2.4702: C++ scope labels are hard-coded
Bram Moolenaar <Bram@vim.org>
parents:
28337
diff
changeset
|
5473 case PV_CINSD: return (char_u *)&(curbuf->b_p_cinsd); |
7 | 5474 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); |
5475 case PV_COM: return (char_u *)&(curbuf->b_p_com); | |
5476 #ifdef FEAT_FOLDING | |
5477 case PV_CMS: return (char_u *)&(curbuf->b_p_cms); | |
5478 #endif | |
5479 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
|
5480 #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
|
5481 case PV_CSL: return (char_u *)&(curbuf->b_p_csl); |
7 | 5482 #endif |
12 | 5483 #ifdef FEAT_COMPL_FUNC |
5484 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); | |
502 | 5485 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); |
12 | 5486 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5487 #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
|
5488 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
|
5489 #endif |
30966
685ee8453163
Add missing entry for the 'endoffile' option.
Bram Moolenaar <Bram@vim.org>
parents:
30853
diff
changeset
|
5490 case PV_EOF: return (char_u *)&(curbuf->b_p_eof); |
7 | 5491 case PV_EOL: return (char_u *)&(curbuf->b_p_eol); |
6933 | 5492 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol); |
7 | 5493 case PV_ET: return (char_u *)&(curbuf->b_p_et); |
5494 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); | |
5495 case PV_FF: return (char_u *)&(curbuf->b_p_ff); | |
5496 case PV_FT: return (char_u *)&(curbuf->b_p_ft); | |
5497 case PV_FO: return (char_u *)&(curbuf->b_p_fo); | |
41 | 5498 case PV_FLP: return (char_u *)&(curbuf->b_p_flp); |
7 | 5499 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); |
5500 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); | |
5501 case PV_INF: return (char_u *)&(curbuf->b_p_inf); | |
5502 case PV_ISK: return (char_u *)&(curbuf->b_p_isk); | |
5503 #ifdef FEAT_FIND_ID | |
5504 # ifdef FEAT_EVAL | |
5505 case PV_INEX: return (char_u *)&(curbuf->b_p_inex); | |
5506 # endif | |
5507 #endif | |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
5508 #if defined(FEAT_EVAL) |
7 | 5509 case PV_INDE: return (char_u *)&(curbuf->b_p_inde); |
5510 case PV_INDK: return (char_u *)&(curbuf->b_p_indk); | |
5511 #endif | |
694 | 5512 #ifdef FEAT_EVAL |
667 | 5513 case PV_FEX: return (char_u *)&(curbuf->b_p_fex); |
5514 #endif | |
7 | 5515 #ifdef FEAT_CRYPT |
5516 case PV_KEY: return (char_u *)&(curbuf->b_p_key); | |
5517 #endif | |
5518 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp); | |
30853
40df8a6515f6
patch 9.0.0761: cannot use 'indentexpr' for Lisp indenting
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
5519 case PV_LOP: return (char_u *)&(curbuf->b_p_lop); |
7 | 5520 case PV_ML: return (char_u *)&(curbuf->b_p_ml); |
5521 case PV_MPS: return (char_u *)&(curbuf->b_p_mps); | |
5522 case PV_MA: return (char_u *)&(curbuf->b_p_ma); | |
5523 case PV_MOD: return (char_u *)&(curbuf->b_changed); | |
5524 case PV_NF: return (char_u *)&(curbuf->b_p_nf); | |
5525 case PV_PI: return (char_u *)&(curbuf->b_p_pi); | |
12 | 5526 case PV_QE: return (char_u *)&(curbuf->b_p_qe); |
7 | 5527 case PV_RO: return (char_u *)&(curbuf->b_p_ro); |
5528 case PV_SI: return (char_u *)&(curbuf->b_p_si); | |
5529 case PV_SN: return (char_u *)&(curbuf->b_p_sn); | |
5530 case PV_STS: return (char_u *)&(curbuf->b_p_sts); | |
5531 case PV_SUA: return (char_u *)&(curbuf->b_p_sua); | |
5532 case PV_SWF: return (char_u *)&(curbuf->b_p_swf); | |
5533 #ifdef FEAT_SYN_HL | |
410 | 5534 case PV_SMC: return (char_u *)&(curbuf->b_p_smc); |
744 | 5535 case PV_SYN: return (char_u *)&(curbuf->b_p_syn); |
5536 #endif | |
5537 #ifdef FEAT_SPELL | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5538 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
|
5539 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
|
5540 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl); |
20802
ed00f0fbdaef
patch 8.2.0953: spell checking doesn't work for CamelCased words
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
5541 case PV_SPO: return (char_u *)&(curwin->w_s->b_p_spo); |
7 | 5542 #endif |
5543 case PV_SW: return (char_u *)&(curbuf->b_p_sw); | |
5544 case PV_TS: return (char_u *)&(curbuf->b_p_ts); | |
5545 case PV_TW: return (char_u *)&(curbuf->b_p_tw); | |
5546 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
|
5547 #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
|
5548 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
|
5549 #endif |
7 | 5550 case PV_WM: return (char_u *)&(curbuf->b_p_wm); |
5551 #ifdef FEAT_KEYMAP | |
5552 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); | |
5553 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5554 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5555 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
|
5556 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5557 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5558 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
|
5559 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
|
5560 #endif |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
5561 default: iemsg(_(e_get_varp_error)); |
7 | 5562 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5563 // always return a valid pointer to avoid a crash! |
7 | 5564 return (char_u *)&(curbuf->b_p_wm); |
5565 } | |
5566 | |
5567 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5568 * 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
|
5569 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5570 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5571 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
|
5572 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5573 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
|
5574 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5575 |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
5576 #if defined(FEAT_EVAL) || defined(PROTO) |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5577 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5578 * 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
|
5579 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5580 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5581 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
|
5582 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5583 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
|
5584 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
5585 #endif |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5586 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5587 /* |
7 | 5588 * Get the value of 'equalprg', either the buffer-local one or the global one. |
5589 */ | |
5590 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5591 get_equalprg(void) |
7 | 5592 { |
5593 if (*curbuf->b_p_ep == NUL) | |
5594 return p_ep; | |
5595 return curbuf->b_p_ep; | |
5596 } | |
5597 | |
5598 /* | |
5599 * Copy options from one window to another. | |
5600 * Used when splitting a window. | |
5601 */ | |
5602 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5603 win_copy_options(win_T *wp_from, win_T *wp_to) |
7 | 5604 { |
5605 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); | |
5606 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
|
5607 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
|
5608 } |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5609 |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5610 /* |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5611 * 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
|
5612 */ |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5613 void |
27659
b5ebc885c25c
patch 8.2.4355: unnecessary call to check_colorcolumn()
Bram Moolenaar <Bram@vim.org>
parents:
27509
diff
changeset
|
5614 after_copy_winopt(win_T *wp) |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5615 { |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5616 #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
|
5617 briopt_check(wp); |
6162 | 5618 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
5619 #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
|
5620 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
|
5621 check_colorcolumn(wp); |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
5622 #endif |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
5623 set_chars_option(wp, &wp->w_p_lcs, TRUE); |
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
5624 set_chars_option(wp, &wp->w_p_fcs, TRUE); |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5625 } |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5626 |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5627 static char_u * |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5628 copy_option_val(char_u *val) |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5629 { |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5630 if (val == empty_option) |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5631 return empty_option; // no need to allocate memory |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5632 return vim_strsave(val); |
7 | 5633 } |
5634 | |
5635 /* | |
5636 * Copy the options from one winopt_T to another. | |
5637 * Doesn't free the old option values in "to", use clear_winopt() for that. | |
5638 * The 'scroll' option is not copied, because it depends on the window height. | |
5639 * The 'previewwindow' option is reset, there can be only one preview window. | |
5640 */ | |
5641 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5642 copy_winopt(winopt_T *from, winopt_T *to) |
7 | 5643 { |
5644 #ifdef FEAT_ARABIC | |
5645 to->wo_arab = from->wo_arab; | |
5646 #endif | |
5647 to->wo_list = from->wo_list; | |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5648 to->wo_lcs = copy_option_val(from->wo_lcs); |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5649 to->wo_fcs = copy_option_val(from->wo_fcs); |
7 | 5650 to->wo_nu = from->wo_nu; |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
5651 to->wo_rnu = from->wo_rnu; |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5652 to->wo_ve = copy_option_val(from->wo_ve); |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5653 to->wo_ve_flags = from->wo_ve_flags; |
13 | 5654 #ifdef FEAT_LINEBREAK |
5655 to->wo_nuw = from->wo_nuw; | |
5656 #endif | |
7 | 5657 #ifdef FEAT_RIGHTLEFT |
5658 to->wo_rl = from->wo_rl; | |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5659 to->wo_rlc = copy_option_val(from->wo_rlc); |
7 | 5660 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5661 #ifdef FEAT_LINEBREAK |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5662 to->wo_sbr = copy_option_val(from->wo_sbr); |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5663 #endif |
40 | 5664 #ifdef FEAT_STL_OPT |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5665 to->wo_stl = copy_option_val(from->wo_stl); |
40 | 5666 #endif |
7 | 5667 to->wo_wrap = from->wo_wrap; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5668 #ifdef FEAT_DIFF |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5669 to->wo_wrap_save = from->wo_wrap_save; |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5670 #endif |
7 | 5671 #ifdef FEAT_LINEBREAK |
5672 to->wo_lbr = from->wo_lbr; | |
5995 | 5673 to->wo_bri = from->wo_bri; |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5674 to->wo_briopt = copy_option_val(from->wo_briopt); |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5675 #endif |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5676 to->wo_wcr = copy_option_val(from->wo_wcr); |
7 | 5677 to->wo_scb = from->wo_scb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5678 to->wo_scb_save = from->wo_scb_save; |
30618
c2031ad5ed54
patch 9.0.0644: 'smoothscroll' is not copied to a new window on :split
Bram Moolenaar <Bram@vim.org>
parents:
30610
diff
changeset
|
5679 to->wo_sms = from->wo_sms; |
2651 | 5680 to->wo_crb = from->wo_crb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5681 to->wo_crb_save = from->wo_crb_save; |
744 | 5682 #ifdef FEAT_SPELL |
5683 to->wo_spell = from->wo_spell; | |
5684 #endif | |
221 | 5685 #ifdef FEAT_SYN_HL |
744 | 5686 to->wo_cuc = from->wo_cuc; |
5687 to->wo_cul = from->wo_cul; | |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5688 to->wo_culopt = copy_option_val(from->wo_culopt); |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5689 to->wo_cc = copy_option_val(from->wo_cc); |
221 | 5690 #endif |
7 | 5691 #ifdef FEAT_DIFF |
5692 to->wo_diff = from->wo_diff; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5693 to->wo_diff_saved = from->wo_diff_saved; |
7 | 5694 #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
|
5695 #ifdef FEAT_CONCEAL |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5696 to->wo_cocu = copy_option_val(from->wo_cocu); |
2379
b67b0b5a93d3
Window split didn't copy the value of 'conceallevel'.
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
5697 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
|
5698 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5699 #ifdef FEAT_TERMINAL |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5700 to->wo_twk = copy_option_val(from->wo_twk); |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5701 to->wo_tws = copy_option_val(from->wo_tws); |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5702 #endif |
7 | 5703 #ifdef FEAT_FOLDING |
5704 to->wo_fdc = from->wo_fdc; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5705 to->wo_fdc_save = from->wo_fdc_save; |
7 | 5706 to->wo_fen = from->wo_fen; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5707 to->wo_fen_save = from->wo_fen_save; |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5708 to->wo_fdi = copy_option_val(from->wo_fdi); |
7 | 5709 to->wo_fml = from->wo_fml; |
5710 to->wo_fdl = from->wo_fdl; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5711 to->wo_fdl_save = from->wo_fdl_save; |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5712 to->wo_fdm = copy_option_val(from->wo_fdm); |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5713 to->wo_fdm_save = from->wo_diff_saved |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5714 ? vim_strsave(from->wo_fdm_save) : empty_option; |
7 | 5715 to->wo_fdn = from->wo_fdn; |
5716 # ifdef FEAT_EVAL | |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5717 to->wo_fde = copy_option_val(from->wo_fde); |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5718 to->wo_fdt = copy_option_val(from->wo_fdt); |
7 | 5719 # endif |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5720 to->wo_fmr = copy_option_val(from->wo_fmr); |
7 | 5721 #endif |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5722 #ifdef FEAT_SIGNS |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5723 to->wo_scl = copy_option_val(from->wo_scl); |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5724 #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
|
5725 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5726 #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
|
5727 // 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
|
5728 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
|
5729 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
|
5730 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5731 check_winopt(to); // don't want NULL pointers |
7 | 5732 } |
5733 | |
5734 /* | |
5735 * Check string options in a window for a NULL value. | |
5736 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
5737 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5738 check_win_options(win_T *win) |
7 | 5739 { |
5740 check_winopt(&win->w_onebuf_opt); | |
5741 check_winopt(&win->w_allbuf_opt); | |
5742 } | |
5743 | |
5744 /* | |
5745 * Check for NULL pointers in a winopt_T and replace them with empty_option. | |
5746 */ | |
5997 | 5747 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5748 check_winopt(winopt_T *wop UNUSED) |
7 | 5749 { |
5750 #ifdef FEAT_FOLDING | |
5751 check_string_option(&wop->wo_fdi); | |
5752 check_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5753 check_string_option(&wop->wo_fdm_save); |
7 | 5754 # ifdef FEAT_EVAL |
5755 check_string_option(&wop->wo_fde); | |
5756 check_string_option(&wop->wo_fdt); | |
5757 # endif | |
5758 check_string_option(&wop->wo_fmr); | |
5759 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5760 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5761 check_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5762 #endif |
7 | 5763 #ifdef FEAT_RIGHTLEFT |
5764 check_string_option(&wop->wo_rlc); | |
5765 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5766 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5767 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
|
5768 #endif |
40 | 5769 #ifdef FEAT_STL_OPT |
5770 check_string_option(&wop->wo_stl); | |
5771 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5772 #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
|
5773 check_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5774 check_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5775 #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
|
5776 #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
|
5777 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
|
5778 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5779 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5780 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
|
5781 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
|
5782 #endif |
5995 | 5783 #ifdef FEAT_LINEBREAK |
5784 check_string_option(&wop->wo_briopt); | |
5785 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5786 check_string_option(&wop->wo_wcr); |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5787 check_string_option(&wop->wo_lcs); |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5788 check_string_option(&wop->wo_fcs); |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5789 check_string_option(&wop->wo_ve); |
7 | 5790 } |
5791 | |
5792 /* | |
5793 * Free the allocated memory inside a winopt_T. | |
5794 */ | |
5795 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5796 clear_winopt(winopt_T *wop UNUSED) |
7 | 5797 { |
5798 #ifdef FEAT_FOLDING | |
5799 clear_string_option(&wop->wo_fdi); | |
5800 clear_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5801 clear_string_option(&wop->wo_fdm_save); |
7 | 5802 # ifdef FEAT_EVAL |
5803 clear_string_option(&wop->wo_fde); | |
5804 clear_string_option(&wop->wo_fdt); | |
5805 # endif | |
5806 clear_string_option(&wop->wo_fmr); | |
5807 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5808 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5809 clear_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5810 #endif |
5995 | 5811 #ifdef FEAT_LINEBREAK |
5812 clear_string_option(&wop->wo_briopt); | |
5813 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5814 clear_string_option(&wop->wo_wcr); |
7 | 5815 #ifdef FEAT_RIGHTLEFT |
5816 clear_string_option(&wop->wo_rlc); | |
5817 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5818 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5819 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
|
5820 #endif |
40 | 5821 #ifdef FEAT_STL_OPT |
5822 clear_string_option(&wop->wo_stl); | |
5823 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5824 #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
|
5825 clear_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5826 clear_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5827 #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
|
5828 #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
|
5829 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
|
5830 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5831 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5832 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
|
5833 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
|
5834 #endif |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5835 clear_string_option(&wop->wo_lcs); |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5836 clear_string_option(&wop->wo_fcs); |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5837 clear_string_option(&wop->wo_ve); |
7 | 5838 } |
5839 | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5840 #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
|
5841 // 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
|
5842 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
|
5843 # 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
|
5844 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5845 /* |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5846 * 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
|
5847 */ |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5848 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
|
5849 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
|
5850 { |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5851 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
|
5852 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
|
5853 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5854 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
|
5855 return; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5856 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
|
5857 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
|
5858 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
|
5859 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
|
5860 } |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5861 #else |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5862 # 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
|
5863 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5864 |
7 | 5865 /* |
5866 * Copy global option values to local options for one buffer. | |
5867 * Used when creating a new buffer and sometimes when entering a buffer. | |
5868 * 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
|
5869 * BCO_ENTER We will enter the buffer "buf". |
7 | 5870 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when |
5871 * appropriate. | |
5872 * BCO_NOHELP Don't copy the values to a help buffer. | |
5873 */ | |
5874 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5875 buf_copy_options(buf_T *buf, int flags) |
7 | 5876 { |
5877 int should_copy = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5878 char_u *save_p_isk = NULL; // init for GCC |
7 | 5879 int dont_do_help; |
5880 int did_isk = FALSE; | |
5881 | |
5882 /* | |
5883 * Skip this when the option defaults have not been set yet. Happens when | |
5884 * main() allocates the first buffer. | |
5885 */ | |
5886 if (p_cpo != NULL) | |
5887 { | |
5888 /* | |
5889 * Always copy when entering and 'cpo' contains 'S'. | |
5890 * Don't copy when already initialized. | |
5891 * Don't copy when 'cpo' contains 's' and not entering. | |
5892 * 'S' BCO_ENTER initialized 's' should_copy | |
5893 * yes yes X X TRUE | |
5894 * yes no yes X FALSE | |
5895 * no X yes X FALSE | |
5896 * X no no yes FALSE | |
5897 * X no no no TRUE | |
5898 * no yes no X TRUE | |
5899 */ | |
5900 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) | |
5901 && (buf->b_p_initialized | |
5902 || (!(flags & BCO_ENTER) | |
5903 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
5904 should_copy = FALSE; | |
5905 | |
5906 if (should_copy || (flags & BCO_ALWAYS)) | |
5907 { | |
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
|
5908 #ifdef FEAT_EVAL |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
5909 CLEAR_FIELD(buf->b_p_script_ctx); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5910 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
|
5911 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5912 // 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
|
5913 // 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
|
5914 // (jumping back to a help file with CTRL-T or CTRL-O) |
7 | 5915 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) |
5916 || 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
|
5917 if (dont_do_help) // don't free b_p_isk |
7 | 5918 { |
5919 save_p_isk = buf->b_p_isk; | |
5920 buf->b_p_isk = NULL; | |
5921 } | |
5922 /* | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14381
diff
changeset
|
5923 * 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
|
5924 * reset 'readonly' and copy 'fileformat'. |
7 | 5925 */ |
5926 if (!buf->b_p_initialized) | |
5927 { | |
5928 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
|
5929 buf->b_p_ro = FALSE; // don't copy readonly |
7 | 5930 buf->b_p_tx = p_tx; |
5931 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
|
5932 switch (*p_ffs) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5933 { |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5934 case 'm': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5935 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
|
5936 case 'd': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5937 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
|
5938 case 'u': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5939 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
|
5940 default: |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5941 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
|
5942 } |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5943 if (buf->b_p_ff != NULL) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5944 buf->b_start_ffc = *buf->b_p_ff; |
7 | 5945 buf->b_p_bh = empty_option; |
5946 buf->b_p_bt = empty_option; | |
5947 } | |
5948 else | |
5949 free_buf_options(buf, FALSE); | |
5950 | |
5951 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
|
5952 COPY_OPT_SCTX(buf, BV_AI); |
7 | 5953 buf->b_p_ai_nopaste = p_ai_nopaste; |
5954 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
|
5955 COPY_OPT_SCTX(buf, BV_SW); |
7 | 5956 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
|
5957 COPY_OPT_SCTX(buf, BV_TW); |
7 | 5958 buf->b_p_tw_nopaste = p_tw_nopaste; |
5959 buf->b_p_tw_nobin = p_tw_nobin; | |
5960 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
|
5961 COPY_OPT_SCTX(buf, BV_WM); |
7 | 5962 buf->b_p_wm_nopaste = p_wm_nopaste; |
5963 buf->b_p_wm_nobin = p_wm_nobin; | |
5964 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
|
5965 COPY_OPT_SCTX(buf, BV_BIN); |
402 | 5966 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
|
5967 COPY_OPT_SCTX(buf, BV_BOMB); |
6954 | 5968 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
|
5969 COPY_OPT_SCTX(buf, BV_FIXEOL); |
7 | 5970 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
|
5971 COPY_OPT_SCTX(buf, BV_ET); |
7 | 5972 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
|
5973 buf->b_p_et_nopaste = p_et_nopaste; |
7 | 5974 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
|
5975 COPY_OPT_SCTX(buf, BV_ML); |
7 | 5976 buf->b_p_ml_nobin = p_ml_nobin; |
5977 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
|
5978 COPY_OPT_SCTX(buf, BV_INF); |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22242
diff
changeset
|
5979 if (cmdmod.cmod_flags & CMOD_NOSWAPFILE) |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5980 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
|
5981 else |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5982 { |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5983 buf->b_p_swf = p_swf; |
26550
919ee902079a
patch 8.2.3804: script context not set when copying 'swf' and 'ts'
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
5984 COPY_OPT_SCTX(buf, BV_SWF); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5985 } |
7 | 5986 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
|
5987 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
|
5988 #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
|
5989 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
|
5990 COPY_OPT_SCTX(buf, BV_CSL); |
7 | 5991 #endif |
12 | 5992 #ifdef FEAT_COMPL_FUNC |
5993 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
|
5994 COPY_OPT_SCTX(buf, BV_CFU); |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
5995 set_buflocal_cfu_callback(buf); |
502 | 5996 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
|
5997 COPY_OPT_SCTX(buf, BV_OFU); |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
5998 set_buflocal_ofu_callback(buf); |
12 | 5999 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
6000 #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
|
6001 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
|
6002 COPY_OPT_SCTX(buf, BV_TFU); |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
6003 set_buflocal_tfu_callback(buf); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
6004 #endif |
7 | 6005 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
|
6006 COPY_OPT_SCTX(buf, BV_STS); |
7 | 6007 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
|
6008 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6009 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
|
6010 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
|
6011 if (p_vsts && p_vsts != empty_option) |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
6012 (void)tabstop_set(p_vsts, &buf->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
|
6013 else |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
6014 buf->b_p_vsts_array = NULL; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6015 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
|
6016 ? 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
|
6017 #endif |
7 | 6018 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
|
6019 COPY_OPT_SCTX(buf, BV_SN); |
7 | 6020 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
|
6021 COPY_OPT_SCTX(buf, BV_COM); |
7 | 6022 #ifdef FEAT_FOLDING |
6023 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
|
6024 COPY_OPT_SCTX(buf, BV_CMS); |
7 | 6025 #endif |
6026 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
|
6027 COPY_OPT_SCTX(buf, BV_FO); |
41 | 6028 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
|
6029 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
|
6030 // 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
|
6031 // when it is set to 8 bytes in defaults.vim. |
7 | 6032 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
|
6033 COPY_OPT_SCTX(buf, BV_NF); |
7 | 6034 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
|
6035 COPY_OPT_SCTX(buf, BV_MPS); |
7 | 6036 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
|
6037 COPY_OPT_SCTX(buf, BV_SI); |
7 | 6038 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
|
6039 COPY_OPT_SCTX(buf, BV_CI); |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
6040 |
7 | 6041 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
|
6042 COPY_OPT_SCTX(buf, BV_CIN); |
7 | 6043 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
|
6044 COPY_OPT_SCTX(buf, BV_CINK); |
7 | 6045 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
|
6046 COPY_OPT_SCTX(buf, BV_CINO); |
28353
8bc8071928ed
patch 8.2.4702: C++ scope labels are hard-coded
Bram Moolenaar <Bram@vim.org>
parents:
28337
diff
changeset
|
6047 buf->b_p_cinsd = vim_strsave(p_cinsd); |
8bc8071928ed
patch 8.2.4702: C++ scope labels are hard-coded
Bram Moolenaar <Bram@vim.org>
parents:
28337
diff
changeset
|
6048 COPY_OPT_SCTX(buf, BV_CINSD); |
30853
40df8a6515f6
patch 9.0.0761: cannot use 'indentexpr' for Lisp indenting
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
6049 buf->b_p_lop = vim_strsave(p_lop); |
40df8a6515f6
patch 9.0.0761: cannot use 'indentexpr' for Lisp indenting
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
6050 COPY_OPT_SCTX(buf, BV_LOP); |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
6051 |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6052 // Don't copy 'filetype', it must be detected |
7 | 6053 buf->b_p_ft = empty_option; |
6054 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
|
6055 COPY_OPT_SCTX(buf, BV_PI); |
7 | 6056 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
|
6057 COPY_OPT_SCTX(buf, BV_CINW); |
7 | 6058 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
|
6059 COPY_OPT_SCTX(buf, BV_LISP); |
7 | 6060 #ifdef FEAT_SYN_HL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6061 // Don't copy 'syntax', it must be set |
7 | 6062 buf->b_p_syn = empty_option; |
410 | 6063 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
|
6064 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
|
6065 buf->b_s.b_syn_isk = empty_option; |
744 | 6066 #endif |
6067 #ifdef FEAT_SPELL | |
2599 | 6068 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
|
6069 COPY_OPT_SCTX(buf, BV_SPC); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6070 (void)compile_cap_prog(&buf->b_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6071 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
|
6072 COPY_OPT_SCTX(buf, BV_SPF); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6073 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
|
6074 COPY_OPT_SCTX(buf, BV_SPL); |
20802
ed00f0fbdaef
patch 8.2.0953: spell checking doesn't work for CamelCased words
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
6075 buf->b_s.b_p_spo = vim_strsave(p_spo); |
ed00f0fbdaef
patch 8.2.0953: spell checking doesn't work for CamelCased words
Bram Moolenaar <Bram@vim.org>
parents:
20603
diff
changeset
|
6076 COPY_OPT_SCTX(buf, BV_SPO); |
7 | 6077 #endif |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
6078 #if defined(FEAT_EVAL) |
7 | 6079 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
|
6080 COPY_OPT_SCTX(buf, BV_INDE); |
7 | 6081 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
|
6082 COPY_OPT_SCTX(buf, BV_INDK); |
7 | 6083 #endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
6084 buf->b_p_fp = empty_option; |
667 | 6085 #if defined(FEAT_EVAL) |
6086 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
|
6087 COPY_OPT_SCTX(buf, BV_FEX); |
667 | 6088 #endif |
7 | 6089 #ifdef FEAT_CRYPT |
6090 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
|
6091 COPY_OPT_SCTX(buf, BV_KEY); |
7 | 6092 #endif |
6093 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
|
6094 COPY_OPT_SCTX(buf, BV_SUA); |
7 | 6095 #ifdef FEAT_KEYMAP |
6096 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
|
6097 COPY_OPT_SCTX(buf, BV_KMAP); |
7 | 6098 buf->b_kmap_state |= KEYMAP_INIT; |
6099 #endif | |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6100 #ifdef FEAT_TERMINAL |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6101 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
|
6102 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
|
6103 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6104 // 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
|
6105 // state from the current buffer is better than resetting it. |
7 | 6106 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
|
6107 COPY_OPT_SCTX(buf, BV_IMI); |
7 | 6108 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
|
6109 COPY_OPT_SCTX(buf, BV_IMS); |
7 | 6110 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6111 // 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
|
6112 // are not copied, start using the global value |
7 | 6113 buf->b_p_ar = -1; |
5446 | 6114 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
6243 | 6115 buf->b_p_bkc = empty_option; |
6116 buf->b_bkc_flags = 0; | |
7 | 6117 #ifdef FEAT_QUICKFIX |
6118 buf->b_p_gp = empty_option; | |
6119 buf->b_p_mp = empty_option; | |
6120 buf->b_p_efm = empty_option; | |
6121 #endif | |
6122 buf->b_p_ep = empty_option; | |
6123 buf->b_p_kp = empty_option; | |
6124 buf->b_p_path = empty_option; | |
6125 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
|
6126 buf->b_p_tc = empty_option; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
6127 buf->b_tc_flags = 0; |
7 | 6128 #ifdef FEAT_FIND_ID |
6129 buf->b_p_def = empty_option; | |
6130 buf->b_p_inc = empty_option; | |
6131 # ifdef FEAT_EVAL | |
6132 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
|
6133 COPY_OPT_SCTX(buf, BV_INEX); |
7 | 6134 # endif |
6135 #endif | |
6136 buf->b_p_dict = empty_option; | |
6137 buf->b_p_tsr = empty_option; | |
25990
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
6138 #ifdef FEAT_COMPL_FUNC |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
6139 buf->b_p_tsrfu = empty_option; |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
6140 #endif |
12 | 6141 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
|
6142 COPY_OPT_SCTX(buf, BV_QE); |
790 | 6143 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
6144 buf->b_p_bexpr = empty_option; | |
6145 #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
|
6146 #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
|
6147 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
|
6148 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
6149 #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
|
6150 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
|
6151 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
|
6152 #endif |
5712 | 6153 buf->b_p_lw = empty_option; |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
6154 buf->b_p_menc = empty_option; |
7 | 6155 |
6156 /* | |
6157 * Don't copy the options set by ex_help(), use the saved values, | |
6158 * when going from a help buffer to a non-help buffer. | |
6159 * Don't touch these at all when BCO_NOHELP is used and going from | |
6160 * or to a help buffer. | |
6161 */ | |
6162 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
|
6163 { |
7 | 6164 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
|
6165 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6166 if (p_vts && p_vts != empty_option && !buf->b_p_vts_array) |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
6167 (void)tabstop_set(p_vts, &buf->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
|
6168 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6169 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
|
6170 #endif |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6171 } |
7 | 6172 else |
6173 { | |
6174 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
|
6175 COPY_OPT_SCTX(buf, BV_ISK); |
7 | 6176 did_isk = TRUE; |
6177 buf->b_p_ts = p_ts; | |
26550
919ee902079a
patch 8.2.3804: script context not set when copying 'swf' and 'ts'
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
6178 COPY_OPT_SCTX(buf, BV_TS); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6179 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6180 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
|
6181 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
|
6182 if (p_vts && p_vts != empty_option && !buf->b_p_vts_array) |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
6183 (void)tabstop_set(p_vts, &buf->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
|
6184 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6185 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
|
6186 #endif |
7 | 6187 buf->b_help = FALSE; |
6188 if (buf->b_p_bt[0] == 'h') | |
6189 clear_string_option(&buf->b_p_bt); | |
6190 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
|
6191 COPY_OPT_SCTX(buf, BV_MA); |
7 | 6192 } |
6193 } | |
6194 | |
6195 /* | |
6196 * When the options should be copied (ignoring BCO_ALWAYS), set the | |
6197 * flag that indicates that the options have been initialized. | |
6198 */ | |
6199 if (should_copy) | |
6200 buf->b_p_initialized = TRUE; | |
6201 } | |
6202 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6203 check_buf_options(buf); // make sure we don't have NULLs |
7 | 6204 if (did_isk) |
6205 (void)buf_init_chartab(buf, FALSE); | |
6206 } | |
6207 | |
6208 /* | |
6209 * Reset the 'modifiable' option and its default value. | |
6210 */ | |
6211 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6212 reset_modifiable(void) |
7 | 6213 { |
6214 int opt_idx; | |
6215 | |
6216 curbuf->b_p_ma = FALSE; | |
6217 p_ma = FALSE; | |
6218 opt_idx = findoption((char_u *)"ma"); | |
838 | 6219 if (opt_idx >= 0) |
6220 options[opt_idx].def_val[VI_DEFAULT] = FALSE; | |
7 | 6221 } |
6222 | |
6223 /* | |
6224 * Set the global value for 'iminsert' to the local value. | |
6225 */ | |
6226 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6227 set_iminsert_global(void) |
7 | 6228 { |
6229 p_iminsert = curbuf->b_p_iminsert; | |
6230 } | |
6231 | |
6232 /* | |
6233 * Set the global value for 'imsearch' to the local value. | |
6234 */ | |
6235 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6236 set_imsearch_global(void) |
7 | 6237 { |
6238 p_imsearch = curbuf->b_p_imsearch; | |
6239 } | |
6240 | |
6241 static int expand_option_idx = -1; | |
6242 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; | |
6243 static int expand_option_flags = 0; | |
6244 | |
6245 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6246 set_context_in_set_cmd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6247 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6248 char_u *arg, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6249 int opt_flags) // OPT_GLOBAL and/or OPT_LOCAL |
7 | 6250 { |
6251 int nextchar; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6252 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
|
6253 int opt_idx = 0; // init for GCC |
7 | 6254 char_u *p; |
6255 char_u *s; | |
6256 int is_term_option = FALSE; | |
6257 int key; | |
6258 | |
6259 expand_option_flags = opt_flags; | |
6260 | |
6261 xp->xp_context = EXPAND_SETTINGS; | |
6262 if (*arg == NUL) | |
6263 { | |
6264 xp->xp_pattern = arg; | |
6265 return; | |
6266 } | |
6267 p = arg + STRLEN(arg) - 1; | |
6268 if (*p == ' ' && *(p - 1) != '\\') | |
6269 { | |
6270 xp->xp_pattern = p + 1; | |
6271 return; | |
6272 } | |
6273 while (p > arg) | |
6274 { | |
6275 s = p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6276 // count number of backslashes before ' ' or ',' |
7 | 6277 if (*p == ' ' || *p == ',') |
6278 { | |
6279 while (s > arg && *(s - 1) == '\\') | |
6280 --s; | |
6281 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6282 // break at a space with an even number of backslashes |
7 | 6283 if (*p == ' ' && ((p - s) & 1) == 0) |
6284 { | |
6285 ++p; | |
6286 break; | |
6287 } | |
6288 --p; | |
6289 } | |
1911 | 6290 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0) |
7 | 6291 { |
6292 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
6293 p += 2; | |
6294 } | |
6295 if (STRNCMP(p, "inv", 3) == 0) | |
6296 { | |
6297 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
6298 p += 3; | |
6299 } | |
6300 xp->xp_pattern = arg = p; | |
6301 if (*arg == '<') | |
6302 { | |
6303 while (*p != '>') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6304 if (*p++ == NUL) // expand terminal option name |
7 | 6305 return; |
6306 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
|
6307 if (key == 0) // unknown name |
7 | 6308 { |
6309 xp->xp_context = EXPAND_NOTHING; | |
6310 return; | |
6311 } | |
6312 nextchar = *++p; | |
6313 is_term_option = TRUE; | |
6314 expand_option_name[2] = KEY2TERMCAP0(key); | |
6315 expand_option_name[3] = KEY2TERMCAP1(key); | |
6316 } | |
6317 else | |
6318 { | |
6319 if (p[0] == 't' && p[1] == '_') | |
6320 { | |
6321 p += 2; | |
6322 if (*p != NUL) | |
6323 ++p; | |
6324 if (*p == NUL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6325 return; // expand option name |
7 | 6326 nextchar = *++p; |
6327 is_term_option = TRUE; | |
6328 expand_option_name[2] = p[-2]; | |
6329 expand_option_name[3] = p[-1]; | |
6330 } | |
6331 else | |
6332 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6333 // Allow * wildcard |
7 | 6334 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') |
6335 p++; | |
6336 if (*p == NUL) | |
6337 return; | |
6338 nextchar = *p; | |
6339 *p = NUL; | |
6340 opt_idx = findoption(arg); | |
6341 *p = nextchar; | |
6342 if (opt_idx == -1 || options[opt_idx].var == NULL) | |
6343 { | |
6344 xp->xp_context = EXPAND_NOTHING; | |
6345 return; | |
6346 } | |
6347 flags = options[opt_idx].flags; | |
6348 if (flags & P_BOOL) | |
6349 { | |
6350 xp->xp_context = EXPAND_NOTHING; | |
6351 return; | |
6352 } | |
6353 } | |
6354 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6355 // handle "-=" and "+=" |
7 | 6356 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') |
6357 { | |
6358 ++p; | |
6359 nextchar = '='; | |
6360 } | |
6361 if ((nextchar != '=' && nextchar != ':') | |
6362 || xp->xp_context == EXPAND_BOOL_SETTINGS) | |
6363 { | |
6364 xp->xp_context = EXPAND_UNSUCCESSFUL; | |
6365 return; | |
6366 } | |
6367 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) | |
6368 { | |
6369 xp->xp_context = EXPAND_OLD_SETTING; | |
6370 if (is_term_option) | |
6371 expand_option_idx = -1; | |
6372 else | |
6373 expand_option_idx = opt_idx; | |
6374 xp->xp_pattern = p + 1; | |
6375 return; | |
6376 } | |
6377 xp->xp_context = EXPAND_NOTHING; | |
6378 if (is_term_option || (flags & P_NUM)) | |
6379 return; | |
6380 | |
6381 xp->xp_pattern = p + 1; | |
6382 | |
6383 if (flags & P_EXPAND) | |
6384 { | |
6385 p = options[opt_idx].var; | |
6386 if (p == (char_u *)&p_bdir | |
6387 || p == (char_u *)&p_dir | |
6388 || p == (char_u *)&p_path | |
8182
95d59081580f
commit https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
6389 || p == (char_u *)&p_pp |
7 | 6390 || p == (char_u *)&p_rtp |
6391 || p == (char_u *)&p_cdpath | |
6392 #ifdef FEAT_SESSION | |
6393 || p == (char_u *)&p_vdir | |
6394 #endif | |
6395 ) | |
6396 { | |
6397 xp->xp_context = EXPAND_DIRECTORIES; | |
29853
31c598083364
patch 9.0.0265: no good reason why the "gf" command isn't in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
29765
diff
changeset
|
6398 if (p == (char_u *)&p_path || p == (char_u *)&p_cdpath) |
7 | 6399 xp->xp_backslash = XP_BS_THREE; |
6400 else | |
6401 xp->xp_backslash = XP_BS_ONE; | |
6402 } | |
23821
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
6403 else if (p == (char_u *)&p_ft) |
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
6404 { |
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
6405 xp->xp_context = EXPAND_FILETYPE; |
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
6406 } |
7 | 6407 else |
6408 { | |
6409 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
|
6410 // for 'tags' need three backslashes for a space |
7 | 6411 if (p == (char_u *)&p_tags) |
6412 xp->xp_backslash = XP_BS_THREE; | |
6413 else | |
6414 xp->xp_backslash = XP_BS_ONE; | |
6415 } | |
6416 } | |
6417 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6418 // 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
|
6419 // last file name. |
7 | 6420 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) |
6421 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6422 // count number of backslashes before ' ' or ',' |
7 | 6423 if (*p == ' ' || *p == ',') |
6424 { | |
6425 s = p; | |
6426 while (s > xp->xp_pattern && *(s - 1) == '\\') | |
6427 --s; | |
6428 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) | |
6429 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) | |
6430 { | |
6431 xp->xp_pattern = p + 1; | |
6432 break; | |
6433 } | |
6434 } | |
374 | 6435 |
744 | 6436 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6437 // for 'spellsuggest' start at "file:" |
374 | 6438 if (options[opt_idx].var == (char_u *)&p_sps |
6439 && STRNCMP(p, "file:", 5) == 0) | |
6440 { | |
6441 xp->xp_pattern = p + 5; | |
6442 break; | |
6443 } | |
6444 #endif | |
7 | 6445 } |
6446 } | |
6447 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6448 /* |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6449 * Returns TRUE if 'str' either matches 'regmatch' or fuzzy matches 'pat'. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6450 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6451 * If 'test_only' is TRUE and 'fuzzy' is FALSE and if 'str' matches the regular |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6452 * expression 'regmatch', then returns TRUE. Otherwise returns FALSE. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6453 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6454 * If 'test_only' is FALSE and 'fuzzy' is FALSE and if 'str' matches the |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6455 * regular expression 'regmatch', then stores the match in matches[idx] and |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6456 * returns TRUE. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6457 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6458 * If 'test_only' is TRUE and 'fuzzy' is TRUE and if 'str' fuzzy matches |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6459 * 'fuzzystr', then returns TRUE. Otherwise returns FALSE. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6460 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6461 * If 'test_only' is FALSE and 'fuzzy' is TRUE and if 'str' fuzzy matches |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6462 * 'fuzzystr', then stores the match details in fuzmatch[idx] and returns TRUE. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6463 */ |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6464 static int |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6465 match_str( |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6466 char_u *str, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6467 regmatch_T *regmatch, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6468 char_u **matches, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6469 int idx, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6470 int test_only, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6471 int fuzzy, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6472 char_u *fuzzystr, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6473 fuzmatch_str_T *fuzmatch) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6474 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6475 if (!fuzzy) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6476 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6477 if (vim_regexec(regmatch, str, (colnr_T)0)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6478 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6479 if (!test_only) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6480 matches[idx] = vim_strsave(str); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6481 return TRUE; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6482 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6483 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6484 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6485 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6486 int score; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6487 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6488 score = fuzzy_match_str(str, fuzzystr); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6489 if (score != 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6490 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6491 if (!test_only) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6492 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6493 fuzmatch[idx].idx = idx; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6494 fuzmatch[idx].str = vim_strsave(str); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6495 fuzmatch[idx].score = score; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6496 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6497 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6498 return TRUE; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6499 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6500 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6501 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6502 return FALSE; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6503 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6504 |
7 | 6505 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6506 ExpandSettings( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6507 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6508 regmatch_T *regmatch, |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6509 char_u *fuzzystr, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6510 int *numMatches, |
28786
fd5942a62312
patch 8.2.4917: fuzzy expansion of option names is not right
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
6511 char_u ***matches, |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
6512 int can_fuzzy) |
7 | 6513 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6514 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
|
6515 int num_term = 0; // Nr of matching terminal code settings |
7 | 6516 int opt_idx; |
6517 int match; | |
6518 int count = 0; | |
6519 char_u *str; | |
6520 int loop; | |
6521 int is_term_opt; | |
6522 char_u name_buf[MAX_KEY_NAME_LEN]; | |
6523 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
|
6524 int ic = regmatch->rm_ic; // remember the ignore-case flag |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6525 int fuzzy; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6526 fuzmatch_str_T *fuzmatch = NULL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6527 |
28786
fd5942a62312
patch 8.2.4917: fuzzy expansion of option names is not right
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
6528 fuzzy = can_fuzzy && cmdline_fuzzy_complete(fuzzystr); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6529 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6530 // do this loop twice: |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6531 // 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
|
6532 // loop == 1: copy the matching options into allocated memory |
7 | 6533 for (loop = 0; loop <= 1; ++loop) |
6534 { | |
6535 regmatch->rm_ic = ic; | |
6536 if (xp->xp_context != EXPAND_BOOL_SETTINGS) | |
6537 { | |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
6538 for (match = 0; match < (int)ARRAY_LENGTH(names); ++match) |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6539 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6540 if (match_str((char_u *)names[match], regmatch, *matches, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6541 count, (loop == 0), fuzzy, fuzzystr, fuzmatch)) |
7 | 6542 { |
6543 if (loop == 0) | |
6544 num_normal++; | |
6545 else | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6546 count++; |
7 | 6547 } |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6548 } |
7 | 6549 } |
6550 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; | |
6551 opt_idx++) | |
6552 { | |
6553 if (options[opt_idx].var == NULL) | |
6554 continue; | |
6555 if (xp->xp_context == EXPAND_BOOL_SETTINGS | |
6556 && !(options[opt_idx].flags & P_BOOL)) | |
6557 continue; | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6558 is_term_opt = istermoption_idx(opt_idx); |
7 | 6559 if (is_term_opt && num_normal > 0) |
6560 continue; | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6561 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6562 if (match_str(str, regmatch, *matches, count, (loop == 0), |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6563 fuzzy, fuzzystr, fuzmatch)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6564 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6565 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6566 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6567 if (is_term_opt) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6568 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6569 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6570 num_normal++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6571 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6572 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6573 count++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6574 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6575 else if (!fuzzy && options[opt_idx].shortname != NULL |
7 | 6576 && vim_regexec(regmatch, |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
6577 (char_u *)options[opt_idx].shortname, (colnr_T)0)) |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6578 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6579 // Compare against the abbreviated option name (for regular |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6580 // expression match). Fuzzy matching (previous if) already |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6581 // matches against both the expanded and abbreviated names. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6582 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6583 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6584 if (is_term_opt) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6585 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6586 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6587 num_normal++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6588 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6589 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6590 (*matches)[count++] = vim_strsave(str); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6591 } |
7 | 6592 else if (is_term_opt) |
6593 { | |
6594 name_buf[0] = '<'; | |
6595 name_buf[1] = 't'; | |
6596 name_buf[2] = '_'; | |
6597 name_buf[3] = str[2]; | |
6598 name_buf[4] = str[3]; | |
6599 name_buf[5] = '>'; | |
6600 name_buf[6] = NUL; | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6601 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6602 if (match_str(name_buf, regmatch, *matches, count, (loop == 0), |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6603 fuzzy, fuzzystr, fuzmatch)) |
7 | 6604 { |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6605 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6606 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6607 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6608 count++; |
7 | 6609 } |
6610 } | |
6611 } | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6612 |
7 | 6613 /* |
6614 * Check terminal key codes, these are not in the option table | |
6615 */ | |
6616 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) | |
6617 { | |
6618 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) | |
6619 { | |
6620 if (!isprint(str[0]) || !isprint(str[1])) | |
6621 continue; | |
6622 | |
6623 name_buf[0] = 't'; | |
6624 name_buf[1] = '_'; | |
6625 name_buf[2] = str[0]; | |
6626 name_buf[3] = str[1]; | |
6627 name_buf[4] = NUL; | |
6628 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6629 if (match_str(name_buf, regmatch, *matches, count, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6630 (loop == 0), fuzzy, fuzzystr, fuzmatch)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6631 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6632 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6633 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6634 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6635 count++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6636 } |
7 | 6637 else |
6638 { | |
6639 name_buf[0] = '<'; | |
6640 name_buf[1] = 't'; | |
6641 name_buf[2] = '_'; | |
6642 name_buf[3] = str[0]; | |
6643 name_buf[4] = str[1]; | |
6644 name_buf[5] = '>'; | |
6645 name_buf[6] = NUL; | |
6646 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6647 if (match_str(name_buf, regmatch, *matches, count, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6648 (loop == 0), fuzzy, fuzzystr, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6649 fuzmatch)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6650 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6651 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6652 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6653 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6654 count++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6655 } |
7 | 6656 } |
6657 } | |
6658 | |
6659 /* | |
6660 * Check special key names. | |
6661 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6662 regmatch->rm_ic = TRUE; // ignore case here |
7 | 6663 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) |
6664 { | |
6665 name_buf[0] = '<'; | |
6666 STRCPY(name_buf + 1, str); | |
6667 STRCAT(name_buf, ">"); | |
6668 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6669 if (match_str(name_buf, regmatch, *matches, count, (loop == 0), |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6670 fuzzy, fuzzystr, fuzmatch)) |
7 | 6671 { |
6672 if (loop == 0) | |
6673 num_term++; | |
6674 else | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6675 count++; |
7 | 6676 } |
6677 } | |
6678 } | |
6679 if (loop == 0) | |
6680 { | |
6681 if (num_normal > 0) | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6682 *numMatches = num_normal; |
7 | 6683 else if (num_term > 0) |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6684 *numMatches = num_term; |
7 | 6685 else |
6686 return OK; | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6687 if (!fuzzy) |
7 | 6688 { |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6689 *matches = ALLOC_MULT(char_u *, *numMatches); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6690 if (*matches == NULL) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6691 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6692 *matches = (char_u **)""; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6693 return FAIL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6694 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6695 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6696 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6697 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6698 fuzmatch = ALLOC_MULT(fuzmatch_str_T, *numMatches); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6699 if (fuzmatch == NULL) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6700 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6701 *matches = (char_u **)""; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6702 return FAIL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6703 } |
7 | 6704 } |
6705 } | |
6706 } | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6707 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6708 if (fuzzy && |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6709 fuzzymatches_to_strmatches(fuzmatch, matches, count, FALSE) == FAIL) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6710 return FAIL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6711 |
7 | 6712 return OK; |
6713 } | |
6714 | |
6715 int | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
6716 ExpandOldSetting(int *numMatches, char_u ***matches) |
7 | 6717 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6718 char_u *var = NULL; // init for GCC |
7 | 6719 char_u *buf; |
6720 | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
6721 *numMatches = 0; |
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
6722 *matches = ALLOC_ONE(char_u *); |
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
6723 if (*matches == NULL) |
7 | 6724 return FAIL; |
6725 | |
6726 /* | |
6727 * For a terminal key code expand_option_idx is < 0. | |
6728 */ | |
6729 if (expand_option_idx < 0) | |
6730 { | |
6731 var = find_termcode(expand_option_name + 2); | |
6732 if (var == NULL) | |
6733 expand_option_idx = findoption(expand_option_name); | |
6734 } | |
6735 | |
6736 if (expand_option_idx >= 0) | |
6737 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6738 // put string of option value in NameBuff |
7 | 6739 option_value2string(&options[expand_option_idx], expand_option_flags); |
6740 var = NameBuff; | |
6741 } | |
6742 else if (var == NULL) | |
6743 var = (char_u *)""; | |
6744 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6745 // 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
|
6746 // what happens in do_set(). |
7 | 6747 buf = vim_strsave_escaped(var, escape_chars); |
6748 | |
6749 if (buf == NULL) | |
6750 { | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
6751 VIM_CLEAR(*matches); |
7 | 6752 return FAIL; |
6753 } | |
6754 | |
6755 #ifdef BACKSLASH_IN_FILENAME | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6756 // 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
|
6757 // 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
|
6758 for (var = buf; *var != NUL; MB_PTR_ADV(var)) |
7 | 6759 if (var[0] == '\\' && var[1] == '\\' |
6760 && expand_option_idx >= 0 | |
6761 && (options[expand_option_idx].flags & P_EXPAND) | |
6762 && vim_isfilec(var[2]) | |
6763 && (var[2] != '\\' || (var == buf && var[4] != '\\'))) | |
1622 | 6764 STRMOVE(var, var + 1); |
7 | 6765 #endif |
6766 | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
6767 *matches[0] = buf; |
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
6768 *numMatches = 1; |
7 | 6769 return OK; |
6770 } | |
6771 | |
6772 /* | |
6773 * Get the value for the numeric or string option *opp in a nice format into | |
6774 * NameBuff[]. Must not be called with a hidden option! | |
6775 */ | |
6776 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6777 option_value2string( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6778 struct vimoption *opp, |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
6779 int scope) // OPT_GLOBAL and/or OPT_LOCAL |
7 | 6780 { |
6781 char_u *varp; | |
6782 | |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
6783 varp = get_varp_scope(opp, scope); |
7 | 6784 |
6785 if (opp->flags & P_NUM) | |
6786 { | |
6787 long wc = 0; | |
6788 | |
6789 if (wc_use_keyname(varp, &wc)) | |
6790 STRCPY(NameBuff, get_special_key_name((int)wc, 0)); | |
6791 else if (wc != 0) | |
6792 STRCPY(NameBuff, transchar((int)wc)); | |
6793 else | |
6794 sprintf((char *)NameBuff, "%ld", *(long *)varp); | |
6795 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6796 else // P_STRING |
7 | 6797 { |
6798 varp = *(char_u **)(varp); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6799 if (varp == NULL) // just in case |
7 | 6800 NameBuff[0] = NUL; |
6801 #ifdef FEAT_CRYPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6802 // don't show the actual value of 'key', only that it's set |
840 | 6803 else if (opp->var == (char_u *)&p_key && *varp) |
7 | 6804 STRCPY(NameBuff, "*****"); |
6805 #endif | |
6806 else if (opp->flags & P_EXPAND) | |
6807 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
|
6808 // Translate 'pastetoggle' into special key names |
7 | 6809 else if ((char_u **)opp->var == &p_pt) |
6810 str2specialbuf(p_pt, NameBuff, MAXPATHL); | |
6811 else | |
419 | 6812 vim_strncpy(NameBuff, varp, MAXPATHL - 1); |
7 | 6813 } |
6814 } | |
6815 | |
6816 /* | |
6817 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be | |
6818 * printed as a keyname. | |
6819 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. | |
6820 */ | |
6821 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6822 wc_use_keyname(char_u *varp, long *wcp) |
7 | 6823 { |
6824 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) | |
6825 { | |
6826 *wcp = *(long *)varp; | |
6827 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0) | |
6828 return TRUE; | |
6829 } | |
6830 return FALSE; | |
6831 } | |
6832 | |
6833 /* | |
6834 * Return TRUE if "x" is present in 'shortmess' option, or | |
6835 * 'shortmess' contains 'a' and "x" is present in SHM_A. | |
6836 */ | |
6837 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6838 shortmess(int x) |
7 | 6839 { |
3384 | 6840 return p_shm != NULL && |
6841 ( vim_strchr(p_shm, x) != NULL | |
7 | 6842 || (vim_strchr(p_shm, 'a') != NULL |
6843 && vim_strchr((char_u *)SHM_A, x) != NULL)); | |
6844 } | |
6845 | |
6846 /* | |
6847 * paste_option_changed() - Called after p_paste was set or reset. | |
6848 */ | |
6849 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6850 paste_option_changed(void) |
7 | 6851 { |
6852 static int old_p_paste = FALSE; | |
6853 static int save_sm = 0; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6854 static int save_sta = 0; |
7 | 6855 static int save_ru = 0; |
6856 #ifdef FEAT_RIGHTLEFT | |
6857 static int save_ri = 0; | |
6858 static int save_hkmap = 0; | |
6859 #endif | |
6860 buf_T *buf; | |
6861 | |
6862 if (p_paste) | |
6863 { | |
6864 /* | |
6865 * Paste switched from off to on. | |
6866 * Save the current values, so they can be restored later. | |
6867 */ | |
6868 if (!old_p_paste) | |
6869 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6870 // save options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6871 FOR_ALL_BUFFERS(buf) |
7 | 6872 { |
6873 buf->b_p_tw_nopaste = buf->b_p_tw; | |
6874 buf->b_p_wm_nopaste = buf->b_p_wm; | |
6875 buf->b_p_sts_nopaste = buf->b_p_sts; | |
6876 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
|
6877 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
|
6878 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6879 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
|
6880 vim_free(buf->b_p_vsts_nopaste); |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6881 buf->b_p_vsts_nopaste = |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6882 buf->b_p_vsts && buf->b_p_vsts != empty_option |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6883 ? vim_strsave(buf->b_p_vsts) : NULL; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6884 #endif |
7 | 6885 } |
6886 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6887 // save global options |
7 | 6888 save_sm = p_sm; |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6889 save_sta = p_sta; |
7 | 6890 save_ru = p_ru; |
6891 #ifdef FEAT_RIGHTLEFT | |
6892 save_ri = p_ri; | |
6893 save_hkmap = p_hkmap; | |
6894 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6895 // 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
|
6896 p_ai_nopaste = p_ai; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6897 p_et_nopaste = p_et; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6898 p_sts_nopaste = p_sts; |
7 | 6899 p_tw_nopaste = p_tw; |
6900 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
|
6901 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6902 if (p_vsts_nopaste) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6903 vim_free(p_vsts_nopaste); |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6904 p_vsts_nopaste = p_vsts && p_vsts != empty_option |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6905 ? vim_strsave(p_vsts) : NULL; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6906 #endif |
7 | 6907 } |
6908 | |
6909 /* | |
6910 * Always set the option values, also when 'paste' is set when it is | |
6911 * already on. | |
6912 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6913 // set options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6914 FOR_ALL_BUFFERS(buf) |
7 | 6915 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6916 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
|
6917 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
|
6918 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
|
6919 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
|
6920 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
|
6921 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6922 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
|
6923 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
|
6924 buf->b_p_vsts = empty_option; |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
6925 VIM_CLEAR(buf->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
|
6926 #endif |
7 | 6927 } |
6928 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6929 // set global options |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6930 p_sm = 0; // no showmatch |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6931 p_sta = 0; // no smarttab |
7 | 6932 if (p_ru) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6933 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
|
6934 p_ru = 0; // no ruler |
7 | 6935 #ifdef FEAT_RIGHTLEFT |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6936 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
|
6937 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
|
6938 #endif |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6939 // set global values for local buffer options |
7 | 6940 p_tw = 0; |
6941 p_wm = 0; | |
6942 p_sts = 0; | |
6943 p_ai = 0; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6944 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6945 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6946 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
|
6947 p_vsts = empty_option; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6948 #endif |
7 | 6949 } |
6950 | |
6951 /* | |
6952 * Paste switched from on to off: Restore saved values. | |
6953 */ | |
6954 else if (old_p_paste) | |
6955 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6956 // restore options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6957 FOR_ALL_BUFFERS(buf) |
7 | 6958 { |
6959 buf->b_p_tw = buf->b_p_tw_nopaste; | |
6960 buf->b_p_wm = buf->b_p_wm_nopaste; | |
6961 buf->b_p_sts = buf->b_p_sts_nopaste; | |
6962 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
|
6963 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
|
6964 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6965 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
|
6966 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
|
6967 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
|
6968 ? vim_strsave(buf->b_p_vsts_nopaste) : empty_option; |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
6969 vim_free(buf->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
|
6970 if (buf->b_p_vsts && buf->b_p_vsts != empty_option) |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
6971 (void)tabstop_set(buf->b_p_vsts, &buf->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
|
6972 else |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
6973 buf->b_p_vsts_array = NULL; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6974 #endif |
7 | 6975 } |
6976 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6977 // restore global options |
7 | 6978 p_sm = save_sm; |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6979 p_sta = save_sta; |
7 | 6980 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
|
6981 status_redraw_all(); // redraw to draw the ruler |
7 | 6982 p_ru = save_ru; |
6983 #ifdef FEAT_RIGHTLEFT | |
6984 p_ri = save_ri; | |
6985 p_hkmap = save_hkmap; | |
6986 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6987 // 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
|
6988 p_ai = p_ai_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6989 p_et = p_et_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6990 p_sts = p_sts_nopaste; |
7 | 6991 p_tw = p_tw_nopaste; |
6992 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
|
6993 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6994 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6995 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
|
6996 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
|
6997 #endif |
7 | 6998 } |
6999 | |
7000 old_p_paste = p_paste; | |
7001 } | |
7002 | |
7003 /* | |
7004 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found. | |
7005 * | |
7006 * Reset 'compatible' and set the values for options that didn't get set yet | |
7007 * to the Vim defaults. | |
7008 * Don't do this if the 'compatible' option has been set or reset before. | |
819 | 7009 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet. |
7 | 7010 */ |
7011 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7012 vimrc_found(char_u *fname, char_u *envname) |
819 | 7013 { |
7014 int opt_idx; | |
826 | 7015 int dofree = FALSE; |
819 | 7016 char_u *p; |
7 | 7017 |
7018 if (!option_was_set((char_u *)"cp")) | |
7019 { | |
7020 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
|
7021 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 7022 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF))) |
7023 set_option_default(opt_idx, OPT_FREE, FALSE); | |
7024 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
7025 didset_options2(); |
7 | 7026 } |
819 | 7027 |
7028 if (fname != NULL) | |
7029 { | |
7030 p = vim_getenv(envname, &dofree); | |
7031 if (p == NULL) | |
7032 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7033 // Set $MYVIMRC to the first vimrc file found. |
819 | 7034 p = FullName_save(fname, FALSE); |
7035 if (p != NULL) | |
7036 { | |
7037 vim_setenv(envname, p); | |
7038 vim_free(p); | |
7039 } | |
7040 } | |
7041 else if (dofree) | |
7042 vim_free(p); | |
7043 } | |
7 | 7044 } |
7045 | |
7046 /* | |
7047 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg. | |
7048 */ | |
7049 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7050 change_compatible(int on) |
7 | 7051 { |
838 | 7052 int opt_idx; |
7053 | |
7 | 7054 if (p_cp != on) |
7055 { | |
7056 p_cp = on; | |
7057 compatible_set(); | |
7058 } | |
838 | 7059 opt_idx = findoption((char_u *)"cp"); |
7060 if (opt_idx >= 0) | |
7061 options[opt_idx].flags |= P_WAS_SET; | |
7 | 7062 } |
7063 | |
7064 /* | |
7065 * 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
|
7066 * Only works correctly for global options. |
7 | 7067 */ |
7068 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7069 option_was_set(char_u *name) |
7 | 7070 { |
7071 int idx; | |
7072 | |
7073 idx = findoption(name); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7074 if (idx < 0) // unknown option |
7 | 7075 return FALSE; |
7076 if (options[idx].flags & P_WAS_SET) | |
7077 return TRUE; | |
7078 return FALSE; | |
7079 } | |
7080 | |
7081 /* | |
3980 | 7082 * Reset the flag indicating option "name" was set. |
7083 */ | |
14748
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
7084 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7085 reset_option_was_set(char_u *name) |
3980 | 7086 { |
7087 int idx = findoption(name); | |
7088 | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7089 if (idx < 0) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7090 return FAIL; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7091 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7092 options[idx].flags &= ~P_WAS_SET; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7093 return OK; |
3980 | 7094 } |
7095 | |
7096 /* | |
7 | 7097 * compatible_set() - Called when 'compatible' has been set or unset. |
7098 * | |
7099 * When 'compatible' set: Set all relevant options (those that have the P_VIM) | |
7100 * flag) to a Vi compatible value. | |
7101 * When 'compatible' is unset: Set all options that have a different default | |
7102 * for Vim (without the P_VI_DEF flag) to that default. | |
7103 */ | |
7104 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7105 compatible_set(void) |
7 | 7106 { |
7107 int opt_idx; | |
7108 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7109 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 7110 if ( ((options[opt_idx].flags & P_VIM) && p_cp) |
7111 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp)) | |
7112 set_option_default(opt_idx, OPT_FREE, p_cp); | |
7113 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
7114 didset_options2(); |
7 | 7115 } |
7116 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7117 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
7 | 7118 |
7119 /* | |
7120 * fill_breakat_flags() -- called when 'breakat' changes value. | |
7121 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7122 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7123 fill_breakat_flags(void) |
7 | 7124 { |
500 | 7125 char_u *p; |
7 | 7126 int i; |
7127 | |
7128 for (i = 0; i < 256; i++) | |
7129 breakat_flags[i] = FALSE; | |
7130 | |
7131 if (p_breakat != NULL) | |
500 | 7132 for (p = p_breakat; *p; p++) |
7133 breakat_flags[*p] = TRUE; | |
7 | 7134 } |
7135 #endif | |
7136 | |
7137 /* | |
7138 * Check if backspacing over something is allowed. | |
7139 */ | |
7140 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7141 can_bs( |
20069
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
7142 int what) // BS_INDENT, BS_EOL, BS_START or BS_NOSTOP |
7 | 7143 { |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
7144 #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
|
7145 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
|
7146 return FALSE; |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
7147 #endif |
7 | 7148 switch (*p_bs) |
7149 { | |
20069
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
7150 case '3': return TRUE; |
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
7151 case '2': return (what != BS_NOSTOP); |
7 | 7152 case '1': return (what != BS_START); |
7153 case '0': return FALSE; | |
7154 } | |
7155 return vim_strchr(p_bs, what) != NULL; | |
7156 } | |
7157 | |
7158 /* | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7159 * 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
|
7160 * 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
|
7161 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7162 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7163 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
|
7164 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7165 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
|
7166 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7167 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7168 /* |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7169 * 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
|
7170 * 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
|
7171 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7172 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7173 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
|
7174 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7175 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
|
7176 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7177 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7178 /* |
6243 | 7179 * Get the local or global value of 'backupcopy'. |
7180 */ | |
7181 unsigned int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7182 get_bkc_value(buf_T *buf) |
6243 | 7183 { |
7184 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags; | |
7185 } | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7186 |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
7187 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7188 /* |
27128
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7189 * Get the local or global value of 'formatlistpat'. |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7190 */ |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7191 char_u * |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7192 get_flp_value(buf_T *buf) |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7193 { |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7194 if (buf->b_p_flp == NULL || *buf->b_p_flp == NUL) |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7195 return p_flp; |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7196 return buf->b_p_flp; |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7197 } |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
7198 #endif |
27128
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7199 |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7200 /* |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7201 * Get the local or global value of the 'virtualedit' flags. |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7202 */ |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7203 unsigned int |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7204 get_ve_flags(void) |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7205 { |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
7206 return (curwin->w_ve_flags ? curwin->w_ve_flags : ve_flags) |
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
7207 & ~(VE_NONE | VE_NONEU); |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7208 } |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7209 |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7210 #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
|
7211 /* |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7212 * 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
|
7213 */ |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7214 char_u * |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7215 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
|
7216 { |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7217 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
|
7218 return p_sbr; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7219 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
|
7220 return empty_option; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7221 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
|
7222 } |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7223 #endif |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7224 |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7225 #if defined(FEAT_EVAL) || defined(PROTO) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7226 /* |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7227 * Get window or buffer local options. |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7228 */ |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7229 dict_T * |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7230 get_winbuf_options(int bufopt) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7231 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7232 dict_T *d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7233 int opt_idx; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7234 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7235 d = dict_alloc(); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7236 if (d == NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7237 return NULL; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7238 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7239 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
|
7240 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7241 struct vimoption *opt = &options[opt_idx]; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7242 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7243 if ((bufopt && (opt->indir & PV_BUF)) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7244 || (!bufopt && (opt->indir & PV_WIN))) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7245 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7246 char_u *varp = get_varp(opt); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7247 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7248 if (varp != NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7249 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7250 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
|
7251 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
|
7252 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
|
7253 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
|
7254 else |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14243
diff
changeset
|
7255 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
|
7256 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7257 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7258 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7259 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7260 return d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7261 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7262 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7263 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7264 #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
|
7265 /* |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7266 * 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
|
7267 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7268 int |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7269 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
|
7270 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7271 char_u *p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7272 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
|
7273 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7274 if (val == NULL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7275 p = wp->w_p_culopt; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7276 else |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7277 p = val; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7278 while (*p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7279 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7280 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
|
7281 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7282 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7283 culopt_flags_new |= CULOPT_LINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7284 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7285 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
|
7286 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7287 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7288 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
|
7289 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7290 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
|
7291 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7292 p += 6; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7293 culopt_flags_new |= CULOPT_NBR; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7294 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7295 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
|
7296 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7297 p += 10; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7298 culopt_flags_new |= CULOPT_SCRLINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7299 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7300 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7301 if (*p != ',' && *p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7302 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7303 if (*p == ',') |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7304 ++p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7305 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7306 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7307 // 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
|
7308 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
|
7309 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7310 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
|
7311 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7312 return OK; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7313 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7314 #endif |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7315 |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7316 /* |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7317 * Get the value of 'magic' adjusted for Vim9 script. |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7318 */ |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7319 int |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7320 magic_isset(void) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7321 { |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7322 switch (magic_overruled) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7323 { |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23467
diff
changeset
|
7324 case OPTION_MAGIC_ON: return TRUE; |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23467
diff
changeset
|
7325 case OPTION_MAGIC_OFF: return FALSE; |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23467
diff
changeset
|
7326 case OPTION_MAGIC_NOT_SET: break; |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7327 } |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7328 #ifdef FEAT_EVAL |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7329 if (in_vim9script()) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7330 return TRUE; |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7331 #endif |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7332 return p_magic; |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7333 } |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7334 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7335 /* |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7336 * Set the callback function value for an option that accepts a function name, |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7337 * lambda, et al. (e.g. 'operatorfunc', 'tagfunc', etc.) |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7338 * Returns OK if the option is successfully set to a function, otherwise |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7339 * returns FAIL. |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7340 */ |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7341 int |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7342 option_set_callback_func(char_u *optval UNUSED, callback_T *optcb UNUSED) |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7343 { |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7344 #ifdef FEAT_EVAL |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7345 typval_T *tv; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7346 callback_T cb; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7347 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7348 if (optval == NULL || *optval == NUL) |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7349 { |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7350 free_callback(optcb); |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7351 return OK; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7352 } |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7353 |
26362
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
7354 if (*optval == '{' || (in_vim9script() && *optval == '(') |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7355 || (STRNCMP(optval, "function(", 9) == 0) |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7356 || (STRNCMP(optval, "funcref(", 8) == 0)) |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7357 // Lambda expression or a funcref |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7358 tv = eval_expr(optval, NULL); |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7359 else |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7360 // treat everything else as a function name string |
26721
9c9b8d95b05f
patch 8.2.3889: duplicate code for translating script-local function name
Bram Moolenaar <Bram@vim.org>
parents:
26618
diff
changeset
|
7361 tv = alloc_string_tv(vim_strsave(optval)); |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7362 if (tv == NULL) |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7363 return FAIL; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7364 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7365 cb = get_callback(tv); |
26452
65b4109a4297
patch 8.2.3756: might crash when callback is not valid
Bram Moolenaar <Bram@vim.org>
parents:
26441
diff
changeset
|
7366 if (cb.cb_name == NULL || *cb.cb_name == NUL) |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7367 { |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7368 free_tv(tv); |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7369 return FAIL; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7370 } |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7371 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7372 free_callback(optcb); |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7373 set_callback(optcb, &cb); |
31313
b6bef244837e
patch 9.0.0990: callback name argument is changed by setqflist()
Bram Moolenaar <Bram@vim.org>
parents:
31259
diff
changeset
|
7374 if (cb.cb_free_name) |
b6bef244837e
patch 9.0.0990: callback name argument is changed by setqflist()
Bram Moolenaar <Bram@vim.org>
parents:
31259
diff
changeset
|
7375 vim_free(cb.cb_name); |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7376 free_tv(tv); |
27285
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27142
diff
changeset
|
7377 |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27142
diff
changeset
|
7378 // when using Vim9 style "import.funcname" it needs to be expanded to |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27142
diff
changeset
|
7379 // "import#funcname". |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27142
diff
changeset
|
7380 expand_autload_callback(optcb); |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27142
diff
changeset
|
7381 |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7382 return OK; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7383 #else |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7384 return FAIL; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7385 #endif |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7386 } |