Mercurial > vim
annotate src/option.c @ 24283:bcfff560e089 v8.2.2682
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Commit: https://github.com/vim/vim/commit/529fb5a5f62378bbaac00e1ed9b9c32c6e20c1b9
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 1 12:57:57 2021 +0200
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Problem: Vim9: cannot find Name.Func from "import * as Name". (Alexander
Goussas)
Solution: When no variable found try finding a function. (closes #8045)
Check that the function was exported.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 01 Apr 2021 13:00:03 +0200 |
parents | a9ff8368d35f |
children | a56f9c2ba51c |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9959
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * Code to handle user-settable options. This is all pretty much table- | |
12 * driven. Checklist for adding a new option: | |
13 * - Put it in the options array below (copy an existing entry). | |
14 * - For a global option: Add a variable for it in option.h. | |
15 * - For a buffer or window local option: | |
16 * - Add a PV_XX entry to the enum below. | |
17 * - Add a variable to the window or buffer struct in structs.h. | |
18 * - For a window option, add some code to copy_winopt(). | |
19 * - For a buffer option, add some code to buf_copy_options(). | |
20 * - For a buffer string option, add code to check_buf_options(). | |
21 * - If it's a numeric option, add any necessary bounds checks to do_set(). | |
22 * - If it's a list of flags, add some code in do_set(), search for WW_ALL. | |
23 * - When adding an option with expansion (P_EXPAND), but with a different | |
24 * default for Vi and Vim (no P_VI_DEF), add some code at VIMEXP. | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10205
diff
changeset
|
25 * - Add documentation! One line in doc/quickref.txt, full description in |
7 | 26 * options.txt, and any other related places. |
27 * - Add an entry in runtime/optwin.vim. | |
28 * When making changes: | |
29 * - Adjust the help for the option in doc/option.txt. | |
30 * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a | |
31 * comment at the help for the 'compatible' option. | |
32 */ | |
33 | |
34 #define IN_OPTION_C | |
35 #include "vim.h" | |
18054
88b5c2b4e3d2
patch 8.1.2022: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18047
diff
changeset
|
36 #include "optiondefs.h" |
7 | 37 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
38 static void set_options_default(int opt_flags); |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
39 static void set_string_default_esc(char *name, char_u *val, int escape); |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
40 static char_u *find_dup_item(char_u *origval, char_u *newval, long_u flags); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
41 static char_u *option_expand(int opt_idx, char_u *val); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
42 static void didset_options(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
43 static void didset_options2(void); |
681 | 44 #if defined(FEAT_EVAL) || defined(PROTO) |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
45 static long_u *insecure_flag(int opt_idx, int opt_flags); |
681 | 46 #else |
47 # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags) | |
48 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
49 static char *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags); |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
50 static char *set_num_option(int opt_idx, char_u *varp, long value, char *errbuf, size_t errbuflen, int opt_flags); |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
51 static int find_key_option(char_u *arg_arg, int has_lt); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
52 static void showoptions(int all, int opt_flags); |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
53 static int optval_default(struct vimoption *, char_u *varp, int compatible); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
54 static void showoneopt(struct vimoption *, int opt_flags); |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
55 static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, long_u flags); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
56 static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
57 static int put_setbool(FILE *fd, char *cmd, char *name, int value); |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
58 static int istermoption(struct vimoption *p); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
59 static char_u *get_varp_scope(struct vimoption *p, int opt_flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
60 static char_u *get_varp(struct vimoption *); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
61 static void check_win_options(win_T *win); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
62 static void option_value2string(struct vimoption *, int opt_flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
63 static void check_winopt(winopt_T *wop); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
64 static int wc_use_keyname(char_u *varp, long *wcp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
65 static void paste_option_changed(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
66 static void compatible_set(void); |
7 | 67 |
68 /* | |
69 * Initialize the options, first part. | |
70 * | |
71 * Called only once from main(), just after creating the first buffer. | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
72 * If "clean_arg" is TRUE Vim was started with --clean. |
7 | 73 */ |
74 void | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
75 set_init_1(int clean_arg) |
7 | 76 { |
77 char_u *p; | |
78 int opt_idx; | |
835 | 79 long_u n; |
7 | 80 |
81 #ifdef FEAT_LANGMAP | |
82 langmap_init(); | |
83 #endif | |
84 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
85 // Be Vi compatible by default |
7 | 86 p_cp = TRUE; |
87 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
88 // Use POSIX compatibility when $VIM_POSIX is set. |
164 | 89 if (mch_getenv((char_u *)"VIM_POSIX") != NULL) |
168 | 90 { |
164 | 91 set_string_default("cpo", (char_u *)CPO_ALL); |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
92 set_string_default("shm", (char_u *)SHM_POSIX); |
168 | 93 } |
164 | 94 |
7 | 95 /* |
96 * Find default value for 'shell' option. | |
161 | 97 * Don't use it if it is empty. |
7 | 98 */ |
161 | 99 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL) |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
100 #if defined(MSWIN) |
161 | 101 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL) |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7829
diff
changeset
|
102 || ((p = (char_u *)default_shell()) != NULL && *p != NUL) |
7 | 103 #endif |
161 | 104 ) |
18241
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
105 #if defined(MSWIN) |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
106 { |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
107 // For MS-Windows put the path in quotes instead of escaping spaces. |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
108 char_u *cmd; |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
109 size_t len; |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
110 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
111 if (vim_strchr(p, ' ') != NULL) |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
112 { |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
113 len = STRLEN(p) + 3; // two quotes and a trailing NUL |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
114 cmd = alloc(len); |
18243
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
115 if (cmd != NULL) |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
116 { |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
117 vim_snprintf((char *)cmd, len, "\"%s\"", p); |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
118 set_string_default("sh", cmd); |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
119 vim_free(cmd); |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
120 } |
18241
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
121 } |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
122 else |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
123 set_string_default("sh", p); |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
124 } |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
125 #else |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
126 set_string_default_esc("sh", p, TRUE); |
18241
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
127 #endif |
7 | 128 |
129 #ifdef FEAT_WILDIGN | |
130 /* | |
131 * Set the default for 'backupskip' to include environment variables for | |
132 * temp files. | |
133 */ | |
134 { | |
135 # ifdef UNIX | |
136 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"}; | |
137 # else | |
138 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"}; | |
139 # endif | |
170 | 140 int len; |
141 garray_T ga; | |
142 int mustfree; | |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
143 char_u *item; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
144 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
145 opt_idx = findoption((char_u *)"backupskip"); |
7 | 146 |
147 ga_init2(&ga, 1, 100); | |
148 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n) | |
149 { | |
170 | 150 mustfree = FALSE; |
7 | 151 # ifdef UNIX |
152 if (*names[n] == NUL) | |
13664
f64c5e636c9f
patch 8.0.1704: 'backupskip' default doesn't work for Mac
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
153 # ifdef MACOS_X |
f64c5e636c9f
patch 8.0.1704: 'backupskip' default doesn't work for Mac
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
154 p = (char_u *)"/private/tmp"; |
f64c5e636c9f
patch 8.0.1704: 'backupskip' default doesn't work for Mac
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
155 # else |
7 | 156 p = (char_u *)"/tmp"; |
13664
f64c5e636c9f
patch 8.0.1704: 'backupskip' default doesn't work for Mac
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
157 # endif |
7 | 158 else |
159 # endif | |
170 | 160 p = vim_getenv((char_u *)names[n], &mustfree); |
7 | 161 if (p != NULL && *p != NUL) |
162 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
163 // First time count the NUL, otherwise count the ','. |
835 | 164 len = (int)STRLEN(p) + 3; |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
165 item = alloc(len); |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
166 STRCPY(item, p); |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
167 add_pathsep(item); |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
168 STRCAT(item, "*"); |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
169 if (find_dup_item(ga.ga_data, item, options[opt_idx].flags) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
170 == NULL |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
171 && ga_grow(&ga, len) == OK) |
7 | 172 { |
173 if (ga.ga_len > 0) | |
174 STRCAT(ga.ga_data, ","); | |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
175 STRCAT(ga.ga_data, item); |
7 | 176 ga.ga_len += len; |
177 } | |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
178 vim_free(item); |
7 | 179 } |
170 | 180 if (mustfree) |
181 vim_free(p); | |
7 | 182 } |
183 if (ga.ga_data != NULL) | |
184 { | |
185 set_string_default("bsk", ga.ga_data); | |
186 vim_free(ga.ga_data); | |
187 } | |
188 } | |
189 #endif | |
190 | |
191 /* | |
192 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory | |
193 */ | |
194 opt_idx = findoption((char_u *)"maxmemtot"); | |
838 | 195 if (opt_idx >= 0) |
196 { | |
7 | 197 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
838 | 198 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) |
199 #endif | |
200 { | |
7 | 201 #ifdef HAVE_AVAIL_MEM |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
202 // Use amount of memory available at this moment. |
3634 | 203 n = (mch_avail_mem(FALSE) >> 1); |
7 | 204 #else |
205 # ifdef HAVE_TOTAL_MEM | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
206 // Use amount of memory available to Vim. |
1110 | 207 n = (mch_total_mem(FALSE) >> 1); |
7 | 208 # else |
838 | 209 n = (0x7fffffff >> 11); |
7 | 210 # endif |
211 #endif | |
212 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; | |
838 | 213 opt_idx = findoption((char_u *)"maxmem"); |
214 if (opt_idx >= 0) | |
215 { | |
216 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) | |
7328
6679f41bddea
commit https://github.com/vim/vim/commit/35be4534c029148a89ccc41e8e465d793e7ed7c2
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
217 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n |
6679f41bddea
commit https://github.com/vim/vim/commit/35be4534c029148a89ccc41e8e465d793e7ed7c2
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
218 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L) |
838 | 219 #endif |
220 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; | |
221 } | |
222 } | |
7 | 223 } |
224 | |
225 #ifdef FEAT_SEARCHPATH | |
226 { | |
227 char_u *cdpath; | |
228 char_u *buf; | |
229 int i; | |
230 int j; | |
170 | 231 int mustfree = FALSE; |
7 | 232 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
233 // Initialize the 'cdpath' option's default value. |
170 | 234 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree); |
7 | 235 if (cdpath != NULL) |
236 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16730
diff
changeset
|
237 buf = alloc((STRLEN(cdpath) << 1) + 2); |
7 | 238 if (buf != NULL) |
239 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
240 buf[0] = ','; // start with ",", current dir first |
7 | 241 j = 1; |
242 for (i = 0; cdpath[i] != NUL; ++i) | |
243 { | |
244 if (vim_ispathlistsep(cdpath[i])) | |
245 buf[j++] = ','; | |
246 else | |
247 { | |
248 if (cdpath[i] == ' ' || cdpath[i] == ',') | |
249 buf[j++] = '\\'; | |
250 buf[j++] = cdpath[i]; | |
251 } | |
252 } | |
253 buf[j] = NUL; | |
254 opt_idx = findoption((char_u *)"cdpath"); | |
838 | 255 if (opt_idx >= 0) |
256 { | |
257 options[opt_idx].def_val[VI_DEFAULT] = buf; | |
258 options[opt_idx].flags |= P_DEF_ALLOCED; | |
259 } | |
2445
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
260 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
261 vim_free(buf); // cannot happen |
7 | 262 } |
170 | 263 if (mustfree) |
264 vim_free(cdpath); | |
7 | 265 } |
266 } | |
267 #endif | |
268 | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
269 #if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux)) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
270 // Set print encoding on platforms that don't default to latin1 |
7 | 271 set_string_default("penc", |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
272 # if defined(MSWIN) |
7 | 273 (char_u *)"cp1252" |
274 # else | |
275 # ifdef VMS | |
276 (char_u *)"dec-mcs" | |
277 # else | |
278 # ifdef EBCDIC | |
279 (char_u *)"ebcdic-uk" | |
280 # else | |
281 # ifdef MAC | |
282 (char_u *)"mac-roman" | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
283 # else // HPUX |
7 | 284 (char_u *)"hp-roman8" |
285 # endif | |
286 # endif | |
287 # endif | |
288 # endif | |
289 ); | |
290 #endif | |
291 | |
292 #ifdef FEAT_POSTSCRIPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
293 // 'printexpr' must be allocated to be able to evaluate it. |
7 | 294 set_string_default("pexpr", |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
295 # if defined(MSWIN) |
8 | 296 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)" |
7 | 297 # else |
298 # ifdef VMS | |
299 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)" | |
300 | |
301 # else | |
302 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error" | |
303 # endif | |
304 # endif | |
305 ); | |
306 #endif | |
307 | |
308 /* | |
309 * Set all the options (except the terminal options) to their default | |
310 * value. Also set the global value for local options. | |
311 */ | |
312 set_options_default(0); | |
313 | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
314 #ifdef CLEAN_RUNTIMEPATH |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
315 if (clean_arg) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
316 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
317 opt_idx = findoption((char_u *)"runtimepath"); |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
318 if (opt_idx >= 0) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
319 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
320 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH; |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
321 p_rtp = (char_u *)CLEAN_RUNTIMEPATH; |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
322 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
323 opt_idx = findoption((char_u *)"packpath"); |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
324 if (opt_idx >= 0) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
325 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
326 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH; |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
327 p_pp = (char_u *)CLEAN_RUNTIMEPATH; |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
328 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
329 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
330 #endif |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
331 |
7 | 332 #ifdef FEAT_GUI |
333 if (found_reverse_arg) | |
334 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0); | |
335 #endif | |
336 | |
337 curbuf->b_p_initialized = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
338 curbuf->b_p_ar = -1; // no local 'autoread' value |
5446 | 339 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
7 | 340 check_buf_options(curbuf); |
341 check_win_options(curwin); | |
342 check_options(); | |
343 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
344 // Must be before option_expand(), because that one needs vim_isIDc() |
7 | 345 didset_options(); |
346 | |
744 | 347 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
348 // Use the current chartab for the generic chartab. This is not in |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
349 // didset_options() because it only depends on 'encoding'. |
227 | 350 init_spell_chartab(); |
351 #endif | |
352 | |
7 | 353 /* |
354 * Expand environment variables and things like "~" for the defaults. | |
355 * If option_expand() returns non-NULL the variable is expanded. This can | |
356 * only happen for non-indirect options. | |
357 * Also set the default to the expanded value, so ":set" does not list | |
358 * them. | |
359 * Don't set the P_ALLOCED flag, because we don't want to free the | |
360 * default. | |
361 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
362 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 363 { |
364 if ((options[opt_idx].flags & P_GETTEXT) | |
365 && options[opt_idx].var != NULL) | |
366 p = (char_u *)_(*(char **)options[opt_idx].var); | |
367 else | |
368 p = option_expand(opt_idx, NULL); | |
369 if (p != NULL && (p = vim_strsave(p)) != NULL) | |
370 { | |
371 *(char_u **)options[opt_idx].var = p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
372 // VIMEXP |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
373 // Defaults for all expanded options are currently the same for Vi |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
374 // and Vim. When this changes, add some code here! Also need to |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
375 // split P_DEF_ALLOCED in two. |
7 | 376 if (options[opt_idx].flags & P_DEF_ALLOCED) |
377 vim_free(options[opt_idx].def_val[VI_DEFAULT]); | |
378 options[opt_idx].def_val[VI_DEFAULT] = p; | |
379 options[opt_idx].flags |= P_DEF_ALLOCED; | |
380 } | |
381 } | |
382 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
383 save_file_ff(curbuf); // Buffer is unchanged |
7 | 384 |
385 #if defined(FEAT_ARABIC) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
386 // Detect use of mlterm. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
387 // Mlterm is a terminal emulator akin to xterm that has some special |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
388 // abilities (bidi namely). |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
389 // NOTE: mlterm's author is being asked to 'set' a variable |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
390 // instead of an environment variable due to inheritance. |
7 | 391 if (mch_getenv((char_u *)"MLTERM") != NULL) |
392 set_option_value((char_u *)"tbidi", 1L, NULL, 0); | |
393 #endif | |
394 | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
395 didset_options2(); |
7 | 396 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
397 # if defined(MSWIN) && defined(FEAT_GETTEXT) |
7 | 398 /* |
399 * If $LANG isn't set, try to get a good value for it. This makes the | |
400 * right language be used automatically. Don't do this for English. | |
401 */ | |
402 if (mch_getenv((char_u *)"LANG") == NULL) | |
403 { | |
404 char buf[20]; | |
405 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
406 // Could use LOCALE_SISO639LANGNAME, but it's not in Win95. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
407 // LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
408 // only the first two. |
7 | 409 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, |
410 (LPTSTR)buf, 20); | |
411 if (n >= 2 && STRNICMP(buf, "en", 2) != 0) | |
412 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
413 // There are a few exceptions (probably more) |
7 | 414 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0) |
415 STRCPY(buf, "zh_TW"); | |
416 else if (STRNICMP(buf, "chs", 3) == 0 | |
417 || STRNICMP(buf, "zhc", 3) == 0) | |
418 STRCPY(buf, "zh_CN"); | |
419 else if (STRNICMP(buf, "jp", 2) == 0) | |
420 STRCPY(buf, "ja"); | |
421 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
422 buf[2] = NUL; // truncate to two-letter code |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7829
diff
changeset
|
423 vim_setenv((char_u *)"LANG", (char_u *)buf); |
7 | 424 } |
425 } | |
168 | 426 # else |
767 | 427 # ifdef MACOS_CONVERT |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
428 // Moved to os_mac_conv.c to avoid dependency problems. |
1622 | 429 mac_lang_init(); |
168 | 430 # endif |
7 | 431 # endif |
432 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
433 // enc_locale() will try to find the encoding of the current locale. |
7 | 434 p = enc_locale(); |
435 if (p != NULL) | |
436 { | |
437 char_u *save_enc; | |
438 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
439 // Try setting 'encoding' and check if the value is valid. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
440 // If not, go back to the default "latin1". |
7 | 441 save_enc = p_enc; |
442 p_enc = p; | |
1080 | 443 if (STRCMP(p_enc, "gb18030") == 0) |
444 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
445 // 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
|
446 // 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
|
447 // still support conversion between gb18030 and utf-8. |
1080 | 448 p_enc = vim_strsave((char_u *)"cp936"); |
449 vim_free(p); | |
450 } | |
7 | 451 if (mb_init() == NULL) |
452 { | |
453 opt_idx = findoption((char_u *)"encoding"); | |
838 | 454 if (opt_idx >= 0) |
455 { | |
456 options[opt_idx].def_val[VI_DEFAULT] = p_enc; | |
457 options[opt_idx].flags |= P_DEF_ALLOCED; | |
458 } | |
7 | 459 |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12636
diff
changeset
|
460 #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
|
461 if (STRCMP(p_enc, "latin1") == 0 || enc_utf8) |
24 | 462 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
463 // 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
|
464 // 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
|
465 // set. |
24 | 466 set_string_option_direct((char_u *)"isp", -1, |
719 | 467 ISP_LATIN1, OPT_FREE, SID_NONE); |
714 | 468 set_string_option_direct((char_u *)"isk", -1, |
469 ISK_LATIN1, OPT_FREE, SID_NONE); | |
470 opt_idx = findoption((char_u *)"isp"); | |
838 | 471 if (opt_idx >= 0) |
472 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1; | |
714 | 473 opt_idx = findoption((char_u *)"isk"); |
838 | 474 if (opt_idx >= 0) |
475 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1; | |
24 | 476 (void)init_chartab(); |
477 } | |
478 #endif | |
479 | |
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
|
480 #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
|
481 // 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
|
482 // 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
|
483 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
|
484 # 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
|
485 (!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
|
486 # 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
|
487 GetACP() != GetConsoleCP()) |
7 | 488 { |
489 char buf[50]; | |
490 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
491 // 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
|
492 // 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
|
493 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
|
494 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
|
495 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
|
496 sprintf(buf, "cp%ld", (long)GetConsoleCP()); |
7 | 497 p_tenc = vim_strsave((char_u *)buf); |
498 if (p_tenc != NULL) | |
499 { | |
500 opt_idx = findoption((char_u *)"termencoding"); | |
838 | 501 if (opt_idx >= 0) |
502 { | |
503 options[opt_idx].def_val[VI_DEFAULT] = p_tenc; | |
504 options[opt_idx].flags |= P_DEF_ALLOCED; | |
505 } | |
7 | 506 convert_setup(&input_conv, p_tenc, p_enc); |
507 convert_setup(&output_conv, p_enc, p_tenc); | |
508 } | |
509 else | |
510 p_tenc = empty_option; | |
511 } | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
512 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
513 #if defined(MSWIN) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
514 // $HOME may have characters in active code page. |
170 | 515 init_homedir(); |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
516 #endif |
7 | 517 } |
518 else | |
519 { | |
520 vim_free(p_enc); | |
521 p_enc = save_enc; | |
522 } | |
523 } | |
524 | |
525 #ifdef FEAT_MULTI_LANG | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
526 // Set the default for 'helplang'. |
7 | 527 set_helplang_default(get_mess_lang()); |
528 #endif | |
529 } | |
530 | |
531 /* | |
532 * Set an option to its default value. | |
533 * This does not take care of side effects! | |
534 */ | |
535 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
536 set_option_default( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
537 int opt_idx, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
538 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
|
539 int compatible) // use Vi default value |
7 | 540 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
541 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
|
542 int dvi; // index in def_val[] |
7 | 543 long_u flags; |
681 | 544 long_u *flagsp; |
7 | 545 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
546 | |
547 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); | |
548 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
|
549 if (varp != NULL) // skip hidden option, nothing to do for it |
7 | 550 { |
551 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; | |
552 if (flags & P_STRING) | |
553 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
554 // 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
|
555 // freeing and allocating the value. |
13845
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
556 if (options[opt_idx].indir != PV_NONE) |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
557 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
|
558 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
|
559 else |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
560 { |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
561 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
|
562 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
|
563 *(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
|
564 options[opt_idx].flags &= ~P_ALLOCED; |
7 | 565 } |
566 } | |
567 else if (flags & P_NUM) | |
568 { | |
1017 | 569 if (options[opt_idx].indir == PV_SCROLL) |
7 | 570 win_comp_scroll(curwin); |
571 else | |
572 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
573 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
|
574 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
575 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
|
576 || (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
|
577 // '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
|
578 // 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
|
579 *(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
|
580 else |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
581 *(long *)varp = def_val; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
582 // May also set global value for local option. |
7 | 583 if (both) |
584 *(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
|
585 def_val; |
7 | 586 } |
587 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
588 else // P_BOOL |
7 | 589 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
590 // 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
|
591 // MSVC |
840 | 592 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; |
1111 | 593 #ifdef UNIX |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
594 // 'modeline' defaults to off for root |
1111 | 595 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) |
596 *(int *)varp = FALSE; | |
597 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
598 // May also set global value for local option. |
7 | 599 if (both) |
600 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | |
601 *(int *)varp; | |
602 } | |
634 | 603 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
604 // The default value is not insecure. |
681 | 605 flagsp = insecure_flag(opt_idx, opt_flags); |
606 *flagsp = *flagsp & ~P_INSECURE; | |
7 | 607 } |
608 | |
609 #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
|
610 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 611 #endif |
612 } | |
613 | |
614 /* | |
615 * 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
|
616 * When "opt_flags" is non-zero skip 'encoding'. |
7 | 617 */ |
618 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
619 set_options_default( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
620 int opt_flags) // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL |
7 | 621 { |
622 int i; | |
623 win_T *wp; | |
671 | 624 tabpage_T *tp; |
7 | 625 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
626 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
|
627 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
|
628 && (opt_flags == 0 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
629 || (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
|
630 # if defined(FEAT_CRYPT) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
631 && 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
|
632 && 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
|
633 # endif |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
634 ))) |
7 | 635 set_option_default(i, opt_flags, p_cp); |
636 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
637 // The 'scroll' option must be computed for all windows. |
671 | 638 FOR_ALL_TAB_WINDOWS(tp, wp) |
7 | 639 win_comp_scroll(wp); |
6205 | 640 #ifdef FEAT_CINDENT |
641 parse_cino(curbuf); | |
642 #endif | |
7 | 643 } |
644 | |
645 /* | |
646 * Set the Vi-default value of a string option. | |
647 * 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
|
648 * 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
|
649 */ |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
650 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
|
651 set_string_default_esc(char *name, char_u *val, int escape) |
7 | 652 { |
653 char_u *p; | |
654 int opt_idx; | |
655 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
656 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
|
657 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
|
658 else |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
659 p = vim_strsave(val); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
660 if (p != NULL) // we don't want a NULL |
7 | 661 { |
662 opt_idx = findoption((char_u *)name); | |
838 | 663 if (opt_idx >= 0) |
664 { | |
665 if (options[opt_idx].flags & P_DEF_ALLOCED) | |
666 vim_free(options[opt_idx].def_val[VI_DEFAULT]); | |
667 options[opt_idx].def_val[VI_DEFAULT] = p; | |
668 options[opt_idx].flags |= P_DEF_ALLOCED; | |
669 } | |
7 | 670 } |
671 } | |
672 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
673 void |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
674 set_string_default(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
|
675 { |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
676 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
|
677 } |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
678 |
7 | 679 /* |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
680 * 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
|
681 * "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
|
682 */ |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
683 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
|
684 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
|
685 { |
22242
f7871f02ddcd
patch 8.2.1670: a couple of gcc compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
22234
diff
changeset
|
686 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
|
687 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
|
688 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
|
689 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
690 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
|
691 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
|
692 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
693 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
|
694 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
|
695 { |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
696 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
|
697 || 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
|
698 || (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
|
699 && 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
|
700 && (!(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
|
701 || 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
|
702 || 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
|
703 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
|
704 // 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
|
705 // 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
|
706 // 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
|
707 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
|
708 && 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
|
709 && 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
|
710 || (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
|
711 && 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
|
712 ++bs; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
713 else |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
714 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
|
715 } |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
716 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
|
717 } |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
718 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
719 /* |
7 | 720 * Set the Vi-default value of a number option. |
721 * Used for 'lines' and 'columns'. | |
722 */ | |
723 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
724 set_number_default(char *name, long val) |
7 | 725 { |
838 | 726 int opt_idx; |
727 | |
728 opt_idx = findoption((char_u *)name); | |
729 if (opt_idx >= 0) | |
840 | 730 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 731 } |
732 | |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
733 /* |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
734 * 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
|
735 * 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
|
736 * 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
|
737 */ |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
738 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
|
739 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
|
740 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
741 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
|
742 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
|
743 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
744 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
|
745 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
|
746 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
|
747 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
748 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
|
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 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
|
751 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
|
752 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
753 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
|
754 && (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
|
755 && !(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
|
756 && !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
|
757 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
|
758 } |
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 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
|
761 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
|
762 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
|
763 } |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
764 |
359 | 765 #if defined(EXITFREE) || defined(PROTO) |
766 /* | |
767 * Free all options. | |
768 */ | |
769 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
770 free_all_options(void) |
359 | 771 { |
772 int i; | |
773 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
774 for (i = 0; !istermoption_idx(i); i++) |
359 | 775 { |
776 if (options[i].indir == PV_NONE) | |
777 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
778 // 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
|
779 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL) |
359 | 780 free_string_option(*(char_u **)options[i].var); |
781 if (options[i].flags & P_DEF_ALLOCED) | |
782 free_string_option(options[i].def_val[VI_DEFAULT]); | |
783 } | |
784 else if (options[i].var != VAR_WIN | |
785 && (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
|
786 // buffer-local option: free global value |
359 | 787 free_string_option(*(char_u **)options[i].var); |
788 } | |
789 } | |
790 #endif | |
791 | |
792 | |
7 | 793 /* |
794 * Initialize the options, part two: After getting Rows and Columns and | |
795 * setting 'term'. | |
796 */ | |
797 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
798 set_init_2(void) |
7 | 799 { |
164 | 800 int idx; |
801 | |
7 | 802 /* |
12718
f8f505ffc0a6
patch 8.0.1237: ":set scroll&" often gives an error
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
803 * '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
|
804 * which results in the actual value computed from the window height. |
7 | 805 */ |
168 | 806 idx = findoption((char_u *)"scroll"); |
838 | 807 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
168 | 808 set_option_default(idx, OPT_LOCAL, p_cp); |
7 | 809 comp_col(); |
810 | |
164 | 811 /* |
812 * 'window' is only for backwards compatibility with Vi. | |
813 * Default is Rows - 1. | |
814 */ | |
857 | 815 if (!option_was_set((char_u *)"window")) |
164 | 816 p_window = Rows - 1; |
817 set_number_default("window", Rows - 1); | |
818 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
819 // 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
|
820 #if !((defined(MSWIN)) && !defined(FEAT_GUI)) |
671 | 821 /* |
822 * If 'background' wasn't set by the user, try guessing the value, | |
823 * depending on the terminal name. Only need to check for terminals | |
824 * with a dark background, that can handle color. | |
825 */ | |
826 idx = findoption((char_u *)"bg"); | |
838 | 827 if (idx >= 0 && !(options[idx].flags & P_WAS_SET) |
828 && *term_bg_default() == 'd') | |
671 | 829 { |
694 | 830 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
|
831 // 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
|
832 // changed again |
671 | 833 options[idx].flags &= ~P_WAS_SET; |
7 | 834 } |
835 #endif | |
440 | 836 |
837 #ifdef CURSOR_SHAPE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
838 parse_shape_opt(SHAPE_CURSOR); // set cursor shapes from 'guicursor' |
440 | 839 #endif |
840 #ifdef FEAT_MOUSESHAPE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
841 parse_shape_opt(SHAPE_MOUSE); // set mouse shapes from 'mouseshape' |
440 | 842 #endif |
843 #ifdef FEAT_PRINTER | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
844 (void)parse_printoptions(); // parse 'printoptions' default value |
440 | 845 #endif |
7 | 846 } |
847 | |
848 /* | |
849 * Initialize the options, part three: After reading the .vimrc | |
850 */ | |
851 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
852 set_init_3(void) |
7 | 853 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
854 #if defined(UNIX) || defined(MSWIN) |
7 | 855 /* |
856 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. | |
857 * This is done after other initializations, where 'shell' might have been | |
858 * set, but only if they have not been set before. | |
859 */ | |
860 char_u *p; | |
861 int idx_srr; | |
862 int do_srr; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
863 # ifdef FEAT_QUICKFIX |
7 | 864 int idx_sp; |
865 int do_sp; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
866 # endif |
7 | 867 |
868 idx_srr = findoption((char_u *)"srr"); | |
838 | 869 if (idx_srr < 0) |
870 do_srr = FALSE; | |
871 else | |
872 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
|
873 # ifdef FEAT_QUICKFIX |
7 | 874 idx_sp = findoption((char_u *)"sp"); |
838 | 875 if (idx_sp < 0) |
876 do_sp = FALSE; | |
877 else | |
878 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
|
879 # endif |
5867 | 880 p = get_isolated_shell_name(); |
7 | 881 if (p != NULL) |
882 { | |
883 /* | |
884 * Default for p_sp is "| tee", for p_srr is ">". | |
885 * For known shells it is changed here to include stderr. | |
886 */ | |
887 if ( fnamecmp(p, "csh") == 0 | |
888 || 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
|
889 # if defined(MSWIN) // also check with .exe extension |
7 | 890 || fnamecmp(p, "csh.exe") == 0 |
891 || fnamecmp(p, "tcsh.exe") == 0 | |
892 # endif | |
893 ) | |
894 { | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
895 # if defined(FEAT_QUICKFIX) |
7 | 896 if (do_sp) |
897 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
898 # ifdef MSWIN |
7 | 899 p_sp = (char_u *)">&"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
900 # else |
7 | 901 p_sp = (char_u *)"|& tee"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
902 # endif |
7 | 903 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
904 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
905 # endif |
7 | 906 if (do_srr) |
907 { | |
908 p_srr = (char_u *)">&"; | |
909 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
910 } | |
911 } | |
912 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
913 // Always use bourne shell style redirection if we reach this |
7 | 914 if ( fnamecmp(p, "sh") == 0 |
915 || fnamecmp(p, "ksh") == 0 | |
2774 | 916 || fnamecmp(p, "mksh") == 0 |
917 || fnamecmp(p, "pdksh") == 0 | |
7 | 918 || fnamecmp(p, "zsh") == 0 |
836 | 919 || fnamecmp(p, "zsh-beta") == 0 |
7 | 920 || fnamecmp(p, "bash") == 0 |
5867 | 921 || fnamecmp(p, "fish") == 0 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
922 # ifdef MSWIN |
7 | 923 || fnamecmp(p, "cmd") == 0 |
924 || fnamecmp(p, "sh.exe") == 0 | |
925 || fnamecmp(p, "ksh.exe") == 0 | |
2774 | 926 || fnamecmp(p, "mksh.exe") == 0 |
927 || fnamecmp(p, "pdksh.exe") == 0 | |
7 | 928 || fnamecmp(p, "zsh.exe") == 0 |
836 | 929 || fnamecmp(p, "zsh-beta.exe") == 0 |
7 | 930 || fnamecmp(p, "bash.exe") == 0 |
931 || fnamecmp(p, "cmd.exe") == 0 | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
932 # endif |
7 | 933 ) |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
934 { |
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
935 # if defined(FEAT_QUICKFIX) |
7 | 936 if (do_sp) |
937 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
938 # ifdef MSWIN |
7 | 939 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
|
940 # else |
7 | 941 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
|
942 # endif |
7 | 943 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
944 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
945 # endif |
7 | 946 if (do_srr) |
947 { | |
948 p_srr = (char_u *)">%s 2>&1"; | |
949 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
950 } | |
951 } | |
952 vim_free(p); | |
953 } | |
954 #endif | |
955 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
956 #if defined(MSWIN) |
7 | 957 /* |
3352 | 958 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the |
959 * 'shell' option. | |
7 | 960 * This is done after other initializations, where 'shell' might have been |
961 * set, but only if they have not been set before. Default for p_shcf is | |
962 * "/c", for p_shq is "". For "sh" like shells it is changed here to | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
963 * "-c" and "\"". And for Win32 we need to set p_sxq instead. |
7 | 964 */ |
10 | 965 if (strstr((char *)gettail(p_sh), "sh") != NULL) |
7 | 966 { |
967 int idx3; | |
968 | |
969 idx3 = findoption((char_u *)"shcf"); | |
838 | 970 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 971 { |
972 p_shcf = (char_u *)"-c"; | |
973 options[idx3].def_val[VI_DEFAULT] = p_shcf; | |
974 } | |
975 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
976 // Somehow Win32 requires the quotes around the redirection too |
7 | 977 idx3 = findoption((char_u *)"sxq"); |
838 | 978 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 979 { |
980 p_sxq = (char_u *)"\""; | |
981 options[idx3].def_val[VI_DEFAULT] = p_sxq; | |
982 } | |
983 } | |
3352 | 984 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL) |
985 { | |
986 int idx3; | |
987 | |
988 /* | |
989 * cmd.exe on Windows will strip the first and last double quote given | |
990 * on the command line, e.g. most of the time things like: | |
991 * cmd /c "my path/to/echo" "my args to echo" | |
992 * become: | |
993 * my path/to/echo" "my args to echo | |
994 * when executed. | |
995 * | |
3357 | 996 * To avoid this, set shellxquote to surround the command in |
997 * parenthesis. This appears to make most commands work, without | |
998 * breaking commands that worked previously, such as | |
999 * '"path with spaces/cmd" "a&b"'. | |
3352 | 1000 */ |
1001 idx3 = findoption((char_u *)"sxq"); | |
1002 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
1003 { | |
3357 | 1004 p_sxq = (char_u *)"("; |
3352 | 1005 options[idx3].def_val[VI_DEFAULT] = p_sxq; |
1006 } | |
1007 | |
1008 idx3 = findoption((char_u *)"shcf"); | |
1009 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
1010 { | |
3357 | 1011 p_shcf = (char_u *)"/c"; |
3352 | 1012 options[idx3].def_val[VI_DEFAULT] = p_shcf; |
1013 } | |
1014 } | |
7 | 1015 #endif |
1016 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11107
diff
changeset
|
1017 if (BUFEMPTY()) |
8659
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1018 { |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1019 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
|
1020 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1021 // 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
|
1022 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
|
1023 set_fileformat(default_fileformat(), OPT_LOCAL); |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1024 } |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1025 |
7 | 1026 #ifdef FEAT_TITLE |
1027 set_title_defaults(); | |
1028 #endif | |
1029 } | |
1030 | |
1031 #if defined(FEAT_MULTI_LANG) || defined(PROTO) | |
1032 /* | |
1033 * When 'helplang' is still at its default value, set it to "lang". | |
1034 * Only the first two characters of "lang" are used. | |
1035 */ | |
1036 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1037 set_helplang_default(char_u *lang) |
7 | 1038 { |
1039 int idx; | |
1040 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1041 if (lang == NULL || STRLEN(lang) < 2) // safety check |
7 | 1042 return; |
1043 idx = findoption((char_u *)"hlg"); | |
838 | 1044 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
7 | 1045 { |
1046 if (options[idx].flags & P_ALLOCED) | |
1047 free_string_option(p_hlg); | |
1048 p_hlg = vim_strsave(lang); | |
1049 if (p_hlg == NULL) | |
1050 p_hlg = empty_option; | |
1051 else | |
18 | 1052 { |
14997
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1053 // zh_CN becomes "cn", zh_TW becomes "tw" |
18 | 1054 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) |
1055 { | |
1056 p_hlg[0] = TOLOWER_ASC(p_hlg[3]); | |
1057 p_hlg[1] = TOLOWER_ASC(p_hlg[4]); | |
1058 } | |
14997
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1059 // any C like setting, such as C.UTF-8, becomes "en" |
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1060 else if (STRLEN(p_hlg) >= 1 && *p_hlg == 'C') |
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1061 { |
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1062 p_hlg[0] = 'e'; |
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1063 p_hlg[1] = 'n'; |
0058cdd5b752
patch 8.1.0510: filter test fails when $LANG is C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1064 } |
7 | 1065 p_hlg[2] = NUL; |
18 | 1066 } |
7 | 1067 options[idx].flags |= P_ALLOCED; |
1068 } | |
1069 } | |
1070 #endif | |
1071 | |
1072 #ifdef FEAT_TITLE | |
1073 /* | |
1074 * 'title' and 'icon' only default to true if they have not been set or reset | |
1075 * in .vimrc and we can read the old value. | |
1076 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if | |
1077 * they can be reset. This reduces startup time when using X on a remote | |
1078 * machine. | |
1079 */ | |
1080 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1081 set_title_defaults(void) |
7 | 1082 { |
1083 int idx1; | |
1084 long val; | |
1085 | |
1086 /* | |
1087 * If GUI is (going to be) used, we can always set the window title and | |
1088 * icon name. Saves a bit of time, because the X11 display server does | |
1089 * not need to be contacted. | |
1090 */ | |
1091 idx1 = findoption((char_u *)"title"); | |
838 | 1092 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 1093 { |
1094 #ifdef FEAT_GUI | |
1095 if (gui.starting || gui.in_use) | |
1096 val = TRUE; | |
1097 else | |
1098 #endif | |
1099 val = mch_can_restore_title(); | |
840 | 1100 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 1101 p_title = val; |
1102 } | |
1103 idx1 = findoption((char_u *)"icon"); | |
838 | 1104 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 1105 { |
1106 #ifdef FEAT_GUI | |
1107 if (gui.starting || gui.in_use) | |
1108 val = TRUE; | |
1109 else | |
1110 #endif | |
1111 val = mch_can_restore_icon(); | |
840 | 1112 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 1113 p_icon = val; |
1114 } | |
1115 } | |
1116 #endif | |
1117 | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1118 void |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1119 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
|
1120 { |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1121 int flags = 0; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1122 |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1123 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
|
1124 flags = OPT_LOCAL; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1125 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
|
1126 flags = OPT_GLOBAL; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1127 #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
|
1128 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
|
1129 ex_options(eap); |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1130 else |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1131 #endif |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1132 { |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1133 if (eap->forceit) |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1134 flags |= OPT_ONECOLUMN; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1135 (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
|
1136 } |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1137 } |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1138 |
7 | 1139 /* |
1140 * Parse 'arg' for option settings. | |
1141 * | |
1142 * 'arg' may be IObuff, but only when no errors can be present and option | |
1143 * does not need to be expanded with option_expand(). | |
1144 * "opt_flags": | |
1145 * 0 for ":set" | |
717 | 1146 * OPT_GLOBAL for ":setglobal" |
1147 * OPT_LOCAL for ":setlocal" and a modeline | |
7 | 1148 * OPT_MODELINE for a modeline |
717 | 1149 * OPT_WINONLY to only set window-local options |
1150 * OPT_NOWIN to skip setting window-local options | |
7 | 1151 * |
1152 * returns FAIL if an error is detected, OK otherwise | |
1153 */ | |
1154 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1155 do_set( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1156 char_u *arg, // option string (may be written to!) |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1157 int opt_flags) |
7 | 1158 { |
1159 int opt_idx; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1160 char *errmsg; |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1161 char errbuf[80]; |
7 | 1162 char_u *startarg; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1163 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
|
1164 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
|
1165 int afterchar; // character just after option name |
7 | 1166 int len; |
1167 int i; | |
9389
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
1168 varnumber_T value; |
7 | 1169 int key; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1170 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
|
1171 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
|
1172 int did_show = FALSE; // already showed one value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1173 int adding; // "opt+=arg" |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1174 int prepending; // "opt^=arg" |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1175 int removing; // "opt-=arg" |
7 | 1176 int cp_val = 0; |
1177 char_u key_name[2]; | |
1178 | |
1179 if (*arg == NUL) | |
1180 { | |
1181 showoptions(0, opt_flags); | |
168 | 1182 did_show = TRUE; |
1183 goto theend; | |
7 | 1184 } |
1185 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1186 while (*arg != NUL) // loop to process all options |
7 | 1187 { |
1188 errmsg = NULL; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1189 startarg = arg; // remember for error message |
7 | 1190 |
36 | 1191 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3]) |
1192 && !(opt_flags & OPT_MODELINE)) | |
7 | 1193 { |
1194 /* | |
1195 * ":set all" show all options. | |
1196 * ":set all&" set all options to their default value. | |
1197 */ | |
1198 arg += 3; | |
1199 if (*arg == '&') | |
1200 { | |
1201 ++arg; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1202 // Only for :set command set global value of local options. |
7 | 1203 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
|
1204 didset_options(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
1205 didset_options2(); |
7034
e668b160ac68
commit https://github.com/vim/vim/commit/b341dda575899458f7075614dcedf0a80ee9d080
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
1206 redraw_all_later(CLEAR); |
7 | 1207 } |
1208 else | |
168 | 1209 { |
7 | 1210 showoptions(1, opt_flags); |
168 | 1211 did_show = TRUE; |
1212 } | |
7 | 1213 } |
36 | 1214 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) |
7 | 1215 { |
1216 showoptions(2, opt_flags); | |
1217 show_termcodes(); | |
168 | 1218 did_show = TRUE; |
7 | 1219 arg += 7; |
1220 } | |
1221 else | |
1222 { | |
1223 prefix = 1; | |
1911 | 1224 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0) |
7 | 1225 { |
1226 prefix = 0; | |
1227 arg += 2; | |
1228 } | |
1229 else if (STRNCMP(arg, "inv", 3) == 0) | |
1230 { | |
1231 prefix = 2; | |
1232 arg += 3; | |
1233 } | |
1234 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1235 // find end of name |
7 | 1236 key = 0; |
1237 if (*arg == '<') | |
1238 { | |
1239 opt_idx = -1; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1240 // look out for <t_>;> |
7 | 1241 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) |
1242 len = 5; | |
1243 else | |
1244 { | |
1245 len = 1; | |
1246 while (arg[len] != NUL && arg[len] != '>') | |
1247 ++len; | |
1248 } | |
1249 if (arg[len] != '>') | |
1250 { | |
1251 errmsg = e_invarg; | |
1252 goto skip; | |
1253 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1254 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
|
1255 if (arg[1] == 't' && arg[2] == '_') // could be term code |
7 | 1256 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
|
1257 arg[len++] = '>'; // restore '>' |
7 | 1258 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
|
1259 key = find_key_option(arg + 1, TRUE); |
7 | 1260 } |
1261 else | |
1262 { | |
1263 len = 0; | |
1264 /* | |
1265 * The two characters after "t_" may not be alphanumeric. | |
1266 */ | |
1267 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
1268 len = 4; | |
1269 else | |
1270 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') | |
1271 ++len; | |
1272 nextchar = arg[len]; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1273 arg[len] = NUL; // put NUL after name |
7 | 1274 opt_idx = findoption(arg); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1275 arg[len] = nextchar; // restore nextchar |
7 | 1276 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
|
1277 key = find_key_option(arg, FALSE); |
7 | 1278 } |
1279 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1280 // remember character after option name |
7 | 1281 afterchar = arg[len]; |
1282 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1283 // skip white space, allow ":set ai ?" |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1284 while (VIM_ISWHITE(arg[len])) |
7 | 1285 ++len; |
1286 | |
1287 adding = FALSE; | |
1288 prepending = FALSE; | |
1289 removing = FALSE; | |
1290 if (arg[len] != NUL && arg[len + 1] == '=') | |
1291 { | |
1292 if (arg[len] == '+') | |
1293 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1294 adding = TRUE; // "+=" |
7 | 1295 ++len; |
1296 } | |
1297 else if (arg[len] == '^') | |
1298 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1299 prepending = TRUE; // "^=" |
7 | 1300 ++len; |
1301 } | |
1302 else if (arg[len] == '-') | |
1303 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1304 removing = TRUE; // "-=" |
7 | 1305 ++len; |
1306 } | |
1307 } | |
1308 nextchar = arg[len]; | |
1309 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1310 if (opt_idx == -1 && key == 0) // found a mismatch: skip |
7 | 1311 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1312 errmsg = N_("E518: Unknown option"); |
7 | 1313 goto skip; |
1314 } | |
1315 | |
1316 if (opt_idx >= 0) | |
1317 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1318 if (options[opt_idx].var == NULL) // hidden option: skip |
7 | 1319 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1320 // 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
|
1321 // a hidden option, ignore setting it. |
7 | 1322 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL |
1323 && (!(options[opt_idx].flags & P_BOOL) | |
1324 || nextchar == '?')) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1325 errmsg = N_("E519: Option not supported"); |
7 | 1326 goto skip; |
1327 } | |
1328 | |
1329 flags = options[opt_idx].flags; | |
1330 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | |
1331 } | |
1332 else | |
1333 { | |
1334 flags = P_STRING; | |
1335 if (key < 0) | |
1336 { | |
1337 key_name[0] = KEY2TERMCAP0(key); | |
1338 key_name[1] = KEY2TERMCAP1(key); | |
1339 } | |
1340 else | |
1341 { | |
1342 key_name[0] = KS_KEY; | |
1343 key_name[1] = (key & 0xff); | |
1344 } | |
1345 } | |
1346 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1347 // 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
|
1348 // an already loaded buffer in a window). |
634 | 1349 if ((opt_flags & OPT_WINONLY) |
1350 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) | |
1351 goto skip; | |
1352 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1353 // Skip all options that are window-local (used for :vimgrep). |
717 | 1354 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0 |
1355 && options[opt_idx].var == VAR_WIN) | |
1356 goto skip; | |
1357 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1358 // Disallow changing some options from modelines. |
1807 | 1359 if (opt_flags & OPT_MODELINE) |
7 | 1360 { |
2317
2b2cd34569eb
Disallow setting 'enc' in a modeline. (Patrick Texier)
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
1361 if (flags & (P_SECURE | P_NO_ML)) |
1807 | 1362 { |
21672
9099eb378758
patch 8.2.1386: backslash not removed afer space with space in 'isfname'
Bram Moolenaar <Bram@vim.org>
parents:
20802
diff
changeset
|
1363 errmsg = N_("E520: Not allowed in a modeline"); |
1807 | 1364 goto skip; |
1365 } | |
16728
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1366 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
|
1367 { |
21672
9099eb378758
patch 8.2.1386: backslash not removed afer space with space in 'isfname'
Bram Moolenaar <Bram@vim.org>
parents:
20802
diff
changeset
|
1368 errmsg = N_("E992: Not allowed in a modeline when 'modelineexpr' is off"); |
16728
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1369 goto skip; |
e55c26aaf484
patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
1370 } |
1810 | 1371 #ifdef FEAT_DIFF |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1372 // 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
|
1373 // '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
|
1374 // "wrap" gets set. |
1807 | 1375 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
|
1376 && 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
|
1377 && ( |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1378 #ifdef FEAT_FOLDING |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1379 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
|
1380 #endif |
d2178a6cc9f3
patch 8.0.0425: build errors when building without folding
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
1381 options[opt_idx].indir == PV_WRAP)) |
1807 | 1382 goto skip; |
1810 | 1383 #endif |
7 | 1384 } |
1385 | |
1386 #ifdef HAVE_SANDBOX | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1387 // Disallow changing some options in the sandbox |
634 | 1388 if (sandbox != 0 && (flags & P_SECURE)) |
7 | 1389 { |
21672
9099eb378758
patch 8.2.1386: backslash not removed afer space with space in 'isfname'
Bram Moolenaar <Bram@vim.org>
parents:
20802
diff
changeset
|
1390 errmsg = e_sandbox; |
7 | 1391 goto skip; |
1392 } | |
1393 #endif | |
1394 | |
1395 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) | |
1396 { | |
1397 arg += len; | |
1398 cp_val = p_cp; | |
1399 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') | |
1400 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1401 if (arg[3] == 'm') // "opt&vim": set to Vim default |
7 | 1402 { |
1403 cp_val = FALSE; | |
1404 arg += 3; | |
1405 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1406 else // "opt&vi": set to Vi default |
7 | 1407 { |
1408 cp_val = TRUE; | |
1409 arg += 2; | |
1410 } | |
1411 } | |
1412 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
|
1413 && arg[1] != NUL && !VIM_ISWHITE(arg[1])) |
7 | 1414 { |
1415 errmsg = e_trailing; | |
1416 goto skip; | |
1417 } | |
1418 } | |
1419 | |
1420 /* | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
1421 * 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
|
1422 * allows only one '=' character per "set" command line. grrr. (jw) |
7 | 1423 */ |
1424 if (nextchar == '?' | |
1425 || (prefix == 1 | |
1426 && vim_strchr((char_u *)"=:&<", nextchar) == NULL | |
1427 && !(flags & P_BOOL))) | |
1428 { | |
1429 /* | |
1430 * print value | |
1431 */ | |
1432 if (did_show) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1433 msg_putchar('\n'); // cursor below last one |
7 | 1434 else |
1435 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1436 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
|
1437 did_show = TRUE; // remember that we did a line |
7 | 1438 } |
1439 if (opt_idx >= 0) | |
1440 { | |
1441 showoneopt(&options[opt_idx], opt_flags); | |
1442 #ifdef FEAT_EVAL | |
1443 if (p_verbose > 0) | |
694 | 1444 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1445 // Mention where the option was last set. |
694 | 1446 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
|
1447 last_set_msg(options[opt_idx].script_ctx); |
694 | 1448 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
|
1449 last_set_msg(curwin->w_p_script_ctx[ |
694 | 1450 (int)options[opt_idx].indir & PV_MASK]); |
1451 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
|
1452 last_set_msg(curbuf->b_p_script_ctx[ |
694 | 1453 (int)options[opt_idx].indir & PV_MASK]); |
1454 } | |
7 | 1455 #endif |
1456 } | |
1457 else | |
1458 { | |
1459 char_u *p; | |
1460 | |
1461 p = find_termcode(key_name); | |
1462 if (p == NULL) | |
1463 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1464 errmsg = N_("E846: Key code not set"); |
7 | 1465 goto skip; |
1466 } | |
1467 else | |
1468 (void)show_one_termcode(key_name, p, TRUE); | |
1469 } | |
1470 if (nextchar != '?' | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1471 && nextchar != NUL && !VIM_ISWHITE(afterchar)) |
7 | 1472 errmsg = e_trailing; |
1473 } | |
1474 else | |
1475 { | |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1476 int value_is_replaced = !prepending && !adding && !removing; |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
1477 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
|
1478 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1479 if (flags & P_BOOL) // boolean |
7 | 1480 { |
1481 if (nextchar == '=' || nextchar == ':') | |
1482 { | |
1483 errmsg = e_invarg; | |
1484 goto skip; | |
1485 } | |
1486 | |
1487 /* | |
1488 * ":set opt!": invert | |
1489 * ":set opt&": reset to default value | |
1490 * ":set opt<": reset to global value | |
1491 */ | |
1492 if (nextchar == '!') | |
1493 value = *(int *)(varp) ^ 1; | |
1494 else if (nextchar == '&') | |
840 | 1495 value = (int)(long)(long_i)options[opt_idx].def_val[ |
7 | 1496 ((flags & P_VI_DEF) || cp_val) |
1497 ? VI_DEFAULT : VIM_DEFAULT]; | |
1498 else if (nextchar == '<') | |
1499 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1500 // For 'autoread' -1 means to use global value. |
7 | 1501 if ((int *)varp == &curbuf->b_p_ar |
1502 && opt_flags == OPT_LOCAL) | |
1503 value = -1; | |
1504 else | |
1505 value = *(int *)get_varp_scope(&(options[opt_idx]), | |
1506 OPT_GLOBAL); | |
1507 } | |
1508 else | |
1509 { | |
1510 /* | |
1511 * ":set invopt": invert | |
1512 * ":set opt" or ":set noopt": set or reset | |
1513 */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1514 if (nextchar != NUL && !VIM_ISWHITE(afterchar)) |
7 | 1515 { |
1516 errmsg = e_trailing; | |
1517 goto skip; | |
1518 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1519 if (prefix == 2) // inv |
7 | 1520 value = *(int *)(varp) ^ 1; |
1521 else | |
1522 value = prefix; | |
1523 } | |
1524 | |
1525 errmsg = set_bool_option(opt_idx, varp, (int)value, | |
1526 opt_flags); | |
1527 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1528 else // numeric or string |
7 | 1529 { |
1530 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL | |
1531 || prefix != 1) | |
1532 { | |
1533 errmsg = e_invarg; | |
1534 goto skip; | |
1535 } | |
1536 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1537 if (flags & P_NUM) // numeric |
7 | 1538 { |
1539 /* | |
1540 * Different ways to set a number option: | |
1541 * & set to default value | |
1542 * < set to global value | |
1543 * <xx> accept special key codes for 'wildchar' | |
1544 * c accept any non-digit for 'wildchar' | |
1545 * [-]0-9 set number | |
1546 * other error | |
1547 */ | |
1548 ++arg; | |
1549 if (nextchar == '&') | |
840 | 1550 value = (long)(long_i)options[opt_idx].def_val[ |
7 | 1551 ((flags & P_VI_DEF) || cp_val) |
1552 ? VI_DEFAULT : VIM_DEFAULT]; | |
1553 else if (nextchar == '<') | |
5446 | 1554 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1555 // 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
|
1556 // use the global value. |
5446 | 1557 if ((long *)varp == &curbuf->b_p_ul |
1558 && opt_flags == OPT_LOCAL) | |
1559 value = NO_LOCAL_UNDOLEVEL; | |
1560 else | |
1561 value = *(long *)get_varp_scope( | |
1562 &(options[opt_idx]), OPT_GLOBAL); | |
1563 } | |
7 | 1564 else if (((long *)varp == &p_wc |
1565 || (long *)varp == &p_wcm) | |
1566 && (*arg == '<' | |
1567 || *arg == '^' | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1568 || (*arg != NUL |
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1569 && (!arg[1] || VIM_ISWHITE(arg[1])) |
7 | 1570 && !VIM_ISDIGIT(*arg)))) |
1571 { | |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1572 value = string_to_key(arg, FALSE); |
7 | 1573 if (value == 0 && (long *)varp != &p_wcm) |
1574 { | |
1575 errmsg = e_invarg; | |
1576 goto skip; | |
1577 } | |
1578 } | |
1579 else if (*arg == '-' || VIM_ISDIGIT(*arg)) | |
1580 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1581 // 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
|
1582 // hex numbers. |
7447
ad432f8f68fb
commit https://github.com/vim/vim/commit/887c1fea4a114e7170091942d0446c8882701b5b
Christian Brabandt <cb@256bit.org>
parents:
7426
diff
changeset
|
1583 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
|
1584 &value, NULL, 0, TRUE); |
17039
d726d8cce996
patch 8.1.1519: 'backupskip' may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
16843
diff
changeset
|
1585 if (i == 0 || (arg[i] != NUL |
d726d8cce996
patch 8.1.1519: 'backupskip' may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
16843
diff
changeset
|
1586 && !VIM_ISWHITE(arg[i]))) |
7 | 1587 { |
16706
77bcb5055fec
patch 8.1.1355: obvious mistakes are accepted as valid expressions
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
1588 errmsg = N_("E521: Number required after ="); |
7 | 1589 goto skip; |
1590 } | |
1591 } | |
1592 else | |
1593 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1594 errmsg = N_("E521: Number required after ="); |
7 | 1595 goto skip; |
1596 } | |
1597 | |
1598 if (adding) | |
1599 value = *(long *)varp + value; | |
1600 if (prepending) | |
1601 value = *(long *)varp * value; | |
1602 if (removing) | |
1603 value = *(long *)varp - value; | |
1604 errmsg = set_num_option(opt_idx, varp, value, | |
274 | 1605 errbuf, sizeof(errbuf), opt_flags); |
7 | 1606 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1607 else if (opt_idx >= 0) // string |
7 | 1608 { |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1609 char_u *save_arg = NULL; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1610 char_u *s = NULL; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1611 char_u *oldval = NULL; // previous value if *varp |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1612 char_u *newval; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1613 char_u *origval = NULL; |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1614 char_u *origval_l = NULL; |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1615 char_u *origval_g = NULL; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
1616 #if defined(FEAT_EVAL) |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1617 char_u *saved_origval = NULL; |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1618 char_u *saved_origval_l = NULL; |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1619 char_u *saved_origval_g = NULL; |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1620 char_u *saved_newval = NULL; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1621 #endif |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1622 unsigned newlen; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1623 int comma; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1624 int new_value_alloced; // new string option |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1625 // was allocated |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1626 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1627 // When using ":set opt=val" for a global option |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1628 // with a local value the local value will be |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1629 // reset, use the global value here. |
7 | 1630 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
692 | 1631 && ((int)options[opt_idx].indir & PV_BOTH)) |
7 | 1632 varp = options[opt_idx].var; |
1633 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1634 // The old value is kept until we are sure that the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1635 // new value is valid. |
7 | 1636 oldval = *(char_u **)varp; |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1637 |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1638 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
|
1639 { |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1640 origval_l = *(char_u **)get_varp_scope( |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1641 &(options[opt_idx]), OPT_LOCAL); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1642 origval_g = *(char_u **)get_varp_scope( |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1643 &(options[opt_idx]), OPT_GLOBAL); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1644 |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1645 // A global-local string option might have an empty |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1646 // option as value to indicate that the global |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1647 // value should be used. |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1648 if (((int)options[opt_idx].indir & PV_BOTH) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1649 && origval_l == empty_option) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1650 origval_l = origval_g; |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1651 } |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1652 |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1653 // When setting the local value of a global |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1654 // option, the old value may be the global value. |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1655 if (((int)options[opt_idx].indir & PV_BOTH) |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1656 && (opt_flags & OPT_LOCAL)) |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1657 origval = *(char_u **)get_varp( |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1658 &options[opt_idx]); |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1659 else |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1660 origval = oldval; |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1661 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1662 if (nextchar == '&') // set to default val |
7 | 1663 { |
1664 newval = options[opt_idx].def_val[ | |
1665 ((flags & P_VI_DEF) || cp_val) | |
1666 ? VI_DEFAULT : VIM_DEFAULT]; | |
1667 if ((char_u **)varp == &p_bg) | |
1668 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1669 // guess the value of 'background' |
7 | 1670 #ifdef FEAT_GUI |
1671 if (gui.in_use) | |
1672 newval = gui_bg_default(); | |
1673 else | |
1674 #endif | |
671 | 1675 newval = term_bg_default(); |
7 | 1676 } |
1677 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1678 // expand environment variables and ~ (since the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1679 // default value was already expanded, only |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1680 // required when an environment variable was set |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1681 // later |
7 | 1682 if (newval == NULL) |
1683 newval = empty_option; | |
1684 else | |
1685 { | |
1686 s = option_expand(opt_idx, newval); | |
1687 if (s == NULL) | |
1688 s = newval; | |
1689 newval = vim_strsave(s); | |
1690 } | |
1691 new_value_alloced = TRUE; | |
1692 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1693 else if (nextchar == '<') // set to global val |
7 | 1694 { |
1695 newval = vim_strsave(*(char_u **)get_varp_scope( | |
1696 &(options[opt_idx]), OPT_GLOBAL)); | |
1697 new_value_alloced = TRUE; | |
1698 } | |
1699 else | |
1700 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1701 ++arg; // jump to after the '=' or ':' |
7 | 1702 |
1703 /* | |
1704 * Set 'keywordprg' to ":help" if an empty | |
1705 * value was passed to :set by the user. | |
1706 * Misuse errbuf[] for the resulting string. | |
1707 */ | |
1708 if (varp == (char_u *)&p_kp | |
1709 && (*arg == NUL || *arg == ' ')) | |
1710 { | |
1711 STRCPY(errbuf, ":help"); | |
1712 save_arg = arg; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1713 arg = (char_u *)errbuf; |
7 | 1714 } |
1715 /* | |
3168 | 1716 * Convert 'backspace' number to string, for |
1717 * adding, prepending and removing string. | |
1718 */ | |
1719 else if (varp == (char_u *)&p_bs | |
1720 && VIM_ISDIGIT(**(char_u **)varp)) | |
1721 { | |
1722 i = getdigits((char_u **)varp); | |
1723 switch (i) | |
1724 { | |
1725 case 0: | |
1726 *(char_u **)varp = empty_option; | |
1727 break; | |
1728 case 1: | |
1729 *(char_u **)varp = vim_strsave( | |
1730 (char_u *)"indent,eol"); | |
1731 break; | |
1732 case 2: | |
1733 *(char_u **)varp = vim_strsave( | |
1734 (char_u *)"indent,eol,start"); | |
1735 break; | |
20069
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1736 case 3: |
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1737 *(char_u **)varp = vim_strsave( |
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1738 (char_u *)"indent,eol,nostop"); |
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1739 break; |
3168 | 1740 } |
1741 vim_free(oldval); | |
12190
497b78526358
patch 8.0.0975: using freed memory when setting 'backspace'
Christian Brabandt <cb@256bit.org>
parents:
12188
diff
changeset
|
1742 if (origval == oldval) |
497b78526358
patch 8.0.0975: using freed memory when setting 'backspace'
Christian Brabandt <cb@256bit.org>
parents:
12188
diff
changeset
|
1743 origval = *(char_u **)varp; |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1744 if (origval_l == oldval) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1745 origval_l = *(char_u **)varp; |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1746 if (origval_g == oldval) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1747 origval_g = *(char_u **)varp; |
3168 | 1748 oldval = *(char_u **)varp; |
1749 } | |
1750 /* | |
7 | 1751 * Convert 'whichwrap' number to string, for |
1752 * backwards compatibility with Vim 3.0. | |
1753 * Misuse errbuf[] for the resulting string. | |
1754 */ | |
1755 else if (varp == (char_u *)&p_ww | |
1756 && VIM_ISDIGIT(*arg)) | |
1757 { | |
1758 *errbuf = NUL; | |
1759 i = getdigits(&arg); | |
1760 if (i & 1) | |
1761 STRCAT(errbuf, "b,"); | |
1762 if (i & 2) | |
1763 STRCAT(errbuf, "s,"); | |
1764 if (i & 4) | |
1765 STRCAT(errbuf, "h,l,"); | |
1766 if (i & 8) | |
1767 STRCAT(errbuf, "<,>,"); | |
1768 if (i & 16) | |
1769 STRCAT(errbuf, "[,],"); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1770 if (*errbuf != NUL) // remove trailing , |
7 | 1771 errbuf[STRLEN(errbuf) - 1] = NUL; |
1772 save_arg = arg; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
1773 arg = (char_u *)errbuf; |
7 | 1774 } |
1775 /* | |
1776 * Remove '>' before 'dir' and 'bdir', for | |
1777 * backwards compatibility with version 3.0 | |
1778 */ | |
1779 else if ( *arg == '>' | |
1780 && (varp == (char_u *)&p_dir | |
1781 || varp == (char_u *)&p_bdir)) | |
1782 { | |
1783 ++arg; | |
1784 } | |
1785 | |
1786 /* | |
1787 * Copy the new string into allocated memory. | |
1788 * Can't use set_string_option_direct(), because | |
1789 * we need to remove the backslashes. | |
1790 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1791 // get a bit too much |
7 | 1792 newlen = (unsigned)STRLEN(arg) + 1; |
1793 if (adding || prepending || removing) | |
1794 newlen += (unsigned)STRLEN(origval) + 1; | |
1795 newval = alloc(newlen); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1796 if (newval == NULL) // out of mem, don't change |
7 | 1797 break; |
1798 s = newval; | |
1799 | |
1800 /* | |
1801 * Copy the string, skip over escaped chars. | |
1802 * For MS-DOS and WIN32 backslashes before normal | |
1803 * file name characters are not removed, and keep | |
1804 * backslash at start, for "\\machine\path", but | |
1805 * do remove it for "\\\\machine\\path". | |
1806 * The reverse is found in ExpandOldSetting(). | |
1807 */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1808 while (*arg && !VIM_ISWHITE(*arg)) |
7 | 1809 { |
1810 if (*arg == '\\' && arg[1] != NUL | |
1811 #ifdef BACKSLASH_IN_FILENAME | |
1812 && !((flags & P_EXPAND) | |
1813 && vim_isfilec(arg[1]) | |
21672
9099eb378758
patch 8.2.1386: backslash not removed afer space with space in 'isfname'
Bram Moolenaar <Bram@vim.org>
parents:
20802
diff
changeset
|
1814 && !VIM_ISWHITE(arg[1]) |
7 | 1815 && (arg[1] != '\\' |
1816 || (s == newval | |
1817 && arg[2] != '\\'))) | |
1818 #endif | |
1819 ) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1820 ++arg; // remove backslash |
7 | 1821 if (has_mbyte |
474 | 1822 && (i = (*mb_ptr2len)(arg)) > 1) |
7 | 1823 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1824 // copy multibyte char |
7 | 1825 mch_memmove(s, arg, (size_t)i); |
1826 arg += i; | |
1827 s += i; | |
1828 } | |
1829 else | |
1830 *s++ = *arg++; | |
1831 } | |
1832 *s = NUL; | |
1833 | |
1834 /* | |
1835 * Expand environment variables and ~. | |
1836 * Don't do it when adding without inserting a | |
1837 * comma. | |
1838 */ | |
1839 if (!(adding || prepending || removing) | |
1840 || (flags & P_COMMA)) | |
1841 { | |
1842 s = option_expand(opt_idx, newval); | |
1843 if (s != NULL) | |
1844 { | |
1845 vim_free(newval); | |
1846 newlen = (unsigned)STRLEN(s) + 1; | |
1847 if (adding || prepending || removing) | |
1848 newlen += (unsigned)STRLEN(origval) + 1; | |
1849 newval = alloc(newlen); | |
1850 if (newval == NULL) | |
1851 break; | |
1852 STRCPY(newval, s); | |
1853 } | |
1854 } | |
1855 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1856 // locate newval[] in origval[] when removing it |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1857 // and when adding to avoid duplicates |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1858 i = 0; // init for GCC |
7 | 1859 if (removing || (flags & P_NODUP)) |
1860 { | |
1861 i = (int)STRLEN(newval); | |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
1862 s = find_dup_item(origval, newval, flags); |
7 | 1863 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1864 // do not add if already there |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
1865 if ((adding || prepending) && s != NULL) |
7 | 1866 { |
1867 prepending = FALSE; | |
1868 adding = FALSE; | |
1869 STRCPY(newval, origval); | |
1870 } | |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
1871 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
1872 // if no duplicate, move pointer to end of |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
1873 // original value |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
1874 if (s == NULL) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
1875 s = origval + (int)STRLEN(origval); |
7 | 1876 } |
1877 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1878 // concatenate the two strings; add a ',' if |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1879 // needed |
7 | 1880 if (adding || prepending) |
1881 { | |
1882 comma = ((flags & P_COMMA) && *origval != NUL | |
1883 && *newval != NUL); | |
1884 if (adding) | |
1885 { | |
1886 i = (int)STRLEN(origval); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1887 // strip a trailing comma, would get 2 |
7212
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1888 if (comma && i > 1 |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1889 && (flags & P_ONECOMMA) == P_ONECOMMA |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1890 && origval[i - 1] == ',' |
55c67e16e4fd
commit https://github.com/vim/vim/commit/174674743d9a2d7361c9cd89836f8dd8651edeeb
Christian Brabandt <cb@256bit.org>
parents:
7204
diff
changeset
|
1891 && origval[i - 2] != '\\') |
6841 | 1892 i--; |
7 | 1893 mch_memmove(newval + i + comma, newval, |
1894 STRLEN(newval) + 1); | |
1895 mch_memmove(newval, origval, (size_t)i); | |
1896 } | |
1897 else | |
1898 { | |
1899 i = (int)STRLEN(newval); | |
1622 | 1900 STRMOVE(newval + i + comma, origval); |
7 | 1901 } |
1902 if (comma) | |
1903 newval[i] = ','; | |
1904 } | |
1905 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1906 // Remove newval[] from origval[]. (Note: "i" has |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1907 // been set above and is used here). |
7 | 1908 if (removing) |
1909 { | |
1910 STRCPY(newval, origval); | |
1911 if (*s) | |
1912 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1913 // may need to remove a comma |
7 | 1914 if (flags & P_COMMA) |
1915 { | |
1916 if (s == origval) | |
1917 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1918 // include comma after string |
7 | 1919 if (s[i] == ',') |
1920 ++i; | |
1921 } | |
1922 else | |
1923 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1924 // include comma before string |
7 | 1925 --s; |
1926 ++i; | |
1927 } | |
1928 } | |
1622 | 1929 STRMOVE(newval + (s - origval), s + i); |
7 | 1930 } |
1931 } | |
1932 | |
1933 if (flags & P_FLAGLIST) | |
1934 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1935 // Remove flags that appear twice. |
10831
e926c5a7f9bf
patch 8.0.0305: invalid memory access when option has duplicate flag
Christian Brabandt <cb@256bit.org>
parents:
10825
diff
changeset
|
1936 for (s = newval; *s;) |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1937 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1938 // if options have P_FLAGLIST and |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1939 // P_ONECOMMA such as 'whichwrap' |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1940 if (flags & P_ONECOMMA) |
7 | 1941 { |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1942 if (*s != ',' && *(s + 1) == ',' |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1943 && vim_strchr(s + 2, *s) != NULL) |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1944 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1945 // Remove the duplicated value and |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1946 // the next comma. |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1947 STRMOVE(s, s + 2); |
10831
e926c5a7f9bf
patch 8.0.0305: invalid memory access when option has duplicate flag
Christian Brabandt <cb@256bit.org>
parents:
10825
diff
changeset
|
1948 continue; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1949 } |
7 | 1950 } |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1951 else |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1952 { |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1953 if ((!(flags & P_COMMA) || *s != ',') |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1954 && vim_strchr(s + 1, *s) != NULL) |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1955 { |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1956 STRMOVE(s, s + 1); |
10831
e926c5a7f9bf
patch 8.0.0305: invalid memory access when option has duplicate flag
Christian Brabandt <cb@256bit.org>
parents:
10825
diff
changeset
|
1957 continue; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1958 } |
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1959 } |
10831
e926c5a7f9bf
patch 8.0.0305: invalid memory access when option has duplicate flag
Christian Brabandt <cb@256bit.org>
parents:
10825
diff
changeset
|
1960 ++s; |
9798
e34e4547f3d1
commit https://github.com/vim/vim/commit/c8ce615299b4d8c1b2e6cf83496f48cd497d8a37
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1961 } |
7 | 1962 } |
1963 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1964 if (save_arg != NULL) // number for 'whichwrap' |
7 | 1965 arg = save_arg; |
1966 new_value_alloced = TRUE; | |
1967 } | |
1968 | |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1969 /* |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1970 * Set the new value. |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1971 */ |
7 | 1972 *(char_u **)(varp) = newval; |
1973 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
1974 #if defined(FEAT_EVAL) |
6939 | 1975 if (!starting |
1976 # ifdef FEAT_CRYPT | |
1977 && options[opt_idx].indir != PV_KEY | |
1978 # endif | |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1979 && origval != NULL && newval != NULL) |
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1980 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1981 // origval may be freed by |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1982 // did_set_string_option(), make a copy. |
6935 | 1983 saved_origval = vim_strsave(origval); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1984 // newval (and varp) may become invalid if the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1985 // buffer is closed by autocommands. |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1986 saved_newval = vim_strsave(newval); |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1987 if (origval_l != NULL) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1988 saved_origval_l = vim_strsave(origval_l); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1989 if (origval_g != NULL) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
1990 saved_origval_g = vim_strsave(origval_g); |
11587
439835c4b7aa
patch 8.0.0676: crash when closing quickfix window in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11533
diff
changeset
|
1991 } |
6935 | 1992 #endif |
1993 | |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1994 { |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1995 long_u *p = insecure_flag(opt_idx, opt_flags); |
15207
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
1996 int secure_saved = secure; |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1997 |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1998 // When an option is set in the sandbox, from a |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
1999 // modeline or in secure mode, then deal with side |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
2000 // effects in secure mode. Also when the value was |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
2001 // set with the P_INSECURE flag and is not |
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
2002 // completely replaced. |
16082
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
2003 if ((opt_flags & OPT_MODELINE) |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
2004 #ifdef HAVE_SANDBOX |
16082
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
2005 || sandbox != 0 |
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
2006 #endif |
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
2007 || (!value_is_replaced && (*p & P_INSECURE))) |
2699db3e4d9d
patch 8.1.1046: the "secure" variable is used inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
2008 secure = 1; |
15207
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
2009 |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
2010 // Handle side effects, and set the global value |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
2011 // for ":set" on local options. Note: when setting |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
2012 // 'syntax' or 'filetype' autocommands may be |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
2013 // triggered that can cause havoc. |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
2014 errmsg = did_set_string_option( |
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
2015 opt_idx, (char_u **)varp, |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2016 new_value_alloced, oldval, errbuf, |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2017 opt_flags, &value_checked); |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
2018 |
15207
6ab9c18708c4
patch 8.1.0613: when executing an insecure function the secure flag is stuck
Bram Moolenaar <Bram@vim.org>
parents:
15192
diff
changeset
|
2019 secure = secure_saved; |
15058
5997b84a838a
patch 8.1.0540: may evaluate insecure value when appending to option
Bram Moolenaar <Bram@vim.org>
parents:
15056
diff
changeset
|
2020 } |
7 | 2021 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
2022 #if defined(FEAT_EVAL) |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2023 if (errmsg == NULL) |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2024 trigger_optionsset_string( |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2025 opt_idx, opt_flags, saved_origval, |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2026 saved_origval_l, saved_origval_g, |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2027 saved_newval); |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2028 vim_free(saved_origval); |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2029 vim_free(saved_origval_l); |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2030 vim_free(saved_origval_g); |
12188
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2031 vim_free(saved_newval); |
d2e367d9de1f
patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
2032 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2033 // If error detected, print the error message. |
7 | 2034 if (errmsg != NULL) |
2035 goto skip; | |
2036 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2037 else // key code option |
7 | 2038 { |
2039 char_u *p; | |
2040 | |
2041 if (nextchar == '&') | |
2042 { | |
2043 if (add_termcap_entry(key_name, TRUE) == FAIL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2044 errmsg = N_("E522: Not found in termcap"); |
7 | 2045 } |
2046 else | |
2047 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2048 ++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
|
2049 for (p = arg; *p && !VIM_ISWHITE(*p); ++p) |
7 | 2050 if (*p == '\\' && p[1] != NUL) |
2051 ++p; | |
2052 nextchar = *p; | |
2053 *p = NUL; | |
2054 add_termcode(key_name, arg, FALSE); | |
2055 *p = nextchar; | |
2056 } | |
2057 if (full_screen) | |
2058 ttest(FALSE); | |
2059 redraw_all_later(CLEAR); | |
2060 } | |
2061 } | |
634 | 2062 |
7 | 2063 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
|
2064 did_set_option( |
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2065 opt_idx, opt_flags, value_is_replaced, value_checked); |
7 | 2066 } |
2067 | |
2068 skip: | |
2069 /* | |
2070 * Advance to next argument. | |
2071 * - skip until a blank found, taking care of backslashes | |
2072 * - skip blanks | |
2073 * - skip one "=val" argument (for hidden options ":set gfn =xx") | |
2074 */ | |
2075 for (i = 0; i < 2 ; ++i) | |
2076 { | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2077 while (*arg != NUL && !VIM_ISWHITE(*arg)) |
7 | 2078 if (*arg++ == '\\' && *arg != NUL) |
2079 ++arg; | |
2080 arg = skipwhite(arg); | |
2081 if (*arg != '=') | |
2082 break; | |
2083 } | |
2084 } | |
2085 | |
2086 if (errmsg != NULL) | |
2087 { | |
419 | 2088 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1); |
835 | 2089 i = (int)STRLEN(IObuff) + 2; |
7 | 2090 if (i + (arg - startarg) < IOSIZE) |
2091 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2092 // append the argument with the error |
7 | 2093 STRCAT(IObuff, ": "); |
2094 mch_memmove(IObuff + i, startarg, (arg - startarg)); | |
2095 IObuff[i + (arg - startarg)] = NUL; | |
2096 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2097 // make sure all characters are printable |
7 | 2098 trans_characters(IObuff, IOSIZE); |
2099 | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2100 ++no_wait_return; // wait_return done later |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2101 emsg((char *)IObuff); // show error highlighted |
7 | 2102 --no_wait_return; |
2103 | |
2104 return FAIL; | |
2105 } | |
2106 | |
2107 arg = skipwhite(arg); | |
2108 } | |
2109 | |
168 | 2110 theend: |
2111 if (silent_mode && did_show) | |
2112 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2113 // After displaying option values in silent mode. |
168 | 2114 silent_mode = FALSE; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2115 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
168 | 2116 msg_putchar('\n'); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2117 cursor_on(); // msg_start() switches it off |
168 | 2118 out_flush(); |
2119 silent_mode = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2120 info_message = FALSE; // use mch_msg(), not mch_errmsg() |
168 | 2121 } |
2122 | |
7 | 2123 return OK; |
2124 } | |
2125 | |
634 | 2126 /* |
2127 * Call this when an option has been given a new value through a user command. | |
2128 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag. | |
2129 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2130 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2131 did_set_option( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2132 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
|
2133 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
|
2134 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
|
2135 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
|
2136 // P_INSECURE flag. |
634 | 2137 { |
681 | 2138 long_u *p; |
2139 | |
634 | 2140 options[opt_idx].flags |= P_WAS_SET; |
2141 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2142 // 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
|
2143 // 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
|
2144 // flag. |
681 | 2145 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
|
2146 if (!value_checked && (secure |
634 | 2147 #ifdef HAVE_SANDBOX |
2148 || sandbox != 0 | |
2149 #endif | |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2150 || (opt_flags & OPT_MODELINE))) |
681 | 2151 *p = *p | P_INSECURE; |
2152 else if (new_value) | |
2153 *p = *p & ~P_INSECURE; | |
634 | 2154 } |
2155 | |
7 | 2156 /* |
2157 * Convert a key name or string into a key value. | |
2158 * 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
|
2159 * 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
|
2160 */ |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2161 int |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2162 string_to_key(char_u *arg, int multi_byte) |
7 | 2163 { |
2164 if (*arg == '<') | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
2165 return find_key_option(arg + 1, TRUE); |
7 | 2166 if (*arg == '^') |
2167 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
|
2168 if (multi_byte) |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2169 return PTR2CHAR(arg); |
7 | 2170 return *arg; |
2171 } | |
2172 | |
2173 #ifdef FEAT_TITLE | |
2174 /* | |
2175 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call | |
2176 * maketitle() to create and display it. | |
2177 * When switching the title or icon off, call mch_restore_title() to get | |
2178 * the old value back. | |
2179 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2180 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
|
2181 did_set_title(void) |
7 | 2182 { |
2183 if (starting != NO_SCREEN | |
2184 #ifdef FEAT_GUI | |
2185 && !gui.starting | |
2186 #endif | |
2187 ) | |
2188 maketitle(); | |
2189 } | |
2190 #endif | |
2191 | |
2192 /* | |
2193 * set_options_bin - called when 'bin' changes value. | |
2194 */ | |
2195 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2196 set_options_bin( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2197 int oldval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2198 int newval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2199 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 2200 { |
2201 /* | |
2202 * The option values that are changed when 'bin' changes are | |
2203 * copied when 'bin is set and restored when 'bin' is reset. | |
2204 */ | |
2205 if (newval) | |
2206 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2207 if (!oldval) // switched on |
7 | 2208 { |
2209 if (!(opt_flags & OPT_GLOBAL)) | |
2210 { | |
2211 curbuf->b_p_tw_nobin = curbuf->b_p_tw; | |
2212 curbuf->b_p_wm_nobin = curbuf->b_p_wm; | |
2213 curbuf->b_p_ml_nobin = curbuf->b_p_ml; | |
2214 curbuf->b_p_et_nobin = curbuf->b_p_et; | |
2215 } | |
2216 if (!(opt_flags & OPT_LOCAL)) | |
2217 { | |
2218 p_tw_nobin = p_tw; | |
2219 p_wm_nobin = p_wm; | |
2220 p_ml_nobin = p_ml; | |
2221 p_et_nobin = p_et; | |
2222 } | |
2223 } | |
2224 | |
2225 if (!(opt_flags & OPT_GLOBAL)) | |
2226 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2227 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
|
2228 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
|
2229 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
|
2230 curbuf->b_p_et = 0; // no expandtab |
7 | 2231 } |
2232 if (!(opt_flags & OPT_LOCAL)) | |
2233 { | |
2234 p_tw = 0; | |
2235 p_wm = 0; | |
2236 p_ml = FALSE; | |
2237 p_et = FALSE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2238 p_bin = TRUE; // needed when called for the "-b" argument |
7 | 2239 } |
2240 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2241 else if (oldval) // switched off |
7 | 2242 { |
2243 if (!(opt_flags & OPT_GLOBAL)) | |
2244 { | |
2245 curbuf->b_p_tw = curbuf->b_p_tw_nobin; | |
2246 curbuf->b_p_wm = curbuf->b_p_wm_nobin; | |
2247 curbuf->b_p_ml = curbuf->b_p_ml_nobin; | |
2248 curbuf->b_p_et = curbuf->b_p_et_nobin; | |
2249 } | |
2250 if (!(opt_flags & OPT_LOCAL)) | |
2251 { | |
2252 p_tw = p_tw_nobin; | |
2253 p_wm = p_wm_nobin; | |
2254 p_ml = p_ml_nobin; | |
2255 p_et = p_et_nobin; | |
2256 } | |
2257 } | |
2258 } | |
2259 | |
2260 /* | |
2261 * Expand environment variables for some string options. | |
2262 * These string options cannot be indirect! | |
2263 * If "val" is NULL expand the current value of the option. | |
2264 * Return pointer to NameBuff, or NULL when not expanded. | |
2265 */ | |
2266 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2267 option_expand(int opt_idx, char_u *val) |
7 | 2268 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2269 // if option doesn't need expansion nothing to do |
7 | 2270 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) |
2271 return NULL; | |
2272 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2273 // 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
|
2274 // expand_env() would truncate the string. |
7 | 2275 if (val != NULL && STRLEN(val) > MAXPATHL) |
2276 return NULL; | |
2277 | |
2278 if (val == NULL) | |
2279 val = *(char_u **)options[opt_idx].var; | |
2280 | |
2281 /* | |
2282 * Expanding this with NameBuff, expand_env() must not be passed IObuff. | |
2283 * Escape spaces when expanding 'tags', they are used to separate file | |
2284 * names. | |
374 | 2285 * For 'spellsuggest' expand after "file:". |
7 | 2286 */ |
2287 expand_env_esc(val, NameBuff, MAXPATHL, | |
1408 | 2288 (char_u **)options[opt_idx].var == &p_tags, FALSE, |
744 | 2289 #ifdef FEAT_SPELL |
374 | 2290 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : |
2291 #endif | |
2292 NULL); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2293 if (STRCMP(NameBuff, val) == 0) // they are the same |
7 | 2294 return NULL; |
2295 | |
2296 return NameBuff; | |
2297 } | |
2298 | |
2299 /* | |
2300 * After setting various option values: recompute variables that depend on | |
2301 * option values. | |
2302 */ | |
2303 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2304 didset_options(void) |
7 | 2305 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2306 // initialize the table for 'iskeyword' et.al. |
7 | 2307 (void)init_chartab(); |
2308 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2309 didset_string_options(); |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2310 |
744 | 2311 #ifdef FEAT_SPELL |
484 | 2312 (void)spell_check_msm(); |
374 | 2313 (void)spell_check_sps(); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
2314 (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
|
2315 (void)did_set_spell_option(TRUE); |
344 | 2316 #endif |
7 | 2317 #ifdef FEAT_CMDWIN |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2318 // set cedit_key |
7 | 2319 (void)check_cedit(); |
2320 #endif | |
5995 | 2321 #ifdef FEAT_LINEBREAK |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2322 // initialize the table for 'breakat'. |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2323 fill_breakat_flags(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2324 #endif |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2325 after_copy_winopt(curwin); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2326 } |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2327 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2328 /* |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2329 * More side effects of setting options. |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2330 */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2331 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2332 didset_options2(void) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2333 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2334 // Initialize the highlight_attr[] table. |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2335 (void)highlight_changed(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2336 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2337 // Parse default for 'wildmode' |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2338 check_opt_wim(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2339 |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2340 // Parse default for 'listchars'. |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2341 (void)set_chars_option(curwin, &curwin->w_p_lcs); |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2342 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2343 // Parse default for 'fillchars'. |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2344 (void)set_chars_option(curwin, &p_fcs); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2345 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2346 #ifdef FEAT_CLIPBOARD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2347 // Parse default for 'clipboard' |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2348 (void)check_clipboard_option(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2349 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2350 #ifdef FEAT_VARTABS |
15858
3a45b89639fb
patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2351 vim_free(curbuf->b_p_vsts_array); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2352 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
|
2353 vim_free(curbuf->b_p_vts_array); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2354 tabstop_set(curbuf->b_p_vts, &curbuf->b_p_vts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2355 #endif |
7 | 2356 } |
2357 | |
2358 /* | |
2359 * Check for string options that are NULL (normally only termcap options). | |
2360 */ | |
2361 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2362 check_options(void) |
7 | 2363 { |
2364 int opt_idx; | |
2365 | |
2366 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) | |
2367 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL) | |
2368 check_string_option((char_u **)get_varp(&(options[opt_idx]))); | |
2369 } | |
2370 | |
2371 /* | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2372 * 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
|
2373 * 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
|
2374 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2375 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2376 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
|
2377 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2378 int opt_idx; |
7 | 2379 |
2380 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) | |
2381 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
|
2382 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
|
2383 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
|
2384 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2385 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2386 /* |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2387 * 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
|
2388 * 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
|
2389 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2390 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2391 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
|
2392 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2393 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
|
2394 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2395 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
|
2396 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
|
2397 return opt_idx; |
7 | 2398 } |
2399 | |
634 | 2400 #if defined(FEAT_EVAL) || defined(PROTO) |
2401 /* | |
2402 * Return TRUE when option "opt" was set from a modeline or in secure mode. | |
2403 * Return FALSE when it wasn't. | |
2404 * Return -1 for an unknown option. | |
2405 */ | |
2406 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2407 was_set_insecurely(char_u *opt, int opt_flags) |
634 | 2408 { |
2409 int idx = findoption(opt); | |
681 | 2410 long_u *flagp; |
634 | 2411 |
2412 if (idx >= 0) | |
681 | 2413 { |
2414 flagp = insecure_flag(idx, opt_flags); | |
2415 return (*flagp & P_INSECURE) != 0; | |
2416 } | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
2417 internal_error("was_set_insecurely()"); |
634 | 2418 return -1; |
2419 } | |
681 | 2420 |
2421 /* | |
2422 * Get a pointer to the flags used for the P_INSECURE flag of option | |
2423 * "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
|
2424 * 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
|
2425 * the option is used. |
681 | 2426 */ |
2427 static long_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2428 insecure_flag(int opt_idx, int opt_flags) |
681 | 2429 { |
2430 if (opt_flags & OPT_LOCAL) | |
2431 switch ((int)options[opt_idx].indir) | |
2432 { | |
2433 #ifdef FEAT_STL_OPT | |
694 | 2434 case PV_STL: return &curwin->w_p_stl_flags; |
681 | 2435 #endif |
2436 #ifdef FEAT_EVAL | |
885 | 2437 # ifdef FEAT_FOLDING |
694 | 2438 case PV_FDE: return &curwin->w_p_fde_flags; |
2439 case PV_FDT: return &curwin->w_p_fdt_flags; | |
885 | 2440 # endif |
790 | 2441 # ifdef FEAT_BEVAL |
2442 case PV_BEXPR: return &curbuf->b_p_bexpr_flags; | |
2443 # endif | |
681 | 2444 # if defined(FEAT_CINDENT) |
694 | 2445 case PV_INDE: return &curbuf->b_p_inde_flags; |
681 | 2446 # endif |
694 | 2447 case PV_FEX: return &curbuf->b_p_fex_flags; |
681 | 2448 # ifdef FEAT_FIND_ID |
694 | 2449 case PV_INEX: return &curbuf->b_p_inex_flags; |
681 | 2450 # endif |
2451 #endif | |
2452 } | |
2453 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2454 // Nothing special, return global flags field. |
681 | 2455 return &options[opt_idx].flags; |
2456 } | |
634 | 2457 #endif |
2458 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2459 #if defined(FEAT_TITLE) || defined(PROTO) |
1805 | 2460 /* |
2461 * Redraw the window title and/or tab page text later. | |
2462 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2463 void redraw_titles(void) |
1805 | 2464 { |
2465 need_maketitle = TRUE; | |
2466 redraw_tabline = TRUE; | |
2467 } | |
2468 #endif | |
2469 | |
7 | 2470 /* |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2471 * 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
|
2472 * 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
|
2473 */ |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17845
diff
changeset
|
2474 int |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2475 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
|
2476 { |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2477 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
|
2478 |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2479 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
|
2480 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
|
2481 return FALSE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2482 return TRUE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2483 } |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2484 |
681 | 2485 #if defined(FEAT_EVAL) || defined(PROTO) |
2486 /* | |
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
|
2487 * Set the script_ctx for an option, taking care of setting the buffer- or |
694 | 2488 * window-local value. |
681 | 2489 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2490 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
|
2491 set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx) |
694 | 2492 { |
2493 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; | |
2494 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
|
2495 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
|
2496 |
20269
246101db63a4
patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents:
20237
diff
changeset
|
2497 // 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
|
2498 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
|
2499 new_script_ctx.sc_lnum += SOURCING_LNUM; |
694 | 2500 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2501 // 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
|
2502 // in the buffer or window structure. |
694 | 2503 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
|
2504 options[opt_idx].script_ctx = new_script_ctx; |
694 | 2505 if (both || (opt_flags & OPT_LOCAL)) |
2506 { | |
2507 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
|
2508 curbuf->b_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
694 | 2509 else if (indir & PV_WIN) |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2510 curwin->w_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
694 | 2511 } |
681 | 2512 } |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2513 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2514 /* |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2515 * 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
|
2516 * "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
|
2517 * 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
|
2518 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2519 void |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2520 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
|
2521 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2522 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
|
2523 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
|
2524 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2525 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
|
2526 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
|
2527 else |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2528 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2529 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
|
2530 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
|
2531 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
|
2532 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
|
2533 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
|
2534 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
|
2535 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2536 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
|
2537 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
|
2538 } |
681 | 2539 #endif |
2540 | |
19405
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2541 #if defined(FEAT_EVAL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2542 /* |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2543 * Apply the OptionSet autocommand. |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2544 */ |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2545 static void |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2546 apply_optionset_autocmd( |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2547 int opt_idx, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2548 long opt_flags, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2549 long oldval, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2550 long oldval_g, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2551 long newval, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2552 char *errmsg) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2553 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2554 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
|
2555 |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2556 // 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
|
2557 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
|
2558 return; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2559 |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2560 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
|
2561 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
|
2562 oldval_g); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2563 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
|
2564 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
|
2565 (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
|
2566 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
|
2567 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
|
2568 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
|
2569 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
|
2570 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2571 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
|
2572 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
|
2573 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2574 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
|
2575 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2576 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
|
2577 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
|
2578 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2579 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
|
2580 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2581 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
|
2582 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
|
2583 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
|
2584 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2585 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
|
2586 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2587 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
|
2588 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
|
2589 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2590 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
|
2591 NULL, FALSE, NULL); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2592 reset_v_option_vars(); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2593 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2594 #endif |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2595 |
7 | 2596 /* |
2597 * Set the value of a boolean option, and take care of side effects. | |
2598 * Returns NULL for success, or an error message for an error. | |
2599 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2600 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2601 set_bool_option( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2602 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
|
2603 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
|
2604 int value, // new value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2605 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 2606 { |
2607 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
|
2608 #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
|
2609 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
|
2610 #endif |
7 | 2611 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2612 // Disallow changing some options from secure mode |
7 | 2613 if ((secure |
2614 #ifdef HAVE_SANDBOX | |
2615 || sandbox != 0 | |
2616 #endif | |
2617 ) && (options[opt_idx].flags & P_SECURE)) | |
2618 return e_secure; | |
2619 | |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
2620 #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
|
2621 // 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
|
2622 // 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
|
2623 // 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
|
2624 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
|
2625 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
|
2626 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
|
2627 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2628 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2629 *(int *)varp = value; // set the new value |
7 | 2630 #ifdef FEAT_EVAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2631 // 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
|
2632 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 2633 #endif |
2634 | |
634 | 2635 #ifdef FEAT_GUI |
2636 need_mouse_correct = TRUE; | |
2637 #endif | |
2638 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2639 // May set global value for local option. |
7 | 2640 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
2641 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; | |
2642 | |
2643 /* | |
2644 * Handle side effects of changing a bool option. | |
2645 */ | |
2646 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2647 // 'compatible' |
7 | 2648 if ((int *)varp == &p_cp) |
2649 compatible_set(); | |
2650 | |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2651 #ifdef FEAT_LANGMAP |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2652 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
|
2653 // 'langremap' -> !'langnoremap' |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2654 p_lnr = !p_lrm; |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2655 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
|
2656 // 'langnoremap' -> !'langremap' |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2657 p_lrm = !p_lnr; |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2658 #endif |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2659 |
14846
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2660 #ifdef FEAT_SYN_HL |
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2661 else if ((int *)varp == &curwin->w_p_cul && !value && old_value) |
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2662 reset_cursorline(); |
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2663 #endif |
10107703b9b2
patch 8.1.0435: cursorline highlight not removed in some situation
Christian Brabandt <cb@256bit.org>
parents:
14806
diff
changeset
|
2664 |
3246 | 2665 #ifdef FEAT_PERSISTENT_UNDO |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2666 // 'undofile' |
3246 | 2667 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) |
2668 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2669 // 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
|
2670 // 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
|
2671 // any changes in between. |
3894 | 2672 if (curbuf->b_p_udf || p_udf) |
2673 { | |
2674 char_u hash[UNDO_HASH_SIZE]; | |
2675 buf_T *save_curbuf = curbuf; | |
2676 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
2677 FOR_ALL_BUFFERS(curbuf) |
3894 | 2678 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2679 // 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
|
2680 // 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
|
2681 // 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
|
2682 // loaded |
3894 | 2683 if ((curbuf == save_curbuf |
3246 | 2684 || (opt_flags & OPT_GLOBAL) || opt_flags == 0) |
3894 | 2685 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) |
2686 { | |
2687 u_compute_hash(hash); | |
2688 u_read_undo(NULL, hash, curbuf->b_fname); | |
2689 } | |
2690 } | |
2691 curbuf = save_curbuf; | |
2692 } | |
3246 | 2693 } |
2694 #endif | |
2695 | |
7 | 2696 else if ((int *)varp == &curbuf->b_p_ro) |
2697 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2698 // when 'readonly' is reset globally, also reset readonlymode |
7 | 2699 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) |
2700 readonlymode = FALSE; | |
548 | 2701 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2702 // when 'readonly' is set may give W10 again |
548 | 2703 if (curbuf->b_p_ro) |
2704 curbuf->b_did_warn = FALSE; | |
2705 | |
7 | 2706 #ifdef FEAT_TITLE |
1805 | 2707 redraw_titles(); |
7 | 2708 #endif |
2709 } | |
2710 | |
2362
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2711 #ifdef FEAT_GUI |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2712 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
|
2713 { |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2714 if (!p_mh) |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2715 gui_mch_mousehide(FALSE); |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2716 } |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2717 #endif |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2718 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2719 // when 'modifiable' is changed, redraw the window title |
7 | 2720 else if ((int *)varp == &curbuf->b_p_ma) |
1805 | 2721 { |
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
|
2722 # ifdef FEAT_TERMINAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2723 // 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
|
2724 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
|
2725 && 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
|
2726 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2727 curbuf->b_p_ma = FALSE; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2728 return N_("E946: Cannot make a terminal with running job modifiable"); |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2729 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2730 # endif |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2731 # ifdef FEAT_TITLE |
1805 | 2732 redraw_titles(); |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2733 # endif |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2734 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2735 #ifdef FEAT_TITLE |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2736 // when 'endofline' is changed, redraw the window title |
7 | 2737 else if ((int *)varp == &curbuf->b_p_eol) |
1805 | 2738 { |
2739 redraw_titles(); | |
2740 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2741 // when 'fixeol' is changed, redraw the window title |
6933 | 2742 else if ((int *)varp == &curbuf->b_p_fixeol) |
2743 { | |
2744 redraw_titles(); | |
2745 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2746 // when 'bomb' is changed, redraw the window title and tab page text |
1352 | 2747 else if ((int *)varp == &curbuf->b_p_bomb) |
1805 | 2748 { |
2749 redraw_titles(); | |
2750 } | |
7 | 2751 #endif |
2752 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2753 // when 'bin' is set also set some other options |
7 | 2754 else if ((int *)varp == &curbuf->b_p_bin) |
2755 { | |
2756 set_options_bin(old_value, curbuf->b_p_bin, opt_flags); | |
2757 #ifdef FEAT_TITLE | |
1805 | 2758 redraw_titles(); |
7 | 2759 #endif |
2760 } | |
2761 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2762 // when 'buflisted' changes, trigger autocommands |
7 | 2763 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) |
2764 { | |
2765 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, | |
2766 NULL, NULL, TRUE, curbuf); | |
2767 } | |
2768 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2769 // when 'swf' is set, create swapfile, when reset remove swapfile |
7 | 2770 else if ((int *)varp == &curbuf->b_p_swf) |
2771 { | |
2772 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
|
2773 ml_open_file(curbuf); // create the swap file |
7 | 2774 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2775 // 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
|
2776 // buf->b_p_swf |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2777 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
|
2778 } |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2779 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2780 // when 'terse' is set change 'shortmess' |
7 | 2781 else if ((int *)varp == &p_terse) |
2782 { | |
2783 char_u *p; | |
2784 | |
2785 p = vim_strchr(p_shm, SHM_SEARCH); | |
2786 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2787 // insert 's' in p_shm |
7 | 2788 if (p_terse && p == NULL) |
2789 { | |
2790 STRCPY(IObuff, p_shm); | |
2791 STRCAT(IObuff, "s"); | |
694 | 2792 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); |
7 | 2793 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2794 // remove 's' from p_shm |
7 | 2795 else if (!p_terse && p != NULL) |
1622 | 2796 STRMOVE(p, p + 1); |
7 | 2797 } |
2798 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2799 // when 'paste' is set or reset also change other options |
7 | 2800 else if ((int *)varp == &p_paste) |
2801 { | |
2802 paste_option_changed(); | |
2803 } | |
2804 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2805 // when 'insertmode' is set from an autocommand need to do work here |
7 | 2806 else if ((int *)varp == &p_im) |
2807 { | |
2808 if (p_im) | |
2809 { | |
2810 if ((State & INSERT) == 0) | |
2811 need_start_insertmode = TRUE; | |
2812 stop_insert_mode = FALSE; | |
2813 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2814 // 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
|
2815 else if (old_value) |
7 | 2816 { |
2817 need_start_insertmode = FALSE; | |
2818 stop_insert_mode = TRUE; | |
644 | 2819 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
|
2820 clear_cmdline = TRUE; // remove "(insert)" |
7 | 2821 restart_edit = 0; |
2822 } | |
2823 } | |
2824 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2825 // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw |
7 | 2826 else if ((int *)varp == &p_ic && p_hls) |
2827 { | |
744 | 2828 redraw_all_later(SOME_VALID); |
7 | 2829 } |
2830 | |
2831 #ifdef FEAT_SEARCH_EXTRA | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2832 // when 'hlsearch' is set or reset: reset no_hlsearch |
7 | 2833 else if ((int *)varp == &p_hls) |
2834 { | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13774
diff
changeset
|
2835 set_no_hlsearch(FALSE); |
7 | 2836 } |
2837 #endif | |
2838 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2839 // 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
|
2840 // at the end of normal_cmd() |
7 | 2841 else if ((int *)varp == &curwin->w_p_scb) |
2842 { | |
2843 if (curwin->w_p_scb) | |
5157
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2844 { |
7 | 2845 do_check_scrollbind(FALSE); |
5157
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2846 curwin->w_scbind_pos = curwin->w_topline; |
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
2847 } |
7 | 2848 } |
2849 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
2850 #if defined(FEAT_QUICKFIX) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2851 // There can be only one window with 'previewwindow' set. |
7 | 2852 else if ((int *)varp == &curwin->w_p_pvw) |
2853 { | |
2854 if (curwin->w_p_pvw) | |
2855 { | |
2856 win_T *win; | |
2857 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
2858 FOR_ALL_WINDOWS(win) |
7 | 2859 if (win->w_p_pvw && win != curwin) |
2860 { | |
2861 curwin->w_p_pvw = FALSE; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2862 return N_("E590: A preview window already exists"); |
7 | 2863 } |
2864 } | |
2865 } | |
2866 #endif | |
2867 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2868 // when 'textmode' is set or reset also change 'fileformat' |
7 | 2869 else if ((int *)varp == &curbuf->b_p_tx) |
2870 { | |
2871 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); | |
2872 } | |
2873 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2874 // when 'textauto' is set or reset also change 'fileformats' |
7 | 2875 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
|
2876 { |
7 | 2877 set_string_option_direct((char_u *)"ffs", -1, |
2878 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", | |
694 | 2879 OPT_FREE | opt_flags, 0); |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
16082
diff
changeset
|
2880 } |
7 | 2881 |
2882 /* | |
2883 * When 'lisp' option changes include/exclude '-' in | |
2884 * keyword characters. | |
2885 */ | |
2886 #ifdef FEAT_LISP | |
2887 else if (varp == (char_u *)&(curbuf->b_p_lisp)) | |
2888 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2889 (void)buf_init_chartab(curbuf, FALSE); // ignore errors |
7 | 2890 } |
2891 #endif | |
2892 | |
2893 #ifdef FEAT_TITLE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2894 // 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
|
2895 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
|
2896 { |
1d25a3e8e03c
patch 8.1.0061: window title is wrong after resetting and setting 'title'
Christian Brabandt <cb@256bit.org>
parents:
14057
diff
changeset
|
2897 did_set_title(); |
7 | 2898 } |
2899 #endif | |
2900 | |
2901 else if ((int *)varp == &curbuf->b_changed) | |
2902 { | |
2903 if (!value) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2904 save_file_ff(curbuf); // Buffer is unchanged |
7 | 2905 #ifdef FEAT_TITLE |
1805 | 2906 redraw_titles(); |
7 | 2907 #endif |
2908 modified_was_set = value; | |
2909 } | |
2910 | |
2911 #ifdef BACKSLASH_IN_FILENAME | |
2912 else if ((int *)varp == &p_ssl) | |
2913 { | |
2914 if (p_ssl) | |
2915 { | |
2916 psepc = '/'; | |
2917 psepcN = '\\'; | |
2918 pseps[0] = '/'; | |
2919 } | |
2920 else | |
2921 { | |
2922 psepc = '\\'; | |
2923 psepcN = '/'; | |
2924 pseps[0] = '\\'; | |
2925 } | |
2926 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2927 // need to adjust the file name arguments and buffer names. |
7 | 2928 buflist_slash_adjust(); |
2929 alist_slash_adjust(); | |
2930 # ifdef FEAT_EVAL | |
2931 scriptnames_slash_adjust(); | |
2932 # endif | |
2933 } | |
2934 #endif | |
2935 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2936 // If 'wrap' is set, set w_leftcol to zero. |
7 | 2937 else if ((int *)varp == &curwin->w_p_wrap) |
2938 { | |
2939 if (curwin->w_p_wrap) | |
2940 curwin->w_leftcol = 0; | |
2941 } | |
2942 | |
2943 else if ((int *)varp == &p_ea) | |
2944 { | |
2945 if (p_ea && !old_value) | |
2946 win_equal(curwin, FALSE, 0); | |
2947 } | |
2948 | |
2949 else if ((int *)varp == &p_wiv) | |
2950 { | |
2951 /* | |
2952 * When 'weirdinvert' changed, set/reset 't_xs'. | |
2953 * Then set 'weirdinvert' according to value of 't_xs'. | |
2954 */ | |
2955 if (p_wiv && !old_value) | |
2956 T_XS = (char_u *)"y"; | |
2957 else if (!p_wiv && old_value) | |
2958 T_XS = empty_option; | |
2959 p_wiv = (*T_XS != NUL); | |
2960 } | |
2961 | |
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
|
2962 #ifdef FEAT_BEVAL_GUI |
7 | 2963 else if ((int *)varp == &p_beval) |
2964 { | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
2965 if (!balloonEvalForTerm) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
2966 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
2967 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
|
2968 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
|
2969 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
|
2970 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
|
2971 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
2972 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
2973 #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
|
2974 #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
|
2975 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
|
2976 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
2977 mch_bevalterm_changed(); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
2978 } |
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
|
2979 #endif |
820 | 2980 |
2981 #ifdef FEAT_AUTOCHDIR | |
7 | 2982 else if ((int *)varp == &p_acd) |
2983 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2984 // 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
|
2985 DO_AUTOCHDIR; |
7 | 2986 } |
2987 #endif | |
2988 | |
2989 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2990 // 'diff' |
7 | 2991 else if ((int *)varp == &curwin->w_p_diff) |
2992 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2993 // May add or remove the buffer from the list of diff buffers. |
16 | 2994 diff_buf_adjust(curwin); |
2995 # ifdef FEAT_FOLDING | |
7 | 2996 if (foldmethodIsDiff(curwin)) |
2997 foldUpdateAll(curwin); | |
16 | 2998 # endif |
7 | 2999 } |
3000 #endif | |
3001 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3002 #ifdef HAVE_INPUT_METHOD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3003 // 'imdisable' |
7 | 3004 else if ((int *)varp == &p_imdisable) |
3005 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3006 // Only de-activate it here, it will be enabled when changing mode. |
7 | 3007 if (p_imdisable) |
3008 im_set_active(FALSE); | |
3129 | 3009 else if (State & INSERT) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3010 // 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
|
3011 // effect right away. |
3129 | 3012 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); |
7 | 3013 } |
3014 #endif | |
3015 | |
744 | 3016 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3017 // 'spell' |
258 | 3018 else if ((int *)varp == &curwin->w_p_spell) |
3019 { | |
3020 if (curwin->w_p_spell) | |
3021 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3022 char *errmsg = did_set_spelllang(curwin); |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3023 |
258 | 3024 if (errmsg != NULL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3025 emsg(_(errmsg)); |
258 | 3026 } |
3027 } | |
3028 #endif | |
3029 | |
7 | 3030 #ifdef FEAT_ARABIC |
3031 if ((int *)varp == &curwin->w_p_arab) | |
3032 { | |
3033 if (curwin->w_p_arab) | |
3034 { | |
3035 /* | |
3036 * 'arabic' is set, handle various sub-settings. | |
3037 */ | |
3038 if (!p_tbidi) | |
3039 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3040 // set rightleft mode |
7 | 3041 if (!curwin->w_p_rl) |
3042 { | |
3043 curwin->w_p_rl = TRUE; | |
3044 changed_window_setting(); | |
3045 } | |
3046 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3047 // Enable Arabic shaping (major part of what Arabic requires) |
7 | 3048 if (!p_arshape) |
3049 { | |
3050 p_arshape = TRUE; | |
3051 redraw_later_clear(); | |
3052 } | |
3053 } | |
3054 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3055 // Arabic requires a utf-8 encoding, inform the user if its not |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3056 // set. |
7 | 3057 if (STRCMP(p_enc, "utf-8") != 0) |
16 | 3058 { |
1848 | 3059 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); |
3060 | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
3061 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
|
3062 msg_attr(_(w_arabic), HL_ATTR(HLF_W)); |
1848 | 3063 #ifdef FEAT_EVAL |
3064 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); | |
3065 #endif | |
16 | 3066 } |
7 | 3067 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3068 // set 'delcombine' |
7 | 3069 p_deco = TRUE; |
3070 | |
3071 # ifdef FEAT_KEYMAP | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3072 // Force-set the necessary keymap for arabic |
7 | 3073 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", |
3074 OPT_LOCAL); | |
3075 # endif | |
3076 } | |
3077 else | |
3078 { | |
3079 /* | |
3080 * 'arabic' is reset, handle various sub-settings. | |
3081 */ | |
3082 if (!p_tbidi) | |
3083 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3084 // reset rightleft mode |
7 | 3085 if (curwin->w_p_rl) |
3086 { | |
3087 curwin->w_p_rl = FALSE; | |
3088 changed_window_setting(); | |
3089 } | |
3090 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3091 // '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
|
3092 // another window may still need it "on". |
7 | 3093 } |
3094 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3095 // '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
|
3096 // window may still want it "on". |
7 | 3097 |
3098 # ifdef FEAT_KEYMAP | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3099 // Revert to the default keymap |
7 | 3100 curbuf->b_p_iminsert = B_IMODE_NONE; |
3101 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; | |
3102 # endif | |
3103 } | |
3443 | 3104 } |
3105 | |
1958 | 3106 #endif |
3107 | |
17827
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3108 #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
|
3109 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
|
3110 || (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
|
3111 && gui.in_use |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3112 && (*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
|
3113 && curbuf->b_signlist != NULL) |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3114 { |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3115 // 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
|
3116 // '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
|
3117 // 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
|
3118 // 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
|
3119 // '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
|
3120 // (optimization). |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3121 if (!(curwin->w_p_nu && ((int *)varp == &curwin->w_p_rnu))) |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3122 redraw_all_later(CLEAR); |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3123 } |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3124 #endif |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3125 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3126 #ifdef FEAT_TERMGUICOLORS |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3127 // 'termguicolors' |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3128 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
|
3129 { |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3130 # ifdef FEAT_VTP |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3131 // 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
|
3132 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
|
3133 # 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
|
3134 !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
|
3135 # 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
|
3136 !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
|
3137 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3138 p_tgc = 0; |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
3139 return N_("E954: 24-bit colors are not supported on this environment"); |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3140 } |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3141 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
|
3142 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
|
3143 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3144 # ifdef FEAT_GUI |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3145 if (!gui.in_use && !gui.starting) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3146 # endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3147 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
|
3148 # ifdef FEAT_VTP |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3149 // 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
|
3150 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
|
3151 { |
2bebc49116fd
patch 8.1.0123: MS-Windows: colors are wrong after setting 'notgc'
Christian Brabandt <cb@256bit.org>
parents:
14194
diff
changeset
|
3152 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
|
3153 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
|
3154 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
|
3155 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3156 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3157 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3158 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3159 |
7 | 3160 /* |
3161 * End of handling side effects for bool options. | |
3162 */ | |
3163 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3164 // after handling side effects, call autocommand |
6935 | 3165 |
7 | 3166 options[opt_idx].flags |= P_WAS_SET; |
3167 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3168 #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
|
3169 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
|
3170 (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
|
3171 (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
|
3172 (long)(value ? TRUE : FALSE), NULL); |
6935 | 3173 #endif |
3174 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3175 comp_col(); // in case 'ruler' or 'showcmd' changed |
3443 | 3176 if (curwin->w_curswant != MAXCOL |
6669 | 3177 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 3178 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
|
3179 |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3180 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
|
3181 check_redraw(options[opt_idx].flags); |
7 | 3182 |
3183 return NULL; | |
3184 } | |
3185 | |
3186 /* | |
3187 * Set the value of a number option, and take care of side effects. | |
3188 * Returns NULL for success, or an error message for an error. | |
3189 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3190 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3191 set_num_option( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3192 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
|
3193 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
|
3194 long value, // new value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3195 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
|
3196 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
|
3197 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
|
3198 // OPT_MODELINE, etc. |
7 | 3199 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3200 char *errmsg = NULL; |
7 | 3201 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
|
3202 #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
|
3203 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
|
3204 // 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
|
3205 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3206 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
|
3207 long old_Columns = Columns; // remember old Columns |
7 | 3208 long *pp = (long *)varp; |
3209 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3210 // Disallow changing some options from secure mode. |
634 | 3211 if ((secure |
3212 #ifdef HAVE_SANDBOX | |
3213 || sandbox != 0 | |
3214 #endif | |
3215 ) && (options[opt_idx].flags & P_SECURE)) | |
3216 return e_secure; | |
7 | 3217 |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3218 #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
|
3219 // 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
|
3220 // 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
|
3221 // 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
|
3222 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
|
3223 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
|
3224 OPT_GLOBAL); |
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3225 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3226 |
7 | 3227 *pp = value; |
3228 #ifdef FEAT_EVAL | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3229 // 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
|
3230 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 3231 #endif |
634 | 3232 #ifdef FEAT_GUI |
3233 need_mouse_correct = TRUE; | |
3234 #endif | |
7 | 3235 |
3740 | 3236 if (curbuf->b_p_sw < 0) |
7 | 3237 { |
3238 errmsg = e_positive; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3239 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3240 // 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
|
3241 curbuf->b_p_sw = tabstop_count(curbuf->b_p_vts_array) > 0 |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3242 ? tabstop_first(curbuf->b_p_vts_array) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3243 : curbuf->b_p_ts; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3244 #else |
7 | 3245 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
|
3246 #endif |
7 | 3247 } |
3248 | |
3249 /* | |
3250 * Number options that need some action when changed | |
3251 */ | |
3252 if (pp == &p_wh || pp == &p_hh) | |
3253 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3254 // 'winheight' and 'helpheight' |
7 | 3255 if (p_wh < 1) |
3256 { | |
3257 errmsg = e_positive; | |
3258 p_wh = 1; | |
3259 } | |
3260 if (p_wmh > p_wh) | |
3261 { | |
3262 errmsg = e_winheight; | |
3263 p_wh = p_wmh; | |
3264 } | |
3265 if (p_hh < 0) | |
3266 { | |
3267 errmsg = e_positive; | |
3268 p_hh = 0; | |
3269 } | |
3270 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3271 // Change window height NOW |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10340
diff
changeset
|
3272 if (!ONE_WINDOW) |
7 | 3273 { |
3274 if (pp == &p_wh && curwin->w_height < p_wh) | |
3275 win_setheight((int)p_wh); | |
3276 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) | |
3277 win_setheight((int)p_hh); | |
3278 } | |
3279 } | |
3280 else if (pp == &p_wmh) | |
3281 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3282 // 'winminheight' |
7 | 3283 if (p_wmh < 0) |
3284 { | |
3285 errmsg = e_positive; | |
3286 p_wmh = 0; | |
3287 } | |
3288 if (p_wmh > p_wh) | |
3289 { | |
3290 errmsg = e_winheight; | |
3291 p_wmh = p_wh; | |
3292 } | |
3293 win_setminheight(); | |
3294 } | |
13 | 3295 else if (pp == &p_wiw) |
7 | 3296 { |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3297 // 'winwidth' |
7 | 3298 if (p_wiw < 1) |
3299 { | |
3300 errmsg = e_positive; | |
3301 p_wiw = 1; | |
3302 } | |
3303 if (p_wmw > p_wiw) | |
3304 { | |
3305 errmsg = e_winwidth; | |
3306 p_wiw = p_wmw; | |
3307 } | |
3308 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3309 // Change window width NOW |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10340
diff
changeset
|
3310 if (!ONE_WINDOW && curwin->w_width < p_wiw) |
7 | 3311 win_setwidth((int)p_wiw); |
3312 } | |
3313 else if (pp == &p_wmw) | |
3314 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3315 // 'winminwidth' |
7 | 3316 if (p_wmw < 0) |
3317 { | |
3318 errmsg = e_positive; | |
3319 p_wmw = 0; | |
3320 } | |
3321 if (p_wmw > p_wiw) | |
3322 { | |
3323 errmsg = e_winwidth; | |
3324 p_wmw = p_wiw; | |
3325 } | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3326 win_setminwidth(); |
7 | 3327 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
3328 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3329 // (re)set last window status line |
7 | 3330 else if (pp == &p_ls) |
3331 { | |
3332 last_status(FALSE); | |
3333 } | |
670 | 3334 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3335 // (re)set tab page line |
677 | 3336 else if (pp == &p_stal) |
670 | 3337 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3338 shell_new_rows(); // recompute window positions and heights |
670 | 3339 } |
7 | 3340 |
3341 #ifdef FEAT_GUI | |
3342 else if (pp == &p_linespace) | |
3343 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3344 // 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
|
3345 // same number of lines. |
444 | 3346 if (gui.in_use && gui_mch_adjust_charheight() == OK) |
813 | 3347 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); |
7 | 3348 } |
3349 #endif | |
3350 | |
3351 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3352 // 'foldlevel' |
7 | 3353 else if (pp == &curwin->w_p_fdl) |
3354 { | |
3355 if (curwin->w_p_fdl < 0) | |
3356 curwin->w_p_fdl = 0; | |
3357 newFoldLevel(); | |
3358 } | |
3359 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3360 // 'foldminlines' |
7 | 3361 else if (pp == &curwin->w_p_fml) |
3362 { | |
3363 foldUpdateAll(curwin); | |
3364 } | |
3365 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3366 // 'foldnestmax' |
7 | 3367 else if (pp == &curwin->w_p_fdn) |
3368 { | |
3369 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) | |
3370 foldUpdateAll(curwin); | |
3371 } | |
3372 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3373 // 'foldcolumn' |
7 | 3374 else if (pp == &curwin->w_p_fdc) |
3375 { | |
3376 if (curwin->w_p_fdc < 0) | |
3377 { | |
3378 errmsg = e_positive; | |
3379 curwin->w_p_fdc = 0; | |
3380 } | |
3381 else if (curwin->w_p_fdc > 12) | |
3382 { | |
3383 errmsg = e_invarg; | |
3384 curwin->w_p_fdc = 12; | |
3385 } | |
3386 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3387 #endif // FEAT_FOLDING |
5438 | 3388 |
3389 #if defined(FEAT_FOLDING) || defined(FEAT_CINDENT) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3390 // 'shiftwidth' or 'tabstop' |
7 | 3391 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) |
3392 { | |
5438 | 3393 # ifdef FEAT_FOLDING |
7 | 3394 if (foldmethodIsIndent(curwin)) |
3395 foldUpdateAll(curwin); | |
5438 | 3396 # endif |
3397 # ifdef FEAT_CINDENT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3398 // 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
|
3399 // parse 'cinoptions'. |
5438 | 3400 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) |
3401 parse_cino(curbuf); | |
3402 # endif | |
3403 } | |
3404 #endif | |
7 | 3405 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3406 // 'maxcombine' |
714 | 3407 else if (pp == &p_mco) |
3408 { | |
3409 if (p_mco > MAX_MCO) | |
3410 p_mco = MAX_MCO; | |
3411 else if (p_mco < 0) | |
3412 p_mco = 0; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3413 screenclear(); // will re-allocate the screen |
714 | 3414 } |
3415 | |
7 | 3416 else if (pp == &curbuf->b_p_iminsert) |
3417 { | |
3418 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) | |
3419 { | |
3420 errmsg = e_invarg; | |
3421 curbuf->b_p_iminsert = B_IMODE_NONE; | |
3422 } | |
3423 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
|
3424 if (termcap_active) // don't do this in the alternate screen |
7 | 3425 showmode(); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
3426 #if defined(FEAT_KEYMAP) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3427 // Show/unshow value of 'keymap' in status lines. |
7 | 3428 status_redraw_curbuf(); |
3429 #endif | |
3430 } | |
3431 | |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3432 #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
|
3433 // 'imstyle' |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3434 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
|
3435 { |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3436 if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT) |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3437 errmsg = e_invarg; |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3438 } |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3439 #endif |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3440 |
164 | 3441 else if (pp == &p_window) |
3442 { | |
3443 if (p_window < 1) | |
3444 p_window = 1; | |
3445 else if (p_window >= Rows) | |
3446 p_window = Rows - 1; | |
3447 } | |
3448 | |
7 | 3449 else if (pp == &curbuf->b_p_imsearch) |
3450 { | |
3451 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) | |
3452 { | |
3453 errmsg = e_invarg; | |
3454 curbuf->b_p_imsearch = B_IMODE_NONE; | |
3455 } | |
3456 p_imsearch = curbuf->b_p_imsearch; | |
3457 } | |
3458 | |
3459 #ifdef FEAT_TITLE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3460 // if 'titlelen' has changed, redraw the title |
7 | 3461 else if (pp == &p_titlelen) |
3462 { | |
3463 if (p_titlelen < 0) | |
3464 { | |
3465 errmsg = e_positive; | |
3466 p_titlelen = 85; | |
3467 } | |
3468 if (starting != NO_SCREEN && old_value != p_titlelen) | |
3469 need_maketitle = TRUE; | |
3470 } | |
3471 #endif | |
3472 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3473 // if p_ch changed value, change the command line height |
7 | 3474 else if (pp == &p_ch) |
3475 { | |
3476 if (p_ch < 1) | |
3477 { | |
3478 errmsg = e_positive; | |
3479 p_ch = 1; | |
3480 } | |
1404 | 3481 if (p_ch > Rows - min_rows() + 1) |
3482 p_ch = Rows - min_rows() + 1; | |
7 | 3483 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3484 // 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
|
3485 // completed. Otherwise the frame sizes may be wrong. |
7 | 3486 if (p_ch != old_value && full_screen |
3487 #ifdef FEAT_GUI | |
3488 && !gui.starting | |
3489 #endif | |
3490 ) | |
824 | 3491 command_height(); |
7 | 3492 } |
3493 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3494 // when 'updatecount' changes from zero to non-zero, open swap files |
7 | 3495 else if (pp == &p_uc) |
3496 { | |
3497 if (p_uc < 0) | |
3498 { | |
3499 errmsg = e_positive; | |
3500 p_uc = 100; | |
3501 } | |
3502 if (p_uc && !old_value) | |
3503 ml_open_files(); | |
3504 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3505 #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
|
3506 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
|
3507 { |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3508 if (curwin->w_p_cole < 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3509 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3510 errmsg = e_positive; |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3511 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
|
3512 } |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3513 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
|
3514 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3515 errmsg = e_invarg; |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3516 curwin->w_p_cole = 3; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3517 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3518 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3519 #endif |
16 | 3520 #ifdef MZSCHEME_GUI_THREADS |
14 | 3521 else if (pp == &p_mzq) |
3522 mzvim_reset_timer(); | |
3523 #endif | |
7 | 3524 |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3525 #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
|
3526 // 'pyxversion' |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3527 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
|
3528 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3529 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3530 errmsg = e_invarg; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3531 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3532 #endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3533 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3534 // sync undo before 'undolevels' changes |
7 | 3535 else if (pp == &p_ul) |
3536 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3537 // use the old value, otherwise u_sync() may not work properly |
7 | 3538 p_ul = old_value; |
825 | 3539 u_sync(TRUE); |
7 | 3540 p_ul = value; |
3541 } | |
5446 | 3542 else if (pp == &curbuf->b_p_ul) |
3543 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3544 // use the old value, otherwise u_sync() may not work properly |
5446 | 3545 curbuf->b_p_ul = old_value; |
3546 u_sync(TRUE); | |
3547 curbuf->b_p_ul = value; | |
3548 } | |
7 | 3549 |
13 | 3550 #ifdef FEAT_LINEBREAK |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3551 // 'numberwidth' must be positive |
13 | 3552 else if (pp == &curwin->w_p_nuw) |
3553 { | |
3554 if (curwin->w_p_nuw < 1) | |
3555 { | |
3556 errmsg = e_positive; | |
3557 curwin->w_p_nuw = 1; | |
3558 } | |
17229
f1c7b7a4d9e4
patch 8.1.1614: 'numberwidth' can only go up to 10
Bram Moolenaar <Bram@vim.org>
parents:
17176
diff
changeset
|
3559 if (curwin->w_p_nuw > 20) |
13 | 3560 { |
3561 errmsg = e_invarg; | |
17229
f1c7b7a4d9e4
patch 8.1.1614: 'numberwidth' can only go up to 10
Bram Moolenaar <Bram@vim.org>
parents:
17176
diff
changeset
|
3562 curwin->w_p_nuw = 20; |
13 | 3563 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3564 curwin->w_nrwidth_line_count = 0; // trigger a redraw |
13 | 3565 } |
3566 #endif | |
3567 | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3568 else if (pp == &curbuf->b_p_tw) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3569 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3570 if (curbuf->b_p_tw < 0) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3571 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3572 errmsg = e_positive; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3573 curbuf->b_p_tw = 0; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3574 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3575 #ifdef FEAT_SYN_HL |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3576 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3577 win_T *wp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3578 tabpage_T *tp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3579 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3580 FOR_ALL_TAB_WINDOWS(tp, wp) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3581 check_colorcolumn(wp); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3582 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3583 #endif |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3584 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3585 |
7 | 3586 /* |
3587 * Check the bounds for numeric options here | |
3588 */ | |
3589 if (Rows < min_rows() && full_screen) | |
3590 { | |
3591 if (errbuf != NULL) | |
3592 { | |
274 | 3593 vim_snprintf((char *)errbuf, errbuflen, |
3594 _("E593: Need at least %d lines"), min_rows()); | |
7 | 3595 errmsg = errbuf; |
3596 } | |
3597 Rows = min_rows(); | |
3598 } | |
3599 if (Columns < MIN_COLUMNS && full_screen) | |
3600 { | |
3601 if (errbuf != NULL) | |
3602 { | |
274 | 3603 vim_snprintf((char *)errbuf, errbuflen, |
3604 _("E594: Need at least %d columns"), MIN_COLUMNS); | |
7 | 3605 errmsg = errbuf; |
3606 } | |
3607 Columns = MIN_COLUMNS; | |
3608 } | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
5039
diff
changeset
|
3609 limit_screen_size(); |
7 | 3610 |
3611 /* | |
3612 * If the screen (shell) height has been changed, assume it is the | |
3613 * physical screenheight. | |
3614 */ | |
3615 if (old_Rows != Rows || old_Columns != Columns) | |
3616 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3617 // Changing the screen size is not allowed while updating the screen. |
7 | 3618 if (updating_screen) |
3619 *pp = old_value; | |
3620 else if (full_screen | |
3621 #ifdef FEAT_GUI | |
3622 && !gui.starting | |
3623 #endif | |
3624 ) | |
3625 set_shellsize((int)Columns, (int)Rows, TRUE); | |
3626 else | |
3627 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3628 // 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
|
3629 // messages. |
7 | 3630 check_shellsize(); |
3631 if (cmdline_row > Rows - p_ch && Rows > p_ch) | |
3632 cmdline_row = Rows - p_ch; | |
3633 } | |
857 | 3634 if (p_window >= Rows || !option_was_set((char_u *)"window")) |
164 | 3635 p_window = Rows - 1; |
7 | 3636 } |
3637 | |
3638 if (curbuf->b_p_ts <= 0) | |
3639 { | |
3640 errmsg = e_positive; | |
3641 curbuf->b_p_ts = 8; | |
3642 } | |
3643 if (p_tm < 0) | |
3644 { | |
3645 errmsg = e_positive; | |
3646 p_tm = 0; | |
3647 } | |
3648 if ((curwin->w_p_scr <= 0 | |
3649 || (curwin->w_p_scr > curwin->w_height | |
3650 && curwin->w_height > 0)) | |
3651 && full_screen) | |
3652 { | |
3653 if (pp == &(curwin->w_p_scr)) | |
3654 { | |
3655 if (curwin->w_p_scr != 0) | |
3656 errmsg = e_scroll; | |
3657 win_comp_scroll(curwin); | |
3658 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3659 // 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
|
3660 // it. |
7 | 3661 else if (curwin->w_p_scr <= 0) |
3662 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
|
3663 else // curwin->w_p_scr > curwin->w_height |
7 | 3664 curwin->w_p_scr = curwin->w_height; |
3665 } | |
1726 | 3666 if (p_hi < 0) |
3667 { | |
3668 errmsg = e_positive; | |
3669 p_hi = 0; | |
3670 } | |
5991 | 3671 else if (p_hi > 10000) |
3672 { | |
3673 errmsg = e_invarg; | |
3674 p_hi = 10000; | |
3675 } | |
4444 | 3676 if (p_re < 0 || p_re > 2) |
3677 { | |
3678 errmsg = e_invarg; | |
3679 p_re = 0; | |
3680 } | |
7 | 3681 if (p_report < 0) |
3682 { | |
3683 errmsg = e_positive; | |
3684 p_report = 1; | |
3685 } | |
532 | 3686 if ((p_sj < -100 || p_sj >= Rows) && full_screen) |
7 | 3687 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3688 if (Rows != old_Rows) // Rows changed, just adjust p_sj |
7 | 3689 p_sj = Rows / 2; |
3690 else | |
3691 { | |
3692 errmsg = e_scroll; | |
3693 p_sj = 1; | |
3694 } | |
3695 } | |
3696 if (p_so < 0 && full_screen) | |
3697 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
3698 errmsg = e_positive; |
7 | 3699 p_so = 0; |
3700 } | |
3701 if (p_siso < 0 && full_screen) | |
3702 { | |
3703 errmsg = e_positive; | |
3704 p_siso = 0; | |
3705 } | |
3706 #ifdef FEAT_CMDWIN | |
3707 if (p_cwh < 1) | |
3708 { | |
3709 errmsg = e_positive; | |
3710 p_cwh = 1; | |
3711 } | |
3712 #endif | |
3713 if (p_ut < 0) | |
3714 { | |
3715 errmsg = e_positive; | |
3716 p_ut = 2000; | |
3717 } | |
3718 if (p_ss < 0) | |
3719 { | |
3720 errmsg = e_positive; | |
3721 p_ss = 0; | |
3722 } | |
3723 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3724 // May set global value for local option. |
7 | 3725 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
3726 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; | |
3727 | |
3728 options[opt_idx].flags |= P_WAS_SET; | |
3729 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3730 #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
|
3731 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
|
3732 value, errmsg); |
6935 | 3733 #endif |
3734 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3735 comp_col(); // in case 'columns' or 'ls' changed |
3443 | 3736 if (curwin->w_curswant != MAXCOL |
6669 | 3737 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 3738 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
|
3739 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
|
3740 check_redraw(options[opt_idx].flags); |
7 | 3741 |
3742 return errmsg; | |
3743 } | |
3744 | |
3745 /* | |
3746 * Called after an option changed: check if something needs to be redrawn. | |
3747 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
3748 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3749 check_redraw(long_u flags) |
7 | 3750 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3751 // Careful: P_RCLR and P_RALL are a combination of other P_ flags |
3263 | 3752 int doclear = (flags & P_RCLR) == P_RCLR; |
3753 int all = ((flags & P_RALL) == P_RALL || doclear); | |
7 | 3754 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3755 if ((flags & P_RSTAT) || all) // mark all status lines dirty |
7 | 3756 status_redraw_all(); |
3757 | |
3758 if ((flags & P_RBUF) || (flags & P_RWIN) || all) | |
3759 changed_window_setting(); | |
3760 if (flags & P_RBUF) | |
3761 redraw_curbuf_later(NOT_VALID); | |
10456
536a7d49249c
commit https://github.com/vim/vim/commit/a2477fd3490c1166522631eee53c57d34321086a
Christian Brabandt <cb@256bit.org>
parents:
10424
diff
changeset
|
3762 if (flags & P_RWINONLY) |
536a7d49249c
commit https://github.com/vim/vim/commit/a2477fd3490c1166522631eee53c57d34321086a
Christian Brabandt <cb@256bit.org>
parents:
10424
diff
changeset
|
3763 redraw_later(NOT_VALID); |
3263 | 3764 if (doclear) |
7 | 3765 redraw_all_later(CLEAR); |
3766 else if (all) | |
3767 redraw_all_later(NOT_VALID); | |
3768 } | |
3769 | |
3770 /* | |
3771 * Find index for option 'arg'. | |
3772 * Return -1 if not found. | |
3773 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
3774 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3775 findoption(char_u *arg) |
7 | 3776 { |
3777 int opt_idx; | |
3778 char *s, *p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3779 static short quick_tab[27] = {0, 0}; // quick access table |
7 | 3780 int is_term_opt; |
3781 | |
3782 /* | |
3783 * For first call: Initialize the quick-access table. | |
3784 * It contains the index for the first option that starts with a certain | |
3785 * letter. There are 26 letters, plus the first "t_" option. | |
3786 */ | |
3787 if (quick_tab[1] == 0) | |
3788 { | |
3789 p = options[0].fullname; | |
3790 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
3791 { | |
3792 if (s[0] != p[0]) | |
3793 { | |
3794 if (s[0] == 't' && s[1] == '_') | |
3795 quick_tab[26] = opt_idx; | |
3796 else | |
3797 quick_tab[CharOrdLow(s[0])] = opt_idx; | |
3798 } | |
3799 p = s; | |
3800 } | |
3801 } | |
3802 | |
3803 /* | |
3804 * Check for name starting with an illegal character. | |
3805 */ | |
3806 #ifdef EBCDIC | |
3807 if (!islower(arg[0])) | |
3808 #else | |
3809 if (arg[0] < 'a' || arg[0] > 'z') | |
3810 #endif | |
3811 return -1; | |
3812 | |
3813 is_term_opt = (arg[0] == 't' && arg[1] == '_'); | |
3814 if (is_term_opt) | |
3815 opt_idx = quick_tab[26]; | |
3816 else | |
3817 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
3818 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
3819 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3820 if (STRCMP(arg, s) == 0) // match full name |
7 | 3821 break; |
3822 } | |
3823 if (s == NULL && !is_term_opt) | |
3824 { | |
3825 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
3826 for ( ; options[opt_idx].fullname != NULL; opt_idx++) | |
3827 { | |
3828 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
|
3829 if (s != NULL && STRCMP(arg, s) == 0) // match short name |
7 | 3830 break; |
3831 s = NULL; | |
3832 } | |
3833 } | |
3834 if (s == NULL) | |
3835 opt_idx = -1; | |
3836 return opt_idx; | |
3837 } | |
3838 | |
14 | 3839 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME) |
7 | 3840 /* |
3841 * Get the value for an option. | |
3842 * | |
3843 * Returns: | |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3844 * 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
|
3845 * 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
|
3846 * 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
|
3847 * 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
|
3848 * 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
|
3849 * 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
|
3850 * Unknown option: gov_unknown. |
7 | 3851 */ |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3852 getoption_T |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3853 get_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3854 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3855 long *numval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3856 char_u **stringval, // NULL when only checking existence |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3857 int opt_flags) |
7 | 3858 { |
3859 int opt_idx; | |
3860 char_u *varp; | |
3861 | |
3862 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
|
3863 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
|
3864 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3865 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3866 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3867 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
|
3868 && (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
|
3869 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3870 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
|
3871 char_u *p; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3872 |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3873 // 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
|
3874 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3875 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3876 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
|
3877 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
|
3878 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3879 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3880 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3881 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
|
3882 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
|
3883 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3884 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
|
3885 if (p != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3886 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3887 if (stringval != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3888 *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
|
3889 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
|
3890 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
3891 } |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3892 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
|
3893 } |
7 | 3894 |
3895 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | |
3896 | |
3897 if (options[opt_idx].flags & P_STRING) | |
3898 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3899 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
|
3900 return gov_hidden_string; |
7 | 3901 if (stringval != NULL) |
3902 { | |
3903 #ifdef FEAT_CRYPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3904 // never return the value of the crypt key |
1622 | 3905 if ((char_u **)varp == &curbuf->b_p_key |
3906 && **(char_u **)(varp) != NUL) | |
7 | 3907 *stringval = vim_strsave((char_u *)"*****"); |
3908 else | |
3909 #endif | |
3910 *stringval = vim_strsave(*(char_u **)(varp)); | |
3911 } | |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3912 return gov_string; |
7 | 3913 } |
3914 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3915 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
|
3916 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
|
3917 ? gov_hidden_number : gov_hidden_bool; |
7 | 3918 if (options[opt_idx].flags & P_NUM) |
3919 *numval = *(long *)varp; | |
3920 else | |
3921 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3922 // 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
|
3923 // it set when 'ff' or 'fenc' changed. |
7 | 3924 if ((int *)varp == &curbuf->b_changed) |
3925 *numval = curbufIsChanged(); | |
3926 else | |
9395
beab399e3883
commit https://github.com/vim/vim/commit/2acfbed9dbea990f129535de7ff3df360365130b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
3927 *numval = (long) *(int *)varp; |
7 | 3928 } |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3929 return (options[opt_idx].flags & P_NUM) ? gov_number : gov_bool; |
7 | 3930 } |
3931 #endif | |
3932 | |
5610 | 3933 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
4350 | 3934 /* |
3935 * Returns the option attributes and its value. Unlike the above function it | |
3936 * will return either global value or local value of the option depending on | |
3937 * what was requested, but it will never return global value if it was | |
3938 * requested to return local one and vice versa. Neither it will return | |
3939 * buffer-local value if it was requested to return window-local one. | |
3940 * | |
3941 * Pretends that option is absent if it is not present in the requested scope | |
3942 * (i.e. has no global, window-local or buffer-local value depending on | |
3943 * opt_type). Uses | |
3944 * | |
3945 * Returned flags: | |
5867 | 3946 * 0 hidden or unknown option, also option that does not have requested |
3947 * type (see SREQ_* in vim.h) | |
4350 | 3948 * see SOPT_* in vim.h for other flags |
3949 * | |
3950 * Possible opt_type values: see SREQ_* in vim.h | |
3951 */ | |
3952 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3953 get_option_value_strict( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3954 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3955 long *numval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3956 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
|
3957 int opt_type, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3958 void *from) |
4350 | 3959 { |
3960 int opt_idx; | |
4367 | 3961 char_u *varp = NULL; |
4350 | 3962 struct vimoption *p; |
3963 int r = 0; | |
3964 | |
3965 opt_idx = findoption(name); | |
3966 if (opt_idx < 0) | |
3967 return 0; | |
3968 | |
3969 p = &(options[opt_idx]); | |
3970 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3971 // Hidden option |
4350 | 3972 if (p->var == NULL) |
3973 return 0; | |
3974 | |
3975 if (p->flags & P_BOOL) | |
3976 r |= SOPT_BOOL; | |
3977 else if (p->flags & P_NUM) | |
3978 r |= SOPT_NUM; | |
3979 else if (p->flags & P_STRING) | |
3980 r |= SOPT_STRING; | |
3981 | |
3982 if (p->indir == PV_NONE) | |
3983 { | |
3984 if (opt_type == SREQ_GLOBAL) | |
3985 r |= SOPT_GLOBAL; | |
3986 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3987 return 0; // Did not request global-only option |
4350 | 3988 } |
3989 else | |
3990 { | |
3991 if (p->indir & PV_BOTH) | |
3992 r |= SOPT_GLOBAL; | |
3993 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
|
3994 return 0; // Requested global option |
4350 | 3995 |
3996 if (p->indir & PV_WIN) | |
3997 { | |
3998 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
|
3999 return 0; // Did not request window-local option |
4350 | 4000 else |
4001 r |= SOPT_WIN; | |
4002 } | |
4003 else if (p->indir & PV_BUF) | |
4004 { | |
4005 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
|
4006 return 0; // Did not request buffer-local option |
4350 | 4007 else |
4008 r |= SOPT_BUF; | |
4009 } | |
4010 } | |
4011 | |
4012 if (stringval == NULL) | |
4013 return r; | |
4014 | |
4015 if (opt_type == SREQ_GLOBAL) | |
4016 varp = p->var; | |
4017 else | |
4018 { | |
4019 if (opt_type == SREQ_BUF) | |
4020 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4021 // 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
|
4022 // consider it set when 'ff' or 'fenc' changed. |
4350 | 4023 if (p->indir == PV_MOD) |
4024 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4025 *numval = bufIsChanged((buf_T *)from); |
4350 | 4026 varp = NULL; |
4027 } | |
4028 #ifdef FEAT_CRYPT | |
4029 else if (p->indir == PV_KEY) | |
4030 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4031 // never return the value of the crypt key |
4350 | 4032 *stringval = NULL; |
4033 varp = NULL; | |
4034 } | |
4035 #endif | |
4036 else | |
4037 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4038 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
|
4039 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4040 // 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
|
4041 curbuf = (buf_T *)from; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4042 curwin->w_buffer = curbuf; |
4350 | 4043 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
|
4044 curbuf = save_curbuf; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4045 curwin->w_buffer = curbuf; |
4350 | 4046 } |
4047 } | |
4048 else if (opt_type == SREQ_WIN) | |
4049 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4050 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
|
4051 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4052 curwin = (win_T *)from; |
4350 | 4053 curbuf = curwin->w_buffer; |
4054 varp = get_varp(p); | |
4055 curwin = save_curwin; | |
4056 curbuf = curwin->w_buffer; | |
4057 } | |
4058 if (varp == p->var) | |
4059 return (r | SOPT_UNSET); | |
4060 } | |
4061 | |
4062 if (varp != NULL) | |
4063 { | |
4064 if (p->flags & P_STRING) | |
4065 *stringval = vim_strsave(*(char_u **)(varp)); | |
4066 else if (p->flags & P_NUM) | |
4067 *numval = *(long *) varp; | |
4068 else | |
4069 *numval = *(int *)varp; | |
4070 } | |
4071 | |
4072 return r; | |
4073 } | |
5610 | 4074 |
4075 /* | |
6243 | 4076 * Iterate over options. First argument is a pointer to a pointer to a |
4077 * structure inside options[] array, second is option type like in the above | |
4078 * function. | |
5610 | 4079 * |
6243 | 4080 * If first argument points to NULL it is assumed that iteration just started |
5610 | 4081 * and caller needs the very first value. |
6243 | 4082 * If first argument points to the end marker function returns NULL and sets |
5610 | 4083 * first argument to NULL. |
4084 * | |
4085 * Returns full option name for current option on each call. | |
4086 */ | |
4087 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4088 option_iter_next(void **option, int opt_type) |
5610 | 4089 { |
4090 struct vimoption *ret = NULL; | |
4091 do | |
4092 { | |
4093 if (*option == NULL) | |
4094 *option = (void *) options; | |
4095 else if (((struct vimoption *) (*option))->fullname == NULL) | |
4096 { | |
4097 *option = NULL; | |
4098 return NULL; | |
4099 } | |
4100 else | |
4101 *option = (void *) (((struct vimoption *) (*option)) + 1); | |
4102 | |
4103 ret = ((struct vimoption *) (*option)); | |
4104 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4105 // Hidden option |
5610 | 4106 if (ret->var == NULL) |
4107 { | |
4108 ret = NULL; | |
4109 continue; | |
4110 } | |
4111 | |
4112 switch (opt_type) | |
4113 { | |
4114 case SREQ_GLOBAL: | |
4115 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH)) | |
4116 ret = NULL; | |
4117 break; | |
4118 case SREQ_BUF: | |
4119 if (!(ret->indir & PV_BUF)) | |
4120 ret = NULL; | |
4121 break; | |
4122 case SREQ_WIN: | |
4123 if (!(ret->indir & PV_WIN)) | |
4124 ret = NULL; | |
4125 break; | |
4126 default: | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
4127 internal_error("option_iter_next()"); |
5610 | 4128 return NULL; |
4129 } | |
4130 } | |
4131 while (ret == NULL); | |
4132 | |
4133 return (char_u *)ret->fullname; | |
4134 } | |
4350 | 4135 #endif |
4136 | |
7 | 4137 /* |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4138 * 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
|
4139 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4140 long_u |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4141 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
|
4142 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4143 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
|
4144 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4145 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4146 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4147 * 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
|
4148 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4149 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4150 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
|
4151 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4152 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
|
4153 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4154 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4155 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4156 * 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
|
4157 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4158 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4159 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
|
4160 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4161 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
|
4162 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4163 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4164 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4165 * 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
|
4166 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4167 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4168 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
|
4169 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4170 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
|
4171 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4172 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4173 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4174 * 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
|
4175 * local value. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4176 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4177 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4178 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
|
4179 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4180 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
|
4181 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4182 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4183 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4184 * 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
|
4185 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4186 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4187 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
|
4188 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4189 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
|
4190 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4191 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4192 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4193 * 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
|
4194 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4195 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4196 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
|
4197 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4198 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
|
4199 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4200 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4201 #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
|
4202 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4203 * 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
|
4204 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4205 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4206 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
|
4207 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4208 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
|
4209 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4210 #endif |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4211 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4212 /* |
7 | 4213 * Set the value of option "name". |
4214 * 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
|
4215 * |
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4216 * Returns NULL on success or error message on error. |
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4217 */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4218 char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4219 set_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4220 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4221 long number, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4222 char_u *string, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4223 int opt_flags) // OPT_LOCAL or 0 (both) |
7 | 4224 { |
4225 int opt_idx; | |
4226 char_u *varp; | |
835 | 4227 long_u flags; |
7 | 4228 |
4229 opt_idx = findoption(name); | |
838 | 4230 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
|
4231 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4232 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4233 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4234 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
|
4235 && (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
|
4236 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4237 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
|
4238 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4239 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4240 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4241 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
|
4242 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
|
4243 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4244 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4245 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4246 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
|
4247 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
|
4248 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4249 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
|
4250 if (full_screen) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4251 ttest(FALSE); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4252 redraw_all_later(CLEAR); |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4253 return NULL; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4254 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4255 |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4256 semsg(_("E355: Unknown option: %s"), name); |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4257 } |
7 | 4258 else |
4259 { | |
4260 flags = options[opt_idx].flags; | |
4261 #ifdef HAVE_SANDBOX | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4262 // Disallow changing some options in the sandbox |
7 | 4263 if (sandbox > 0 && (flags & P_SECURE)) |
634 | 4264 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4265 emsg(_(e_sandbox)); |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4266 return NULL; |
634 | 4267 } |
4268 #endif | |
4269 if (flags & P_STRING) | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4270 return set_string_option(opt_idx, string, opt_flags); |
7 | 4271 else |
4272 { | |
1667 | 4273 varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4274 if (varp != NULL) // hidden option is not changed |
7 | 4275 { |
1298 | 4276 if (number == 0 && string != NULL) |
4277 { | |
1757 | 4278 int idx; |
1298 | 4279 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4280 // Either we are given a string or we are setting option |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4281 // to zero. |
1757 | 4282 for (idx = 0; string[idx] == '0'; ++idx) |
1298 | 4283 ; |
1757 | 4284 if (string[idx] != NUL || idx == 0) |
1298 | 4285 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4286 // There's another character after zeros or the string |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4287 // is empty. In both cases, we are trying to set a |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4288 // num option using a string. |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4289 semsg(_("E521: Number required: &%s = '%s'"), |
1298 | 4290 name, string); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4291 return NULL; // do nothing as we hit an error |
1298 | 4292 |
4293 } | |
4294 } | |
7 | 4295 if (flags & P_NUM) |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4296 return set_num_option(opt_idx, varp, number, |
274 | 4297 NULL, 0, opt_flags); |
7 | 4298 else |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4299 return set_bool_option(opt_idx, varp, (int)number, |
634 | 4300 opt_flags); |
7 | 4301 } |
4302 } | |
4303 } | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4304 return NULL; |
7 | 4305 } |
4306 | |
4307 /* | |
4308 * Get the terminal code for a terminal option. | |
4309 * Returns NULL when not found. | |
4310 */ | |
4311 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4312 get_term_code(char_u *tname) |
7 | 4313 { |
4314 int opt_idx; | |
4315 char_u *varp; | |
4316 | |
4317 if (tname[0] != 't' || tname[1] != '_' || | |
4318 tname[2] == NUL || tname[3] == NUL) | |
4319 return NULL; | |
4320 if ((opt_idx = findoption(tname)) >= 0) | |
4321 { | |
4322 varp = get_varp(&(options[opt_idx])); | |
4323 if (varp != NULL) | |
4324 varp = *(char_u **)(varp); | |
4325 return varp; | |
4326 } | |
4327 return find_termcode(tname + 2); | |
4328 } | |
4329 | |
4330 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4331 get_highlight_default(void) |
7 | 4332 { |
4333 int i; | |
4334 | |
4335 i = findoption((char_u *)"hl"); | |
4336 if (i >= 0) | |
4337 return options[i].def_val[VI_DEFAULT]; | |
4338 return (char_u *)NULL; | |
4339 } | |
4340 | |
39 | 4341 char_u * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4342 get_encoding_default(void) |
39 | 4343 { |
4344 int i; | |
4345 | |
4346 i = findoption((char_u *)"enc"); | |
4347 if (i >= 0) | |
4348 return options[i].def_val[VI_DEFAULT]; | |
4349 return (char_u *)NULL; | |
4350 } | |
4351 | |
7 | 4352 /* |
4353 * 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
|
4354 * 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
|
4355 * Returns 0 when the key is not recognized. |
7 | 4356 */ |
4357 static int | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4358 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
|
4359 { |
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4360 int key = 0; |
7 | 4361 int modifiers; |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4362 char_u *arg = arg_arg; |
7 | 4363 |
4364 /* | |
4365 * Don't use get_special_key_code() for t_xx, we don't want it to call | |
4366 * add_termcap_entry(). | |
4367 */ | |
4368 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
4369 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
|
4370 else if (has_lt) |
7 | 4371 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4372 --arg; // put arg at the '<' |
7 | 4373 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
|
4374 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
|
4375 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
|
4376 if (modifiers) // can't handle modifiers here |
7 | 4377 key = 0; |
4378 } | |
4379 return key; | |
4380 } | |
4381 | |
4382 /* | |
4383 * if 'all' == 0: show changed options | |
4384 * if 'all' == 1: show all normal options | |
4385 * if 'all' == 2: show all terminal options | |
4386 */ | |
4387 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4388 showoptions( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4389 int all, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4390 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 4391 { |
4392 struct vimoption *p; | |
4393 int col; | |
4394 int isterm; | |
4395 char_u *varp; | |
4396 struct vimoption **items; | |
4397 int item_count; | |
4398 int run; | |
4399 int row, rows; | |
4400 int cols; | |
4401 int i; | |
4402 int len; | |
4403 | |
4404 #define INC 20 | |
4405 #define GAP 3 | |
4406 | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4407 items = ALLOC_MULT(struct vimoption *, OPTION_COUNT); |
7 | 4408 if (items == NULL) |
4409 return; | |
4410 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4411 // Highlight title |
7 | 4412 if (all == 2) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4413 msg_puts_title(_("\n--- Terminal codes ---")); |
7 | 4414 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
|
4415 msg_puts_title(_("\n--- Global option values ---")); |
7 | 4416 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
|
4417 msg_puts_title(_("\n--- Local option values ---")); |
7 | 4418 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4419 msg_puts_title(_("\n--- Options ---")); |
7 | 4420 |
4421 /* | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4422 * Do the loop two times: |
7 | 4423 * 1. display the short items |
4424 * 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
|
4425 * When "opt_flags" has OPT_ONECOLUMN do everything in run 2. |
7 | 4426 */ |
4427 for (run = 1; run <= 2 && !got_int; ++run) | |
4428 { | |
4429 /* | |
4430 * collect the items in items[] | |
4431 */ | |
4432 item_count = 0; | |
4433 for (p = &options[0]; p->fullname != NULL; p++) | |
4434 { | |
14968
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4435 // apply :filter /pat/ |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4436 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
|
4437 continue; |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4438 |
7 | 4439 varp = NULL; |
4440 isterm = istermoption(p); | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4441 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) != 0) |
7 | 4442 { |
4443 if (p->indir != PV_NONE && !isterm) | |
4444 varp = get_varp_scope(p, opt_flags); | |
4445 } | |
4446 else | |
4447 varp = get_varp(p); | |
4448 if (varp != NULL | |
4449 && ((all == 2 && isterm) | |
4450 || (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
|
4451 || (all == 0 && !optval_default(p, varp, p_cp)))) |
7 | 4452 { |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4453 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
|
4454 len = Columns; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4455 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
|
4456 len = 1; // a toggle option fits always |
7 | 4457 else |
4458 { | |
4459 option_value2string(p, opt_flags); | |
4460 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; | |
4461 } | |
4462 if ((len <= INC - GAP && run == 1) || | |
4463 (len > INC - GAP && run == 2)) | |
4464 items[item_count++] = p; | |
4465 } | |
4466 } | |
4467 | |
4468 /* | |
4469 * display the items | |
4470 */ | |
4471 if (run == 1) | |
4472 { | |
4473 cols = (Columns + GAP - 3) / INC; | |
4474 if (cols == 0) | |
4475 cols = 1; | |
4476 rows = (item_count + cols - 1) / cols; | |
4477 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4478 else // run == 2 |
7 | 4479 rows = item_count; |
4480 for (row = 0; row < rows && !got_int; ++row) | |
4481 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4482 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
|
4483 if (got_int) // 'q' typed in more |
7 | 4484 break; |
4485 col = 0; | |
4486 for (i = row; i < item_count; i += rows) | |
4487 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4488 msg_col = col; // make columns |
7 | 4489 showoneopt(items[i], opt_flags); |
4490 col += INC; | |
4491 } | |
4492 out_flush(); | |
4493 ui_breakcheck(); | |
4494 } | |
4495 } | |
4496 vim_free(items); | |
4497 } | |
4498 | |
4499 /* | |
4500 * Return TRUE if option "p" has its default value. | |
4501 */ | |
4502 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
|
4503 optval_default(struct vimoption *p, char_u *varp, int compatible) |
7 | 4504 { |
4505 int dvi; | |
4506 | |
4507 if (varp == NULL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4508 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
|
4509 dvi = ((p->flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; |
7 | 4510 if (p->flags & P_NUM) |
840 | 4511 return (*(long *)varp == (long)(long_i)p->def_val[dvi]); |
7 | 4512 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
|
4513 // 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
|
4514 // needed for MSVC |
840 | 4515 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
|
4516 // P_STRING |
7 | 4517 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); |
4518 } | |
4519 | |
4520 /* | |
4521 * showoneopt: show the value of one option | |
4522 * must not be called with a hidden option! | |
4523 */ | |
4524 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4525 showoneopt( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4526 struct vimoption *p, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4527 int opt_flags) // OPT_LOCAL or OPT_GLOBAL |
7 | 4528 { |
168 | 4529 char_u *varp; |
4530 int save_silent = silent_mode; | |
4531 | |
4532 silent_mode = FALSE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4533 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
7 | 4534 |
4535 varp = get_varp_scope(p, opt_flags); | |
4536 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4537 // for 'modified' we also need to check if 'ff' or 'fenc' changed. |
7 | 4538 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed |
4539 ? !curbufIsChanged() : !*(int *)varp)) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4540 msg_puts("no"); |
7 | 4541 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
|
4542 msg_puts("--"); |
7 | 4543 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4544 msg_puts(" "); |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4545 msg_puts(p->fullname); |
7 | 4546 if (!(p->flags & P_BOOL)) |
4547 { | |
4548 msg_putchar('='); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4549 // put value string in NameBuff |
7 | 4550 option_value2string(p, opt_flags); |
4551 msg_outtrans(NameBuff); | |
4552 } | |
168 | 4553 |
4554 silent_mode = save_silent; | |
4555 info_message = FALSE; | |
7 | 4556 } |
4557 | |
4558 /* | |
4559 * Write modified options as ":set" commands to a file. | |
4560 * | |
4561 * There are three values for "opt_flags": | |
4562 * OPT_GLOBAL: Write global option values and fresh values of | |
4563 * buffer-local options (used for start of a session | |
4564 * file). | |
4565 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for | |
4566 * curwin (used for a vimrc file). | |
4567 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh | |
4568 * and local values for window-local options of | |
4569 * curwin. Local values are also written when at the | |
4570 * default value, because a modeline or autocommand | |
4571 * may have set them when doing ":edit file" and the | |
4572 * user has set them back at the default or fresh | |
4573 * value. | |
4574 * When "local_only" is TRUE, don't write fresh | |
4575 * values, only local values (for ":mkview"). | |
4576 * (fresh value = value used for a new buffer or window for a local option). | |
4577 * | |
4578 * Return FAIL on error, OK otherwise. | |
4579 */ | |
4580 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4581 makeset(FILE *fd, int opt_flags, int local_only) |
7 | 4582 { |
4583 struct vimoption *p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4584 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
|
4585 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
|
4586 char_u *varp_local = NULL; // fresh value |
7 | 4587 char *cmd; |
4588 int round; | |
1384 | 4589 int pri; |
7 | 4590 |
4591 /* | |
4592 * The options that don't have a default (terminal name, columns, lines) | |
4593 * are never written. Terminal options are also not written. | |
1384 | 4594 * Do the loop over "options[]" twice: once for options with the |
4595 * P_PRI_MKRC flag and once without. | |
7 | 4596 */ |
1384 | 4597 for (pri = 1; pri >= 0; --pri) |
4598 { | |
4599 for (p = &options[0]; !istermoption(p); p++) | |
4600 if (!(p->flags & P_NO_MKRC) | |
4601 && !istermoption(p) | |
4602 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) | |
7 | 4603 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4604 // skip global option when only doing locals |
7 | 4605 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) |
4606 continue; | |
4607 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4608 // 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
|
4609 // file, they are always buffer-specific. |
7 | 4610 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) |
4611 continue; | |
4612 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4613 // Global values are only written when not at the default value. |
7 | 4614 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
|
4615 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp, p_cp)) |
7 | 4616 continue; |
4617 | |
4618 round = 2; | |
4619 if (p->indir != PV_NONE) | |
4620 { | |
4621 if (p->var == VAR_WIN) | |
4622 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4623 // skip window-local option when only doing globals |
7 | 4624 if (!(opt_flags & OPT_LOCAL)) |
4625 continue; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4626 // 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
|
4627 // default, need to write it too. |
7 | 4628 if (!(opt_flags & OPT_GLOBAL) && !local_only) |
4629 { | |
4630 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
|
4631 if (!optval_default(p, varp_fresh, p_cp)) |
7 | 4632 { |
4633 round = 1; | |
4634 varp_local = varp; | |
4635 varp = varp_fresh; | |
4636 } | |
4637 } | |
4638 } | |
4639 } | |
4640 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4641 // 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
|
4642 // Round 2: other values |
7 | 4643 for ( ; round <= 2; varp = varp_local, ++round) |
4644 { | |
4645 if (round == 1 || (opt_flags & OPT_GLOBAL)) | |
4646 cmd = "set"; | |
4647 else | |
4648 cmd = "setlocal"; | |
4649 | |
4650 if (p->flags & P_BOOL) | |
4651 { | |
4652 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) | |
4653 return FAIL; | |
4654 } | |
4655 else if (p->flags & P_NUM) | |
4656 { | |
4657 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) | |
4658 return FAIL; | |
4659 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4660 else // P_STRING |
7 | 4661 { |
694 | 4662 int do_endif = FALSE; |
4663 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4664 // 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
|
4665 // already right, avoids reloading the syntax file. |
694 | 4666 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4667 #if defined(FEAT_SYN_HL) |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4668 p->indir == PV_SYN || |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4669 #endif |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4670 p->indir == PV_FT) |
7 | 4671 { |
4672 if (fprintf(fd, "if &%s != '%s'", p->fullname, | |
4673 *(char_u **)(varp)) < 0 | |
4674 || put_eol(fd) < 0) | |
4675 return FAIL; | |
694 | 4676 do_endif = TRUE; |
7 | 4677 } |
4678 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
|
4679 p->flags) == FAIL) |
7 | 4680 return FAIL; |
694 | 4681 if (do_endif) |
7 | 4682 { |
4683 if (put_line(fd, "endif") == FAIL) | |
4684 return FAIL; | |
4685 } | |
4686 } | |
4687 } | |
4688 } | |
1384 | 4689 } |
7 | 4690 return OK; |
4691 } | |
4692 | |
4693 #if defined(FEAT_FOLDING) || defined(PROTO) | |
4694 /* | |
4695 * Generate set commands for the local fold options only. Used when | |
4696 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options". | |
4697 */ | |
4698 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4699 makefoldset(FILE *fd) |
7 | 4700 { |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4701 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, 0) == FAIL |
7 | 4702 # 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
|
4703 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, 0) |
7 | 4704 == FAIL |
4705 # endif | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4706 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, 0) |
7 | 4707 == FAIL |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4708 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, 0) |
7 | 4709 == FAIL |
4710 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL | |
4711 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL | |
4712 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL | |
4713 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL | |
4714 ) | |
4715 return FAIL; | |
4716 | |
4717 return OK; | |
4718 } | |
4719 #endif | |
4720 | |
4721 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4722 put_setstring( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4723 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4724 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4725 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4726 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
|
4727 long_u flags) |
7 | 4728 { |
4729 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
|
4730 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
|
4731 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
|
4732 char_u *p; |
7 | 4733 |
4734 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
4735 return FAIL; | |
4736 if (*valuep != NULL) | |
4737 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4738 // 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
|
4739 // 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
|
4740 // CTRL-V or backslash |
7 | 4741 if (valuep == &p_pt) |
4742 { | |
4743 s = *valuep; | |
4744 while (*s != NUL) | |
1601 | 4745 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL) |
7 | 4746 return FAIL; |
4747 } | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4748 // 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
|
4749 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
|
4750 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4751 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
|
4752 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4753 // 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
|
4754 buf = alloc(size); |
2780 | 4755 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
|
4756 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4757 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
|
4758 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4759 // 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
|
4760 // 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
|
4761 // 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
|
4762 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
|
4763 && 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
|
4764 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4765 part = alloc(size); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4766 if (part == NULL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4767 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4768 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4769 // 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
|
4770 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
|
4771 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4772 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4773 p = buf; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4774 while (*p != NUL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4775 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4776 // 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
|
4777 // 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
|
4778 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
|
4779 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4780 (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
|
4781 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
|
4782 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4783 } |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4784 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4785 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4786 return OK; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4787 } |
7 | 4788 if (put_escstr(fd, buf, 2) == FAIL) |
2780 | 4789 { |
4790 vim_free(buf); | |
7 | 4791 return FAIL; |
2780 | 4792 } |
4793 vim_free(buf); | |
7 | 4794 } |
4795 else if (put_escstr(fd, *valuep, 2) == FAIL) | |
4796 return FAIL; | |
4797 } | |
4798 if (put_eol(fd) < 0) | |
4799 return FAIL; | |
4800 return OK; | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4801 fail: |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4802 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4803 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4804 return FAIL; |
7 | 4805 } |
4806 | |
4807 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4808 put_setnum( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4809 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4810 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4811 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4812 long *valuep) |
7 | 4813 { |
4814 long wc; | |
4815 | |
4816 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
4817 return FAIL; | |
4818 if (wc_use_keyname((char_u *)valuep, &wc)) | |
4819 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4820 // print 'wildchar' and 'wildcharm' as a key name |
7 | 4821 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) |
4822 return FAIL; | |
4823 } | |
4824 else if (fprintf(fd, "%ld", *valuep) < 0) | |
4825 return FAIL; | |
4826 if (put_eol(fd) < 0) | |
4827 return FAIL; | |
4828 return OK; | |
4829 } | |
4830 | |
4831 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4832 put_setbool( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4833 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4834 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4835 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4836 int value) |
7 | 4837 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4838 if (value < 0) // global/local option using global value |
1416 | 4839 return OK; |
7 | 4840 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 |
4841 || put_eol(fd) < 0) | |
4842 return FAIL; | |
4843 return OK; | |
4844 } | |
4845 | |
4846 /* | |
4847 * Clear all the terminal options. | |
4848 * If the option has been allocated, free the memory. | |
4849 * Terminal options are never hidden or indirect. | |
4850 */ | |
4851 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4852 clear_termoptions(void) |
7 | 4853 { |
4854 /* | |
4855 * Reset a few things before clearing the old options. This may cause | |
4856 * outputting a few things that the terminal doesn't understand, but the | |
4857 * screen will be cleared later, so this is OK. | |
4858 */ | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
4859 mch_setmouse(FALSE); // switch mouse off |
7 | 4860 #ifdef FEAT_TITLE |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4861 mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles |
7 | 4862 #endif |
4863 #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
|
4864 // 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
|
4865 // After restoring the title, because that will need the display. |
7 | 4866 if (gui.starting) |
4867 clear_xterm_clip(); | |
4868 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4869 stoptermcap(); // stop termcap mode |
7 | 4870 |
359 | 4871 free_termoptions(); |
4872 } | |
4873 | |
4874 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4875 free_termoptions(void) |
359 | 4876 { |
4877 struct vimoption *p; | |
4878 | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
4879 for (p = options; p->fullname != NULL; p++) |
7 | 4880 if (istermoption(p)) |
4881 { | |
4882 if (p->flags & P_ALLOCED) | |
4883 free_string_option(*(char_u **)(p->var)); | |
4884 if (p->flags & P_DEF_ALLOCED) | |
4885 free_string_option(p->def_val[VI_DEFAULT]); | |
4886 *(char_u **)(p->var) = empty_option; | |
4887 p->def_val[VI_DEFAULT] = empty_option; | |
4888 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
|
4889 #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
|
4890 // 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
|
4891 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
|
4892 #endif |
7 | 4893 } |
4894 clear_termcodes(); | |
4895 } | |
4896 | |
4897 /* | |
1941 | 4898 * Free the string for one term option, if it was allocated. |
4899 * Set the string to empty_option and clear allocated flag. | |
4900 * "var" points to the option value. | |
4901 */ | |
4902 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4903 free_one_termoption(char_u *var) |
1941 | 4904 { |
4905 struct vimoption *p; | |
4906 | |
4907 for (p = &options[0]; p->fullname != NULL; p++) | |
4908 if (p->var == var) | |
4909 { | |
4910 if (p->flags & P_ALLOCED) | |
4911 free_string_option(*(char_u **)(p->var)); | |
4912 *(char_u **)(p->var) = empty_option; | |
4913 p->flags &= ~P_ALLOCED; | |
4914 break; | |
4915 } | |
4916 } | |
4917 | |
4918 /* | |
7 | 4919 * Set the terminal option defaults to the current value. |
4920 * Used after setting the terminal name. | |
4921 */ | |
4922 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4923 set_term_defaults(void) |
7 | 4924 { |
4925 struct vimoption *p; | |
4926 | |
4927 for (p = &options[0]; p->fullname != NULL; p++) | |
4928 { | |
4929 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) | |
4930 { | |
4931 if (p->flags & P_DEF_ALLOCED) | |
4932 { | |
4933 free_string_option(p->def_val[VI_DEFAULT]); | |
4934 p->flags &= ~P_DEF_ALLOCED; | |
4935 } | |
4936 p->def_val[VI_DEFAULT] = *(char_u **)(p->var); | |
4937 if (p->flags & P_ALLOCED) | |
4938 { | |
4939 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
|
4940 p->flags &= ~P_ALLOCED; // don't free the value now |
7 | 4941 } |
4942 } | |
4943 } | |
4944 } | |
4945 | |
4946 /* | |
4947 * return TRUE if 'p' starts with 't_' | |
4948 */ | |
4949 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4950 istermoption(struct vimoption *p) |
7 | 4951 { |
4952 return (p->fullname[0] == 't' && p->fullname[1] == '_'); | |
4953 } | |
4954 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4955 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4956 * 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
|
4957 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4958 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4959 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
|
4960 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4961 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
|
4962 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4963 |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
4964 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
7 | 4965 /* |
4350 | 4966 * Unset local option value, similar to ":set opt<". |
4967 */ | |
4968 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4969 unset_global_local_option(char_u *name, void *from) |
4350 | 4970 { |
4971 struct vimoption *p; | |
4972 int opt_idx; | |
4361 | 4973 buf_T *buf = (buf_T *)from; |
4350 | 4974 |
4975 opt_idx = findoption(name); | |
7007 | 4976 if (opt_idx < 0) |
4977 return; | |
4350 | 4978 p = &(options[opt_idx]); |
4979 | |
4980 switch ((int)p->indir) | |
4981 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4982 // global option with local value: use local value if it's been set |
4350 | 4983 case PV_EP: |
4361 | 4984 clear_string_option(&buf->b_p_ep); |
4350 | 4985 break; |
4986 case PV_KP: | |
4361 | 4987 clear_string_option(&buf->b_p_kp); |
4350 | 4988 break; |
4989 case PV_PATH: | |
4361 | 4990 clear_string_option(&buf->b_p_path); |
4350 | 4991 break; |
4992 case PV_AR: | |
4993 buf->b_p_ar = -1; | |
4994 break; | |
6243 | 4995 case PV_BKC: |
4996 clear_string_option(&buf->b_p_bkc); | |
4997 buf->b_bkc_flags = 0; | |
4998 break; | |
4350 | 4999 case PV_TAGS: |
4361 | 5000 clear_string_option(&buf->b_p_tags); |
4350 | 5001 break; |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5002 case PV_TC: |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5003 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
|
5004 buf->b_tc_flags = 0; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5005 break; |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5006 case PV_SISO: |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5007 curwin->w_p_siso = -1; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5008 break; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5009 case PV_SO: |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5010 curwin->w_p_so = -1; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5011 break; |
4350 | 5012 #ifdef FEAT_FIND_ID |
5013 case PV_DEF: | |
4361 | 5014 clear_string_option(&buf->b_p_def); |
4350 | 5015 break; |
5016 case PV_INC: | |
4361 | 5017 clear_string_option(&buf->b_p_inc); |
4350 | 5018 break; |
5019 #endif | |
5020 case PV_DICT: | |
4361 | 5021 clear_string_option(&buf->b_p_dict); |
4350 | 5022 break; |
5023 case PV_TSR: | |
4361 | 5024 clear_string_option(&buf->b_p_tsr); |
4350 | 5025 break; |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5026 case PV_FP: |
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5027 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
|
5028 break; |
4350 | 5029 #ifdef FEAT_QUICKFIX |
5030 case PV_EFM: | |
4361 | 5031 clear_string_option(&buf->b_p_efm); |
4350 | 5032 break; |
5033 case PV_GP: | |
4361 | 5034 clear_string_option(&buf->b_p_gp); |
4350 | 5035 break; |
5036 case PV_MP: | |
4361 | 5037 clear_string_option(&buf->b_p_mp); |
4350 | 5038 break; |
5039 #endif | |
5040 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) | |
5041 case PV_BEXPR: | |
4361 | 5042 clear_string_option(&buf->b_p_bexpr); |
4350 | 5043 break; |
5044 #endif | |
5045 #if defined(FEAT_CRYPT) | |
5046 case PV_CM: | |
4361 | 5047 clear_string_option(&buf->b_p_cm); |
4350 | 5048 break; |
5049 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5050 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5051 case PV_SBR: |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5052 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
|
5053 break; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5054 #endif |
4350 | 5055 #ifdef FEAT_STL_OPT |
5056 case PV_STL: | |
4361 | 5057 clear_string_option(&((win_T *)from)->w_p_stl); |
4350 | 5058 break; |
5059 #endif | |
5446 | 5060 case PV_UL: |
5061 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; | |
5062 break; | |
5712 | 5063 #ifdef FEAT_LISP |
5064 case PV_LW: | |
5065 clear_string_option(&buf->b_p_lw); | |
5066 break; | |
5067 #endif | |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
5068 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
|
5069 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
|
5070 break; |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5071 case PV_LCS: |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5072 clear_string_option(&((win_T *)from)->w_p_lcs); |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5073 set_chars_option((win_T *)from, &((win_T *)from)->w_p_lcs); |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5074 redraw_later(NOT_VALID); |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5075 break; |
4350 | 5076 } |
5077 } | |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
5078 #endif |
4350 | 5079 |
5080 /* | |
7 | 5081 * Get pointer to option variable, depending on local or global scope. |
5082 */ | |
5083 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5084 get_varp_scope(struct vimoption *p, int opt_flags) |
7 | 5085 { |
5086 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE) | |
5087 { | |
5088 if (p->var == VAR_WIN) | |
5089 return (char_u *)GLOBAL_WO(get_varp(p)); | |
5090 return p->var; | |
5091 } | |
692 | 5092 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) |
7 | 5093 { |
5094 switch ((int)p->indir) | |
5095 { | |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5096 case PV_FP: return (char_u *)&(curbuf->b_p_fp); |
7 | 5097 #ifdef FEAT_QUICKFIX |
694 | 5098 case PV_EFM: return (char_u *)&(curbuf->b_p_efm); |
5099 case PV_GP: return (char_u *)&(curbuf->b_p_gp); | |
5100 case PV_MP: return (char_u *)&(curbuf->b_p_mp); | |
5101 #endif | |
5102 case PV_EP: return (char_u *)&(curbuf->b_p_ep); | |
5103 case PV_KP: return (char_u *)&(curbuf->b_p_kp); | |
5104 case PV_PATH: return (char_u *)&(curbuf->b_p_path); | |
692 | 5105 case PV_AR: return (char_u *)&(curbuf->b_p_ar); |
694 | 5106 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
|
5107 case PV_TC: return (char_u *)&(curbuf->b_p_tc); |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5108 case PV_SISO: return (char_u *)&(curwin->w_p_siso); |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
5109 case PV_SO: return (char_u *)&(curwin->w_p_so); |
7 | 5110 #ifdef FEAT_FIND_ID |
694 | 5111 case PV_DEF: return (char_u *)&(curbuf->b_p_def); |
5112 case PV_INC: return (char_u *)&(curbuf->b_p_inc); | |
7 | 5113 #endif |
694 | 5114 case PV_DICT: return (char_u *)&(curbuf->b_p_dict); |
5115 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr); | |
790 | 5116 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5117 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr); | |
5118 #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
|
5119 #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
|
5120 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
|
5121 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5122 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5123 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
|
5124 #endif |
40 | 5125 #ifdef FEAT_STL_OPT |
694 | 5126 case PV_STL: return (char_u *)&(curwin->w_p_stl); |
40 | 5127 #endif |
5446 | 5128 case PV_UL: return (char_u *)&(curbuf->b_p_ul); |
5712 | 5129 #ifdef FEAT_LISP |
5130 case PV_LW: return (char_u *)&(curbuf->b_p_lw); | |
5131 #endif | |
6243 | 5132 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
|
5133 case PV_MENC: return (char_u *)&(curbuf->b_p_menc); |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5134 case PV_LCS: return (char_u *)&(curwin->w_p_lcs); |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5135 |
7 | 5136 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5137 return NULL; // "cannot happen" |
7 | 5138 } |
5139 return get_varp(p); | |
5140 } | |
5141 | |
5142 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5143 * 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
|
5144 * scope. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5145 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5146 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5147 get_option_varp_scope(int opt_idx, int opt_flags) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5148 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5149 return get_varp_scope(&(options[opt_idx]), opt_flags); |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5150 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5151 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5152 /* |
7 | 5153 * Get pointer to option variable. |
5154 */ | |
5155 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5156 get_varp(struct vimoption *p) |
7 | 5157 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5158 // hidden option, always return NULL |
7 | 5159 if (p->var == NULL) |
5160 return NULL; | |
5161 | |
5162 switch ((int)p->indir) | |
5163 { | |
5164 case PV_NONE: return p->var; | |
5165 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5166 // global option with local value: use local value if it's been set |
694 | 5167 case PV_EP: return *curbuf->b_p_ep != NUL |
7 | 5168 ? (char_u *)&curbuf->b_p_ep : p->var; |
694 | 5169 case PV_KP: return *curbuf->b_p_kp != NUL |
7 | 5170 ? (char_u *)&curbuf->b_p_kp : p->var; |
694 | 5171 case PV_PATH: return *curbuf->b_p_path != NUL |
7 | 5172 ? (char_u *)&(curbuf->b_p_path) : p->var; |
692 | 5173 case PV_AR: return curbuf->b_p_ar >= 0 |
7 | 5174 ? (char_u *)&(curbuf->b_p_ar) : p->var; |
694 | 5175 case PV_TAGS: return *curbuf->b_p_tags != NUL |
7 | 5176 ? (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
|
5177 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
|
5178 ? (char_u *)&(curbuf->b_p_tc) : p->var; |
6243 | 5179 case PV_BKC: return *curbuf->b_p_bkc != NUL |
5180 ? (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
|
5181 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
|
5182 ? (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
|
5183 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
|
5184 ? (char_u *)&(curwin->w_p_so) : p->var; |
7 | 5185 #ifdef FEAT_FIND_ID |
694 | 5186 case PV_DEF: return *curbuf->b_p_def != NUL |
7 | 5187 ? (char_u *)&(curbuf->b_p_def) : p->var; |
694 | 5188 case PV_INC: return *curbuf->b_p_inc != NUL |
7 | 5189 ? (char_u *)&(curbuf->b_p_inc) : p->var; |
5190 #endif | |
694 | 5191 case PV_DICT: return *curbuf->b_p_dict != NUL |
7 | 5192 ? (char_u *)&(curbuf->b_p_dict) : p->var; |
694 | 5193 case PV_TSR: return *curbuf->b_p_tsr != NUL |
7 | 5194 ? (char_u *)&(curbuf->b_p_tsr) : p->var; |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5195 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
|
5196 ? (char_u *)&(curbuf->b_p_fp) : p->var; |
7 | 5197 #ifdef FEAT_QUICKFIX |
694 | 5198 case PV_EFM: return *curbuf->b_p_efm != NUL |
5199 ? (char_u *)&(curbuf->b_p_efm) : p->var; | |
5200 case PV_GP: return *curbuf->b_p_gp != NUL | |
7 | 5201 ? (char_u *)&(curbuf->b_p_gp) : p->var; |
694 | 5202 case PV_MP: return *curbuf->b_p_mp != NUL |
7 | 5203 ? (char_u *)&(curbuf->b_p_mp) : p->var; |
5204 #endif | |
790 | 5205 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5206 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL | |
5207 ? (char_u *)&(curbuf->b_p_bexpr) : p->var; | |
5208 #endif | |
2360
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5209 #if defined(FEAT_CRYPT) |
d8e4b27cef80
Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5210 case PV_CM: return *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
|
5211 ? (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
|
5212 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5213 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5214 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
|
5215 ? (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
|
5216 #endif |
40 | 5217 #ifdef FEAT_STL_OPT |
694 | 5218 case PV_STL: return *curwin->w_p_stl != NUL |
40 | 5219 ? (char_u *)&(curwin->w_p_stl) : p->var; |
5220 #endif | |
5446 | 5221 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL |
5222 ? (char_u *)&(curbuf->b_p_ul) : p->var; | |
5712 | 5223 #ifdef FEAT_LISP |
5224 case PV_LW: return *curbuf->b_p_lw != NUL | |
5225 ? (char_u *)&(curbuf->b_p_lw) : p->var; | |
5226 #endif | |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
5227 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
|
5228 ? (char_u *)&(curbuf->b_p_menc) : p->var; |
7 | 5229 #ifdef FEAT_ARABIC |
5230 case PV_ARAB: return (char_u *)&(curwin->w_p_arab); | |
5231 #endif | |
5232 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
|
5233 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
|
5234 ? (char_u *)&(curwin->w_p_lcs) : p->var; |
744 | 5235 #ifdef FEAT_SPELL |
5236 case PV_SPELL: return (char_u *)&(curwin->w_p_spell); | |
5237 #endif | |
221 | 5238 #ifdef FEAT_SYN_HL |
744 | 5239 case PV_CUC: return (char_u *)&(curwin->w_p_cuc); |
5240 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
|
5241 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
|
5242 case PV_CC: return (char_u *)&(curwin->w_p_cc); |
221 | 5243 #endif |
7 | 5244 #ifdef FEAT_DIFF |
5245 case PV_DIFF: return (char_u *)&(curwin->w_p_diff); | |
5246 #endif | |
5247 #ifdef FEAT_FOLDING | |
5248 case PV_FDC: return (char_u *)&(curwin->w_p_fdc); | |
5249 case PV_FEN: return (char_u *)&(curwin->w_p_fen); | |
5250 case PV_FDI: return (char_u *)&(curwin->w_p_fdi); | |
5251 case PV_FDL: return (char_u *)&(curwin->w_p_fdl); | |
5252 case PV_FDM: return (char_u *)&(curwin->w_p_fdm); | |
5253 case PV_FML: return (char_u *)&(curwin->w_p_fml); | |
5254 case PV_FDN: return (char_u *)&(curwin->w_p_fdn); | |
5255 # ifdef FEAT_EVAL | |
5256 case PV_FDE: return (char_u *)&(curwin->w_p_fde); | |
5257 case PV_FDT: return (char_u *)&(curwin->w_p_fdt); | |
5258 # endif | |
5259 case PV_FMR: return (char_u *)&(curwin->w_p_fmr); | |
5260 #endif | |
5261 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
|
5262 case PV_RNU: return (char_u *)&(curwin->w_p_rnu); |
13 | 5263 #ifdef FEAT_LINEBREAK |
5264 case PV_NUW: return (char_u *)&(curwin->w_p_nuw); | |
5265 #endif | |
7 | 5266 case PV_WFH: return (char_u *)&(curwin->w_p_wfh); |
782 | 5267 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
|
5268 #if defined(FEAT_QUICKFIX) |
7 | 5269 case PV_PVW: return (char_u *)&(curwin->w_p_pvw); |
5270 #endif | |
5271 #ifdef FEAT_RIGHTLEFT | |
5272 case PV_RL: return (char_u *)&(curwin->w_p_rl); | |
5273 case PV_RLC: return (char_u *)&(curwin->w_p_rlc); | |
5274 #endif | |
5275 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr); | |
5276 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); | |
5277 #ifdef FEAT_LINEBREAK | |
5278 case PV_LBR: return (char_u *)&(curwin->w_p_lbr); | |
5995 | 5279 case PV_BRI: return (char_u *)&(curwin->w_p_bri); |
5280 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt); | |
7 | 5281 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5282 case PV_WCR: return (char_u *)&(curwin->w_p_wcr); |
7 | 5283 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
|
5284 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
|
5285 #ifdef FEAT_CONCEAL |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5286 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
|
5287 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
|
5288 #endif |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5289 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5290 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
|
5291 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
|
5292 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
|
5293 #endif |
7 | 5294 |
5295 case PV_AI: return (char_u *)&(curbuf->b_p_ai); | |
5296 case PV_BIN: return (char_u *)&(curbuf->b_p_bin); | |
5297 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); | |
5298 case PV_BH: return (char_u *)&(curbuf->b_p_bh); | |
5299 case PV_BT: return (char_u *)&(curbuf->b_p_bt); | |
5300 case PV_BL: return (char_u *)&(curbuf->b_p_bl); | |
5301 case PV_CI: return (char_u *)&(curbuf->b_p_ci); | |
5302 #ifdef FEAT_CINDENT | |
5303 case PV_CIN: return (char_u *)&(curbuf->b_p_cin); | |
5304 case PV_CINK: return (char_u *)&(curbuf->b_p_cink); | |
5305 case PV_CINO: return (char_u *)&(curbuf->b_p_cino); | |
5306 #endif | |
5307 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) | |
5308 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); | |
5309 #endif | |
5310 case PV_COM: return (char_u *)&(curbuf->b_p_com); | |
5311 #ifdef FEAT_FOLDING | |
5312 case PV_CMS: return (char_u *)&(curbuf->b_p_cms); | |
5313 #endif | |
5314 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
|
5315 #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
|
5316 case PV_CSL: return (char_u *)&(curbuf->b_p_csl); |
7 | 5317 #endif |
12 | 5318 #ifdef FEAT_COMPL_FUNC |
5319 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); | |
502 | 5320 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); |
12 | 5321 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5322 #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
|
5323 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
|
5324 #endif |
7 | 5325 case PV_EOL: return (char_u *)&(curbuf->b_p_eol); |
6933 | 5326 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol); |
7 | 5327 case PV_ET: return (char_u *)&(curbuf->b_p_et); |
5328 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); | |
5329 case PV_FF: return (char_u *)&(curbuf->b_p_ff); | |
5330 case PV_FT: return (char_u *)&(curbuf->b_p_ft); | |
5331 case PV_FO: return (char_u *)&(curbuf->b_p_fo); | |
41 | 5332 case PV_FLP: return (char_u *)&(curbuf->b_p_flp); |
7 | 5333 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); |
5334 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); | |
5335 case PV_INF: return (char_u *)&(curbuf->b_p_inf); | |
5336 case PV_ISK: return (char_u *)&(curbuf->b_p_isk); | |
5337 #ifdef FEAT_FIND_ID | |
5338 # ifdef FEAT_EVAL | |
5339 case PV_INEX: return (char_u *)&(curbuf->b_p_inex); | |
5340 # endif | |
5341 #endif | |
5342 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
5343 case PV_INDE: return (char_u *)&(curbuf->b_p_inde); | |
5344 case PV_INDK: return (char_u *)&(curbuf->b_p_indk); | |
5345 #endif | |
694 | 5346 #ifdef FEAT_EVAL |
667 | 5347 case PV_FEX: return (char_u *)&(curbuf->b_p_fex); |
5348 #endif | |
7 | 5349 #ifdef FEAT_CRYPT |
5350 case PV_KEY: return (char_u *)&(curbuf->b_p_key); | |
5351 #endif | |
5352 #ifdef FEAT_LISP | |
5353 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp); | |
5354 #endif | |
5355 case PV_ML: return (char_u *)&(curbuf->b_p_ml); | |
5356 case PV_MPS: return (char_u *)&(curbuf->b_p_mps); | |
5357 case PV_MA: return (char_u *)&(curbuf->b_p_ma); | |
5358 case PV_MOD: return (char_u *)&(curbuf->b_changed); | |
5359 case PV_NF: return (char_u *)&(curbuf->b_p_nf); | |
5360 case PV_PI: return (char_u *)&(curbuf->b_p_pi); | |
12 | 5361 #ifdef FEAT_TEXTOBJ |
5362 case PV_QE: return (char_u *)&(curbuf->b_p_qe); | |
5363 #endif | |
7 | 5364 case PV_RO: return (char_u *)&(curbuf->b_p_ro); |
5365 #ifdef FEAT_SMARTINDENT | |
5366 case PV_SI: return (char_u *)&(curbuf->b_p_si); | |
5367 #endif | |
5368 case PV_SN: return (char_u *)&(curbuf->b_p_sn); | |
5369 case PV_STS: return (char_u *)&(curbuf->b_p_sts); | |
5370 #ifdef FEAT_SEARCHPATH | |
5371 case PV_SUA: return (char_u *)&(curbuf->b_p_sua); | |
5372 #endif | |
5373 case PV_SWF: return (char_u *)&(curbuf->b_p_swf); | |
5374 #ifdef FEAT_SYN_HL | |
410 | 5375 case PV_SMC: return (char_u *)&(curbuf->b_p_smc); |
744 | 5376 case PV_SYN: return (char_u *)&(curbuf->b_p_syn); |
5377 #endif | |
5378 #ifdef FEAT_SPELL | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5379 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
|
5380 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
|
5381 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
|
5382 case PV_SPO: return (char_u *)&(curwin->w_s->b_p_spo); |
7 | 5383 #endif |
5384 case PV_SW: return (char_u *)&(curbuf->b_p_sw); | |
5385 case PV_TS: return (char_u *)&(curbuf->b_p_ts); | |
5386 case PV_TW: return (char_u *)&(curbuf->b_p_tw); | |
5387 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
|
5388 #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
|
5389 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
|
5390 #endif |
7 | 5391 case PV_WM: return (char_u *)&(curbuf->b_p_wm); |
5392 #ifdef FEAT_KEYMAP | |
5393 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); | |
5394 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5395 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5396 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
|
5397 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5398 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5399 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
|
5400 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
|
5401 #endif |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
5402 default: iemsg(_("E356: get_varp ERROR")); |
7 | 5403 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5404 // always return a valid pointer to avoid a crash! |
7 | 5405 return (char_u *)&(curbuf->b_p_wm); |
5406 } | |
5407 | |
5408 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5409 * 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
|
5410 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5411 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5412 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
|
5413 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5414 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
|
5415 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5416 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5417 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5418 * 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
|
5419 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5420 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5421 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
|
5422 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5423 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
|
5424 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5425 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5426 /* |
7 | 5427 * Get the value of 'equalprg', either the buffer-local one or the global one. |
5428 */ | |
5429 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5430 get_equalprg(void) |
7 | 5431 { |
5432 if (*curbuf->b_p_ep == NUL) | |
5433 return p_ep; | |
5434 return curbuf->b_p_ep; | |
5435 } | |
5436 | |
5437 /* | |
5438 * Copy options from one window to another. | |
5439 * Used when splitting a window. | |
5440 */ | |
5441 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5442 win_copy_options(win_T *wp_from, win_T *wp_to) |
7 | 5443 { |
5444 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); | |
5445 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
|
5446 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
|
5447 } |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5448 |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5449 /* |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5450 * 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
|
5451 */ |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5452 void |
18199
e2be5a6485f5
patch 8.1.2094: the fileio.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18156
diff
changeset
|
5453 after_copy_winopt(win_T *wp UNUSED) |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5454 { |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5455 #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
|
5456 briopt_check(wp); |
6162 | 5457 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
5458 #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
|
5459 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
|
5460 check_colorcolumn(wp); |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
5461 #endif |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5462 set_chars_option(wp, &wp->w_p_lcs); |
7 | 5463 } |
5464 | |
5465 /* | |
5466 * Copy the options from one winopt_T to another. | |
5467 * Doesn't free the old option values in "to", use clear_winopt() for that. | |
5468 * The 'scroll' option is not copied, because it depends on the window height. | |
5469 * The 'previewwindow' option is reset, there can be only one preview window. | |
5470 */ | |
5471 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5472 copy_winopt(winopt_T *from, winopt_T *to) |
7 | 5473 { |
5474 #ifdef FEAT_ARABIC | |
5475 to->wo_arab = from->wo_arab; | |
5476 #endif | |
5477 to->wo_list = from->wo_list; | |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5478 to->wo_lcs = vim_strsave(from->wo_lcs); |
7 | 5479 to->wo_nu = from->wo_nu; |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
5480 to->wo_rnu = from->wo_rnu; |
13 | 5481 #ifdef FEAT_LINEBREAK |
5482 to->wo_nuw = from->wo_nuw; | |
5483 #endif | |
7 | 5484 #ifdef FEAT_RIGHTLEFT |
5485 to->wo_rl = from->wo_rl; | |
5486 to->wo_rlc = vim_strsave(from->wo_rlc); | |
5487 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5488 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5489 to->wo_sbr = vim_strsave(from->wo_sbr); |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5490 #endif |
40 | 5491 #ifdef FEAT_STL_OPT |
5492 to->wo_stl = vim_strsave(from->wo_stl); | |
5493 #endif | |
7 | 5494 to->wo_wrap = from->wo_wrap; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5495 #ifdef FEAT_DIFF |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5496 to->wo_wrap_save = from->wo_wrap_save; |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5497 #endif |
7 | 5498 #ifdef FEAT_LINEBREAK |
5499 to->wo_lbr = from->wo_lbr; | |
5995 | 5500 to->wo_bri = from->wo_bri; |
5501 to->wo_briopt = vim_strsave(from->wo_briopt); | |
7 | 5502 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5503 to->wo_wcr = vim_strsave(from->wo_wcr); |
7 | 5504 to->wo_scb = from->wo_scb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5505 to->wo_scb_save = from->wo_scb_save; |
2651 | 5506 to->wo_crb = from->wo_crb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5507 to->wo_crb_save = from->wo_crb_save; |
744 | 5508 #ifdef FEAT_SPELL |
5509 to->wo_spell = from->wo_spell; | |
5510 #endif | |
221 | 5511 #ifdef FEAT_SYN_HL |
744 | 5512 to->wo_cuc = from->wo_cuc; |
5513 to->wo_cul = from->wo_cul; | |
18047
6650e3dff8d4
patch 8.1.2019: 'cursorline' always highlights the whole line
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
5514 to->wo_culopt = vim_strsave(from->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5515 to->wo_cc = vim_strsave(from->wo_cc); |
221 | 5516 #endif |
7 | 5517 #ifdef FEAT_DIFF |
5518 to->wo_diff = from->wo_diff; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5519 to->wo_diff_saved = from->wo_diff_saved; |
7 | 5520 #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
|
5521 #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
|
5522 to->wo_cocu = vim_strsave(from->wo_cocu); |
2379
b67b0b5a93d3
Window split didn't copy the value of 'conceallevel'.
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
5523 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
|
5524 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5525 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5526 to->wo_twk = vim_strsave(from->wo_twk); |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5527 to->wo_tws = vim_strsave(from->wo_tws); |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5528 #endif |
7 | 5529 #ifdef FEAT_FOLDING |
5530 to->wo_fdc = from->wo_fdc; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5531 to->wo_fdc_save = from->wo_fdc_save; |
7 | 5532 to->wo_fen = from->wo_fen; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5533 to->wo_fen_save = from->wo_fen_save; |
7 | 5534 to->wo_fdi = vim_strsave(from->wo_fdi); |
5535 to->wo_fml = from->wo_fml; | |
5536 to->wo_fdl = from->wo_fdl; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5537 to->wo_fdl_save = from->wo_fdl_save; |
7 | 5538 to->wo_fdm = vim_strsave(from->wo_fdm); |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5539 to->wo_fdm_save = from->wo_diff_saved |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5540 ? vim_strsave(from->wo_fdm_save) : empty_option; |
7 | 5541 to->wo_fdn = from->wo_fdn; |
5542 # ifdef FEAT_EVAL | |
5543 to->wo_fde = vim_strsave(from->wo_fde); | |
5544 to->wo_fdt = vim_strsave(from->wo_fdt); | |
5545 # endif | |
5546 to->wo_fmr = vim_strsave(from->wo_fmr); | |
5547 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5548 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5549 to->wo_scl = vim_strsave(from->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5550 #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
|
5551 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5552 #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
|
5553 // 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
|
5554 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
|
5555 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
|
5556 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5557 check_winopt(to); // don't want NULL pointers |
7 | 5558 } |
5559 | |
5560 /* | |
5561 * Check string options in a window for a NULL value. | |
5562 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
5563 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5564 check_win_options(win_T *win) |
7 | 5565 { |
5566 check_winopt(&win->w_onebuf_opt); | |
5567 check_winopt(&win->w_allbuf_opt); | |
5568 } | |
5569 | |
5570 /* | |
5571 * Check for NULL pointers in a winopt_T and replace them with empty_option. | |
5572 */ | |
5997 | 5573 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5574 check_winopt(winopt_T *wop UNUSED) |
7 | 5575 { |
5576 #ifdef FEAT_FOLDING | |
5577 check_string_option(&wop->wo_fdi); | |
5578 check_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5579 check_string_option(&wop->wo_fdm_save); |
7 | 5580 # ifdef FEAT_EVAL |
5581 check_string_option(&wop->wo_fde); | |
5582 check_string_option(&wop->wo_fdt); | |
5583 # endif | |
5584 check_string_option(&wop->wo_fmr); | |
5585 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5586 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5587 check_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5588 #endif |
7 | 5589 #ifdef FEAT_RIGHTLEFT |
5590 check_string_option(&wop->wo_rlc); | |
5591 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5592 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5593 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
|
5594 #endif |
40 | 5595 #ifdef FEAT_STL_OPT |
5596 check_string_option(&wop->wo_stl); | |
5597 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5598 #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
|
5599 check_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5600 check_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5601 #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
|
5602 #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
|
5603 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
|
5604 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5605 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5606 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
|
5607 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
|
5608 #endif |
5995 | 5609 #ifdef FEAT_LINEBREAK |
5610 check_string_option(&wop->wo_briopt); | |
5611 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5612 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
|
5613 check_string_option(&wop->wo_lcs); |
7 | 5614 } |
5615 | |
5616 /* | |
5617 * Free the allocated memory inside a winopt_T. | |
5618 */ | |
5619 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5620 clear_winopt(winopt_T *wop UNUSED) |
7 | 5621 { |
5622 #ifdef FEAT_FOLDING | |
5623 clear_string_option(&wop->wo_fdi); | |
5624 clear_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5625 clear_string_option(&wop->wo_fdm_save); |
7 | 5626 # ifdef FEAT_EVAL |
5627 clear_string_option(&wop->wo_fde); | |
5628 clear_string_option(&wop->wo_fdt); | |
5629 # endif | |
5630 clear_string_option(&wop->wo_fmr); | |
5631 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5632 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5633 clear_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5634 #endif |
5995 | 5635 #ifdef FEAT_LINEBREAK |
5636 clear_string_option(&wop->wo_briopt); | |
5637 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5638 clear_string_option(&wop->wo_wcr); |
7 | 5639 #ifdef FEAT_RIGHTLEFT |
5640 clear_string_option(&wop->wo_rlc); | |
5641 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5642 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5643 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
|
5644 #endif |
40 | 5645 #ifdef FEAT_STL_OPT |
5646 clear_string_option(&wop->wo_stl); | |
5647 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5648 #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
|
5649 clear_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5650 clear_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5651 #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
|
5652 #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
|
5653 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
|
5654 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5655 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5656 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
|
5657 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
|
5658 #endif |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5659 clear_string_option(&wop->wo_lcs); |
7 | 5660 } |
5661 | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5662 #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
|
5663 // 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
|
5664 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
|
5665 # 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
|
5666 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5667 /* |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5668 * 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
|
5669 */ |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5670 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
|
5671 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
|
5672 { |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5673 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
|
5674 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
|
5675 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5676 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
|
5677 return; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5678 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
|
5679 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
|
5680 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
|
5681 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
|
5682 } |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5683 #else |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5684 # 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
|
5685 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5686 |
7 | 5687 /* |
5688 * Copy global option values to local options for one buffer. | |
5689 * Used when creating a new buffer and sometimes when entering a buffer. | |
5690 * 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
|
5691 * BCO_ENTER We will enter the buffer "buf". |
7 | 5692 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when |
5693 * appropriate. | |
5694 * BCO_NOHELP Don't copy the values to a help buffer. | |
5695 */ | |
5696 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5697 buf_copy_options(buf_T *buf, int flags) |
7 | 5698 { |
5699 int should_copy = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5700 char_u *save_p_isk = NULL; // init for GCC |
7 | 5701 int dont_do_help; |
5702 int did_isk = FALSE; | |
5703 | |
5704 /* | |
5705 * Skip this when the option defaults have not been set yet. Happens when | |
5706 * main() allocates the first buffer. | |
5707 */ | |
5708 if (p_cpo != NULL) | |
5709 { | |
5710 /* | |
5711 * Always copy when entering and 'cpo' contains 'S'. | |
5712 * Don't copy when already initialized. | |
5713 * Don't copy when 'cpo' contains 's' and not entering. | |
5714 * 'S' BCO_ENTER initialized 's' should_copy | |
5715 * yes yes X X TRUE | |
5716 * yes no yes X FALSE | |
5717 * no X yes X FALSE | |
5718 * X no no yes FALSE | |
5719 * X no no no TRUE | |
5720 * no yes no X TRUE | |
5721 */ | |
5722 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) | |
5723 && (buf->b_p_initialized | |
5724 || (!(flags & BCO_ENTER) | |
5725 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
5726 should_copy = FALSE; | |
5727 | |
5728 if (should_copy || (flags & BCO_ALWAYS)) | |
5729 { | |
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
|
5730 #ifdef FEAT_EVAL |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
5731 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
|
5732 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
|
5733 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5734 // 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
|
5735 // 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
|
5736 // (jumping back to a help file with CTRL-T or CTRL-O) |
7 | 5737 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) |
5738 || 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
|
5739 if (dont_do_help) // don't free b_p_isk |
7 | 5740 { |
5741 save_p_isk = buf->b_p_isk; | |
5742 buf->b_p_isk = NULL; | |
5743 } | |
5744 /* | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14381
diff
changeset
|
5745 * 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
|
5746 * reset 'readonly' and copy 'fileformat'. |
7 | 5747 */ |
5748 if (!buf->b_p_initialized) | |
5749 { | |
5750 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
|
5751 buf->b_p_ro = FALSE; // don't copy readonly |
7 | 5752 buf->b_p_tx = p_tx; |
5753 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
|
5754 switch (*p_ffs) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5755 { |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5756 case 'm': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5757 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
|
5758 case 'd': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5759 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
|
5760 case 'u': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5761 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
|
5762 default: |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5763 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
|
5764 } |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5765 if (buf->b_p_ff != NULL) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
5766 buf->b_start_ffc = *buf->b_p_ff; |
7 | 5767 buf->b_p_bh = empty_option; |
5768 buf->b_p_bt = empty_option; | |
5769 } | |
5770 else | |
5771 free_buf_options(buf, FALSE); | |
5772 | |
5773 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
|
5774 COPY_OPT_SCTX(buf, BV_AI); |
7 | 5775 buf->b_p_ai_nopaste = p_ai_nopaste; |
5776 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
|
5777 COPY_OPT_SCTX(buf, BV_SW); |
7 | 5778 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
|
5779 COPY_OPT_SCTX(buf, BV_TW); |
7 | 5780 buf->b_p_tw_nopaste = p_tw_nopaste; |
5781 buf->b_p_tw_nobin = p_tw_nobin; | |
5782 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
|
5783 COPY_OPT_SCTX(buf, BV_WM); |
7 | 5784 buf->b_p_wm_nopaste = p_wm_nopaste; |
5785 buf->b_p_wm_nobin = p_wm_nobin; | |
5786 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
|
5787 COPY_OPT_SCTX(buf, BV_BIN); |
402 | 5788 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
|
5789 COPY_OPT_SCTX(buf, BV_BOMB); |
6954 | 5790 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
|
5791 COPY_OPT_SCTX(buf, BV_FIXEOL); |
7 | 5792 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
|
5793 COPY_OPT_SCTX(buf, BV_ET); |
7 | 5794 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
|
5795 buf->b_p_et_nopaste = p_et_nopaste; |
7 | 5796 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
|
5797 COPY_OPT_SCTX(buf, BV_ML); |
7 | 5798 buf->b_p_ml_nobin = p_ml_nobin; |
5799 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
|
5800 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
|
5801 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
|
5802 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
|
5803 else |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5804 { |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5805 buf->b_p_swf = p_swf; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5806 COPY_OPT_SCTX(buf, BV_INF); |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5807 } |
7 | 5808 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
|
5809 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
|
5810 #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
|
5811 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
|
5812 COPY_OPT_SCTX(buf, BV_CSL); |
7 | 5813 #endif |
12 | 5814 #ifdef FEAT_COMPL_FUNC |
5815 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
|
5816 COPY_OPT_SCTX(buf, BV_CFU); |
502 | 5817 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
|
5818 COPY_OPT_SCTX(buf, BV_OFU); |
12 | 5819 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5820 #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
|
5821 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
|
5822 COPY_OPT_SCTX(buf, BV_TFU); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5823 #endif |
7 | 5824 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
|
5825 COPY_OPT_SCTX(buf, BV_STS); |
7 | 5826 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
|
5827 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5828 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
|
5829 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
|
5830 if (p_vsts && p_vsts != empty_option) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5831 tabstop_set(p_vsts, &buf->b_p_vsts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5832 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5833 buf->b_p_vsts_array = 0; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5834 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
|
5835 ? 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
|
5836 #endif |
7 | 5837 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
|
5838 COPY_OPT_SCTX(buf, BV_SN); |
7 | 5839 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
|
5840 COPY_OPT_SCTX(buf, BV_COM); |
7 | 5841 #ifdef FEAT_FOLDING |
5842 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
|
5843 COPY_OPT_SCTX(buf, BV_CMS); |
7 | 5844 #endif |
5845 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
|
5846 COPY_OPT_SCTX(buf, BV_FO); |
41 | 5847 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
|
5848 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
|
5849 // 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
|
5850 // when it is set to 8 bytes in defaults.vim. |
7 | 5851 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
|
5852 COPY_OPT_SCTX(buf, BV_NF); |
7 | 5853 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
|
5854 COPY_OPT_SCTX(buf, BV_MPS); |
7 | 5855 #ifdef FEAT_SMARTINDENT |
5856 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
|
5857 COPY_OPT_SCTX(buf, BV_SI); |
7 | 5858 #endif |
5859 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
|
5860 COPY_OPT_SCTX(buf, BV_CI); |
7 | 5861 #ifdef FEAT_CINDENT |
5862 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
|
5863 COPY_OPT_SCTX(buf, BV_CIN); |
7 | 5864 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
|
5865 COPY_OPT_SCTX(buf, BV_CINK); |
7 | 5866 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
|
5867 COPY_OPT_SCTX(buf, BV_CINO); |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5868 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5869 // Don't copy 'filetype', it must be detected |
7 | 5870 buf->b_p_ft = empty_option; |
5871 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
|
5872 COPY_OPT_SCTX(buf, BV_PI); |
7 | 5873 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) |
5874 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
|
5875 COPY_OPT_SCTX(buf, BV_CINW); |
7 | 5876 #endif |
5877 #ifdef FEAT_LISP | |
5878 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
|
5879 COPY_OPT_SCTX(buf, BV_LISP); |
7 | 5880 #endif |
5881 #ifdef FEAT_SYN_HL | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5882 // Don't copy 'syntax', it must be set |
7 | 5883 buf->b_p_syn = empty_option; |
410 | 5884 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
|
5885 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
|
5886 buf->b_s.b_syn_isk = empty_option; |
744 | 5887 #endif |
5888 #ifdef FEAT_SPELL | |
2599 | 5889 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
|
5890 COPY_OPT_SCTX(buf, BV_SPC); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5891 (void)compile_cap_prog(&buf->b_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5892 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
|
5893 COPY_OPT_SCTX(buf, BV_SPF); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5894 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
|
5895 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
|
5896 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
|
5897 COPY_OPT_SCTX(buf, BV_SPO); |
7 | 5898 #endif |
5899 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) | |
5900 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
|
5901 COPY_OPT_SCTX(buf, BV_INDE); |
7 | 5902 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
|
5903 COPY_OPT_SCTX(buf, BV_INDK); |
7 | 5904 #endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5905 buf->b_p_fp = empty_option; |
667 | 5906 #if defined(FEAT_EVAL) |
5907 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
|
5908 COPY_OPT_SCTX(buf, BV_FEX); |
667 | 5909 #endif |
7 | 5910 #ifdef FEAT_CRYPT |
5911 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
|
5912 COPY_OPT_SCTX(buf, BV_KEY); |
7 | 5913 #endif |
5914 #ifdef FEAT_SEARCHPATH | |
5915 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
|
5916 COPY_OPT_SCTX(buf, BV_SUA); |
7 | 5917 #endif |
5918 #ifdef FEAT_KEYMAP | |
5919 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
|
5920 COPY_OPT_SCTX(buf, BV_KMAP); |
7 | 5921 buf->b_kmap_state |= KEYMAP_INIT; |
5922 #endif | |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5923 #ifdef FEAT_TERMINAL |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5924 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
|
5925 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
|
5926 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5927 // 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
|
5928 // state from the current buffer is better than resetting it. |
7 | 5929 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
|
5930 COPY_OPT_SCTX(buf, BV_IMI); |
7 | 5931 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
|
5932 COPY_OPT_SCTX(buf, BV_IMS); |
7 | 5933 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5934 // 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
|
5935 // are not copied, start using the global value |
7 | 5936 buf->b_p_ar = -1; |
5446 | 5937 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
6243 | 5938 buf->b_p_bkc = empty_option; |
5939 buf->b_bkc_flags = 0; | |
7 | 5940 #ifdef FEAT_QUICKFIX |
5941 buf->b_p_gp = empty_option; | |
5942 buf->b_p_mp = empty_option; | |
5943 buf->b_p_efm = empty_option; | |
5944 #endif | |
5945 buf->b_p_ep = empty_option; | |
5946 buf->b_p_kp = empty_option; | |
5947 buf->b_p_path = empty_option; | |
5948 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
|
5949 buf->b_p_tc = empty_option; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5950 buf->b_tc_flags = 0; |
7 | 5951 #ifdef FEAT_FIND_ID |
5952 buf->b_p_def = empty_option; | |
5953 buf->b_p_inc = empty_option; | |
5954 # ifdef FEAT_EVAL | |
5955 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
|
5956 COPY_OPT_SCTX(buf, BV_INEX); |
7 | 5957 # endif |
5958 #endif | |
5959 buf->b_p_dict = empty_option; | |
5960 buf->b_p_tsr = empty_option; | |
12 | 5961 #ifdef FEAT_TEXTOBJ |
5962 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
|
5963 COPY_OPT_SCTX(buf, BV_QE); |
12 | 5964 #endif |
790 | 5965 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5966 buf->b_p_bexpr = empty_option; | |
5967 #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
|
5968 #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
|
5969 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
|
5970 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
5971 #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
|
5972 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
|
5973 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
|
5974 #endif |
5712 | 5975 #ifdef FEAT_LISP |
5976 buf->b_p_lw = empty_option; | |
5977 #endif | |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
5978 buf->b_p_menc = empty_option; |
7 | 5979 |
5980 /* | |
5981 * Don't copy the options set by ex_help(), use the saved values, | |
5982 * when going from a help buffer to a non-help buffer. | |
5983 * Don't touch these at all when BCO_NOHELP is used and going from | |
5984 * or to a help buffer. | |
5985 */ | |
5986 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
|
5987 { |
7 | 5988 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
|
5989 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5990 if (p_vts && p_vts != empty_option && !buf->b_p_vts_array) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5991 tabstop_set(p_vts, &buf->b_p_vts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5992 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5993 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
|
5994 #endif |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5995 } |
7 | 5996 else |
5997 { | |
5998 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
|
5999 COPY_OPT_SCTX(buf, BV_ISK); |
7 | 6000 did_isk = TRUE; |
6001 buf->b_p_ts = p_ts; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6002 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6003 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
|
6004 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
|
6005 if (p_vts && p_vts != empty_option && !buf->b_p_vts_array) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6006 tabstop_set(p_vts, &buf->b_p_vts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6007 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6008 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
|
6009 #endif |
7 | 6010 buf->b_help = FALSE; |
6011 if (buf->b_p_bt[0] == 'h') | |
6012 clear_string_option(&buf->b_p_bt); | |
6013 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
|
6014 COPY_OPT_SCTX(buf, BV_MA); |
7 | 6015 } |
6016 } | |
6017 | |
6018 /* | |
6019 * When the options should be copied (ignoring BCO_ALWAYS), set the | |
6020 * flag that indicates that the options have been initialized. | |
6021 */ | |
6022 if (should_copy) | |
6023 buf->b_p_initialized = TRUE; | |
6024 } | |
6025 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6026 check_buf_options(buf); // make sure we don't have NULLs |
7 | 6027 if (did_isk) |
6028 (void)buf_init_chartab(buf, FALSE); | |
6029 } | |
6030 | |
6031 /* | |
6032 * Reset the 'modifiable' option and its default value. | |
6033 */ | |
6034 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6035 reset_modifiable(void) |
7 | 6036 { |
6037 int opt_idx; | |
6038 | |
6039 curbuf->b_p_ma = FALSE; | |
6040 p_ma = FALSE; | |
6041 opt_idx = findoption((char_u *)"ma"); | |
838 | 6042 if (opt_idx >= 0) |
6043 options[opt_idx].def_val[VI_DEFAULT] = FALSE; | |
7 | 6044 } |
6045 | |
6046 /* | |
6047 * Set the global value for 'iminsert' to the local value. | |
6048 */ | |
6049 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6050 set_iminsert_global(void) |
7 | 6051 { |
6052 p_iminsert = curbuf->b_p_iminsert; | |
6053 } | |
6054 | |
6055 /* | |
6056 * Set the global value for 'imsearch' to the local value. | |
6057 */ | |
6058 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6059 set_imsearch_global(void) |
7 | 6060 { |
6061 p_imsearch = curbuf->b_p_imsearch; | |
6062 } | |
6063 | |
6064 static int expand_option_idx = -1; | |
6065 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; | |
6066 static int expand_option_flags = 0; | |
6067 | |
6068 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6069 set_context_in_set_cmd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6070 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6071 char_u *arg, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6072 int opt_flags) // OPT_GLOBAL and/or OPT_LOCAL |
7 | 6073 { |
6074 int nextchar; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6075 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
|
6076 int opt_idx = 0; // init for GCC |
7 | 6077 char_u *p; |
6078 char_u *s; | |
6079 int is_term_option = FALSE; | |
6080 int key; | |
6081 | |
6082 expand_option_flags = opt_flags; | |
6083 | |
6084 xp->xp_context = EXPAND_SETTINGS; | |
6085 if (*arg == NUL) | |
6086 { | |
6087 xp->xp_pattern = arg; | |
6088 return; | |
6089 } | |
6090 p = arg + STRLEN(arg) - 1; | |
6091 if (*p == ' ' && *(p - 1) != '\\') | |
6092 { | |
6093 xp->xp_pattern = p + 1; | |
6094 return; | |
6095 } | |
6096 while (p > arg) | |
6097 { | |
6098 s = p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6099 // count number of backslashes before ' ' or ',' |
7 | 6100 if (*p == ' ' || *p == ',') |
6101 { | |
6102 while (s > arg && *(s - 1) == '\\') | |
6103 --s; | |
6104 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6105 // break at a space with an even number of backslashes |
7 | 6106 if (*p == ' ' && ((p - s) & 1) == 0) |
6107 { | |
6108 ++p; | |
6109 break; | |
6110 } | |
6111 --p; | |
6112 } | |
1911 | 6113 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0) |
7 | 6114 { |
6115 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
6116 p += 2; | |
6117 } | |
6118 if (STRNCMP(p, "inv", 3) == 0) | |
6119 { | |
6120 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
6121 p += 3; | |
6122 } | |
6123 xp->xp_pattern = arg = p; | |
6124 if (*arg == '<') | |
6125 { | |
6126 while (*p != '>') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6127 if (*p++ == NUL) // expand terminal option name |
7 | 6128 return; |
6129 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
|
6130 if (key == 0) // unknown name |
7 | 6131 { |
6132 xp->xp_context = EXPAND_NOTHING; | |
6133 return; | |
6134 } | |
6135 nextchar = *++p; | |
6136 is_term_option = TRUE; | |
6137 expand_option_name[2] = KEY2TERMCAP0(key); | |
6138 expand_option_name[3] = KEY2TERMCAP1(key); | |
6139 } | |
6140 else | |
6141 { | |
6142 if (p[0] == 't' && p[1] == '_') | |
6143 { | |
6144 p += 2; | |
6145 if (*p != NUL) | |
6146 ++p; | |
6147 if (*p == NUL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6148 return; // expand option name |
7 | 6149 nextchar = *++p; |
6150 is_term_option = TRUE; | |
6151 expand_option_name[2] = p[-2]; | |
6152 expand_option_name[3] = p[-1]; | |
6153 } | |
6154 else | |
6155 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6156 // Allow * wildcard |
7 | 6157 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') |
6158 p++; | |
6159 if (*p == NUL) | |
6160 return; | |
6161 nextchar = *p; | |
6162 *p = NUL; | |
6163 opt_idx = findoption(arg); | |
6164 *p = nextchar; | |
6165 if (opt_idx == -1 || options[opt_idx].var == NULL) | |
6166 { | |
6167 xp->xp_context = EXPAND_NOTHING; | |
6168 return; | |
6169 } | |
6170 flags = options[opt_idx].flags; | |
6171 if (flags & P_BOOL) | |
6172 { | |
6173 xp->xp_context = EXPAND_NOTHING; | |
6174 return; | |
6175 } | |
6176 } | |
6177 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6178 // handle "-=" and "+=" |
7 | 6179 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') |
6180 { | |
6181 ++p; | |
6182 nextchar = '='; | |
6183 } | |
6184 if ((nextchar != '=' && nextchar != ':') | |
6185 || xp->xp_context == EXPAND_BOOL_SETTINGS) | |
6186 { | |
6187 xp->xp_context = EXPAND_UNSUCCESSFUL; | |
6188 return; | |
6189 } | |
6190 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) | |
6191 { | |
6192 xp->xp_context = EXPAND_OLD_SETTING; | |
6193 if (is_term_option) | |
6194 expand_option_idx = -1; | |
6195 else | |
6196 expand_option_idx = opt_idx; | |
6197 xp->xp_pattern = p + 1; | |
6198 return; | |
6199 } | |
6200 xp->xp_context = EXPAND_NOTHING; | |
6201 if (is_term_option || (flags & P_NUM)) | |
6202 return; | |
6203 | |
6204 xp->xp_pattern = p + 1; | |
6205 | |
6206 if (flags & P_EXPAND) | |
6207 { | |
6208 p = options[opt_idx].var; | |
6209 if (p == (char_u *)&p_bdir | |
6210 || p == (char_u *)&p_dir | |
6211 || p == (char_u *)&p_path | |
8182
95d59081580f
commit https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
6212 || p == (char_u *)&p_pp |
7 | 6213 || p == (char_u *)&p_rtp |
6214 #ifdef FEAT_SEARCHPATH | |
6215 || p == (char_u *)&p_cdpath | |
6216 #endif | |
6217 #ifdef FEAT_SESSION | |
6218 || p == (char_u *)&p_vdir | |
6219 #endif | |
6220 ) | |
6221 { | |
6222 xp->xp_context = EXPAND_DIRECTORIES; | |
6223 if (p == (char_u *)&p_path | |
6224 #ifdef FEAT_SEARCHPATH | |
6225 || p == (char_u *)&p_cdpath | |
6226 #endif | |
6227 ) | |
6228 xp->xp_backslash = XP_BS_THREE; | |
6229 else | |
6230 xp->xp_backslash = XP_BS_ONE; | |
6231 } | |
23821
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
6232 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
|
6233 { |
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
6234 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
|
6235 } |
7 | 6236 else |
6237 { | |
6238 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
|
6239 // for 'tags' need three backslashes for a space |
7 | 6240 if (p == (char_u *)&p_tags) |
6241 xp->xp_backslash = XP_BS_THREE; | |
6242 else | |
6243 xp->xp_backslash = XP_BS_ONE; | |
6244 } | |
6245 } | |
6246 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6247 // 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
|
6248 // last file name. |
7 | 6249 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) |
6250 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6251 // count number of backslashes before ' ' or ',' |
7 | 6252 if (*p == ' ' || *p == ',') |
6253 { | |
6254 s = p; | |
6255 while (s > xp->xp_pattern && *(s - 1) == '\\') | |
6256 --s; | |
6257 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) | |
6258 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) | |
6259 { | |
6260 xp->xp_pattern = p + 1; | |
6261 break; | |
6262 } | |
6263 } | |
374 | 6264 |
744 | 6265 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6266 // for 'spellsuggest' start at "file:" |
374 | 6267 if (options[opt_idx].var == (char_u *)&p_sps |
6268 && STRNCMP(p, "file:", 5) == 0) | |
6269 { | |
6270 xp->xp_pattern = p + 5; | |
6271 break; | |
6272 } | |
6273 #endif | |
7 | 6274 } |
6275 | |
6276 return; | |
6277 } | |
6278 | |
6279 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6280 ExpandSettings( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6281 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6282 regmatch_T *regmatch, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6283 int *num_file, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6284 char_u ***file) |
7 | 6285 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6286 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
|
6287 int num_term = 0; // Nr of matching terminal code settings |
7 | 6288 int opt_idx; |
6289 int match; | |
6290 int count = 0; | |
6291 char_u *str; | |
6292 int loop; | |
6293 int is_term_opt; | |
6294 char_u name_buf[MAX_KEY_NAME_LEN]; | |
6295 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
|
6296 int ic = regmatch->rm_ic; // remember the ignore-case flag |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6297 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6298 // do this loop twice: |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6299 // 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
|
6300 // loop == 1: copy the matching options into allocated memory |
7 | 6301 for (loop = 0; loop <= 1; ++loop) |
6302 { | |
6303 regmatch->rm_ic = ic; | |
6304 if (xp->xp_context != EXPAND_BOOL_SETTINGS) | |
6305 { | |
1883 | 6306 for (match = 0; match < (int)(sizeof(names) / sizeof(char *)); |
6307 ++match) | |
7 | 6308 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0)) |
6309 { | |
6310 if (loop == 0) | |
6311 num_normal++; | |
6312 else | |
6313 (*file)[count++] = vim_strsave((char_u *)names[match]); | |
6314 } | |
6315 } | |
6316 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; | |
6317 opt_idx++) | |
6318 { | |
6319 if (options[opt_idx].var == NULL) | |
6320 continue; | |
6321 if (xp->xp_context == EXPAND_BOOL_SETTINGS | |
6322 && !(options[opt_idx].flags & P_BOOL)) | |
6323 continue; | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6324 is_term_opt = istermoption_idx(opt_idx); |
7 | 6325 if (is_term_opt && num_normal > 0) |
6326 continue; | |
6327 match = FALSE; | |
6328 if (vim_regexec(regmatch, str, (colnr_T)0) | |
6329 || (options[opt_idx].shortname != NULL | |
6330 && vim_regexec(regmatch, | |
6331 (char_u *)options[opt_idx].shortname, (colnr_T)0))) | |
6332 match = TRUE; | |
6333 else if (is_term_opt) | |
6334 { | |
6335 name_buf[0] = '<'; | |
6336 name_buf[1] = 't'; | |
6337 name_buf[2] = '_'; | |
6338 name_buf[3] = str[2]; | |
6339 name_buf[4] = str[3]; | |
6340 name_buf[5] = '>'; | |
6341 name_buf[6] = NUL; | |
6342 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6343 { | |
6344 match = TRUE; | |
6345 str = name_buf; | |
6346 } | |
6347 } | |
6348 if (match) | |
6349 { | |
6350 if (loop == 0) | |
6351 { | |
6352 if (is_term_opt) | |
6353 num_term++; | |
6354 else | |
6355 num_normal++; | |
6356 } | |
6357 else | |
6358 (*file)[count++] = vim_strsave(str); | |
6359 } | |
6360 } | |
6361 /* | |
6362 * Check terminal key codes, these are not in the option table | |
6363 */ | |
6364 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) | |
6365 { | |
6366 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) | |
6367 { | |
6368 if (!isprint(str[0]) || !isprint(str[1])) | |
6369 continue; | |
6370 | |
6371 name_buf[0] = 't'; | |
6372 name_buf[1] = '_'; | |
6373 name_buf[2] = str[0]; | |
6374 name_buf[3] = str[1]; | |
6375 name_buf[4] = NUL; | |
6376 | |
6377 match = FALSE; | |
6378 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6379 match = TRUE; | |
6380 else | |
6381 { | |
6382 name_buf[0] = '<'; | |
6383 name_buf[1] = 't'; | |
6384 name_buf[2] = '_'; | |
6385 name_buf[3] = str[0]; | |
6386 name_buf[4] = str[1]; | |
6387 name_buf[5] = '>'; | |
6388 name_buf[6] = NUL; | |
6389 | |
6390 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6391 match = TRUE; | |
6392 } | |
6393 if (match) | |
6394 { | |
6395 if (loop == 0) | |
6396 num_term++; | |
6397 else | |
6398 (*file)[count++] = vim_strsave(name_buf); | |
6399 } | |
6400 } | |
6401 | |
6402 /* | |
6403 * Check special key names. | |
6404 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6405 regmatch->rm_ic = TRUE; // ignore case here |
7 | 6406 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) |
6407 { | |
6408 name_buf[0] = '<'; | |
6409 STRCPY(name_buf + 1, str); | |
6410 STRCAT(name_buf, ">"); | |
6411 | |
6412 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) | |
6413 { | |
6414 if (loop == 0) | |
6415 num_term++; | |
6416 else | |
6417 (*file)[count++] = vim_strsave(name_buf); | |
6418 } | |
6419 } | |
6420 } | |
6421 if (loop == 0) | |
6422 { | |
6423 if (num_normal > 0) | |
6424 *num_file = num_normal; | |
6425 else if (num_term > 0) | |
6426 *num_file = num_term; | |
6427 else | |
6428 return OK; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16806
diff
changeset
|
6429 *file = ALLOC_MULT(char_u *, *num_file); |
7 | 6430 if (*file == NULL) |
6431 { | |
6432 *file = (char_u **)""; | |
6433 return FAIL; | |
6434 } | |
6435 } | |
6436 } | |
6437 return OK; | |
6438 } | |
6439 | |
6440 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6441 ExpandOldSetting(int *num_file, char_u ***file) |
7 | 6442 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6443 char_u *var = NULL; // init for GCC |
7 | 6444 char_u *buf; |
6445 | |
6446 *num_file = 0; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16806
diff
changeset
|
6447 *file = ALLOC_ONE(char_u *); |
7 | 6448 if (*file == NULL) |
6449 return FAIL; | |
6450 | |
6451 /* | |
6452 * For a terminal key code expand_option_idx is < 0. | |
6453 */ | |
6454 if (expand_option_idx < 0) | |
6455 { | |
6456 var = find_termcode(expand_option_name + 2); | |
6457 if (var == NULL) | |
6458 expand_option_idx = findoption(expand_option_name); | |
6459 } | |
6460 | |
6461 if (expand_option_idx >= 0) | |
6462 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6463 // put string of option value in NameBuff |
7 | 6464 option_value2string(&options[expand_option_idx], expand_option_flags); |
6465 var = NameBuff; | |
6466 } | |
6467 else if (var == NULL) | |
6468 var = (char_u *)""; | |
6469 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6470 // 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
|
6471 // what happens in do_set(). |
7 | 6472 buf = vim_strsave_escaped(var, escape_chars); |
6473 | |
6474 if (buf == NULL) | |
6475 { | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13242
diff
changeset
|
6476 VIM_CLEAR(*file); |
7 | 6477 return FAIL; |
6478 } | |
6479 | |
6480 #ifdef BACKSLASH_IN_FILENAME | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6481 // 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
|
6482 // 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
|
6483 for (var = buf; *var != NUL; MB_PTR_ADV(var)) |
7 | 6484 if (var[0] == '\\' && var[1] == '\\' |
6485 && expand_option_idx >= 0 | |
6486 && (options[expand_option_idx].flags & P_EXPAND) | |
6487 && vim_isfilec(var[2]) | |
6488 && (var[2] != '\\' || (var == buf && var[4] != '\\'))) | |
1622 | 6489 STRMOVE(var, var + 1); |
7 | 6490 #endif |
6491 | |
6492 *file[0] = buf; | |
6493 *num_file = 1; | |
6494 return OK; | |
6495 } | |
6496 | |
6497 /* | |
6498 * Get the value for the numeric or string option *opp in a nice format into | |
6499 * NameBuff[]. Must not be called with a hidden option! | |
6500 */ | |
6501 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6502 option_value2string( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6503 struct vimoption *opp, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6504 int opt_flags) // OPT_GLOBAL and/or OPT_LOCAL |
7 | 6505 { |
6506 char_u *varp; | |
6507 | |
6508 varp = get_varp_scope(opp, opt_flags); | |
6509 | |
6510 if (opp->flags & P_NUM) | |
6511 { | |
6512 long wc = 0; | |
6513 | |
6514 if (wc_use_keyname(varp, &wc)) | |
6515 STRCPY(NameBuff, get_special_key_name((int)wc, 0)); | |
6516 else if (wc != 0) | |
6517 STRCPY(NameBuff, transchar((int)wc)); | |
6518 else | |
6519 sprintf((char *)NameBuff, "%ld", *(long *)varp); | |
6520 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6521 else // P_STRING |
7 | 6522 { |
6523 varp = *(char_u **)(varp); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6524 if (varp == NULL) // just in case |
7 | 6525 NameBuff[0] = NUL; |
6526 #ifdef FEAT_CRYPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6527 // don't show the actual value of 'key', only that it's set |
840 | 6528 else if (opp->var == (char_u *)&p_key && *varp) |
7 | 6529 STRCPY(NameBuff, "*****"); |
6530 #endif | |
6531 else if (opp->flags & P_EXPAND) | |
6532 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
|
6533 // Translate 'pastetoggle' into special key names |
7 | 6534 else if ((char_u **)opp->var == &p_pt) |
6535 str2specialbuf(p_pt, NameBuff, MAXPATHL); | |
6536 else | |
419 | 6537 vim_strncpy(NameBuff, varp, MAXPATHL - 1); |
7 | 6538 } |
6539 } | |
6540 | |
6541 /* | |
6542 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be | |
6543 * printed as a keyname. | |
6544 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. | |
6545 */ | |
6546 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6547 wc_use_keyname(char_u *varp, long *wcp) |
7 | 6548 { |
6549 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) | |
6550 { | |
6551 *wcp = *(long *)varp; | |
6552 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0) | |
6553 return TRUE; | |
6554 } | |
6555 return FALSE; | |
6556 } | |
6557 | |
6558 /* | |
6559 * Return TRUE if "x" is present in 'shortmess' option, or | |
6560 * 'shortmess' contains 'a' and "x" is present in SHM_A. | |
6561 */ | |
6562 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6563 shortmess(int x) |
7 | 6564 { |
3384 | 6565 return p_shm != NULL && |
6566 ( vim_strchr(p_shm, x) != NULL | |
7 | 6567 || (vim_strchr(p_shm, 'a') != NULL |
6568 && vim_strchr((char_u *)SHM_A, x) != NULL)); | |
6569 } | |
6570 | |
6571 /* | |
6572 * paste_option_changed() - Called after p_paste was set or reset. | |
6573 */ | |
6574 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6575 paste_option_changed(void) |
7 | 6576 { |
6577 static int old_p_paste = FALSE; | |
6578 static int save_sm = 0; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6579 static int save_sta = 0; |
7 | 6580 #ifdef FEAT_CMDL_INFO |
6581 static int save_ru = 0; | |
6582 #endif | |
6583 #ifdef FEAT_RIGHTLEFT | |
6584 static int save_ri = 0; | |
6585 static int save_hkmap = 0; | |
6586 #endif | |
6587 buf_T *buf; | |
6588 | |
6589 if (p_paste) | |
6590 { | |
6591 /* | |
6592 * Paste switched from off to on. | |
6593 * Save the current values, so they can be restored later. | |
6594 */ | |
6595 if (!old_p_paste) | |
6596 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6597 // save options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6598 FOR_ALL_BUFFERS(buf) |
7 | 6599 { |
6600 buf->b_p_tw_nopaste = buf->b_p_tw; | |
6601 buf->b_p_wm_nopaste = buf->b_p_wm; | |
6602 buf->b_p_sts_nopaste = buf->b_p_sts; | |
6603 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
|
6604 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
|
6605 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6606 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
|
6607 vim_free(buf->b_p_vsts_nopaste); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6608 buf->b_p_vsts_nopaste = buf->b_p_vsts && buf->b_p_vsts != empty_option |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6609 ? vim_strsave(buf->b_p_vsts) : NULL; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6610 #endif |
7 | 6611 } |
6612 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6613 // save global options |
7 | 6614 save_sm = p_sm; |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6615 save_sta = p_sta; |
7 | 6616 #ifdef FEAT_CMDL_INFO |
6617 save_ru = p_ru; | |
6618 #endif | |
6619 #ifdef FEAT_RIGHTLEFT | |
6620 save_ri = p_ri; | |
6621 save_hkmap = p_hkmap; | |
6622 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6623 // 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
|
6624 p_ai_nopaste = p_ai; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6625 p_et_nopaste = p_et; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6626 p_sts_nopaste = p_sts; |
7 | 6627 p_tw_nopaste = p_tw; |
6628 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
|
6629 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6630 if (p_vsts_nopaste) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6631 vim_free(p_vsts_nopaste); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6632 p_vsts_nopaste = p_vsts && p_vsts != empty_option ? vim_strsave(p_vsts) : NULL; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6633 #endif |
7 | 6634 } |
6635 | |
6636 /* | |
6637 * Always set the option values, also when 'paste' is set when it is | |
6638 * already on. | |
6639 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6640 // set options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6641 FOR_ALL_BUFFERS(buf) |
7 | 6642 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6643 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
|
6644 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
|
6645 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
|
6646 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
|
6647 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
|
6648 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6649 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
|
6650 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
|
6651 buf->b_p_vsts = empty_option; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6652 if (buf->b_p_vsts_array) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6653 vim_free(buf->b_p_vsts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6654 buf->b_p_vsts_array = 0; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6655 #endif |
7 | 6656 } |
6657 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6658 // set global options |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6659 p_sm = 0; // no showmatch |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6660 p_sta = 0; // no smarttab |
7 | 6661 #ifdef FEAT_CMDL_INFO |
6662 if (p_ru) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6663 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
|
6664 p_ru = 0; // no ruler |
7 | 6665 #endif |
6666 #ifdef FEAT_RIGHTLEFT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6667 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
|
6668 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
|
6669 #endif |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6670 // set global values for local buffer options |
7 | 6671 p_tw = 0; |
6672 p_wm = 0; | |
6673 p_sts = 0; | |
6674 p_ai = 0; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6675 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6676 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6677 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
|
6678 p_vsts = empty_option; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6679 #endif |
7 | 6680 } |
6681 | |
6682 /* | |
6683 * Paste switched from on to off: Restore saved values. | |
6684 */ | |
6685 else if (old_p_paste) | |
6686 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6687 // restore options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
6688 FOR_ALL_BUFFERS(buf) |
7 | 6689 { |
6690 buf->b_p_tw = buf->b_p_tw_nopaste; | |
6691 buf->b_p_wm = buf->b_p_wm_nopaste; | |
6692 buf->b_p_sts = buf->b_p_sts_nopaste; | |
6693 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
|
6694 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
|
6695 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6696 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
|
6697 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
|
6698 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
|
6699 ? vim_strsave(buf->b_p_vsts_nopaste) : empty_option; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6700 if (buf->b_p_vsts_array) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6701 vim_free(buf->b_p_vsts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6702 if (buf->b_p_vsts && buf->b_p_vsts != empty_option) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6703 tabstop_set(buf->b_p_vsts, &buf->b_p_vsts_array); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6704 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6705 buf->b_p_vsts_array = 0; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6706 #endif |
7 | 6707 } |
6708 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6709 // restore global options |
7 | 6710 p_sm = save_sm; |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6711 p_sta = save_sta; |
7 | 6712 #ifdef FEAT_CMDL_INFO |
6713 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
|
6714 status_redraw_all(); // redraw to draw the ruler |
7 | 6715 p_ru = save_ru; |
6716 #endif | |
6717 #ifdef FEAT_RIGHTLEFT | |
6718 p_ri = save_ri; | |
6719 p_hkmap = save_hkmap; | |
6720 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6721 // 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
|
6722 p_ai = p_ai_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6723 p_et = p_et_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
6724 p_sts = p_sts_nopaste; |
7 | 6725 p_tw = p_tw_nopaste; |
6726 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
|
6727 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6728 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6729 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
|
6730 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
|
6731 #endif |
7 | 6732 } |
6733 | |
6734 old_p_paste = p_paste; | |
6735 } | |
6736 | |
6737 /* | |
6738 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found. | |
6739 * | |
6740 * Reset 'compatible' and set the values for options that didn't get set yet | |
6741 * to the Vim defaults. | |
6742 * Don't do this if the 'compatible' option has been set or reset before. | |
819 | 6743 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet. |
7 | 6744 */ |
6745 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6746 vimrc_found(char_u *fname, char_u *envname) |
819 | 6747 { |
6748 int opt_idx; | |
826 | 6749 int dofree = FALSE; |
819 | 6750 char_u *p; |
7 | 6751 |
6752 if (!option_was_set((char_u *)"cp")) | |
6753 { | |
6754 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
|
6755 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 6756 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF))) |
6757 set_option_default(opt_idx, OPT_FREE, FALSE); | |
6758 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
6759 didset_options2(); |
7 | 6760 } |
819 | 6761 |
6762 if (fname != NULL) | |
6763 { | |
6764 p = vim_getenv(envname, &dofree); | |
6765 if (p == NULL) | |
6766 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6767 // Set $MYVIMRC to the first vimrc file found. |
819 | 6768 p = FullName_save(fname, FALSE); |
6769 if (p != NULL) | |
6770 { | |
6771 vim_setenv(envname, p); | |
6772 vim_free(p); | |
6773 } | |
6774 } | |
6775 else if (dofree) | |
6776 vim_free(p); | |
6777 } | |
7 | 6778 } |
6779 | |
6780 /* | |
6781 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg. | |
6782 */ | |
6783 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6784 change_compatible(int on) |
7 | 6785 { |
838 | 6786 int opt_idx; |
6787 | |
7 | 6788 if (p_cp != on) |
6789 { | |
6790 p_cp = on; | |
6791 compatible_set(); | |
6792 } | |
838 | 6793 opt_idx = findoption((char_u *)"cp"); |
6794 if (opt_idx >= 0) | |
6795 options[opt_idx].flags |= P_WAS_SET; | |
7 | 6796 } |
6797 | |
6798 /* | |
6799 * 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
|
6800 * Only works correctly for global options. |
7 | 6801 */ |
6802 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6803 option_was_set(char_u *name) |
7 | 6804 { |
6805 int idx; | |
6806 | |
6807 idx = findoption(name); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6808 if (idx < 0) // unknown option |
7 | 6809 return FALSE; |
6810 if (options[idx].flags & P_WAS_SET) | |
6811 return TRUE; | |
6812 return FALSE; | |
6813 } | |
6814 | |
6815 /* | |
3980 | 6816 * Reset the flag indicating option "name" was set. |
6817 */ | |
14748
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6818 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6819 reset_option_was_set(char_u *name) |
3980 | 6820 { |
6821 int idx = findoption(name); | |
6822 | |
6823 if (idx >= 0) | |
14748
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6824 { |
3980 | 6825 options[idx].flags &= ~P_WAS_SET; |
14748
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6826 return OK; |
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6827 } |
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
6828 return FAIL; |
3980 | 6829 } |
6830 | |
6831 /* | |
7 | 6832 * compatible_set() - Called when 'compatible' has been set or unset. |
6833 * | |
6834 * When 'compatible' set: Set all relevant options (those that have the P_VIM) | |
6835 * flag) to a Vi compatible value. | |
6836 * When 'compatible' is unset: Set all options that have a different default | |
6837 * for Vim (without the P_VI_DEF flag) to that default. | |
6838 */ | |
6839 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6840 compatible_set(void) |
7 | 6841 { |
6842 int opt_idx; | |
6843 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6844 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 6845 if ( ((options[opt_idx].flags & P_VIM) && p_cp) |
6846 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp)) | |
6847 set_option_default(opt_idx, OPT_FREE, p_cp); | |
6848 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
6849 didset_options2(); |
7 | 6850 } |
6851 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6852 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
7 | 6853 |
6854 /* | |
6855 * fill_breakat_flags() -- called when 'breakat' changes value. | |
6856 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6857 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6858 fill_breakat_flags(void) |
7 | 6859 { |
500 | 6860 char_u *p; |
7 | 6861 int i; |
6862 | |
6863 for (i = 0; i < 256; i++) | |
6864 breakat_flags[i] = FALSE; | |
6865 | |
6866 if (p_breakat != NULL) | |
500 | 6867 for (p = p_breakat; *p; p++) |
6868 breakat_flags[*p] = TRUE; | |
7 | 6869 } |
6870 #endif | |
6871 | |
6872 /* | |
6873 * Check if backspacing over something is allowed. | |
6874 */ | |
6875 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6876 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
|
6877 int what) // BS_INDENT, BS_EOL, BS_START or BS_NOSTOP |
7 | 6878 { |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
6879 #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
|
6880 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
|
6881 return FALSE; |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
6882 #endif |
7 | 6883 switch (*p_bs) |
6884 { | |
20069
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
6885 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
|
6886 case '2': return (what != BS_NOSTOP); |
7 | 6887 case '1': return (what != BS_START); |
6888 case '0': return FALSE; | |
6889 } | |
6890 return vim_strchr(p_bs, what) != NULL; | |
6891 } | |
6892 | |
6893 /* | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6894 * 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
|
6895 * 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
|
6896 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6897 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6898 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
|
6899 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6900 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
|
6901 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6902 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6903 /* |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6904 * 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
|
6905 * 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
|
6906 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6907 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6908 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
|
6909 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6910 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
|
6911 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6912 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
6913 /* |
6243 | 6914 * Get the local or global value of 'backupcopy'. |
6915 */ | |
6916 unsigned int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6917 get_bkc_value(buf_T *buf) |
6243 | 6918 { |
6919 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags; | |
6920 } | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6921 |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6922 #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
|
6923 /* |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6924 * 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
|
6925 */ |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6926 char_u * |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6927 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
|
6928 { |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6929 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
|
6930 return p_sbr; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6931 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
|
6932 return empty_option; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6933 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
|
6934 } |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6935 #endif |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6936 |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6937 #if defined(FEAT_EVAL) || defined(PROTO) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6938 /* |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6939 * Get window or buffer local options. |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6940 */ |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6941 dict_T * |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6942 get_winbuf_options(int bufopt) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6943 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6944 dict_T *d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6945 int opt_idx; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6946 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6947 d = dict_alloc(); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6948 if (d == NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6949 return NULL; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6950 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6951 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6952 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6953 struct vimoption *opt = &options[opt_idx]; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6954 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6955 if ((bufopt && (opt->indir & PV_BUF)) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6956 || (!bufopt && (opt->indir & PV_WIN))) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6957 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6958 char_u *varp = get_varp(opt); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6959 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6960 if (varp != NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6961 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6962 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
|
6963 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
|
6964 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
|
6965 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
|
6966 else |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14243
diff
changeset
|
6967 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
|
6968 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6969 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6970 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6971 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6972 return d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6973 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
6974 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6975 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6976 #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
|
6977 /* |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6978 * 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
|
6979 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6980 int |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6981 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
|
6982 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6983 char_u *p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6984 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
|
6985 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6986 if (val == NULL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6987 p = wp->w_p_culopt; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6988 else |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6989 p = val; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6990 while (*p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6991 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6992 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
|
6993 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6994 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6995 culopt_flags_new |= CULOPT_LINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6996 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6997 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
|
6998 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6999 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7000 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
|
7001 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7002 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
|
7003 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7004 p += 6; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7005 culopt_flags_new |= CULOPT_NBR; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7006 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7007 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
|
7008 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7009 p += 10; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7010 culopt_flags_new |= CULOPT_SCRLINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7011 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7012 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7013 if (*p != ',' && *p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7014 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7015 if (*p == ',') |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7016 ++p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7017 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7018 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7019 // 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
|
7020 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
|
7021 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7022 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
|
7023 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7024 return OK; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7025 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7026 #endif |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7027 |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7028 /* |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7029 * 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
|
7030 */ |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7031 int |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7032 magic_isset(void) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7033 { |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7034 switch (magic_overruled) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7035 { |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23467
diff
changeset
|
7036 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
|
7037 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
|
7038 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
|
7039 } |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7040 #ifdef FEAT_EVAL |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7041 if (in_vim9script()) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7042 return TRUE; |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7043 #endif |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7044 return p_magic; |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7045 } |