Mercurial > vim
annotate src/option.c @ 31918:6ca26985ccb3 v9.0.1291
patch 9.0.1291: Move language files are not recognized
Commit: https://github.com/vim/vim/commit/6642982beaf4f1f5164f0315a1b3e3c275156089
Author: Amaan Qureshi <amaanq12@gmail.com>
Date: Tue Feb 7 19:37:32 2023 +0000
patch 9.0.1291: Move language files are not recognized
Problem: Move language files are not recognized.
Solution: Recognize Move language files. (Amaan Qureshi, closes https://github.com/vim/vim/issues/11947)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 07 Feb 2023 20:45:04 +0100 |
parents | 1ae3ad2e3d03 |
children | 440256d03990 |
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: | |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
13 * - Put it in the options array in optiondefs.h (copy an existing entry). |
7 | 14 * - For a global option: Add a variable for it in option.h. |
15 * - For a buffer or window local option: | |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
16 * - Add a PV_XX macro definition to the optiondefs.h file. |
7 | 17 * - Add a variable to the window or buffer struct in structs.h. |
18 * - For a window option, add some code to copy_winopt(). | |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
19 * - For a window string option, add code to check_win_options() and |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
20 * clear_winopt(). |
7 | 21 * - For a buffer option, add some code to buf_copy_options(). |
22 * - For a buffer string option, add code to check_buf_options(). | |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
23 * - If it's a numeric option, add any necessary bounds checks to |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
24 * set_num_option(). |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
25 * - If it's a list of flags, add some code in did_set_string_option(), search |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
26 * for WW_ALL. |
7 | 27 * - When adding an option with expansion (P_EXPAND), but with a different |
28 * 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
|
29 * - Add documentation! One line in doc/quickref.txt, full description in |
7 | 30 * options.txt, and any other related places. |
31 * - Add an entry in runtime/optwin.vim. | |
32 * When making changes: | |
33 * - Adjust the help for the option in doc/option.txt. | |
34 * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a | |
35 * comment at the help for the 'compatible' option. | |
36 */ | |
37 | |
38 #define IN_OPTION_C | |
39 #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
|
40 #include "optiondefs.h" |
7 | 41 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
42 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
|
43 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
|
44 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
|
45 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
|
46 static void didset_options(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
47 static void didset_options2(void); |
681 | 48 #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
|
49 static long_u *insecure_flag(int opt_idx, int opt_flags); |
681 | 50 #else |
51 # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags) | |
52 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 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
|
62 static int istermoption(struct vimoption *p); |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
63 static char_u *get_varp_scope(struct vimoption *p, int scope); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
64 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
|
65 static void check_win_options(win_T *win); |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
66 static void option_value2string(struct vimoption *, int scope); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
67 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
|
68 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
|
69 static void paste_option_changed(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
70 static void compatible_set(void); |
7 | 71 |
72 /* | |
73 * Initialize the options, first part. | |
74 * | |
75 * 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
|
76 * If "clean_arg" is TRUE Vim was started with --clean. |
7 | 77 */ |
78 void | |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
79 set_init_1(int clean_arg) |
7 | 80 { |
81 char_u *p; | |
82 int opt_idx; | |
835 | 83 long_u n; |
7 | 84 |
85 #ifdef FEAT_LANGMAP | |
86 langmap_init(); | |
87 #endif | |
88 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
89 // Be Vi compatible by default |
7 | 90 p_cp = TRUE; |
91 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
92 // Use POSIX compatibility when $VIM_POSIX is set. |
164 | 93 if (mch_getenv((char_u *)"VIM_POSIX") != NULL) |
168 | 94 { |
164 | 95 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
|
96 set_string_default("shm", (char_u *)SHM_POSIX); |
168 | 97 } |
164 | 98 |
7 | 99 /* |
100 * Find default value for 'shell' option. | |
161 | 101 * Don't use it if it is empty. |
7 | 102 */ |
161 | 103 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
|
104 #if defined(MSWIN) |
161 | 105 || ((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
|
106 || ((p = (char_u *)default_shell()) != NULL && *p != NUL) |
7 | 107 #endif |
161 | 108 ) |
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
|
109 #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
|
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 // 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
|
112 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
|
113 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
|
114 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
115 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
|
116 { |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
117 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
|
118 cmd = alloc(len); |
18243
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
119 if (cmd != NULL) |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
120 { |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
121 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
|
122 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
|
123 vim_free(cmd); |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
124 } |
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
|
125 } |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
126 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
|
127 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
|
128 } |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
129 #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
|
130 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
|
131 #endif |
7 | 132 |
133 /* | |
134 * Set the default for 'backupskip' to include environment variables for | |
135 * temp files. | |
136 */ | |
137 { | |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
138 #ifdef UNIX |
7 | 139 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"}; |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
140 #else |
7 | 141 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"}; |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
142 #endif |
170 | 143 int len; |
144 garray_T ga; | |
145 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
|
146 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
|
147 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
148 opt_idx = findoption((char_u *)"backupskip"); |
7 | 149 |
150 ga_init2(&ga, 1, 100); | |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
151 for (n = 0; n < (long)ARRAY_LENGTH(names); ++n) |
7 | 152 { |
170 | 153 mustfree = FALSE; |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
154 #ifdef UNIX |
7 | 155 if (*names[n] == NUL) |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
156 # ifdef MACOS_X |
13664
f64c5e636c9f
patch 8.0.1704: 'backupskip' default doesn't work for Mac
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
157 p = (char_u *)"/private/tmp"; |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
158 # else |
7 | 159 p = (char_u *)"/tmp"; |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
160 # endif |
7 | 161 else |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
162 #endif |
170 | 163 p = vim_getenv((char_u *)names[n], &mustfree); |
7 | 164 if (p != NULL && *p != NUL) |
165 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
166 // First time count the NUL, otherwise count the ','. |
835 | 167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 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
|
173 == NULL |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
174 && ga_grow(&ga, len) == OK) |
7 | 175 { |
176 if (ga.ga_len > 0) | |
177 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
|
178 STRCAT(ga.ga_data, item); |
7 | 179 ga.ga_len += len; |
180 } | |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
181 vim_free(item); |
7 | 182 } |
170 | 183 if (mustfree) |
184 vim_free(p); | |
7 | 185 } |
186 if (ga.ga_data != NULL) | |
187 { | |
188 set_string_default("bsk", ga.ga_data); | |
189 vim_free(ga.ga_data); | |
190 } | |
191 } | |
192 | |
193 /* | |
194 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory | |
195 */ | |
196 opt_idx = findoption((char_u *)"maxmemtot"); | |
838 | 197 if (opt_idx >= 0) |
198 { | |
7 | 199 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
838 | 200 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) |
201 #endif | |
202 { | |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
203 #if defined(HAVE_AVAIL_MEM) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
204 // Use amount of memory available at this moment. |
3634 | 205 n = (mch_avail_mem(FALSE) >> 1); |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
206 #elif defined(HAVE_TOTAL_MEM) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
207 // Use amount of memory available to Vim. |
1110 | 208 n = (mch_total_mem(FALSE) >> 1); |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
209 #else |
838 | 210 n = (0x7fffffff >> 11); |
7 | 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 { | |
226 char_u *cdpath; | |
227 char_u *buf; | |
228 int i; | |
229 int j; | |
170 | 230 int mustfree = FALSE; |
7 | 231 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
232 // Initialize the 'cdpath' option's default value. |
170 | 233 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree); |
7 | 234 if (cdpath != NULL) |
235 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16730
diff
changeset
|
236 buf = alloc((STRLEN(cdpath) << 1) + 2); |
7 | 237 if (buf != NULL) |
238 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
239 buf[0] = ','; // start with ",", current dir first |
7 | 240 j = 1; |
241 for (i = 0; cdpath[i] != NUL; ++i) | |
242 { | |
243 if (vim_ispathlistsep(cdpath[i])) | |
244 buf[j++] = ','; | |
245 else | |
246 { | |
247 if (cdpath[i] == ' ' || cdpath[i] == ',') | |
248 buf[j++] = '\\'; | |
249 buf[j++] = cdpath[i]; | |
250 } | |
251 } | |
252 buf[j] = NUL; | |
253 opt_idx = findoption((char_u *)"cdpath"); | |
838 | 254 if (opt_idx >= 0) |
255 { | |
256 options[opt_idx].def_val[VI_DEFAULT] = buf; | |
257 options[opt_idx].flags |= P_DEF_ALLOCED; | |
258 } | |
2445
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
259 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
260 vim_free(buf); // cannot happen |
7 | 261 } |
170 | 262 if (mustfree) |
263 vim_free(cdpath); | |
7 | 264 } |
265 } | |
266 | |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
267 #if defined(FEAT_POSTSCRIPT) && \ |
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
268 (defined(MSWIN) || defined(VMS) || defined(MAC) || defined(hpux)) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
269 // Set print encoding on platforms that don't default to latin1 |
7 | 270 set_string_default("penc", |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
271 # if defined(MSWIN) |
7 | 272 (char_u *)"cp1252" |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
273 # elif defined(VMS) |
7 | 274 (char_u *)"dec-mcs" |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
275 # elif defined(MAC) |
7 | 276 (char_u *)"mac-roman" |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
277 # else // HPUX |
7 | 278 (char_u *)"hp-roman8" |
279 # endif | |
280 ); | |
281 #endif | |
282 | |
283 #ifdef FEAT_POSTSCRIPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
284 // 'printexpr' must be allocated to be able to evaluate it. |
7 | 285 set_string_default("pexpr", |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
286 # if defined(MSWIN) |
8 | 287 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)" |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
288 # elif defined(VMS) |
7 | 289 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)" |
290 | |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
291 # else |
7 | 292 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error" |
293 # endif | |
294 ); | |
295 #endif | |
296 | |
297 /* | |
298 * Set all the options (except the terminal options) to their default | |
299 * value. Also set the global value for local options. | |
300 */ | |
301 set_options_default(0); | |
302 | |
27509
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
303 #ifdef UNIX |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
304 // Force restricted-mode on for "nologin" or "false" $SHELL |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
305 p = get_isolated_shell_name(); |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
306 if (p != NULL) |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
307 { |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
308 if (fnamecmp(p, "nologin") == 0 || fnamecmp(p, "false") == 0) |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
309 restricted = TRUE; |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
310 vim_free(p); |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
311 } |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
312 #endif |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
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) | |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
334 set_option_value_give_err((char_u *)"bg", 0L, (char_u *)"dark", 0); |
7 | 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) |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
392 set_option_value_give_err((char_u *)"tbidi", 1L, NULL, 0); |
7 | 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 } | |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
426 # elif defined(MACOS_CONVERT) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
427 // Moved to os_mac_conv.c to avoid dependency problems. |
1622 | 428 mac_lang_init(); |
7 | 429 # endif |
430 | |
24747
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
431 # ifdef MSWIN |
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
432 // MS-Windows has builtin support for conversion to and from Unicode, using |
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
433 // "utf-8" for 'encoding' should work best for most users. |
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
434 p = vim_strsave((char_u *)ENC_DFLT); |
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
435 # else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
436 // enc_locale() will try to find the encoding of the current locale. |
24747
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
437 // This works best for properly configured systems, old and new. |
7 | 438 p = enc_locale(); |
24747
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
439 # endif |
7 | 440 if (p != NULL) |
441 { | |
442 char_u *save_enc; | |
443 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
444 // Try setting 'encoding' and check if the value is valid. |
24747
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24600
diff
changeset
|
445 // If not, go back to the default encoding. |
7 | 446 save_enc = p_enc; |
447 p_enc = p; | |
1080 | 448 if (STRCMP(p_enc, "gb18030") == 0) |
449 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
450 // 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
|
451 // 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
|
452 // still support conversion between gb18030 and utf-8. |
1080 | 453 p_enc = vim_strsave((char_u *)"cp936"); |
454 vim_free(p); | |
455 } | |
7 | 456 if (mb_init() == NULL) |
457 { | |
458 opt_idx = findoption((char_u *)"encoding"); | |
838 | 459 if (opt_idx >= 0) |
460 { | |
461 options[opt_idx].def_val[VI_DEFAULT] = p_enc; | |
462 options[opt_idx].flags |= P_DEF_ALLOCED; | |
463 } | |
7 | 464 |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12636
diff
changeset
|
465 #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
|
466 if (STRCMP(p_enc, "latin1") == 0 || enc_utf8) |
24 | 467 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
468 // 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
|
469 // 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
|
470 // set. |
24 | 471 set_string_option_direct((char_u *)"isp", -1, |
719 | 472 ISP_LATIN1, OPT_FREE, SID_NONE); |
714 | 473 set_string_option_direct((char_u *)"isk", -1, |
474 ISK_LATIN1, OPT_FREE, SID_NONE); | |
475 opt_idx = findoption((char_u *)"isp"); | |
838 | 476 if (opt_idx >= 0) |
477 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1; | |
714 | 478 opt_idx = findoption((char_u *)"isk"); |
838 | 479 if (opt_idx >= 0) |
480 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1; | |
24 | 481 (void)init_chartab(); |
482 } | |
483 #endif | |
484 | |
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
|
485 #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
|
486 // 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
|
487 // 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
|
488 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
|
489 # 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
|
490 (!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
|
491 # endif |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
492 GetACP() != GetConsoleCP()) |
7 | 493 { |
494 char buf[50]; | |
495 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
496 // 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
|
497 // 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
|
498 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
|
499 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
|
500 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
|
501 sprintf(buf, "cp%ld", (long)GetConsoleCP()); |
7 | 502 p_tenc = vim_strsave((char_u *)buf); |
503 if (p_tenc != NULL) | |
504 { | |
505 opt_idx = findoption((char_u *)"termencoding"); | |
838 | 506 if (opt_idx >= 0) |
507 { | |
508 options[opt_idx].def_val[VI_DEFAULT] = p_tenc; | |
509 options[opt_idx].flags |= P_DEF_ALLOCED; | |
510 } | |
7 | 511 convert_setup(&input_conv, p_tenc, p_enc); |
512 convert_setup(&output_conv, p_enc, p_tenc); | |
513 } | |
514 else | |
515 p_tenc = empty_option; | |
516 } | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
517 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
518 #if defined(MSWIN) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
519 // $HOME may have characters in active code page. |
170 | 520 init_homedir(); |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
521 #endif |
7 | 522 } |
523 else | |
524 { | |
525 vim_free(p_enc); | |
526 p_enc = save_enc; | |
527 } | |
528 } | |
529 | |
530 #ifdef FEAT_MULTI_LANG | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
531 // Set the default for 'helplang'. |
7 | 532 set_helplang_default(get_mess_lang()); |
533 #endif | |
534 } | |
535 | |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
536 static char_u *fencs_utf8_default = (char_u *)"ucs-bom,utf-8,default,latin1"; |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
537 |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
538 /* |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
539 * Set the "fileencodings" option to the default value for when 'encoding' is |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
540 * utf-8. |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
541 */ |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
542 void |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
543 set_fencs_unicode() |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
544 { |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
545 set_string_option_direct((char_u *)"fencs", -1, fencs_utf8_default, |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
546 OPT_FREE, 0); |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
547 } |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
548 |
7 | 549 /* |
550 * Set an option to its default value. | |
551 * This does not take care of side effects! | |
552 */ | |
553 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
554 set_option_default( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
555 int opt_idx, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
556 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
|
557 int compatible) // use Vi default value |
7 | 558 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
559 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
|
560 int dvi; // index in def_val[] |
7 | 561 long_u flags; |
681 | 562 long_u *flagsp; |
7 | 563 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
564 | |
565 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); | |
566 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
|
567 if (varp != NULL) // skip hidden option, nothing to do for it |
7 | 568 { |
569 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; | |
570 if (flags & P_STRING) | |
571 { | |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
572 // 'fencs' default value depends on 'encoding' |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
573 if (options[opt_idx].var == (char_u *)&p_fencs && enc_utf8) |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
574 set_fencs_unicode(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
575 // 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
|
576 // freeing and allocating the value. |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
577 else if (options[opt_idx].indir != PV_NONE) |
13845
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
578 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
|
579 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
|
580 else |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
581 { |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
582 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
|
583 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
|
584 *(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
|
585 options[opt_idx].flags &= ~P_ALLOCED; |
7 | 586 } |
587 } | |
588 else if (flags & P_NUM) | |
589 { | |
1017 | 590 if (options[opt_idx].indir == PV_SCROLL) |
7 | 591 win_comp_scroll(curwin); |
592 else | |
593 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
594 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
|
595 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
596 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
|
597 || (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
|
598 // '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
|
599 // 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
|
600 *(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
|
601 else |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
602 *(long *)varp = def_val; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
603 // May also set global value for local option. |
7 | 604 if (both) |
605 *(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
|
606 def_val; |
7 | 607 } |
608 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
609 else // P_BOOL |
7 | 610 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
611 // 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
|
612 // MSVC |
840 | 613 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; |
1111 | 614 #ifdef UNIX |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
615 // 'modeline' defaults to off for root |
1111 | 616 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) |
617 *(int *)varp = FALSE; | |
618 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
619 // May also set global value for local option. |
7 | 620 if (both) |
621 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | |
622 *(int *)varp; | |
623 } | |
634 | 624 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
625 // The default value is not insecure. |
681 | 626 flagsp = insecure_flag(opt_idx, opt_flags); |
627 *flagsp = *flagsp & ~P_INSECURE; | |
7 | 628 } |
629 | |
630 #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
|
631 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 632 #endif |
633 } | |
634 | |
635 /* | |
636 * 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
|
637 * When "opt_flags" is non-zero skip 'encoding'. |
7 | 638 */ |
639 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
640 set_options_default( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
641 int opt_flags) // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL |
7 | 642 { |
643 int i; | |
644 win_T *wp; | |
671 | 645 tabpage_T *tp; |
7 | 646 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
647 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
|
648 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
|
649 && (opt_flags == 0 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
650 || (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
|
651 # if defined(FEAT_CRYPT) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
652 && 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
|
653 && 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
|
654 # endif |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
655 ))) |
7 | 656 set_option_default(i, opt_flags, p_cp); |
657 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
658 // The 'scroll' option must be computed for all windows. |
671 | 659 FOR_ALL_TAB_WINDOWS(tp, wp) |
7 | 660 win_comp_scroll(wp); |
6205 | 661 parse_cino(curbuf); |
7 | 662 } |
663 | |
664 /* | |
665 * Set the Vi-default value of a string option. | |
666 * 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
|
667 * 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
|
668 */ |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
669 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
|
670 set_string_default_esc(char *name, char_u *val, int escape) |
7 | 671 { |
672 char_u *p; | |
673 int opt_idx; | |
674 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
675 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
|
676 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
|
677 else |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
678 p = vim_strsave(val); |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
679 if (p == NULL) // we don't want a NULL |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
680 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
681 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
682 opt_idx = findoption((char_u *)name); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
683 if (opt_idx < 0) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
684 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
685 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
686 if (options[opt_idx].flags & P_DEF_ALLOCED) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
687 vim_free(options[opt_idx].def_val[VI_DEFAULT]); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
688 options[opt_idx].def_val[VI_DEFAULT] = p; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
689 options[opt_idx].flags |= P_DEF_ALLOCED; |
7 | 690 } |
691 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
692 void |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
693 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
|
694 { |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
695 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
|
696 } |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
697 |
7 | 698 /* |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
699 * 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
|
700 * "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
|
701 */ |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
702 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
|
703 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
|
704 { |
22242
f7871f02ddcd
patch 8.2.1670: a couple of gcc compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
22234
diff
changeset
|
705 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
|
706 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
|
707 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
|
708 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
709 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
|
710 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
|
711 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
712 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
|
713 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
|
714 { |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
715 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
|
716 || 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
|
717 || (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
|
718 && 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
|
719 && (!(flags & P_COMMA) |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
720 || s[newlen] == ',' |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
721 || s[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
|
722 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
|
723 // 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
|
724 // 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
|
725 // 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
|
726 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
|
727 && 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
|
728 && 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
|
729 || (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
|
730 && 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
|
731 ++bs; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
732 else |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
733 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
|
734 } |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
735 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
|
736 } |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
737 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
738 /* |
7 | 739 * Set the Vi-default value of a number option. |
740 * Used for 'lines' and 'columns'. | |
741 */ | |
742 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
743 set_number_default(char *name, long val) |
7 | 744 { |
838 | 745 int opt_idx; |
746 | |
747 opt_idx = findoption((char_u *)name); | |
748 if (opt_idx >= 0) | |
840 | 749 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 750 } |
751 | |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
752 #if defined(FEAT_PROP_POPUP) || defined(PROTO) |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
753 /* |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
754 * 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
|
755 * 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
|
756 * 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
|
757 */ |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
758 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
|
759 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
|
760 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
761 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
|
762 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
|
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 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
|
765 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
|
766 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
|
767 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
768 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
|
769 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
770 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
|
771 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
|
772 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
773 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
|
774 && (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
|
775 && !(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
|
776 && !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
|
777 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
|
778 } |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
779 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
780 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
|
781 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
|
782 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
|
783 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
784 #endif |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
785 |
359 | 786 #if defined(EXITFREE) || defined(PROTO) |
787 /* | |
788 * Free all options. | |
789 */ | |
790 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
791 free_all_options(void) |
359 | 792 { |
793 int i; | |
794 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
795 for (i = 0; !istermoption_idx(i); i++) |
359 | 796 { |
797 if (options[i].indir == PV_NONE) | |
798 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
799 // 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
|
800 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL) |
359 | 801 free_string_option(*(char_u **)options[i].var); |
802 if (options[i].flags & P_DEF_ALLOCED) | |
803 free_string_option(options[i].def_val[VI_DEFAULT]); | |
804 } | |
805 else if (options[i].var != VAR_WIN | |
806 && (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
|
807 // buffer-local option: free global value |
25419
8a0234862ce6
patch 8.2.3246: memory use after free
Bram Moolenaar <Bram@vim.org>
parents:
25380
diff
changeset
|
808 clear_string_option((char_u **)options[i].var); |
359 | 809 } |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
810 free_operatorfunc_option(); |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26193
diff
changeset
|
811 free_tagfunc_option(); |
359 | 812 } |
813 #endif | |
814 | |
815 | |
7 | 816 /* |
817 * Initialize the options, part two: After getting Rows and Columns and | |
818 * setting 'term'. | |
819 */ | |
820 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
821 set_init_2(void) |
7 | 822 { |
164 | 823 int idx; |
824 | |
7 | 825 /* |
12718
f8f505ffc0a6
patch 8.0.1237: ":set scroll&" often gives an error
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
826 * 'scroll' defaults to half the window height. The stored default is zero, |
f8f505ffc0a6
patch 8.0.1237: ":set scroll&" often gives an error
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
827 * which results in the actual value computed from the window height. |
7 | 828 */ |
168 | 829 idx = findoption((char_u *)"scroll"); |
838 | 830 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
168 | 831 set_option_default(idx, OPT_LOCAL, p_cp); |
7 | 832 comp_col(); |
833 | |
164 | 834 /* |
835 * 'window' is only for backwards compatibility with Vi. | |
836 * Default is Rows - 1. | |
837 */ | |
857 | 838 if (!option_was_set((char_u *)"window")) |
164 | 839 p_window = Rows - 1; |
840 set_number_default("window", Rows - 1); | |
841 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
842 // For DOS console the default is always black. |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
843 #if !((defined(MSWIN)) && !defined(FEAT_GUI)) |
671 | 844 /* |
845 * If 'background' wasn't set by the user, try guessing the value, | |
846 * depending on the terminal name. Only need to check for terminals | |
847 * with a dark background, that can handle color. | |
848 */ | |
849 idx = findoption((char_u *)"bg"); | |
838 | 850 if (idx >= 0 && !(options[idx].flags & P_WAS_SET) |
851 && *term_bg_default() == 'd') | |
671 | 852 { |
694 | 853 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
854 // don't mark it as set, when starting the GUI it may be |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
855 // changed again |
671 | 856 options[idx].flags &= ~P_WAS_SET; |
7 | 857 } |
858 #endif | |
440 | 859 |
860 #ifdef CURSOR_SHAPE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
861 parse_shape_opt(SHAPE_CURSOR); // set cursor shapes from 'guicursor' |
440 | 862 #endif |
863 #ifdef FEAT_MOUSESHAPE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
864 parse_shape_opt(SHAPE_MOUSE); // set mouse shapes from 'mouseshape' |
440 | 865 #endif |
866 #ifdef FEAT_PRINTER | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
867 (void)parse_printoptions(); // parse 'printoptions' default value |
440 | 868 #endif |
7 | 869 } |
870 | |
871 /* | |
872 * Initialize the options, part three: After reading the .vimrc | |
873 */ | |
874 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
875 set_init_3(void) |
7 | 876 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
877 #if defined(UNIX) || defined(MSWIN) |
7 | 878 /* |
879 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. | |
880 * This is done after other initializations, where 'shell' might have been | |
881 * set, but only if they have not been set before. | |
882 */ | |
883 char_u *p; | |
884 int idx_srr; | |
885 int do_srr; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
886 # ifdef FEAT_QUICKFIX |
7 | 887 int idx_sp; |
888 int do_sp; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
889 # endif |
7 | 890 |
891 idx_srr = findoption((char_u *)"srr"); | |
838 | 892 if (idx_srr < 0) |
893 do_srr = FALSE; | |
894 else | |
895 do_srr = !(options[idx_srr].flags & P_WAS_SET); | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
896 # ifdef FEAT_QUICKFIX |
7 | 897 idx_sp = findoption((char_u *)"sp"); |
838 | 898 if (idx_sp < 0) |
899 do_sp = FALSE; | |
900 else | |
901 do_sp = !(options[idx_sp].flags & P_WAS_SET); | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
902 # endif |
5867 | 903 p = get_isolated_shell_name(); |
7 | 904 if (p != NULL) |
905 { | |
906 /* | |
907 * Default for p_sp is "| tee", for p_srr is ">". | |
908 * For known shells it is changed here to include stderr. | |
909 */ | |
910 if ( fnamecmp(p, "csh") == 0 | |
911 || fnamecmp(p, "tcsh") == 0 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
912 # if defined(MSWIN) // also check with .exe extension |
7 | 913 || fnamecmp(p, "csh.exe") == 0 |
914 || fnamecmp(p, "tcsh.exe") == 0 | |
915 # endif | |
916 ) | |
917 { | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
918 # if defined(FEAT_QUICKFIX) |
7 | 919 if (do_sp) |
920 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
921 # ifdef MSWIN |
7 | 922 p_sp = (char_u *)">&"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
923 # else |
7 | 924 p_sp = (char_u *)"|& tee"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
925 # endif |
7 | 926 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
927 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
928 # endif |
7 | 929 if (do_srr) |
930 { | |
931 p_srr = (char_u *)">&"; | |
932 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
933 } | |
934 } | |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
935 # ifdef MSWIN |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
936 // Windows PowerShell output is UTF-16 with BOM so re-encode to the |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
937 // current codepage. |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
938 else if ( fnamecmp(p, "powershell") == 0 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
939 || fnamecmp(p, "powershell.exe") == 0 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
940 ) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
941 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
942 # if defined(FEAT_QUICKFIX) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
943 if (do_sp) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
944 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
945 p_sp = (char_u *)"2>&1 | Out-File -Encoding default"; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
946 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
947 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
948 # endif |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
949 if (do_srr) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
950 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
951 p_srr = (char_u *)"2>&1 | Out-File -Encoding default"; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
952 options[idx_srr].def_val[VI_DEFAULT] = p_srr; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
953 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
954 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
955 #endif |
7 | 956 else |
24600
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
957 // Always use POSIX shell style redirection if we reach this |
7 | 958 if ( fnamecmp(p, "sh") == 0 |
959 || fnamecmp(p, "ksh") == 0 | |
2774 | 960 || fnamecmp(p, "mksh") == 0 |
961 || fnamecmp(p, "pdksh") == 0 | |
7 | 962 || fnamecmp(p, "zsh") == 0 |
836 | 963 || fnamecmp(p, "zsh-beta") == 0 |
7 | 964 || fnamecmp(p, "bash") == 0 |
5867 | 965 || fnamecmp(p, "fish") == 0 |
24600
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
966 || fnamecmp(p, "ash") == 0 |
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
967 || fnamecmp(p, "dash") == 0 |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
968 || fnamecmp(p, "pwsh") == 0 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
969 # ifdef MSWIN |
7 | 970 || fnamecmp(p, "cmd") == 0 |
971 || fnamecmp(p, "sh.exe") == 0 | |
972 || fnamecmp(p, "ksh.exe") == 0 | |
2774 | 973 || fnamecmp(p, "mksh.exe") == 0 |
974 || fnamecmp(p, "pdksh.exe") == 0 | |
7 | 975 || fnamecmp(p, "zsh.exe") == 0 |
836 | 976 || fnamecmp(p, "zsh-beta.exe") == 0 |
7 | 977 || fnamecmp(p, "bash.exe") == 0 |
978 || fnamecmp(p, "cmd.exe") == 0 | |
24600
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
979 || fnamecmp(p, "dash.exe") == 0 |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
980 || fnamecmp(p, "pwsh.exe") == 0 |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
981 # endif |
7 | 982 ) |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
983 { |
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
984 # if defined(FEAT_QUICKFIX) |
7 | 985 if (do_sp) |
986 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
987 # ifdef MSWIN |
7 | 988 p_sp = (char_u *)">%s 2>&1"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
989 # else |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
990 if (fnamecmp(p, "pwsh") == 0) |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
991 p_sp = (char_u *)">%s 2>&1"; |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
992 else |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
993 p_sp = (char_u *)"2>&1| tee"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
994 # endif |
7 | 995 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
996 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
997 # endif |
7 | 998 if (do_srr) |
999 { | |
1000 p_srr = (char_u *)">%s 2>&1"; | |
1001 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
1002 } | |
1003 } | |
1004 vim_free(p); | |
1005 } | |
1006 #endif | |
1007 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
1008 #if defined(MSWIN) |
7 | 1009 /* |
3352 | 1010 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the |
1011 * 'shell' option. | |
7 | 1012 * This is done after other initializations, where 'shell' might have been |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1013 * set, but only if they have not been set before. |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1014 * Default values depend on shell (cmd.exe is default shell): |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1015 * |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1016 * p_shcf p_sxq |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
1017 * cmd.exe - "/c" "(" |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1018 * powershell.exe - "-Command" "\"" |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
1019 * pwsh.exe - "-c" "\"" |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1020 * "sh" like shells - "-c" "\"" |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1021 * |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1022 * For Win32 p_sxq is set instead of p_shq to include shell redirection. |
7 | 1023 */ |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1024 if (strstr((char *)gettail(p_sh), "powershell") != NULL) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1025 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1026 int idx_opt; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1027 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1028 idx_opt = findoption((char_u *)"shcf"); |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1029 if (idx_opt >= 0 && !(options[idx_opt].flags & P_WAS_SET)) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1030 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1031 p_shcf = (char_u*)"-Command"; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1032 options[idx_opt].def_val[VI_DEFAULT] = p_shcf; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1033 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1034 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1035 idx_opt = findoption((char_u *)"sxq"); |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1036 if (idx_opt >= 0 && !(options[idx_opt].flags & P_WAS_SET)) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1037 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1038 p_sxq = (char_u*)"\""; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1039 options[idx_opt].def_val[VI_DEFAULT] = p_sxq; |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1040 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1041 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1042 else if (strstr((char *)gettail(p_sh), "sh") != NULL) |
7 | 1043 { |
1044 int idx3; | |
1045 | |
1046 idx3 = findoption((char_u *)"shcf"); | |
838 | 1047 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 1048 { |
1049 p_shcf = (char_u *)"-c"; | |
1050 options[idx3].def_val[VI_DEFAULT] = p_shcf; | |
1051 } | |
1052 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1053 // Somehow Win32 requires the quotes around the redirection too |
7 | 1054 idx3 = findoption((char_u *)"sxq"); |
838 | 1055 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 1056 { |
1057 p_sxq = (char_u *)"\""; | |
1058 options[idx3].def_val[VI_DEFAULT] = p_sxq; | |
1059 } | |
1060 } | |
3352 | 1061 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL) |
1062 { | |
1063 int idx3; | |
1064 | |
1065 /* | |
1066 * cmd.exe on Windows will strip the first and last double quote given | |
1067 * on the command line, e.g. most of the time things like: | |
1068 * cmd /c "my path/to/echo" "my args to echo" | |
1069 * become: | |
1070 * my path/to/echo" "my args to echo | |
1071 * when executed. | |
1072 * | |
3357 | 1073 * To avoid this, set shellxquote to surround the command in |
1074 * parenthesis. This appears to make most commands work, without | |
1075 * breaking commands that worked previously, such as | |
1076 * '"path with spaces/cmd" "a&b"'. | |
3352 | 1077 */ |
1078 idx3 = findoption((char_u *)"sxq"); | |
1079 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
1080 { | |
3357 | 1081 p_sxq = (char_u *)"("; |
3352 | 1082 options[idx3].def_val[VI_DEFAULT] = p_sxq; |
1083 } | |
1084 | |
1085 idx3 = findoption((char_u *)"shcf"); | |
1086 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
1087 { | |
3357 | 1088 p_shcf = (char_u *)"/c"; |
3352 | 1089 options[idx3].def_val[VI_DEFAULT] = p_shcf; |
1090 } | |
1091 } | |
7 | 1092 #endif |
1093 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11107
diff
changeset
|
1094 if (BUFEMPTY()) |
8659
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1095 { |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1096 int idx_ffs = findoption((char_u *)"ffs"); |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1097 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1098 // Apply the first entry of 'fileformats' to the initial buffer. |
8659
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1099 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET)) |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1100 set_fileformat(default_fileformat(), OPT_LOCAL); |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1101 } |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1102 |
7 | 1103 set_title_defaults(); |
1104 } | |
1105 | |
1106 #if defined(FEAT_MULTI_LANG) || defined(PROTO) | |
1107 /* | |
1108 * When 'helplang' is still at its default value, set it to "lang". | |
1109 * Only the first two characters of "lang" are used. | |
1110 */ | |
1111 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1112 set_helplang_default(char_u *lang) |
7 | 1113 { |
1114 int idx; | |
1115 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1116 if (lang == NULL || STRLEN(lang) < 2) // safety check |
7 | 1117 return; |
1118 idx = findoption((char_u *)"hlg"); | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1119 if (idx < 0 || (options[idx].flags & P_WAS_SET)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1120 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1121 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1122 if (options[idx].flags & P_ALLOCED) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1123 free_string_option(p_hlg); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1124 p_hlg = vim_strsave(lang); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1125 if (p_hlg == NULL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1126 p_hlg = empty_option; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1127 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1128 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1129 // zh_CN becomes "cn", zh_TW becomes "tw" |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1130 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1131 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1132 p_hlg[0] = TOLOWER_ASC(p_hlg[3]); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1133 p_hlg[1] = TOLOWER_ASC(p_hlg[4]); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1134 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1135 // any C like setting, such as C.UTF-8, becomes "en" |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1136 else if (STRLEN(p_hlg) >= 1 && *p_hlg == 'C') |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1137 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1138 p_hlg[0] = 'e'; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1139 p_hlg[1] = 'n'; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1140 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1141 p_hlg[2] = NUL; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1142 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1143 options[idx].flags |= P_ALLOCED; |
7 | 1144 } |
1145 #endif | |
1146 | |
1147 /* | |
1148 * 'title' and 'icon' only default to true if they have not been set or reset | |
1149 * in .vimrc and we can read the old value. | |
1150 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if | |
1151 * they can be reset. This reduces startup time when using X on a remote | |
1152 * machine. | |
1153 */ | |
1154 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1155 set_title_defaults(void) |
7 | 1156 { |
1157 int idx1; | |
1158 long val; | |
1159 | |
1160 /* | |
1161 * If GUI is (going to be) used, we can always set the window title and | |
1162 * icon name. Saves a bit of time, because the X11 display server does | |
1163 * not need to be contacted. | |
1164 */ | |
1165 idx1 = findoption((char_u *)"title"); | |
838 | 1166 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 1167 { |
1168 #ifdef FEAT_GUI | |
1169 if (gui.starting || gui.in_use) | |
1170 val = TRUE; | |
1171 else | |
1172 #endif | |
1173 val = mch_can_restore_title(); | |
840 | 1174 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 1175 p_title = val; |
1176 } | |
1177 idx1 = findoption((char_u *)"icon"); | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1178 if (idx1 < 0 || (options[idx1].flags & P_WAS_SET)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1179 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1180 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1181 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1182 |
7 | 1183 #ifdef FEAT_GUI |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1184 if (gui.starting || gui.in_use) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1185 val = TRUE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1186 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1187 #endif |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1188 val = mch_can_restore_icon(); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1189 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1190 p_icon = val; |
7 | 1191 } |
1192 | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1193 void |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1194 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
|
1195 { |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1196 int flags = 0; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1197 |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1198 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
|
1199 flags = OPT_LOCAL; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1200 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
|
1201 flags = OPT_GLOBAL; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1202 #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
|
1203 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
|
1204 ex_options(eap); |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1205 else |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1206 #endif |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1207 { |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1208 if (eap->forceit) |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1209 flags |= OPT_ONECOLUMN; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1210 (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
|
1211 } |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1212 } |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1213 |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1214 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1215 * :set operator types |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1216 */ |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1217 typedef enum { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1218 OP_NONE = 0, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1219 OP_ADDING, // "opt+=arg" |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1220 OP_PREPENDING, // "opt^=arg" |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1221 OP_REMOVING, // "opt-=arg" |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1222 } set_op_T; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1223 |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1224 typedef enum { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1225 PREFIX_NO = 0, // "no" prefix |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1226 PREFIX_NONE, // no prefix |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1227 PREFIX_INV, // "inv" prefix |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1228 } set_prefix_T; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1229 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1230 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1231 * Return the prefix type for the option name in *argp. |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1232 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1233 static set_prefix_T |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1234 get_option_prefix(char_u **argp) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1235 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1236 int prefix = PREFIX_NONE; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1237 char_u *arg = *argp; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1238 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1239 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1240 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1241 prefix = PREFIX_NO; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1242 arg += 2; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1243 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1244 else if (STRNCMP(arg, "inv", 3) == 0) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1245 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1246 prefix = PREFIX_INV; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1247 arg += 3; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1248 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1249 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1250 *argp = arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1251 return prefix; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1252 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1253 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1254 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1255 * Parse the option name in "arg" and return the option index in "*opt_idxp", |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1256 * and the option name length in "*lenp". For a <t_xx> option, return the key |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1257 * number in "*keyp". |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1258 * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1259 * Returns FAIL if an option starting with "<" doesn't end with a ">", |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1260 * otherwise returns OK. |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1261 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1262 static int |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1263 parse_option_name(char_u *arg, int *opt_idxp, int *lenp, int *keyp) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1264 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1265 int key = 0; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1266 int len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1267 int opt_idx; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1268 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1269 if (*arg == '<') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1270 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1271 opt_idx = -1; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1272 // look out for <t_>;> |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1273 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1274 len = 5; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1275 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1276 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1277 len = 1; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1278 while (arg[len] != NUL && arg[len] != '>') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1279 ++len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1280 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1281 if (arg[len] != '>') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1282 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1283 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1284 arg[len] = NUL; // put NUL after name |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1285 if (arg[1] == 't' && arg[2] == '_') // could be term code |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1286 opt_idx = findoption(arg + 1); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1287 arg[len++] = '>'; // restore '>' |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1288 if (opt_idx == -1) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1289 key = find_key_option(arg + 1, TRUE); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1290 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1291 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1292 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1293 int nextchar; // next non-white char after option name |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1294 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1295 len = 0; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1296 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1297 * The two characters after "t_" may not be alphanumeric. |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1298 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1299 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1300 len = 4; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1301 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1302 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1303 ++len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1304 nextchar = arg[len]; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1305 arg[len] = NUL; // put NUL after name |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1306 opt_idx = findoption(arg); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1307 arg[len] = nextchar; // restore nextchar |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1308 if (opt_idx == -1) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1309 key = find_key_option(arg, FALSE); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1310 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1311 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1312 *keyp = key; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1313 *lenp = len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1314 *opt_idxp = opt_idx; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1315 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1316 return OK; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1317 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1318 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1319 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1320 * Get the option operator (+=, ^=, -=). |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1321 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1322 static set_op_T |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1323 get_opt_op(char_u *arg) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1324 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1325 set_op_T op = OP_NONE; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1326 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1327 if (*arg != NUL && *(arg + 1) == '=') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1328 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1329 if (*arg == '+') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1330 op = OP_ADDING; // "+=" |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1331 else if (*arg == '^') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1332 op = OP_PREPENDING; // "^=" |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1333 else if (*arg == '-') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1334 op = OP_REMOVING; // "-=" |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1335 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1336 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1337 return op; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1338 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1339 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1340 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1341 * Validate whether the value of the option in "opt_idx" can be changed. |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1342 * Returns FAIL if the option can be skipped or cannot be changed. Returns OK |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1343 * if it can be changed. |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1344 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1345 static int |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1346 validate_opt_idx(int opt_idx, int opt_flags, long_u flags, char **errmsg) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1347 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1348 // Skip all options that are not window-local (used when showing |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1349 // an already loaded buffer in a window). |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1350 if ((opt_flags & OPT_WINONLY) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1351 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1352 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1353 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1354 // Skip all options that are window-local (used for :vimgrep). |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1355 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1356 && options[opt_idx].var == VAR_WIN) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1357 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1358 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1359 // Disallow changing some options from modelines. |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1360 if (opt_flags & OPT_MODELINE) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1361 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1362 if (flags & (P_SECURE | P_NO_ML)) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1363 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1364 *errmsg = e_not_allowed_in_modeline; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1365 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1366 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1367 if ((flags & P_MLE) && !p_mle) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1368 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1369 *errmsg = e_not_allowed_in_modeline_when_modelineexpr_is_off; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1370 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1371 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1372 #ifdef FEAT_DIFF |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1373 // In diff mode some options are overruled. This avoids that |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1374 // 'foldmethod' becomes "marker" instead of "diff" and that |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1375 // "wrap" gets set. |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1376 if (curwin->w_p_diff |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1377 && opt_idx >= 0 // shut up coverity warning |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1378 && ( |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1379 # ifdef FEAT_FOLDING |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1380 options[opt_idx].indir == PV_FDM || |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1381 # endif |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1382 options[opt_idx].indir == PV_WRAP)) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1383 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1384 #endif |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1385 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1386 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1387 #ifdef HAVE_SANDBOX |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1388 // Disallow changing some options in the sandbox |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1389 if (sandbox != 0 && (flags & P_SECURE)) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1390 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1391 *errmsg = e_not_allowed_in_sandbox; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1392 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1393 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1394 #endif |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1395 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1396 return OK; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1397 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1398 |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1399 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1400 * Part of do_set() for string options. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1401 * Returns FAIL on failure, do not process further options. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1402 */ |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1403 static int |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1404 do_set_string( |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1405 int opt_idx, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1406 int opt_flags, |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1407 char_u **argp, |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1408 int nextchar, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1409 set_op_T op_arg, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1410 int flags, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1411 int cp_val, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1412 char_u *varp_arg, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1413 char *errbuf, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1414 int *value_checked, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1415 char **errmsg) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1416 { |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1417 char_u *arg = *argp; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1418 set_op_T op = op_arg; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1419 char_u *varp = varp_arg; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1420 char_u *save_arg = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1421 char_u *s = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1422 char_u *oldval = NULL; // previous value if *varp |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1423 char_u *newval; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1424 char_u *origval = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1425 char_u *origval_l = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1426 char_u *origval_g = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1427 #if defined(FEAT_EVAL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1428 char_u *saved_origval = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1429 char_u *saved_origval_l = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1430 char_u *saved_origval_g = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1431 char_u *saved_newval = NULL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1432 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1433 unsigned newlen; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1434 int comma; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1435 char_u whichwrap[80]; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1436 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1437 // When using ":set opt=val" for a global option |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1438 // with a local value the local value will be |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1439 // reset, use the global value here. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1440 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1441 && ((int)options[opt_idx].indir & PV_BOTH)) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1442 varp = options[opt_idx].var; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1443 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1444 // The old value is kept until we are sure that the new value is valid. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1445 oldval = *(char_u **)varp; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1446 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1447 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1448 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1449 origval_l = *(char_u **)get_varp_scope( |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1450 &(options[opt_idx]), OPT_LOCAL); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1451 origval_g = *(char_u **)get_varp_scope( |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1452 &(options[opt_idx]), OPT_GLOBAL); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1453 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1454 // A global-local string option might have an empty option as value to |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1455 // indicate that the global value should be used. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1456 if (((int)options[opt_idx].indir & PV_BOTH) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1457 && origval_l == empty_option) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1458 origval_l = origval_g; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1459 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1460 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1461 // When setting the local value of a global option, the old value may be |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1462 // the global value. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1463 if (((int)options[opt_idx].indir & PV_BOTH) && (opt_flags & OPT_LOCAL)) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1464 origval = *(char_u **)get_varp(&options[opt_idx]); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1465 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1466 origval = oldval; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1467 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1468 if (nextchar == '&') // set to default val |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1469 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1470 newval = options[opt_idx].def_val[((flags & P_VI_DEF) || cp_val) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1471 ? VI_DEFAULT : VIM_DEFAULT]; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1472 if ((char_u **)varp == &p_bg) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1473 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1474 // guess the value of 'background' |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1475 #ifdef FEAT_GUI |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1476 if (gui.in_use) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1477 newval = gui_bg_default(); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1478 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1479 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1480 newval = term_bg_default(); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1481 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1482 else if ((char_u **)varp == &p_fencs && enc_utf8) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1483 newval = fencs_utf8_default; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1484 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1485 // expand environment variables and ~ since the default value was |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1486 // already expanded, only required when an environment variable was set |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1487 // later |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1488 if (newval == NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1489 newval = empty_option; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1490 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1491 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1492 s = option_expand(opt_idx, newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1493 if (s == NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1494 s = newval; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1495 newval = vim_strsave(s); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1496 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1497 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1498 else if (nextchar == '<') // set to global val |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1499 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1500 newval = vim_strsave(*(char_u **)get_varp_scope( |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1501 &(options[opt_idx]), OPT_GLOBAL)); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1502 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1503 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1504 { |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1505 ++arg; // jump to after the '=' or ':' |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1506 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1507 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1508 * Set 'keywordprg' to ":help" if an empty |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1509 * value was passed to :set by the user. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1510 */ |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1511 if (varp == (char_u *)&p_kp && (*arg == NUL || *arg == ' ')) |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1512 { |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1513 save_arg = arg; |
30417
6a1862bfb280
patch 9.0.0544: minor issues with setting a string option
Bram Moolenaar <Bram@vim.org>
parents:
30409
diff
changeset
|
1514 arg = (char_u *)":help"; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1515 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1516 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1517 * Convert 'backspace' number to string, for |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1518 * adding, prepending and removing string. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1519 */ |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1520 else if (varp == (char_u *)&p_bs && VIM_ISDIGIT(**(char_u **)varp)) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1521 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1522 int i = getdigits((char_u **)varp); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1523 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1524 switch (i) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1525 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1526 case 0: |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1527 *(char_u **)varp = empty_option; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1528 break; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1529 case 1: |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1530 *(char_u **)varp = vim_strsave((char_u *)"indent,eol"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1531 break; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1532 case 2: |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1533 *(char_u **)varp = vim_strsave( |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1534 (char_u *)"indent,eol,start"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1535 break; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1536 case 3: |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1537 *(char_u **)varp = vim_strsave( |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1538 (char_u *)"indent,eol,nostop"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1539 break; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1540 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1541 vim_free(oldval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1542 if (origval == oldval) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1543 origval = *(char_u **)varp; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1544 if (origval_l == oldval) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1545 origval_l = *(char_u **)varp; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1546 if (origval_g == oldval) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1547 origval_g = *(char_u **)varp; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1548 oldval = *(char_u **)varp; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1549 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1550 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1551 * Convert 'whichwrap' number to string, for backwards compatibility |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1552 * with Vim 3.0. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1553 */ |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1554 else if (varp == (char_u *)&p_ww && VIM_ISDIGIT(*arg)) |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1555 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1556 *whichwrap = NUL; |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1557 int i = getdigits(&arg); |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1558 if (i & 1) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1559 STRCAT(whichwrap, "b,"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1560 if (i & 2) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1561 STRCAT(whichwrap, "s,"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1562 if (i & 4) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1563 STRCAT(whichwrap, "h,l,"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1564 if (i & 8) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1565 STRCAT(whichwrap, "<,>,"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1566 if (i & 16) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1567 STRCAT(whichwrap, "[,],"); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1568 if (*whichwrap != NUL) // remove trailing , |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1569 whichwrap[STRLEN(whichwrap) - 1] = NUL; |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1570 save_arg = arg; |
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1571 arg = (char_u *)whichwrap; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1572 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1573 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1574 * Remove '>' before 'dir' and 'bdir', for backwards compatibility with |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1575 * version 3.0 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1576 */ |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1577 else if (*arg == '>' && (varp == (char_u *)&p_dir |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1578 || varp == (char_u *)&p_bdir)) |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1579 ++arg; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1580 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1581 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1582 * Copy the new string into allocated memory. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1583 * Can't use set_string_option_direct(), because we need to remove the |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1584 * backslashes. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1585 */ |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1586 // get a bit too much |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1587 newlen = (unsigned)STRLEN(arg) + 1; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1588 if (op != OP_NONE) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1589 newlen += (unsigned)STRLEN(origval) + 1; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1590 newval = alloc(newlen); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1591 if (newval == NULL) // out of mem, don't change |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1592 return FAIL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1593 s = newval; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1594 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1595 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1596 * Copy the string, skip over escaped chars. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1597 * For MS-DOS and WIN32 backslashes before normal file name characters |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1598 * are not removed, and keep backslash at start, for "\\machine\path", |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1599 * but do remove it for "\\\\machine\\path". |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1600 * The reverse is found in ExpandOldSetting(). |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1601 */ |
30417
6a1862bfb280
patch 9.0.0544: minor issues with setting a string option
Bram Moolenaar <Bram@vim.org>
parents:
30409
diff
changeset
|
1602 while (*arg != NUL && !VIM_ISWHITE(*arg)) |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1603 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1604 int i; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1605 |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1606 if (*arg == '\\' && arg[1] != NUL |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1607 #ifdef BACKSLASH_IN_FILENAME |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1608 && !((flags & P_EXPAND) |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1609 && vim_isfilec(arg[1]) |
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1610 && !VIM_ISWHITE(arg[1]) |
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1611 && (arg[1] != '\\' |
30417
6a1862bfb280
patch 9.0.0544: minor issues with setting a string option
Bram Moolenaar <Bram@vim.org>
parents:
30409
diff
changeset
|
1612 || (s == newval && arg[2] != '\\'))) |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1613 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1614 ) |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1615 ++arg; // remove backslash |
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1616 if (has_mbyte && (i = (*mb_ptr2len)(arg)) > 1) |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1617 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1618 // copy multibyte char |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1619 mch_memmove(s, arg, (size_t)i); |
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1620 arg += i; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1621 s += i; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1622 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1623 else |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1624 *s++ = *arg++; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1625 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1626 *s = NUL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1627 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1628 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1629 * Expand environment variables and ~. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1630 * Don't do it when adding without inserting a comma. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1631 */ |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1632 if (op == OP_NONE || (flags & P_COMMA)) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1633 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1634 s = option_expand(opt_idx, newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1635 if (s != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1636 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1637 vim_free(newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1638 newlen = (unsigned)STRLEN(s) + 1; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1639 if (op != OP_NONE) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1640 newlen += (unsigned)STRLEN(origval) + 1; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1641 newval = alloc(newlen); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1642 if (newval == NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1643 return FAIL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1644 STRCPY(newval, s); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1645 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1646 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1647 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1648 // locate newval[] in origval[] when removing it |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1649 // and when adding to avoid duplicates |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1650 int len = 0; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1651 if (op == OP_REMOVING || (flags & P_NODUP)) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1652 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1653 len = (int)STRLEN(newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1654 s = find_dup_item(origval, newval, flags); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1655 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1656 // do not add if already there |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1657 if ((op == OP_ADDING || op == OP_PREPENDING) && s != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1658 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1659 op = OP_NONE; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1660 STRCPY(newval, origval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1661 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1662 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1663 // if no duplicate, move pointer to end of original value |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1664 if (s == NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1665 s = origval + (int)STRLEN(origval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1666 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1667 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1668 // concatenate the two strings; add a ',' if needed |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1669 if (op == OP_ADDING || op == OP_PREPENDING) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1670 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1671 comma = ((flags & P_COMMA) && *origval != NUL && *newval != NUL); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1672 if (op == OP_ADDING) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1673 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1674 len = (int)STRLEN(origval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1675 // strip a trailing comma, would get 2 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1676 if (comma && len > 1 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1677 && (flags & P_ONECOMMA) == P_ONECOMMA |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1678 && origval[len - 1] == ',' |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1679 && origval[len - 2] != '\\') |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1680 len--; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1681 mch_memmove(newval + len + comma, newval, STRLEN(newval) + 1); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1682 mch_memmove(newval, origval, (size_t)len); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1683 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1684 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1685 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1686 len = (int)STRLEN(newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1687 STRMOVE(newval + len + comma, origval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1688 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1689 if (comma) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1690 newval[len] = ','; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1691 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1692 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1693 // Remove newval[] from origval[]. (Note: "len" has been set above and |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1694 // is used here). |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1695 if (op == OP_REMOVING) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1696 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1697 STRCPY(newval, origval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1698 if (*s) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1699 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1700 // may need to remove a comma |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1701 if (flags & P_COMMA) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1702 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1703 if (s == origval) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1704 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1705 // include comma after string |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1706 if (s[len] == ',') |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1707 ++len; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1708 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1709 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1710 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1711 // include comma before string |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1712 --s; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1713 ++len; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1714 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1715 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1716 STRMOVE(newval + (s - origval), s + len); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1717 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1718 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1719 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1720 if (flags & P_FLAGLIST) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1721 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1722 // Remove flags that appear twice. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1723 for (s = newval; *s;) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1724 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1725 // if options have P_FLAGLIST and P_ONECOMMA such as |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1726 // 'whichwrap' |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1727 if (flags & P_ONECOMMA) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1728 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1729 if (*s != ',' && *(s + 1) == ',' |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1730 && vim_strchr(s + 2, *s) != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1731 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1732 // Remove the duplicated value and the next comma. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1733 STRMOVE(s, s + 2); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1734 continue; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1735 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1736 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1737 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1738 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1739 if ((!(flags & P_COMMA) || *s != ',') |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1740 && vim_strchr(s + 1, *s) != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1741 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1742 STRMOVE(s, s + 1); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1743 continue; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1744 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1745 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1746 ++s; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1747 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1748 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1749 |
30417
6a1862bfb280
patch 9.0.0544: minor issues with setting a string option
Bram Moolenaar <Bram@vim.org>
parents:
30409
diff
changeset
|
1750 if (save_arg != NULL) |
6a1862bfb280
patch 9.0.0544: minor issues with setting a string option
Bram Moolenaar <Bram@vim.org>
parents:
30409
diff
changeset
|
1751 arg = save_arg; // arg was temporarily changed, restore it |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1752 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1753 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1754 /* |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1755 * Set the new value. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1756 */ |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1757 *(char_u **)(varp) = newval; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1758 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1759 #if defined(FEAT_EVAL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1760 if (!starting |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1761 # ifdef FEAT_CRYPT |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1762 && options[opt_idx].indir != PV_KEY |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1763 # endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1764 && origval != NULL && newval != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1765 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1766 // origval may be freed by did_set_string_option(), make a copy. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1767 saved_origval = vim_strsave(origval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1768 // newval (and varp) may become invalid if the buffer is closed by |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1769 // autocommands. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1770 saved_newval = vim_strsave(newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1771 if (origval_l != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1772 saved_origval_l = vim_strsave(origval_l); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1773 if (origval_g != NULL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1774 saved_origval_g = vim_strsave(origval_g); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1775 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1776 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1777 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1778 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1779 long_u *p = insecure_flag(opt_idx, opt_flags); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1780 int secure_saved = secure; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1781 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1782 // When an option is set in the sandbox, from a modeline or in secure |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1783 // mode, then deal with side effects in secure mode. Also when the |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1784 // value was set with the P_INSECURE flag and is not completely |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1785 // replaced. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1786 if ((opt_flags & OPT_MODELINE) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1787 #ifdef HAVE_SANDBOX |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1788 || sandbox != 0 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1789 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1790 || (op != OP_NONE && (*p & P_INSECURE))) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1791 secure = 1; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1792 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1793 // Handle side effects, and set the global value for ":set" on local |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1794 // options. Note: when setting 'syntax' or 'filetype' autocommands may |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1795 // be triggered that can cause havoc. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1796 *errmsg = did_set_string_option( |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1797 opt_idx, (char_u **)varp, oldval, errbuf, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1798 opt_flags, value_checked); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1799 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1800 secure = secure_saved; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1801 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1802 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1803 #if defined(FEAT_EVAL) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1804 if (*errmsg == NULL) |
31259
a7dba627a21b
patch 9.0.0963: function name does not match autocmd event name
Bram Moolenaar <Bram@vim.org>
parents:
31174
diff
changeset
|
1805 trigger_optionset_string(opt_idx, opt_flags, saved_origval, |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1806 saved_origval_l, saved_origval_g, saved_newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1807 vim_free(saved_origval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1808 vim_free(saved_origval_l); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1809 vim_free(saved_origval_g); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1810 vim_free(saved_newval); |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1811 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1812 |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1813 *argp = arg; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1814 return *errmsg == NULL ? OK : FAIL; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1815 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1816 |
7 | 1817 /* |
31908
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
1818 * Set a boolean option. |
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
1819 * Returns an untranslated error message or NULL. |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1820 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1821 static char * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1822 do_set_option_bool( |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1823 int opt_idx, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1824 int opt_flags, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1825 set_prefix_T prefix, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1826 long_u flags, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1827 char_u *varp, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1828 int nextchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1829 int afterchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1830 int cp_val) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1831 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1832 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1833 varnumber_T value; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1834 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1835 if (nextchar == '=' || nextchar == ':') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1836 return e_invalid_argument; |
31908
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
1837 if (opt_idx < 0 || varp == NULL) |
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
1838 return NULL; // "cannot happen" |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1839 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1840 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1841 * ":set opt!": invert |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1842 * ":set opt&": reset to default value |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1843 * ":set opt<": reset to global value |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1844 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1845 if (nextchar == '!') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1846 value = *(int *)(varp) ^ 1; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1847 else if (nextchar == '&') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1848 value = (int)(long)(long_i)options[opt_idx].def_val[ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1849 ((flags & P_VI_DEF) || cp_val) ? VI_DEFAULT : VIM_DEFAULT]; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1850 else if (nextchar == '<') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1851 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1852 // For 'autoread' -1 means to use global value. |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1853 if ((int *)varp == &curbuf->b_p_ar && opt_flags == OPT_LOCAL) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1854 value = -1; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1855 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1856 value = *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1857 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1858 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1859 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1860 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1861 * ":set invopt": invert |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1862 * ":set opt" or ":set noopt": set or reset |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1863 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1864 if (nextchar != NUL && !VIM_ISWHITE(afterchar)) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1865 return e_trailing_characters; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1866 if (prefix == PREFIX_INV) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1867 value = *(int *)(varp) ^ 1; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1868 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1869 value = prefix == PREFIX_NO ? 0 : 1; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1870 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1871 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1872 return set_bool_option(opt_idx, varp, (int)value, opt_flags); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1873 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1874 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1875 /* |
31908
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
1876 * Set a numeric option. |
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
1877 * Returns an untranslated error message or NULL. |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1878 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1879 static char * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1880 do_set_option_numeric( |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1881 int opt_idx, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1882 int opt_flags, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1883 char_u **argp, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1884 int nextchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1885 set_op_T op, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1886 long_u flags, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1887 int cp_val, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1888 char_u *varp, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1889 char *errbuf, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1890 size_t errbuflen) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1891 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1892 char_u *arg = *argp; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1893 varnumber_T value; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1894 int i; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1895 char *errmsg = NULL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1896 |
31908
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
1897 if (opt_idx < 0 || varp == NULL) |
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
1898 return NULL; // "cannot happen" |
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
1899 // |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1900 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1901 * Different ways to set a number option: |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1902 * & set to default value |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1903 * < set to global value |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1904 * <xx> accept special key codes for 'wildchar' |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1905 * c accept any non-digit for 'wildchar' |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1906 * [-]0-9 set number |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1907 * other error |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1908 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1909 ++arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1910 if (nextchar == '&') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1911 value = (long)(long_i)options[opt_idx].def_val[ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1912 ((flags & P_VI_DEF) || cp_val) ? VI_DEFAULT : VIM_DEFAULT]; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1913 else if (nextchar == '<') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1914 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1915 // For 'undolevels' NO_LOCAL_UNDOLEVEL means to |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1916 // use the global value. |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1917 if ((long *)varp == &curbuf->b_p_ul && opt_flags == OPT_LOCAL) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1918 value = NO_LOCAL_UNDOLEVEL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1919 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1920 value = *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1921 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1922 else if (((long *)varp == &p_wc || (long *)varp == &p_wcm) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1923 && (*arg == '<' |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1924 || *arg == '^' |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1925 || (*arg != NUL |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1926 && (!arg[1] || VIM_ISWHITE(arg[1])) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1927 && !VIM_ISDIGIT(*arg)))) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1928 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1929 value = string_to_key(arg, FALSE); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1930 if (value == 0 && (long *)varp != &p_wcm) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1931 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1932 errmsg = e_invalid_argument; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1933 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1934 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1935 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1936 else if (*arg == '-' || VIM_ISDIGIT(*arg)) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1937 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1938 // Allow negative (for 'undolevels'), octal and hex numbers. |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1939 vim_str2nr(arg, NULL, &i, STR2NR_ALL, &value, NULL, 0, TRUE); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1940 if (i == 0 || (arg[i] != NUL && !VIM_ISWHITE(arg[i]))) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1941 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1942 errmsg = e_number_required_after_equal; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1943 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1944 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1945 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1946 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1947 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1948 errmsg = e_number_required_after_equal; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1949 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1950 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1951 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1952 if (op == OP_ADDING) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1953 value = *(long *)varp + value; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1954 else if (op == OP_PREPENDING) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1955 value = *(long *)varp * value; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1956 else if (op == OP_REMOVING) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1957 value = *(long *)varp - value; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1958 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1959 errmsg = set_num_option(opt_idx, varp, value, errbuf, errbuflen, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1960 opt_flags); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1961 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1962 skip: |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1963 *argp = arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1964 return errmsg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1965 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1966 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1967 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1968 * Set a key code (t_xx) option |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1969 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1970 static char * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1971 do_set_option_keycode(char_u **argp, char_u *key_name, int nextchar) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1972 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1973 char_u *arg = *argp; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1974 char_u *p; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1975 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1976 if (nextchar == '&') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1977 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1978 if (add_termcap_entry(key_name, TRUE) == FAIL) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1979 return e_not_found_in_termcap; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1980 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1981 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1982 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1983 ++arg; // jump to after the '=' or ':' |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1984 for (p = arg; *p && !VIM_ISWHITE(*p); ++p) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1985 if (*p == '\\' && p[1] != NUL) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1986 ++p; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1987 nextchar = *p; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1988 *p = NUL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1989 add_termcode(key_name, arg, FALSE); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1990 *p = nextchar; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1991 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1992 if (full_screen) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1993 ttest(FALSE); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1994 redraw_all_later(UPD_CLEAR); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1995 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1996 *argp = arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1997 return NULL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1998 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1999 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2000 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2001 * Set an option to a new value. |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2002 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2003 static char * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2004 do_set_option_value( |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2005 int opt_idx, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2006 int opt_flags, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2007 char_u **argp, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2008 set_prefix_T prefix, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2009 set_op_T op, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2010 long_u flags, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2011 char_u *varp, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2012 char_u *key_name, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2013 int nextchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2014 int afterchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2015 int cp_val, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2016 int *stopopteval, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2017 char *errbuf, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2018 size_t errbuflen) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2019 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2020 int value_checked = FALSE; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2021 char *errmsg = NULL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2022 char_u *arg = *argp; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2023 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2024 if (flags & P_BOOL) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2025 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2026 // boolean option |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2027 errmsg = do_set_option_bool(opt_idx, opt_flags, prefix, flags, varp, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2028 nextchar, afterchar, cp_val); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2029 if (errmsg != NULL) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2030 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2031 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2032 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2033 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2034 // numeric or string option |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2035 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2036 || prefix != PREFIX_NONE) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2037 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2038 errmsg = e_invalid_argument; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2039 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2040 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2041 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2042 if (flags & P_NUM) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2043 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2044 // numeric option |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2045 errmsg = do_set_option_numeric(opt_idx, opt_flags, &arg, nextchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2046 op, flags, cp_val, varp, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2047 errbuf, errbuflen); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2048 if (errmsg != NULL) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2049 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2050 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2051 else if (opt_idx >= 0) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2052 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2053 // string option |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2054 if (do_set_string(opt_idx, opt_flags, &arg, nextchar, op, flags, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2055 cp_val, varp, errbuf, &value_checked, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2056 &errmsg) == FAIL) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2057 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2058 if (errmsg != NULL) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2059 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2060 *stopopteval = TRUE; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2061 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2062 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2063 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2064 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2065 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2066 // key code option |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2067 errmsg = do_set_option_keycode(&arg, key_name, nextchar); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2068 if (errmsg != NULL) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2069 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2070 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2071 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2072 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2073 if (opt_idx >= 0) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2074 did_set_option(opt_idx, opt_flags, op == OP_NONE, value_checked); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2075 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2076 skip: |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2077 *argp = arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2078 return errmsg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2079 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2080 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2081 /* |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2082 * Set an option to a new value. |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2083 * Return NULL if OK, return an untranslated error message when something is |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2084 * wrong. "errbuf[errbuflen]" can be used to create the error message. |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2085 */ |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2086 static char * |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2087 do_set_option( |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2088 int opt_flags, |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2089 char_u **argp, |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2090 char_u *arg_start, |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2091 char_u **startarg, |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2092 int *did_show, |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2093 int *stopopteval, |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2094 char *errbuf, |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2095 size_t errbuflen) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2096 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2097 int opt_idx; |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2098 char_u *arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2099 set_prefix_T prefix; // no prefix, "no" prefix or "inv" prefix |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2100 set_op_T op; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2101 long_u flags; // flags for current option |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2102 char_u *varp; // pointer to variable for current option |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2103 char_u key_name[2]; |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2104 int nextchar; // next non-white char after option name |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2105 int afterchar; // character just after option name |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2106 char *errmsg = NULL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2107 int key; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2108 int len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2109 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2110 prefix = get_option_prefix(argp); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2111 arg = *argp; |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2112 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2113 // find end of name |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2114 key = 0; |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2115 if (parse_option_name(arg, &opt_idx, &len, &key) == FAIL) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2116 return e_invalid_argument; |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2117 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2118 // remember character after option name |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2119 afterchar = arg[len]; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2120 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2121 if (in_vim9script()) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2122 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2123 char_u *p = skipwhite(arg + len); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2124 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2125 // disallow white space before =val, +=val, -=val, ^=val |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2126 if (p > arg + len && (p[0] == '=' |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2127 || (vim_strchr((char_u *)"+-^", p[0]) != NULL |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2128 && p[1] == '='))) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2129 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2130 errmsg = e_no_white_space_allowed_between_option_and; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2131 arg = p; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2132 *startarg = p; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2133 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2134 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2135 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2136 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2137 // skip white space, allow ":set ai ?", ":set hlsearch !" |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2138 while (VIM_ISWHITE(arg[len])) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2139 ++len; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2140 |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2141 op = get_opt_op(arg + len); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2142 if (op != OP_NONE) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2143 len++; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2144 |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2145 nextchar = arg[len]; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2146 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2147 if (opt_idx == -1 && key == 0) // found a mismatch: skip |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2148 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2149 if (in_vim9script() && arg > arg_start |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2150 && vim_strchr((char_u *)"!&<", *arg) != NULL) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2151 errmsg = e_no_white_space_allowed_between_option_and; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2152 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2153 errmsg = e_unknown_option; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2154 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2155 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2156 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2157 if (opt_idx >= 0) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2158 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2159 if (options[opt_idx].var == NULL) // hidden option: skip |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2160 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2161 // Only give an error message when requesting the value of |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2162 // a hidden option, ignore setting it. |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2163 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2164 && (!(options[opt_idx].flags & P_BOOL) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2165 || nextchar == '?')) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2166 errmsg = e_option_not_supported; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2167 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2168 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2169 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2170 flags = options[opt_idx].flags; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2171 varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2172 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2173 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2174 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2175 flags = P_STRING; |
31904
a4358b58d3fb
patch 9.0.1284: compiler warnings for uninitialized variables
Bram Moolenaar <Bram@vim.org>
parents:
31902
diff
changeset
|
2176 varp = NULL; |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2177 if (key < 0) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2178 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2179 key_name[0] = KEY2TERMCAP0(key); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2180 key_name[1] = KEY2TERMCAP1(key); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2181 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2182 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2183 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2184 key_name[0] = KS_KEY; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2185 key_name[1] = (key & 0xff); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2186 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2187 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2188 |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2189 // Make sure the option value can be changed. |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2190 if (validate_opt_idx(opt_idx, opt_flags, flags, &errmsg) == FAIL) |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2191 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2192 |
31904
a4358b58d3fb
patch 9.0.1284: compiler warnings for uninitialized variables
Bram Moolenaar <Bram@vim.org>
parents:
31902
diff
changeset
|
2193 int cp_val = p_cp; |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2194 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2195 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2196 arg += len; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2197 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2198 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2199 if (arg[3] == 'm') // "opt&vim": set to Vim default |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2200 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2201 cp_val = FALSE; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2202 arg += 3; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2203 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2204 else // "opt&vi": set to Vi default |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2205 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2206 cp_val = TRUE; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2207 arg += 2; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2208 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2209 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2210 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2211 && arg[1] != NUL && !VIM_ISWHITE(arg[1])) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2212 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2213 errmsg = e_trailing_characters; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2214 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2215 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2216 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2217 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2218 /* |
31908
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
2219 * Allow '=' and ':' for historical reasons (MSDOS command.com). |
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
2220 * Allows only one '=' character per "set" command line. grrr. (jw) |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2221 */ |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2222 if (nextchar == '?' |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2223 || (prefix == PREFIX_NONE |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2224 && vim_strchr((char_u *)"=:&<", nextchar) == NULL |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2225 && !(flags & P_BOOL))) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2226 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2227 /* |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2228 * print value |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2229 */ |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2230 if (*did_show) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2231 msg_putchar('\n'); // cursor below last one |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2232 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2233 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2234 gotocmdline(TRUE); // cursor at status line |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2235 *did_show = TRUE; // remember that we did a line |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2236 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2237 if (opt_idx >= 0) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2238 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2239 showoneopt(&options[opt_idx], opt_flags); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2240 #ifdef FEAT_EVAL |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2241 if (p_verbose > 0) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2242 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2243 // Mention where the option was last set. |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2244 if (varp == options[opt_idx].var) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2245 last_set_msg(options[opt_idx].script_ctx); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2246 else if ((int)options[opt_idx].indir & PV_WIN) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2247 last_set_msg(curwin->w_p_script_ctx[ |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2248 (int)options[opt_idx].indir & PV_MASK]); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2249 else if ((int)options[opt_idx].indir & PV_BUF) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2250 last_set_msg(curbuf->b_p_script_ctx[ |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2251 (int)options[opt_idx].indir & PV_MASK]); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2252 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2253 #endif |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2254 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2255 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2256 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2257 char_u *p; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2258 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2259 p = find_termcode(key_name); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2260 if (p == NULL) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2261 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2262 errmsg = e_key_code_not_set; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2263 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2264 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2265 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2266 (void)show_one_termcode(key_name, p, TRUE); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2267 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2268 if (nextchar != '?' |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2269 && nextchar != NUL && !VIM_ISWHITE(afterchar)) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2270 errmsg = e_trailing_characters; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2271 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2272 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2273 { |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2274 errmsg = do_set_option_value(opt_idx, opt_flags, &arg, prefix, op, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2275 flags, varp, key_name, nextchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2276 afterchar, cp_val, stopopteval, errbuf, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2277 errbuflen); |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2278 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2279 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2280 skip: |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2281 *argp = arg; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2282 return errmsg; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2283 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2284 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2285 /* |
7 | 2286 * Parse 'arg' for option settings. |
2287 * | |
2288 * 'arg' may be IObuff, but only when no errors can be present and option | |
2289 * does not need to be expanded with option_expand(). | |
2290 * "opt_flags": | |
2291 * 0 for ":set" | |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
2292 * OPT_GLOBAL for ":setglobal" |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
2293 * OPT_LOCAL for ":setlocal" and a modeline |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
2294 * OPT_MODELINE for a modeline |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
2295 * OPT_WINONLY to only set window-local options |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
2296 * OPT_NOWIN to skip setting window-local options |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
2297 * OPT_ONECOLUMN do not use multiple columns |
7 | 2298 * |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2299 * Returns FAIL if an error is detected, OK otherwise. |
7 | 2300 */ |
2301 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2302 do_set( |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
2303 char_u *arg_start, // option string (may be written to!) |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2304 int opt_flags) |
7 | 2305 { |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
2306 char_u *arg = arg_start; |
7 | 2307 int i; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2308 int did_show = FALSE; // already showed one value |
7 | 2309 |
2310 if (*arg == NUL) | |
2311 { | |
2312 showoptions(0, opt_flags); | |
168 | 2313 did_show = TRUE; |
2314 goto theend; | |
7 | 2315 } |
2316 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2317 while (*arg != NUL) // loop to process all options |
7 | 2318 { |
31766
9f1504e36ae9
patch 9.0.1215: using isalpha() adds dependency on current locale
Bram Moolenaar <Bram@vim.org>
parents:
31752
diff
changeset
|
2319 if (STRNCMP(arg, "all", 3) == 0 && !ASCII_ISALPHA(arg[3]) |
36 | 2320 && !(opt_flags & OPT_MODELINE)) |
7 | 2321 { |
2322 /* | |
2323 * ":set all" show all options. | |
2324 * ":set all&" set all options to their default value. | |
2325 */ | |
2326 arg += 3; | |
2327 if (*arg == '&') | |
2328 { | |
2329 ++arg; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2330 // Only for :set command set global value of local options. |
7 | 2331 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
|
2332 didset_options(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2333 didset_options2(); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
2334 redraw_all_later(UPD_CLEAR); |
7 | 2335 } |
2336 else | |
168 | 2337 { |
7 | 2338 showoptions(1, opt_flags); |
168 | 2339 did_show = TRUE; |
2340 } | |
7 | 2341 } |
36 | 2342 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) |
7 | 2343 { |
2344 showoptions(2, opt_flags); | |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
2345 show_termcodes(opt_flags); |
168 | 2346 did_show = TRUE; |
7 | 2347 arg += 7; |
2348 } | |
2349 else | |
2350 { | |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2351 int stopopteval = FALSE; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2352 char *errmsg = NULL; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2353 char errbuf[80]; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2354 char_u *startarg = arg; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2355 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2356 errmsg = do_set_option(opt_flags, &arg, arg_start, &startarg, |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2357 &did_show, &stopopteval, errbuf, |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2358 sizeof(errbuf)); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2359 if (stopopteval) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2360 break; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2361 |
7 | 2362 /* |
2363 * Advance to next argument. | |
2364 * - skip until a blank found, taking care of backslashes | |
2365 * - skip blanks | |
2366 * - skip one "=val" argument (for hidden options ":set gfn =xx") | |
2367 */ | |
2368 for (i = 0; i < 2 ; ++i) | |
2369 { | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2370 while (*arg != NUL && !VIM_ISWHITE(*arg)) |
7 | 2371 if (*arg++ == '\\' && *arg != NUL) |
2372 ++arg; | |
2373 arg = skipwhite(arg); | |
2374 if (*arg != '=') | |
2375 break; | |
2376 } | |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2377 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2378 if (errmsg != NULL) |
7 | 2379 { |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2380 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2381 i = (int)STRLEN(IObuff) + 2; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2382 if (i + (arg - startarg) < IOSIZE) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2383 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2384 // append the argument with the error |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2385 STRCAT(IObuff, ": "); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2386 mch_memmove(IObuff + i, startarg, (arg - startarg)); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2387 IObuff[i + (arg - startarg)] = NUL; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2388 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2389 // make sure all characters are printable |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2390 trans_characters(IObuff, IOSIZE); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2391 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2392 ++no_wait_return; // wait_return() done later |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2393 emsg((char *)IObuff); // show error highlighted |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2394 --no_wait_return; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2395 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2396 return FAIL; |
7 | 2397 } |
2398 } | |
2399 | |
2400 arg = skipwhite(arg); | |
2401 } | |
2402 | |
168 | 2403 theend: |
2404 if (silent_mode && did_show) | |
2405 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2406 // After displaying option values in silent mode. |
168 | 2407 silent_mode = FALSE; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2408 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
168 | 2409 msg_putchar('\n'); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2410 cursor_on(); // msg_start() switches it off |
168 | 2411 out_flush(); |
2412 silent_mode = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2413 info_message = FALSE; // use mch_msg(), not mch_errmsg() |
168 | 2414 } |
2415 | |
7 | 2416 return OK; |
2417 } | |
2418 | |
634 | 2419 /* |
2420 * Call this when an option has been given a new value through a user command. | |
2421 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag. | |
2422 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2423 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2424 did_set_option( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2425 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
|
2426 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
|
2427 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
|
2428 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
|
2429 // P_INSECURE flag. |
634 | 2430 { |
681 | 2431 long_u *p; |
2432 | |
634 | 2433 options[opt_idx].flags |= P_WAS_SET; |
2434 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2435 // 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
|
2436 // 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
|
2437 // flag. |
681 | 2438 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
|
2439 if (!value_checked && (secure |
634 | 2440 #ifdef HAVE_SANDBOX |
2441 || sandbox != 0 | |
2442 #endif | |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2443 || (opt_flags & OPT_MODELINE))) |
681 | 2444 *p = *p | P_INSECURE; |
2445 else if (new_value) | |
2446 *p = *p & ~P_INSECURE; | |
634 | 2447 } |
2448 | |
7 | 2449 /* |
2450 * Convert a key name or string into a key value. | |
2451 * 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
|
2452 * 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
|
2453 */ |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2454 int |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2455 string_to_key(char_u *arg, int multi_byte) |
7 | 2456 { |
2457 if (*arg == '<') | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
2458 return find_key_option(arg + 1, TRUE); |
7 | 2459 if (*arg == '^') |
2460 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
|
2461 if (multi_byte) |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2462 return PTR2CHAR(arg); |
7 | 2463 return *arg; |
2464 } | |
2465 | |
2466 /* | |
2467 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call | |
2468 * maketitle() to create and display it. | |
2469 * When switching the title or icon off, call mch_restore_title() to get | |
2470 * the old value back. | |
2471 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2472 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
|
2473 did_set_title(void) |
7 | 2474 { |
2475 if (starting != NO_SCREEN | |
2476 #ifdef FEAT_GUI | |
2477 && !gui.starting | |
2478 #endif | |
2479 ) | |
2480 maketitle(); | |
2481 } | |
2482 | |
2483 /* | |
2484 * set_options_bin - called when 'bin' changes value. | |
2485 */ | |
2486 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2487 set_options_bin( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2488 int oldval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2489 int newval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2490 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 2491 { |
2492 /* | |
2493 * The option values that are changed when 'bin' changes are | |
2494 * copied when 'bin is set and restored when 'bin' is reset. | |
2495 */ | |
2496 if (newval) | |
2497 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2498 if (!oldval) // switched on |
7 | 2499 { |
2500 if (!(opt_flags & OPT_GLOBAL)) | |
2501 { | |
2502 curbuf->b_p_tw_nobin = curbuf->b_p_tw; | |
2503 curbuf->b_p_wm_nobin = curbuf->b_p_wm; | |
2504 curbuf->b_p_ml_nobin = curbuf->b_p_ml; | |
2505 curbuf->b_p_et_nobin = curbuf->b_p_et; | |
2506 } | |
2507 if (!(opt_flags & OPT_LOCAL)) | |
2508 { | |
2509 p_tw_nobin = p_tw; | |
2510 p_wm_nobin = p_wm; | |
2511 p_ml_nobin = p_ml; | |
2512 p_et_nobin = p_et; | |
2513 } | |
2514 } | |
2515 | |
2516 if (!(opt_flags & OPT_GLOBAL)) | |
2517 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2518 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
|
2519 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
|
2520 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
|
2521 curbuf->b_p_et = 0; // no expandtab |
7 | 2522 } |
2523 if (!(opt_flags & OPT_LOCAL)) | |
2524 { | |
2525 p_tw = 0; | |
2526 p_wm = 0; | |
2527 p_ml = FALSE; | |
2528 p_et = FALSE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2529 p_bin = TRUE; // needed when called for the "-b" argument |
7 | 2530 } |
2531 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2532 else if (oldval) // switched off |
7 | 2533 { |
2534 if (!(opt_flags & OPT_GLOBAL)) | |
2535 { | |
2536 curbuf->b_p_tw = curbuf->b_p_tw_nobin; | |
2537 curbuf->b_p_wm = curbuf->b_p_wm_nobin; | |
2538 curbuf->b_p_ml = curbuf->b_p_ml_nobin; | |
2539 curbuf->b_p_et = curbuf->b_p_et_nobin; | |
2540 } | |
2541 if (!(opt_flags & OPT_LOCAL)) | |
2542 { | |
2543 p_tw = p_tw_nobin; | |
2544 p_wm = p_wm_nobin; | |
2545 p_ml = p_ml_nobin; | |
2546 p_et = p_et_nobin; | |
2547 } | |
2548 } | |
2549 } | |
2550 | |
2551 /* | |
2552 * Expand environment variables for some string options. | |
2553 * These string options cannot be indirect! | |
2554 * If "val" is NULL expand the current value of the option. | |
2555 * Return pointer to NameBuff, or NULL when not expanded. | |
2556 */ | |
2557 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2558 option_expand(int opt_idx, char_u *val) |
7 | 2559 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2560 // if option doesn't need expansion nothing to do |
7 | 2561 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) |
2562 return NULL; | |
2563 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2564 // 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
|
2565 // expand_env() would truncate the string. |
7 | 2566 if (val != NULL && STRLEN(val) > MAXPATHL) |
2567 return NULL; | |
2568 | |
2569 if (val == NULL) | |
2570 val = *(char_u **)options[opt_idx].var; | |
2571 | |
2572 /* | |
2573 * Expanding this with NameBuff, expand_env() must not be passed IObuff. | |
2574 * Escape spaces when expanding 'tags', they are used to separate file | |
2575 * names. | |
374 | 2576 * For 'spellsuggest' expand after "file:". |
7 | 2577 */ |
2578 expand_env_esc(val, NameBuff, MAXPATHL, | |
1408 | 2579 (char_u **)options[opt_idx].var == &p_tags, FALSE, |
744 | 2580 #ifdef FEAT_SPELL |
374 | 2581 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : |
2582 #endif | |
2583 NULL); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2584 if (STRCMP(NameBuff, val) == 0) // they are the same |
7 | 2585 return NULL; |
2586 | |
2587 return NameBuff; | |
2588 } | |
2589 | |
2590 /* | |
2591 * After setting various option values: recompute variables that depend on | |
2592 * option values. | |
2593 */ | |
2594 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2595 didset_options(void) |
7 | 2596 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2597 // initialize the table for 'iskeyword' et.al. |
7 | 2598 (void)init_chartab(); |
2599 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2600 didset_string_options(); |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2601 |
744 | 2602 #ifdef FEAT_SPELL |
484 | 2603 (void)spell_check_msm(); |
374 | 2604 (void)spell_check_sps(); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
2605 (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
|
2606 (void)did_set_spell_option(TRUE); |
344 | 2607 #endif |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2608 // set cedit_key |
7 | 2609 (void)check_cedit(); |
5995 | 2610 #ifdef FEAT_LINEBREAK |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2611 // initialize the table for 'breakat'. |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2612 fill_breakat_flags(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2613 #endif |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2614 after_copy_winopt(curwin); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2615 } |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2616 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2617 /* |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2618 * More side effects of setting options. |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2619 */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2620 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2621 didset_options2(void) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2622 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2623 // Initialize the highlight_attr[] table. |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2624 (void)highlight_changed(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2625 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2626 // Parse default for 'wildmode' |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2627 check_opt_wim(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2628 |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2629 // Parse default for 'listchars'. |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2630 (void)set_chars_option(curwin, &curwin->w_p_lcs, TRUE); |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2631 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2632 // Parse default for 'fillchars'. |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2633 (void)set_chars_option(curwin, &curwin->w_p_fcs, TRUE); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2634 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2635 #ifdef FEAT_CLIPBOARD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2636 // Parse default for 'clipboard' |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2637 (void)check_clipboard_option(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2638 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2639 #ifdef FEAT_VARTABS |
15858
3a45b89639fb
patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2640 vim_free(curbuf->b_p_vsts_array); |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
2641 (void)tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array); |
15858
3a45b89639fb
patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2642 vim_free(curbuf->b_p_vts_array); |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
2643 (void)tabstop_set(curbuf->b_p_vts, &curbuf->b_p_vts_array); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2644 #endif |
7 | 2645 } |
2646 | |
2647 /* | |
2648 * Check for string options that are NULL (normally only termcap options). | |
2649 */ | |
2650 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2651 check_options(void) |
7 | 2652 { |
2653 int opt_idx; | |
2654 | |
2655 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) | |
2656 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL) | |
2657 check_string_option((char_u **)get_varp(&(options[opt_idx]))); | |
2658 } | |
2659 | |
2660 /* | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2661 * 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
|
2662 * 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
|
2663 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2664 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2665 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
|
2666 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2667 int opt_idx; |
7 | 2668 |
2669 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) | |
2670 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
|
2671 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
|
2672 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
|
2673 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2674 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2675 /* |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2676 * 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
|
2677 * 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
|
2678 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2679 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2680 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
|
2681 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2682 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
|
2683 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2684 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
|
2685 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
|
2686 return opt_idx; |
7 | 2687 } |
2688 | |
634 | 2689 #if defined(FEAT_EVAL) || defined(PROTO) |
2690 /* | |
2691 * Return TRUE when option "opt" was set from a modeline or in secure mode. | |
2692 * Return FALSE when it wasn't. | |
2693 * Return -1 for an unknown option. | |
2694 */ | |
2695 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2696 was_set_insecurely(char_u *opt, int opt_flags) |
634 | 2697 { |
2698 int idx = findoption(opt); | |
681 | 2699 long_u *flagp; |
634 | 2700 |
2701 if (idx >= 0) | |
681 | 2702 { |
2703 flagp = insecure_flag(idx, opt_flags); | |
2704 return (*flagp & P_INSECURE) != 0; | |
2705 } | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
2706 internal_error("was_set_insecurely()"); |
634 | 2707 return -1; |
2708 } | |
681 | 2709 |
2710 /* | |
2711 * Get a pointer to the flags used for the P_INSECURE flag of option | |
2712 * "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
|
2713 * 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
|
2714 * the option is used. |
681 | 2715 */ |
2716 static long_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2717 insecure_flag(int opt_idx, int opt_flags) |
681 | 2718 { |
2719 if (opt_flags & OPT_LOCAL) | |
2720 switch ((int)options[opt_idx].indir) | |
2721 { | |
2722 #ifdef FEAT_STL_OPT | |
694 | 2723 case PV_STL: return &curwin->w_p_stl_flags; |
681 | 2724 #endif |
2725 #ifdef FEAT_EVAL | |
885 | 2726 # ifdef FEAT_FOLDING |
694 | 2727 case PV_FDE: return &curwin->w_p_fde_flags; |
2728 case PV_FDT: return &curwin->w_p_fdt_flags; | |
885 | 2729 # endif |
790 | 2730 # ifdef FEAT_BEVAL |
2731 case PV_BEXPR: return &curbuf->b_p_bexpr_flags; | |
2732 # endif | |
694 | 2733 case PV_INDE: return &curbuf->b_p_inde_flags; |
2734 case PV_FEX: return &curbuf->b_p_fex_flags; | |
681 | 2735 # ifdef FEAT_FIND_ID |
694 | 2736 case PV_INEX: return &curbuf->b_p_inex_flags; |
681 | 2737 # endif |
2738 #endif | |
2739 } | |
2740 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2741 // Nothing special, return global flags field. |
681 | 2742 return &options[opt_idx].flags; |
2743 } | |
634 | 2744 #endif |
2745 | |
1805 | 2746 /* |
2747 * Redraw the window title and/or tab page text later. | |
2748 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2749 void redraw_titles(void) |
1805 | 2750 { |
2751 need_maketitle = TRUE; | |
2752 redraw_tabline = TRUE; | |
2753 } | |
2754 | |
7 | 2755 /* |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2756 * 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
|
2757 * 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
|
2758 */ |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17845
diff
changeset
|
2759 int |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2760 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
|
2761 { |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2762 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
|
2763 |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2764 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
|
2765 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
|
2766 return FALSE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2767 return TRUE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2768 } |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2769 |
681 | 2770 #if defined(FEAT_EVAL) || defined(PROTO) |
2771 /* | |
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
|
2772 * Set the script_ctx for an option, taking care of setting the buffer- or |
694 | 2773 * window-local value. |
681 | 2774 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2775 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
|
2776 set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx) |
694 | 2777 { |
2778 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; | |
2779 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
|
2780 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
|
2781 |
20269
246101db63a4
patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents:
20237
diff
changeset
|
2782 // 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
|
2783 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
|
2784 new_script_ctx.sc_lnum += SOURCING_LNUM; |
694 | 2785 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2786 // 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
|
2787 // in the buffer or window structure. |
694 | 2788 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
|
2789 options[opt_idx].script_ctx = new_script_ctx; |
694 | 2790 if (both || (opt_flags & OPT_LOCAL)) |
2791 { | |
2792 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
|
2793 curbuf->b_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
694 | 2794 else if (indir & PV_WIN) |
27289
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
2795 { |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2796 curwin->w_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
27289
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
2797 if (both) |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
2798 // also setting the "all buffers" value |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
2799 curwin->w_allbuf_opt.wo_script_ctx[indir & PV_MASK] = |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
2800 new_script_ctx; |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
2801 } |
694 | 2802 } |
681 | 2803 } |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2804 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2805 /* |
27303
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2806 * Get the script context of global option "name". |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2807 * |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2808 */ |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2809 sctx_T * |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2810 get_option_sctx(char *name) |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2811 { |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2812 int idx = findoption((char_u *)name); |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2813 |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2814 if (idx >= 0) |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2815 return &options[idx].script_ctx; |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2816 siemsg("no such option: %s", name); |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2817 return NULL; |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2818 } |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2819 |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
2820 /* |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2821 * 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
|
2822 * "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
|
2823 * 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
|
2824 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2825 void |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2826 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
|
2827 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2828 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
|
2829 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
|
2830 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2831 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
|
2832 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
|
2833 else |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2834 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2835 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
|
2836 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
|
2837 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
|
2838 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
|
2839 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
|
2840 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
|
2841 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2842 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
|
2843 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
|
2844 } |
681 | 2845 #endif |
2846 | |
19405
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2847 #if defined(FEAT_EVAL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2848 /* |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2849 * Apply the OptionSet autocommand. |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2850 */ |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2851 static void |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2852 apply_optionset_autocmd( |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2853 int opt_idx, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2854 long opt_flags, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2855 long oldval, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2856 long oldval_g, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2857 long newval, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2858 char *errmsg) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2859 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2860 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
|
2861 |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2862 // 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
|
2863 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
|
2864 return; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2865 |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2866 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
|
2867 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
|
2868 oldval_g); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2869 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
|
2870 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
|
2871 (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
|
2872 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
|
2873 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
|
2874 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
|
2875 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
|
2876 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2877 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
|
2878 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
|
2879 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2880 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
|
2881 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2882 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
|
2883 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
|
2884 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2885 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
|
2886 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2887 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
|
2888 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
|
2889 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
|
2890 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2891 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
|
2892 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2893 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
|
2894 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
|
2895 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2896 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
|
2897 NULL, FALSE, NULL); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2898 reset_v_option_vars(); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2899 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2900 #endif |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2901 |
7 | 2902 /* |
2903 * Set the value of a boolean option, and take care of side effects. | |
2904 * Returns NULL for success, or an error message for an error. | |
2905 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
2906 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2907 set_bool_option( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2908 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
|
2909 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
|
2910 int value, // new value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2911 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 2912 { |
2913 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
|
2914 #if defined(FEAT_EVAL) |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2915 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
|
2916 #endif |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
2917 char *errmsg = NULL; |
7 | 2918 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2919 // Disallow changing some options from secure mode |
7 | 2920 if ((secure |
2921 #ifdef HAVE_SANDBOX | |
2922 || sandbox != 0 | |
2923 #endif | |
2924 ) && (options[opt_idx].flags & P_SECURE)) | |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
2925 return e_not_allowed_here; |
7 | 2926 |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
2927 #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
|
2928 // 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
|
2929 // 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
|
2930 // 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
|
2931 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
|
2932 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
|
2933 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
|
2934 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
2935 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2936 *(int *)varp = value; // set the new value |
7 | 2937 #ifdef FEAT_EVAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2938 // 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
|
2939 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 2940 #endif |
2941 | |
634 | 2942 #ifdef FEAT_GUI |
2943 need_mouse_correct = TRUE; | |
2944 #endif | |
2945 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2946 // May set global value for local option. |
7 | 2947 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
2948 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; | |
2949 | |
2950 /* | |
2951 * Handle side effects of changing a bool option. | |
2952 */ | |
2953 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2954 // 'compatible' |
7 | 2955 if ((int *)varp == &p_cp) |
2956 compatible_set(); | |
2957 | |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2958 #ifdef FEAT_LANGMAP |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2959 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
|
2960 // 'langremap' -> !'langnoremap' |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2961 p_lnr = !p_lrm; |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2962 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
|
2963 // 'langnoremap' -> !'langremap' |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2964 p_lrm = !p_lnr; |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2965 #endif |
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9877
diff
changeset
|
2966 |
3246 | 2967 #ifdef FEAT_PERSISTENT_UNDO |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2968 // 'undofile' |
3246 | 2969 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) |
2970 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2971 // 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
|
2972 // 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
|
2973 // any changes in between. |
3894 | 2974 if (curbuf->b_p_udf || p_udf) |
2975 { | |
2976 char_u hash[UNDO_HASH_SIZE]; | |
2977 buf_T *save_curbuf = curbuf; | |
2978 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
2979 FOR_ALL_BUFFERS(curbuf) |
3894 | 2980 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2981 // 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
|
2982 // 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
|
2983 // 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
|
2984 // loaded |
3894 | 2985 if ((curbuf == save_curbuf |
3246 | 2986 || (opt_flags & OPT_GLOBAL) || opt_flags == 0) |
3894 | 2987 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) |
2988 { | |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2989 #ifdef FEAT_CRYPT |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2990 if (crypt_get_method_nr(curbuf) == CRYPT_M_SOD) |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2991 continue; |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2992 #endif |
3894 | 2993 u_compute_hash(hash); |
2994 u_read_undo(NULL, hash, curbuf->b_fname); | |
2995 } | |
2996 } | |
2997 curbuf = save_curbuf; | |
2998 } | |
3246 | 2999 } |
3000 #endif | |
3001 | |
7 | 3002 else if ((int *)varp == &curbuf->b_p_ro) |
3003 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3004 // when 'readonly' is reset globally, also reset readonlymode |
7 | 3005 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) |
3006 readonlymode = FALSE; | |
548 | 3007 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3008 // when 'readonly' is set may give W10 again |
548 | 3009 if (curbuf->b_p_ro) |
3010 curbuf->b_did_warn = FALSE; | |
3011 | |
1805 | 3012 redraw_titles(); |
7 | 3013 } |
3014 | |
2362
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3015 #ifdef FEAT_GUI |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3016 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
|
3017 { |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3018 if (!p_mh) |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3019 gui_mch_mousehide(FALSE); |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3020 } |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3021 #endif |
6cee3bf00495
When resetting 'mousehide' show the mouse pointer right away.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3022 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3023 // when 'modifiable' is changed, redraw the window title |
7 | 3024 else if ((int *)varp == &curbuf->b_p_ma) |
1805 | 3025 { |
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
|
3026 # ifdef FEAT_TERMINAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3027 // 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
|
3028 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
|
3029 && 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
|
3030 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
3031 curbuf->b_p_ma = FALSE; |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
3032 return e_cannot_make_terminal_with_running_job_modifiable; |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
3033 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
3034 # endif |
1805 | 3035 redraw_titles(); |
26336
a2e6da79274d
patch 8.2.3699: the +title feature adds a lot of #ifdef but little code
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
3036 } |
31000
2a1a4a13b396
patch 9.0.0835: the window title is not redrawn when 'endoffile' changes
Bram Moolenaar <Bram@vim.org>
parents:
30966
diff
changeset
|
3037 // redraw the window title and tab page text when 'endoffile', 'endofline', |
2a1a4a13b396
patch 9.0.0835: the window title is not redrawn when 'endoffile' changes
Bram Moolenaar <Bram@vim.org>
parents:
30966
diff
changeset
|
3038 // 'fixeol' or 'bomb' is changed |
2a1a4a13b396
patch 9.0.0835: the window title is not redrawn when 'endoffile' changes
Bram Moolenaar <Bram@vim.org>
parents:
30966
diff
changeset
|
3039 else if ((int *)varp == &curbuf->b_p_eof |
2a1a4a13b396
patch 9.0.0835: the window title is not redrawn when 'endoffile' changes
Bram Moolenaar <Bram@vim.org>
parents:
30966
diff
changeset
|
3040 || (int *)varp == &curbuf->b_p_eol |
2a1a4a13b396
patch 9.0.0835: the window title is not redrawn when 'endoffile' changes
Bram Moolenaar <Bram@vim.org>
parents:
30966
diff
changeset
|
3041 || (int *)varp == &curbuf->b_p_fixeol |
2a1a4a13b396
patch 9.0.0835: the window title is not redrawn when 'endoffile' changes
Bram Moolenaar <Bram@vim.org>
parents:
30966
diff
changeset
|
3042 || (int *)varp == &curbuf->b_p_bomb) |
1805 | 3043 { |
3044 redraw_titles(); | |
3045 } | |
7 | 3046 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3047 // when 'bin' is set also set some other options |
7 | 3048 else if ((int *)varp == &curbuf->b_p_bin) |
3049 { | |
3050 set_options_bin(old_value, curbuf->b_p_bin, opt_flags); | |
1805 | 3051 redraw_titles(); |
7 | 3052 } |
3053 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3054 // when 'buflisted' changes, trigger autocommands |
7 | 3055 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) |
3056 { | |
3057 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, | |
3058 NULL, NULL, TRUE, curbuf); | |
3059 } | |
3060 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3061 // when 'swf' is set, create swapfile, when reset remove swapfile |
7 | 3062 else if ((int *)varp == &curbuf->b_p_swf) |
3063 { | |
3064 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
|
3065 ml_open_file(curbuf); // create the swap file |
7 | 3066 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3067 // 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
|
3068 // buf->b_p_swf |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3069 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
|
3070 } |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3071 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3072 // when 'terse' is set change 'shortmess' |
7 | 3073 else if ((int *)varp == &p_terse) |
3074 { | |
3075 char_u *p; | |
3076 | |
3077 p = vim_strchr(p_shm, SHM_SEARCH); | |
3078 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3079 // insert 's' in p_shm |
7 | 3080 if (p_terse && p == NULL) |
3081 { | |
3082 STRCPY(IObuff, p_shm); | |
3083 STRCAT(IObuff, "s"); | |
694 | 3084 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); |
7 | 3085 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3086 // remove 's' from p_shm |
7 | 3087 else if (!p_terse && p != NULL) |
1622 | 3088 STRMOVE(p, p + 1); |
7 | 3089 } |
3090 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3091 // when 'paste' is set or reset also change other options |
7 | 3092 else if ((int *)varp == &p_paste) |
3093 { | |
3094 paste_option_changed(); | |
3095 } | |
3096 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3097 // when 'insertmode' is set from an autocommand need to do work here |
7 | 3098 else if ((int *)varp == &p_im) |
3099 { | |
3100 if (p_im) | |
3101 { | |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
3102 if ((State & MODE_INSERT) == 0) |
7 | 3103 need_start_insertmode = TRUE; |
3104 stop_insert_mode = FALSE; | |
3105 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3106 // 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
|
3107 else if (old_value) |
7 | 3108 { |
3109 need_start_insertmode = FALSE; | |
3110 stop_insert_mode = TRUE; | |
644 | 3111 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
|
3112 clear_cmdline = TRUE; // remove "(insert)" |
7 | 3113 restart_edit = 0; |
3114 } | |
3115 } | |
3116 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3117 // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw |
7 | 3118 else if ((int *)varp == &p_ic && p_hls) |
3119 { | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
3120 redraw_all_later(UPD_SOME_VALID); |
7 | 3121 } |
3122 | |
3123 #ifdef FEAT_SEARCH_EXTRA | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3124 // when 'hlsearch' is set or reset: reset no_hlsearch |
7 | 3125 else if ((int *)varp == &p_hls) |
3126 { | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13774
diff
changeset
|
3127 set_no_hlsearch(FALSE); |
7 | 3128 } |
3129 #endif | |
3130 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3131 // 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
|
3132 // at the end of normal_cmd() |
7 | 3133 else if ((int *)varp == &curwin->w_p_scb) |
3134 { | |
3135 if (curwin->w_p_scb) | |
5157
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
3136 { |
7 | 3137 do_check_scrollbind(FALSE); |
5157
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
3138 curwin->w_scbind_pos = curwin->w_topline; |
7a6ce0c426fe
updated for version 7.4a.005
Bram Moolenaar <bram@vim.org>
parents:
5102
diff
changeset
|
3139 } |
7 | 3140 } |
3141 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
3142 #if defined(FEAT_QUICKFIX) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3143 // There can be only one window with 'previewwindow' set. |
7 | 3144 else if ((int *)varp == &curwin->w_p_pvw) |
3145 { | |
3146 if (curwin->w_p_pvw) | |
3147 { | |
3148 win_T *win; | |
3149 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
3150 FOR_ALL_WINDOWS(win) |
7 | 3151 if (win->w_p_pvw && win != curwin) |
3152 { | |
3153 curwin->w_p_pvw = FALSE; | |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
3154 return e_preview_window_already_exists; |
7 | 3155 } |
3156 } | |
3157 } | |
3158 #endif | |
3159 | |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
3160 else if ((int *)varp == &curwin->w_p_sms) |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
3161 { |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
3162 if (!curwin->w_p_sms) |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
3163 { |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
3164 curwin->w_skipcol = 0; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
3165 changed_line_abv_curs(); |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
3166 } |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
3167 } |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
3168 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3169 // when 'textmode' is set or reset also change 'fileformat' |
7 | 3170 else if ((int *)varp == &curbuf->b_p_tx) |
3171 { | |
3172 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); | |
3173 } | |
3174 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3175 // when 'textauto' is set or reset also change 'fileformats' |
7 | 3176 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
|
3177 { |
7 | 3178 set_string_option_direct((char_u *)"ffs", -1, |
3179 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", | |
694 | 3180 OPT_FREE | opt_flags, 0); |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
16082
diff
changeset
|
3181 } |
7 | 3182 |
3183 /* | |
3184 * When 'lisp' option changes include/exclude '-' in | |
3185 * keyword characters. | |
3186 */ | |
3187 else if (varp == (char_u *)&(curbuf->b_p_lisp)) | |
3188 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3189 (void)buf_init_chartab(curbuf, FALSE); // ignore errors |
7 | 3190 } |
3191 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3192 // 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
|
3193 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
|
3194 { |
1d25a3e8e03c
patch 8.1.0061: window title is wrong after resetting and setting 'title'
Christian Brabandt <cb@256bit.org>
parents:
14057
diff
changeset
|
3195 did_set_title(); |
7 | 3196 } |
3197 | |
3198 else if ((int *)varp == &curbuf->b_changed) | |
3199 { | |
3200 if (!value) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3201 save_file_ff(curbuf); // Buffer is unchanged |
1805 | 3202 redraw_titles(); |
7 | 3203 modified_was_set = value; |
3204 } | |
3205 | |
3206 #ifdef BACKSLASH_IN_FILENAME | |
3207 else if ((int *)varp == &p_ssl) | |
3208 { | |
3209 if (p_ssl) | |
3210 { | |
3211 psepc = '/'; | |
3212 psepcN = '\\'; | |
3213 pseps[0] = '/'; | |
3214 } | |
3215 else | |
3216 { | |
3217 psepc = '\\'; | |
3218 psepcN = '/'; | |
3219 pseps[0] = '\\'; | |
3220 } | |
3221 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3222 // need to adjust the file name arguments and buffer names. |
7 | 3223 buflist_slash_adjust(); |
3224 alist_slash_adjust(); | |
3225 # ifdef FEAT_EVAL | |
3226 scriptnames_slash_adjust(); | |
3227 # endif | |
3228 } | |
3229 #endif | |
3230 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3231 // If 'wrap' is set, set w_leftcol to zero. |
7 | 3232 else if ((int *)varp == &curwin->w_p_wrap) |
3233 { | |
3234 if (curwin->w_p_wrap) | |
3235 curwin->w_leftcol = 0; | |
3236 } | |
3237 | |
3238 else if ((int *)varp == &p_ea) | |
3239 { | |
3240 if (p_ea && !old_value) | |
3241 win_equal(curwin, FALSE, 0); | |
3242 } | |
3243 | |
3244 else if ((int *)varp == &p_wiv) | |
3245 { | |
3246 /* | |
3247 * When 'weirdinvert' changed, set/reset 't_xs'. | |
3248 * Then set 'weirdinvert' according to value of 't_xs'. | |
3249 */ | |
3250 if (p_wiv && !old_value) | |
3251 T_XS = (char_u *)"y"; | |
3252 else if (!p_wiv && old_value) | |
3253 T_XS = empty_option; | |
3254 p_wiv = (*T_XS != NUL); | |
3255 } | |
3256 | |
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
|
3257 #ifdef FEAT_BEVAL_GUI |
7 | 3258 else if ((int *)varp == &p_beval) |
3259 { | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3260 if (!balloonEvalForTerm) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3261 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3262 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
|
3263 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
|
3264 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
|
3265 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
|
3266 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3267 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3268 #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
|
3269 #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
|
3270 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
|
3271 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3272 mch_bevalterm_changed(); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3273 } |
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
|
3274 #endif |
820 | 3275 |
3276 #ifdef FEAT_AUTOCHDIR | |
7 | 3277 else if ((int *)varp == &p_acd) |
3278 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3279 // 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
|
3280 DO_AUTOCHDIR; |
7 | 3281 } |
3282 #endif | |
3283 | |
3284 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3285 // 'diff' |
7 | 3286 else if ((int *)varp == &curwin->w_p_diff) |
3287 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3288 // May add or remove the buffer from the list of diff buffers. |
16 | 3289 diff_buf_adjust(curwin); |
3290 # ifdef FEAT_FOLDING | |
7 | 3291 if (foldmethodIsDiff(curwin)) |
3292 foldUpdateAll(curwin); | |
16 | 3293 # endif |
7 | 3294 } |
3295 #endif | |
3296 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3297 #ifdef HAVE_INPUT_METHOD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3298 // 'imdisable' |
7 | 3299 else if ((int *)varp == &p_imdisable) |
3300 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3301 // Only de-activate it here, it will be enabled when changing mode. |
7 | 3302 if (p_imdisable) |
3303 im_set_active(FALSE); | |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
3304 else if (State & MODE_INSERT) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3305 // 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
|
3306 // effect right away. |
3129 | 3307 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); |
7 | 3308 } |
3309 #endif | |
3310 | |
744 | 3311 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3312 // 'spell' |
258 | 3313 else if ((int *)varp == &curwin->w_p_spell) |
3314 { | |
3315 if (curwin->w_p_spell) | |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
3316 errmsg = did_set_spelllang(curwin); |
258 | 3317 } |
3318 #endif | |
3319 | |
7 | 3320 #ifdef FEAT_ARABIC |
3321 if ((int *)varp == &curwin->w_p_arab) | |
3322 { | |
3323 if (curwin->w_p_arab) | |
3324 { | |
3325 /* | |
3326 * 'arabic' is set, handle various sub-settings. | |
3327 */ | |
3328 if (!p_tbidi) | |
3329 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3330 // set rightleft mode |
7 | 3331 if (!curwin->w_p_rl) |
3332 { | |
3333 curwin->w_p_rl = TRUE; | |
3334 changed_window_setting(); | |
3335 } | |
3336 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3337 // Enable Arabic shaping (major part of what Arabic requires) |
7 | 3338 if (!p_arshape) |
3339 { | |
3340 p_arshape = TRUE; | |
3341 redraw_later_clear(); | |
3342 } | |
3343 } | |
3344 | |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
26721
diff
changeset
|
3345 // Arabic requires a utf-8 encoding, inform the user if it's not |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3346 // set. |
7 | 3347 if (STRCMP(p_enc, "utf-8") != 0) |
16 | 3348 { |
1848 | 3349 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); |
3350 | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
3351 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
|
3352 msg_attr(_(w_arabic), HL_ATTR(HLF_W)); |
1848 | 3353 #ifdef FEAT_EVAL |
3354 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); | |
3355 #endif | |
16 | 3356 } |
7 | 3357 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3358 // set 'delcombine' |
7 | 3359 p_deco = TRUE; |
3360 | |
3361 # ifdef FEAT_KEYMAP | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3362 // Force-set the necessary keymap for arabic |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
3363 errmsg = set_option_value((char_u *)"keymap", |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
3364 0L, (char_u *)"arabic", OPT_LOCAL); |
7 | 3365 # endif |
3366 } | |
3367 else | |
3368 { | |
3369 /* | |
3370 * 'arabic' is reset, handle various sub-settings. | |
3371 */ | |
3372 if (!p_tbidi) | |
3373 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3374 // reset rightleft mode |
7 | 3375 if (curwin->w_p_rl) |
3376 { | |
3377 curwin->w_p_rl = FALSE; | |
3378 changed_window_setting(); | |
3379 } | |
3380 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3381 // '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
|
3382 // another window may still need it "on". |
7 | 3383 } |
3384 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3385 // '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
|
3386 // window may still want it "on". |
7 | 3387 |
3388 # ifdef FEAT_KEYMAP | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3389 // Revert to the default keymap |
7 | 3390 curbuf->b_p_iminsert = B_IMODE_NONE; |
3391 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; | |
3392 # endif | |
3393 } | |
3443 | 3394 } |
3395 | |
1958 | 3396 #endif |
3397 | |
17827
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3398 #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
|
3399 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
|
3400 || (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
|
3401 && gui.in_use |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3402 && (*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
|
3403 && curbuf->b_signlist != NULL) |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3404 { |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3405 // 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
|
3406 // '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
|
3407 // 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
|
3408 // 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
|
3409 // '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
|
3410 // (optimization). |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3411 if (!(curwin->w_p_nu && ((int *)varp == &curwin->w_p_rnu))) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
3412 redraw_all_later(UPD_CLEAR); |
17827
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3413 } |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3414 #endif |
6de5558c5242
patch 8.1.1910: redrawing too much when toggling 'relativenumber'
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3415 |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3416 #ifdef FEAT_TERMGUICOLORS |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3417 // 'termguicolors' |
9027
773d627cac0b
commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents:
8969
diff
changeset
|
3418 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
|
3419 { |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3420 # ifdef FEAT_VTP |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3421 // 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
|
3422 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
|
3423 # 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
|
3424 !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
|
3425 # 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
|
3426 !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
|
3427 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3428 p_tgc = 0; |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
3429 return e_24_bit_colors_are_not_supported_on_this_environment; |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3430 } |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3431 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
|
3432 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
|
3433 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3434 # ifdef FEAT_GUI |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3435 if (!gui.in_use && !gui.starting) |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3436 # endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3437 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
|
3438 # ifdef FEAT_VTP |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3439 // 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
|
3440 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
|
3441 { |
2bebc49116fd
patch 8.1.0123: MS-Windows: colors are wrong after setting 'notgc'
Christian Brabandt <cb@256bit.org>
parents:
14194
diff
changeset
|
3442 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
|
3443 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
|
3444 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
|
3445 } |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3446 # endif |
26193
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26175
diff
changeset
|
3447 # ifdef FEAT_TERMINAL |
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26175
diff
changeset
|
3448 term_update_colors_all(); |
28919
99c1356f4210
patch 8.2.4982: colors in terminal window are not 100% correct
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
3449 term_update_palette_all(); |
26193
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26175
diff
changeset
|
3450 term_update_wincolor_all(); |
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26175
diff
changeset
|
3451 # endif |
8969
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3452 } |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3453 #endif |
c83e2c1e7f2b
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents:
8941
diff
changeset
|
3454 |
7 | 3455 /* |
3456 * End of handling side effects for bool options. | |
3457 */ | |
3458 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3459 // after handling side effects, call autocommand |
6935 | 3460 |
7 | 3461 options[opt_idx].flags |= P_WAS_SET; |
3462 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3463 #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
|
3464 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
|
3465 (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
|
3466 (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
|
3467 (long)(value ? TRUE : FALSE), NULL); |
6935 | 3468 #endif |
3469 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3470 comp_col(); // in case 'ruler' or 'showcmd' changed |
3443 | 3471 if (curwin->w_curswant != MAXCOL |
6669 | 3472 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 3473 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
|
3474 |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3475 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
|
3476 check_redraw(options[opt_idx].flags); |
7 | 3477 |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
3478 return errmsg; |
7 | 3479 } |
3480 | |
3481 /* | |
3482 * Set the value of a number option, and take care of side effects. | |
3483 * Returns NULL for success, or an error message for an error. | |
3484 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3485 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3486 set_num_option( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3487 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
|
3488 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
|
3489 long value, // new value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3490 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
|
3491 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
|
3492 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
|
3493 // OPT_MODELINE, etc. |
7 | 3494 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3495 char *errmsg = NULL; |
7 | 3496 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
|
3497 #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
|
3498 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
|
3499 // 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
|
3500 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3501 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
|
3502 long old_Columns = Columns; // remember old Columns |
7 | 3503 long *pp = (long *)varp; |
3504 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3505 // Disallow changing some options from secure mode. |
634 | 3506 if ((secure |
3507 #ifdef HAVE_SANDBOX | |
3508 || sandbox != 0 | |
3509 #endif | |
3510 ) && (options[opt_idx].flags & P_SECURE)) | |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3511 return e_not_allowed_here; |
7 | 3512 |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3513 #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
|
3514 // 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
|
3515 // 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
|
3516 // 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
|
3517 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
|
3518 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
|
3519 OPT_GLOBAL); |
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3520 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3521 |
7 | 3522 *pp = value; |
3523 #ifdef FEAT_EVAL | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3524 // 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
|
3525 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 3526 #endif |
634 | 3527 #ifdef FEAT_GUI |
3528 need_mouse_correct = TRUE; | |
3529 #endif | |
7 | 3530 |
3740 | 3531 if (curbuf->b_p_sw < 0) |
7 | 3532 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3533 errmsg = e_argument_must_be_positive; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3534 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3535 // 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
|
3536 curbuf->b_p_sw = tabstop_count(curbuf->b_p_vts_array) > 0 |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
3537 ? tabstop_first(curbuf->b_p_vts_array) |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3538 : curbuf->b_p_ts; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
3539 #else |
7 | 3540 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
|
3541 #endif |
7 | 3542 } |
3543 | |
3544 /* | |
3545 * Number options that need some action when changed | |
3546 */ | |
3547 if (pp == &p_wh || pp == &p_hh) | |
3548 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3549 // 'winheight' and 'helpheight' |
7 | 3550 if (p_wh < 1) |
3551 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3552 errmsg = e_argument_must_be_positive; |
7 | 3553 p_wh = 1; |
3554 } | |
3555 if (p_wmh > p_wh) | |
3556 { | |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3557 errmsg = e_winheight_cannot_be_smaller_than_winminheight; |
7 | 3558 p_wh = p_wmh; |
3559 } | |
3560 if (p_hh < 0) | |
3561 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3562 errmsg = e_argument_must_be_positive; |
7 | 3563 p_hh = 0; |
3564 } | |
3565 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3566 // Change window height NOW |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10340
diff
changeset
|
3567 if (!ONE_WINDOW) |
7 | 3568 { |
3569 if (pp == &p_wh && curwin->w_height < p_wh) | |
3570 win_setheight((int)p_wh); | |
3571 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) | |
3572 win_setheight((int)p_hh); | |
3573 } | |
3574 } | |
3575 else if (pp == &p_wmh) | |
3576 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3577 // 'winminheight' |
7 | 3578 if (p_wmh < 0) |
3579 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3580 errmsg = e_argument_must_be_positive; |
7 | 3581 p_wmh = 0; |
3582 } | |
3583 if (p_wmh > p_wh) | |
3584 { | |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3585 errmsg = e_winheight_cannot_be_smaller_than_winminheight; |
7 | 3586 p_wmh = p_wh; |
3587 } | |
3588 win_setminheight(); | |
3589 } | |
13 | 3590 else if (pp == &p_wiw) |
7 | 3591 { |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3592 // 'winwidth' |
7 | 3593 if (p_wiw < 1) |
3594 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3595 errmsg = e_argument_must_be_positive; |
7 | 3596 p_wiw = 1; |
3597 } | |
3598 if (p_wmw > p_wiw) | |
3599 { | |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3600 errmsg = e_winwidth_cannot_be_smaller_than_winminwidth; |
7 | 3601 p_wiw = p_wmw; |
3602 } | |
3603 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3604 // Change window width NOW |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10340
diff
changeset
|
3605 if (!ONE_WINDOW && curwin->w_width < p_wiw) |
7 | 3606 win_setwidth((int)p_wiw); |
3607 } | |
3608 else if (pp == &p_wmw) | |
3609 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3610 // 'winminwidth' |
7 | 3611 if (p_wmw < 0) |
3612 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3613 errmsg = e_argument_must_be_positive; |
7 | 3614 p_wmw = 0; |
3615 } | |
3616 if (p_wmw > p_wiw) | |
3617 { | |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3618 errmsg = e_winwidth_cannot_be_smaller_than_winminwidth; |
7 | 3619 p_wmw = p_wiw; |
3620 } | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14029
diff
changeset
|
3621 win_setminwidth(); |
7 | 3622 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
3623 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3624 // (re)set last window status line |
7 | 3625 else if (pp == &p_ls) |
3626 { | |
3627 last_status(FALSE); | |
3628 } | |
670 | 3629 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3630 // (re)set tab page line |
677 | 3631 else if (pp == &p_stal) |
670 | 3632 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3633 shell_new_rows(); // recompute window positions and heights |
670 | 3634 } |
7 | 3635 |
3636 #ifdef FEAT_GUI | |
3637 else if (pp == &p_linespace) | |
3638 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3639 // 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
|
3640 // same number of lines. |
444 | 3641 if (gui.in_use && gui_mch_adjust_charheight() == OK) |
813 | 3642 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); |
7 | 3643 } |
3644 #endif | |
3645 | |
3646 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3647 // 'foldlevel' |
7 | 3648 else if (pp == &curwin->w_p_fdl) |
3649 { | |
3650 if (curwin->w_p_fdl < 0) | |
3651 curwin->w_p_fdl = 0; | |
3652 newFoldLevel(); | |
3653 } | |
3654 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3655 // 'foldminlines' |
7 | 3656 else if (pp == &curwin->w_p_fml) |
3657 { | |
3658 foldUpdateAll(curwin); | |
3659 } | |
3660 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3661 // 'foldnestmax' |
7 | 3662 else if (pp == &curwin->w_p_fdn) |
3663 { | |
3664 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) | |
3665 foldUpdateAll(curwin); | |
3666 } | |
3667 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3668 // 'foldcolumn' |
7 | 3669 else if (pp == &curwin->w_p_fdc) |
3670 { | |
3671 if (curwin->w_p_fdc < 0) | |
3672 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3673 errmsg = e_argument_must_be_positive; |
7 | 3674 curwin->w_p_fdc = 0; |
3675 } | |
3676 else if (curwin->w_p_fdc > 12) | |
3677 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3678 errmsg = e_invalid_argument; |
7 | 3679 curwin->w_p_fdc = 12; |
3680 } | |
3681 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3682 #endif // FEAT_FOLDING |
5438 | 3683 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3684 // 'shiftwidth' or 'tabstop' |
7 | 3685 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) |
3686 { | |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
3687 #ifdef FEAT_FOLDING |
7 | 3688 if (foldmethodIsIndent(curwin)) |
3689 foldUpdateAll(curwin); | |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
3690 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3691 // 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
|
3692 // parse 'cinoptions'. |
5438 | 3693 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) |
3694 parse_cino(curbuf); | |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
3695 } |
7 | 3696 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3697 // 'maxcombine' |
714 | 3698 else if (pp == &p_mco) |
3699 { | |
3700 if (p_mco > MAX_MCO) | |
3701 p_mco = MAX_MCO; | |
3702 else if (p_mco < 0) | |
3703 p_mco = 0; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3704 screenclear(); // will re-allocate the screen |
714 | 3705 } |
3706 | |
7 | 3707 else if (pp == &curbuf->b_p_iminsert) |
3708 { | |
3709 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) | |
3710 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3711 errmsg = e_invalid_argument; |
7 | 3712 curbuf->b_p_iminsert = B_IMODE_NONE; |
3713 } | |
3714 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
|
3715 if (termcap_active) // don't do this in the alternate screen |
7 | 3716 showmode(); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
3717 #if defined(FEAT_KEYMAP) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3718 // Show/unshow value of 'keymap' in status lines. |
7 | 3719 status_redraw_curbuf(); |
3720 #endif | |
3721 } | |
3722 | |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3723 #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
|
3724 // 'imstyle' |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3725 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
|
3726 { |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3727 if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3728 errmsg = e_invalid_argument; |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3729 } |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3730 #endif |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
12259
diff
changeset
|
3731 |
164 | 3732 else if (pp == &p_window) |
3733 { | |
3734 if (p_window < 1) | |
3735 p_window = 1; | |
3736 else if (p_window >= Rows) | |
3737 p_window = Rows - 1; | |
3738 } | |
3739 | |
7 | 3740 else if (pp == &curbuf->b_p_imsearch) |
3741 { | |
3742 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) | |
3743 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3744 errmsg = e_invalid_argument; |
7 | 3745 curbuf->b_p_imsearch = B_IMODE_NONE; |
3746 } | |
3747 p_imsearch = curbuf->b_p_imsearch; | |
3748 } | |
3749 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3750 // if 'titlelen' has changed, redraw the title |
7 | 3751 else if (pp == &p_titlelen) |
3752 { | |
3753 if (p_titlelen < 0) | |
3754 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3755 errmsg = e_argument_must_be_positive; |
7 | 3756 p_titlelen = 85; |
3757 } | |
3758 if (starting != NO_SCREEN && old_value != p_titlelen) | |
3759 need_maketitle = TRUE; | |
3760 } | |
3761 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3762 // if p_ch changed value, change the command line height |
7 | 3763 else if (pp == &p_ch) |
3764 { | |
30005
bb0e525e1393
patch 9.0.0340: the 'cmdheight' zero support causes too much trouble
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
3765 if (p_ch < 1) |
7 | 3766 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3767 errmsg = e_argument_must_be_positive; |
7 | 3768 p_ch = 1; |
3769 } | |
1404 | 3770 if (p_ch > Rows - min_rows() + 1) |
3771 p_ch = Rows - min_rows() + 1; | |
7 | 3772 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3773 // 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
|
3774 // completed. Otherwise the frame sizes may be wrong. |
30671
15ac28c12c8f
patch 9.0.0670: no space for command line when there is a tabline
Bram Moolenaar <Bram@vim.org>
parents:
30661
diff
changeset
|
3775 if ((p_ch != old_value |
15ac28c12c8f
patch 9.0.0670: no space for command line when there is a tabline
Bram Moolenaar <Bram@vim.org>
parents:
30661
diff
changeset
|
3776 || tabline_height() + topframe->fr_height != Rows - p_ch) |
30661
57ebc2a4d2ca
patch 9.0.0665: setting 'cmdheight' has no effect if last window was resized
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
3777 && full_screen |
7 | 3778 #ifdef FEAT_GUI |
3779 && !gui.starting | |
3780 #endif | |
30661
57ebc2a4d2ca
patch 9.0.0665: setting 'cmdheight' has no effect if last window was resized
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
3781 ) |
824 | 3782 command_height(); |
7 | 3783 } |
3784 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3785 // when 'updatecount' changes from zero to non-zero, open swap files |
7 | 3786 else if (pp == &p_uc) |
3787 { | |
3788 if (p_uc < 0) | |
3789 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3790 errmsg = e_argument_must_be_positive; |
7 | 3791 p_uc = 100; |
3792 } | |
3793 if (p_uc && !old_value) | |
3794 ml_open_files(); | |
3795 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3796 #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
|
3797 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
|
3798 { |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3799 if (curwin->w_p_cole < 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3800 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3801 errmsg = e_argument_must_be_positive; |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3802 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
|
3803 } |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3804 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
|
3805 { |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3806 errmsg = e_invalid_argument; |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2362
diff
changeset
|
3807 curwin->w_p_cole = 3; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3808 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3809 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
3810 #endif |
16 | 3811 #ifdef MZSCHEME_GUI_THREADS |
14 | 3812 else if (pp == &p_mzq) |
3813 mzvim_reset_timer(); | |
3814 #endif | |
7 | 3815 |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3816 #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
|
3817 // 'pyxversion' |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3818 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
|
3819 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3820 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3821 errmsg = e_invalid_argument; |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3822 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3823 #endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10708
diff
changeset
|
3824 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3825 // sync undo before 'undolevels' changes |
7 | 3826 else if (pp == &p_ul) |
3827 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3828 // use the old value, otherwise u_sync() may not work properly |
7 | 3829 p_ul = old_value; |
825 | 3830 u_sync(TRUE); |
7 | 3831 p_ul = value; |
3832 } | |
5446 | 3833 else if (pp == &curbuf->b_p_ul) |
3834 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3835 // use the old value, otherwise u_sync() may not work properly |
5446 | 3836 curbuf->b_p_ul = old_value; |
3837 u_sync(TRUE); | |
3838 curbuf->b_p_ul = value; | |
3839 } | |
7 | 3840 |
13 | 3841 #ifdef FEAT_LINEBREAK |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3842 // 'numberwidth' must be positive |
13 | 3843 else if (pp == &curwin->w_p_nuw) |
3844 { | |
3845 if (curwin->w_p_nuw < 1) | |
3846 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3847 errmsg = e_argument_must_be_positive; |
13 | 3848 curwin->w_p_nuw = 1; |
3849 } | |
17229
f1c7b7a4d9e4
patch 8.1.1614: 'numberwidth' can only go up to 10
Bram Moolenaar <Bram@vim.org>
parents:
17176
diff
changeset
|
3850 if (curwin->w_p_nuw > 20) |
13 | 3851 { |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3852 errmsg = e_invalid_argument; |
17229
f1c7b7a4d9e4
patch 8.1.1614: 'numberwidth' can only go up to 10
Bram Moolenaar <Bram@vim.org>
parents:
17176
diff
changeset
|
3853 curwin->w_p_nuw = 20; |
13 | 3854 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3855 curwin->w_nrwidth_line_count = 0; // trigger a redraw |
13 | 3856 } |
3857 #endif | |
3858 | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3859 else if (pp == &curbuf->b_p_tw) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3860 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3861 if (curbuf->b_p_tw < 0) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3862 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3863 errmsg = e_argument_must_be_positive; |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3864 curbuf->b_p_tw = 0; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3865 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3866 #ifdef FEAT_SYN_HL |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3867 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3868 win_T *wp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3869 tabpage_T *tp; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3870 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3871 FOR_ALL_TAB_WINDOWS(tp, wp) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3872 check_colorcolumn(wp); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3873 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3874 #endif |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3875 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
3876 |
7 | 3877 /* |
3878 * Check the bounds for numeric options here | |
3879 */ | |
3880 if (Rows < min_rows() && full_screen) | |
3881 { | |
3882 if (errbuf != NULL) | |
3883 { | |
27426
41e0dcf38521
patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents:
27303
diff
changeset
|
3884 vim_snprintf(errbuf, errbuflen, |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
3885 _(e_need_at_least_nr_lines), min_rows()); |
7 | 3886 errmsg = errbuf; |
3887 } | |
3888 Rows = min_rows(); | |
3889 } | |
3890 if (Columns < MIN_COLUMNS && full_screen) | |
3891 { | |
3892 if (errbuf != NULL) | |
3893 { | |
27426
41e0dcf38521
patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents:
27303
diff
changeset
|
3894 vim_snprintf(errbuf, errbuflen, |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
3895 _(e_need_at_least_nr_columns), MIN_COLUMNS); |
7 | 3896 errmsg = errbuf; |
3897 } | |
3898 Columns = MIN_COLUMNS; | |
3899 } | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
5039
diff
changeset
|
3900 limit_screen_size(); |
7 | 3901 |
3902 /* | |
3903 * If the screen (shell) height has been changed, assume it is the | |
3904 * physical screenheight. | |
3905 */ | |
3906 if (old_Rows != Rows || old_Columns != Columns) | |
3907 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3908 // Changing the screen size is not allowed while updating the screen. |
7 | 3909 if (updating_screen) |
3910 *pp = old_value; | |
3911 else if (full_screen | |
3912 #ifdef FEAT_GUI | |
3913 && !gui.starting | |
3914 #endif | |
3915 ) | |
3916 set_shellsize((int)Columns, (int)Rows, TRUE); | |
3917 else | |
3918 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3919 // 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
|
3920 // messages. |
7 | 3921 check_shellsize(); |
3922 if (cmdline_row > Rows - p_ch && Rows > p_ch) | |
3923 cmdline_row = Rows - p_ch; | |
3924 } | |
857 | 3925 if (p_window >= Rows || !option_was_set((char_u *)"window")) |
164 | 3926 p_window = Rows - 1; |
7 | 3927 } |
3928 | |
3929 if (curbuf->b_p_ts <= 0) | |
3930 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3931 errmsg = e_argument_must_be_positive; |
7 | 3932 curbuf->b_p_ts = 8; |
3933 } | |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3934 else if (curbuf->b_p_ts > TABSTOP_MAX) |
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3935 { |
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3936 errmsg = e_invalid_argument; |
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3937 curbuf->b_p_ts = 8; |
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3938 } |
7 | 3939 if (p_tm < 0) |
3940 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3941 errmsg = e_argument_must_be_positive; |
7 | 3942 p_tm = 0; |
3943 } | |
3944 if ((curwin->w_p_scr <= 0 | |
3945 || (curwin->w_p_scr > curwin->w_height | |
3946 && curwin->w_height > 0)) | |
3947 && full_screen) | |
3948 { | |
3949 if (pp == &(curwin->w_p_scr)) | |
3950 { | |
3951 if (curwin->w_p_scr != 0) | |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25176
diff
changeset
|
3952 errmsg = e_invalid_scroll_size; |
7 | 3953 win_comp_scroll(curwin); |
3954 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3955 // 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
|
3956 // it. |
7 | 3957 else if (curwin->w_p_scr <= 0) |
3958 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
|
3959 else // curwin->w_p_scr > curwin->w_height |
7 | 3960 curwin->w_p_scr = curwin->w_height; |
3961 } | |
1726 | 3962 if (p_hi < 0) |
3963 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3964 errmsg = e_argument_must_be_positive; |
1726 | 3965 p_hi = 0; |
3966 } | |
5991 | 3967 else if (p_hi > 10000) |
3968 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3969 errmsg = e_invalid_argument; |
5991 | 3970 p_hi = 10000; |
3971 } | |
4444 | 3972 if (p_re < 0 || p_re > 2) |
3973 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
3974 errmsg = e_invalid_argument; |
4444 | 3975 p_re = 0; |
3976 } | |
7 | 3977 if (p_report < 0) |
3978 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3979 errmsg = e_argument_must_be_positive; |
7 | 3980 p_report = 1; |
3981 } | |
532 | 3982 if ((p_sj < -100 || p_sj >= Rows) && full_screen) |
7 | 3983 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3984 if (Rows != old_Rows) // Rows changed, just adjust p_sj |
7 | 3985 p_sj = Rows / 2; |
3986 else | |
3987 { | |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25176
diff
changeset
|
3988 errmsg = e_invalid_scroll_size; |
7 | 3989 p_sj = 1; |
3990 } | |
3991 } | |
3992 if (p_so < 0 && full_screen) | |
3993 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3994 errmsg = e_argument_must_be_positive; |
7 | 3995 p_so = 0; |
3996 } | |
3997 if (p_siso < 0 && full_screen) | |
3998 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3999 errmsg = e_argument_must_be_positive; |
7 | 4000 p_siso = 0; |
4001 } | |
4002 if (p_cwh < 1) | |
4003 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4004 errmsg = e_argument_must_be_positive; |
7 | 4005 p_cwh = 1; |
4006 } | |
4007 if (p_ut < 0) | |
4008 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4009 errmsg = e_argument_must_be_positive; |
7 | 4010 p_ut = 2000; |
4011 } | |
4012 if (p_ss < 0) | |
4013 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4014 errmsg = e_argument_must_be_positive; |
7 | 4015 p_ss = 0; |
4016 } | |
4017 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4018 // May set global value for local option. |
7 | 4019 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
4020 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; | |
4021 | |
4022 options[opt_idx].flags |= P_WAS_SET; | |
4023 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4024 #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
|
4025 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
|
4026 value, errmsg); |
6935 | 4027 #endif |
4028 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4029 comp_col(); // in case 'columns' or 'ls' changed |
3443 | 4030 if (curwin->w_curswant != MAXCOL |
6669 | 4031 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 4032 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
|
4033 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
|
4034 check_redraw(options[opt_idx].flags); |
7 | 4035 |
4036 return errmsg; | |
4037 } | |
4038 | |
4039 /* | |
4040 * Called after an option changed: check if something needs to be redrawn. | |
4041 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4042 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4043 check_redraw(long_u flags) |
7 | 4044 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4045 // Careful: P_RCLR and P_RALL are a combination of other P_ flags |
3263 | 4046 int doclear = (flags & P_RCLR) == P_RCLR; |
4047 int all = ((flags & P_RALL) == P_RALL || doclear); | |
7 | 4048 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4049 if ((flags & P_RSTAT) || all) // mark all status lines dirty |
7 | 4050 status_redraw_all(); |
4051 | |
4052 if ((flags & P_RBUF) || (flags & P_RWIN) || all) | |
4053 changed_window_setting(); | |
4054 if (flags & P_RBUF) | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
4055 redraw_curbuf_later(UPD_NOT_VALID); |
10456
536a7d49249c
commit https://github.com/vim/vim/commit/a2477fd3490c1166522631eee53c57d34321086a
Christian Brabandt <cb@256bit.org>
parents:
10424
diff
changeset
|
4056 if (flags & P_RWINONLY) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
4057 redraw_later(UPD_NOT_VALID); |
3263 | 4058 if (doclear) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
4059 redraw_all_later(UPD_CLEAR); |
7 | 4060 else if (all) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
4061 redraw_all_later(UPD_NOT_VALID); |
7 | 4062 } |
4063 | |
4064 /* | |
4065 * Find index for option 'arg'. | |
4066 * Return -1 if not found. | |
4067 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4068 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4069 findoption(char_u *arg) |
7 | 4070 { |
4071 int opt_idx; | |
4072 char *s, *p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4073 static short quick_tab[27] = {0, 0}; // quick access table |
7 | 4074 int is_term_opt; |
4075 | |
4076 /* | |
4077 * For first call: Initialize the quick-access table. | |
4078 * It contains the index for the first option that starts with a certain | |
4079 * letter. There are 26 letters, plus the first "t_" option. | |
4080 */ | |
4081 if (quick_tab[1] == 0) | |
4082 { | |
4083 p = options[0].fullname; | |
4084 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
4085 { | |
4086 if (s[0] != p[0]) | |
4087 { | |
4088 if (s[0] == 't' && s[1] == '_') | |
4089 quick_tab[26] = opt_idx; | |
4090 else | |
4091 quick_tab[CharOrdLow(s[0])] = opt_idx; | |
4092 } | |
4093 p = s; | |
4094 } | |
4095 } | |
4096 | |
4097 /* | |
4098 * Check for name starting with an illegal character. | |
4099 */ | |
4100 if (arg[0] < 'a' || arg[0] > 'z') | |
4101 return -1; | |
4102 | |
4103 is_term_opt = (arg[0] == 't' && arg[1] == '_'); | |
4104 if (is_term_opt) | |
4105 opt_idx = quick_tab[26]; | |
4106 else | |
4107 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
4108 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
4109 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4110 if (STRCMP(arg, s) == 0) // match full name |
7 | 4111 break; |
4112 } | |
4113 if (s == NULL && !is_term_opt) | |
4114 { | |
4115 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
4116 for ( ; options[opt_idx].fullname != NULL; opt_idx++) | |
4117 { | |
4118 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
|
4119 if (s != NULL && STRCMP(arg, s) == 0) // match short name |
7 | 4120 break; |
4121 s = NULL; | |
4122 } | |
4123 } | |
4124 if (s == NULL) | |
4125 opt_idx = -1; | |
4126 return opt_idx; | |
4127 } | |
4128 | |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
4129 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME) \ |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
4130 || defined(FEAT_SPELL) || defined(PROTO) |
7 | 4131 /* |
4132 * Get the value for an option. | |
4133 * | |
4134 * Returns: | |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4135 * 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
|
4136 * 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
|
4137 * 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
|
4138 * 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
|
4139 * 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
|
4140 * 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
|
4141 * Unknown option: gov_unknown. |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
4142 * |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
4143 * "flagsp" (if not NULL) is set to the option flags (P_xxxx). |
7 | 4144 */ |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4145 getoption_T |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4146 get_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4147 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4148 long *numval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4149 char_u **stringval, // NULL when only checking existence |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
4150 int *flagsp, |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
4151 int scope) |
7 | 4152 { |
4153 int opt_idx; | |
4154 char_u *varp; | |
4155 | |
4156 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
|
4157 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
|
4158 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4159 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4160 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4161 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
|
4162 && (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
|
4163 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4164 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
|
4165 char_u *p; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4166 |
26802
f6b10a501a0e
patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
4167 if (flagsp != NULL) |
f6b10a501a0e
patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
4168 *flagsp = 0; // terminal option has no flags |
f6b10a501a0e
patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
4169 |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4170 // 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
|
4171 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4172 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4173 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
|
4174 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
|
4175 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4176 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4177 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4178 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
|
4179 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
|
4180 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4181 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
|
4182 if (p != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4183 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4184 if (stringval != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4185 *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
|
4186 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
|
4187 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4188 } |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4189 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
|
4190 } |
7 | 4191 |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
4192 varp = get_varp_scope(&(options[opt_idx]), scope); |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
4193 |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
4194 if (flagsp != NULL) |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
4195 // Return the P_xxxx option flags. |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
4196 *flagsp = options[opt_idx].flags; |
7 | 4197 |
4198 if (options[opt_idx].flags & P_STRING) | |
4199 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4200 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
|
4201 return gov_hidden_string; |
7 | 4202 if (stringval != NULL) |
4203 { | |
28804
12bbd8a31cac
patch 8.2.4926: #ifdef for crypt feature around too many lines
Bram Moolenaar <Bram@vim.org>
parents:
28800
diff
changeset
|
4204 if ((char_u **)varp == &p_pt) // 'pastetoggle' |
30226
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
4205 *stringval = str2special_save(*(char_u **)(varp), FALSE, |
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
4206 FALSE); |
7 | 4207 #ifdef FEAT_CRYPT |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4208 // never return the value of the crypt key |
28804
12bbd8a31cac
patch 8.2.4926: #ifdef for crypt feature around too many lines
Bram Moolenaar <Bram@vim.org>
parents:
28800
diff
changeset
|
4209 else if ((char_u **)varp == &curbuf->b_p_key |
1622 | 4210 && **(char_u **)(varp) != NUL) |
7 | 4211 *stringval = vim_strsave((char_u *)"*****"); |
28804
12bbd8a31cac
patch 8.2.4926: #ifdef for crypt feature around too many lines
Bram Moolenaar <Bram@vim.org>
parents:
28800
diff
changeset
|
4212 #endif |
7 | 4213 else |
4214 *stringval = vim_strsave(*(char_u **)(varp)); | |
4215 } | |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4216 return gov_string; |
7 | 4217 } |
4218 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4219 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
|
4220 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
|
4221 ? gov_hidden_number : gov_hidden_bool; |
7 | 4222 if (options[opt_idx].flags & P_NUM) |
4223 *numval = *(long *)varp; | |
4224 else | |
4225 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4226 // 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
|
4227 // it set when 'ff' or 'fenc' changed. |
7 | 4228 if ((int *)varp == &curbuf->b_changed) |
4229 *numval = curbufIsChanged(); | |
4230 else | |
9395
beab399e3883
commit https://github.com/vim/vim/commit/2acfbed9dbea990f129535de7ff3df360365130b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4231 *numval = (long) *(int *)varp; |
7 | 4232 } |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4233 return (options[opt_idx].flags & P_NUM) ? gov_number : gov_bool; |
7 | 4234 } |
4235 #endif | |
4236 | |
5610 | 4237 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
4350 | 4238 /* |
4239 * Returns the option attributes and its value. Unlike the above function it | |
4240 * will return either global value or local value of the option depending on | |
4241 * what was requested, but it will never return global value if it was | |
4242 * requested to return local one and vice versa. Neither it will return | |
4243 * buffer-local value if it was requested to return window-local one. | |
4244 * | |
4245 * Pretends that option is absent if it is not present in the requested scope | |
4246 * (i.e. has no global, window-local or buffer-local value depending on | |
4247 * opt_type). Uses | |
4248 * | |
4249 * Returned flags: | |
5867 | 4250 * 0 hidden or unknown option, also option that does not have requested |
4251 * type (see SREQ_* in vim.h) | |
4350 | 4252 * see SOPT_* in vim.h for other flags |
4253 * | |
4254 * Possible opt_type values: see SREQ_* in vim.h | |
4255 */ | |
4256 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4257 get_option_value_strict( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4258 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4259 long *numval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4260 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
|
4261 int opt_type, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4262 void *from) |
4350 | 4263 { |
4264 int opt_idx; | |
4367 | 4265 char_u *varp = NULL; |
4350 | 4266 struct vimoption *p; |
4267 int r = 0; | |
4268 | |
4269 opt_idx = findoption(name); | |
4270 if (opt_idx < 0) | |
4271 return 0; | |
4272 | |
4273 p = &(options[opt_idx]); | |
4274 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4275 // Hidden option |
4350 | 4276 if (p->var == NULL) |
4277 return 0; | |
4278 | |
4279 if (p->flags & P_BOOL) | |
4280 r |= SOPT_BOOL; | |
4281 else if (p->flags & P_NUM) | |
4282 r |= SOPT_NUM; | |
4283 else if (p->flags & P_STRING) | |
4284 r |= SOPT_STRING; | |
4285 | |
4286 if (p->indir == PV_NONE) | |
4287 { | |
4288 if (opt_type == SREQ_GLOBAL) | |
4289 r |= SOPT_GLOBAL; | |
4290 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4291 return 0; // Did not request global-only option |
4350 | 4292 } |
4293 else | |
4294 { | |
4295 if (p->indir & PV_BOTH) | |
4296 r |= SOPT_GLOBAL; | |
4297 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
|
4298 return 0; // Requested global option |
4350 | 4299 |
4300 if (p->indir & PV_WIN) | |
4301 { | |
4302 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
|
4303 return 0; // Did not request window-local option |
4350 | 4304 else |
4305 r |= SOPT_WIN; | |
4306 } | |
4307 else if (p->indir & PV_BUF) | |
4308 { | |
4309 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
|
4310 return 0; // Did not request buffer-local option |
4350 | 4311 else |
4312 r |= SOPT_BUF; | |
4313 } | |
4314 } | |
4315 | |
4316 if (stringval == NULL) | |
4317 return r; | |
4318 | |
4319 if (opt_type == SREQ_GLOBAL) | |
4320 varp = p->var; | |
4321 else | |
4322 { | |
4323 if (opt_type == SREQ_BUF) | |
4324 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4325 // 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
|
4326 // consider it set when 'ff' or 'fenc' changed. |
4350 | 4327 if (p->indir == PV_MOD) |
4328 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4329 *numval = bufIsChanged((buf_T *)from); |
4350 | 4330 varp = NULL; |
4331 } | |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
4332 # ifdef FEAT_CRYPT |
4350 | 4333 else if (p->indir == PV_KEY) |
4334 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4335 // never return the value of the crypt key |
4350 | 4336 *stringval = NULL; |
4337 varp = NULL; | |
4338 } | |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
4339 # endif |
4350 | 4340 else |
4341 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4342 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
|
4343 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4344 // 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
|
4345 curbuf = (buf_T *)from; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4346 curwin->w_buffer = curbuf; |
4350 | 4347 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
|
4348 curbuf = save_curbuf; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4349 curwin->w_buffer = curbuf; |
4350 | 4350 } |
4351 } | |
4352 else if (opt_type == SREQ_WIN) | |
4353 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4354 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
|
4355 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4356 curwin = (win_T *)from; |
4350 | 4357 curbuf = curwin->w_buffer; |
4358 varp = get_varp(p); | |
4359 curwin = save_curwin; | |
4360 curbuf = curwin->w_buffer; | |
4361 } | |
4362 if (varp == p->var) | |
4363 return (r | SOPT_UNSET); | |
4364 } | |
4365 | |
4366 if (varp != NULL) | |
4367 { | |
4368 if (p->flags & P_STRING) | |
4369 *stringval = vim_strsave(*(char_u **)(varp)); | |
4370 else if (p->flags & P_NUM) | |
4371 *numval = *(long *) varp; | |
4372 else | |
4373 *numval = *(int *)varp; | |
4374 } | |
4375 | |
4376 return r; | |
4377 } | |
5610 | 4378 |
4379 /* | |
6243 | 4380 * Iterate over options. First argument is a pointer to a pointer to a |
4381 * structure inside options[] array, second is option type like in the above | |
4382 * function. | |
5610 | 4383 * |
6243 | 4384 * If first argument points to NULL it is assumed that iteration just started |
5610 | 4385 * and caller needs the very first value. |
6243 | 4386 * If first argument points to the end marker function returns NULL and sets |
5610 | 4387 * first argument to NULL. |
4388 * | |
4389 * Returns full option name for current option on each call. | |
4390 */ | |
4391 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4392 option_iter_next(void **option, int opt_type) |
5610 | 4393 { |
4394 struct vimoption *ret = NULL; | |
4395 do | |
4396 { | |
4397 if (*option == NULL) | |
4398 *option = (void *) options; | |
4399 else if (((struct vimoption *) (*option))->fullname == NULL) | |
4400 { | |
4401 *option = NULL; | |
4402 return NULL; | |
4403 } | |
4404 else | |
4405 *option = (void *) (((struct vimoption *) (*option)) + 1); | |
4406 | |
4407 ret = ((struct vimoption *) (*option)); | |
4408 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4409 // Hidden option |
5610 | 4410 if (ret->var == NULL) |
4411 { | |
4412 ret = NULL; | |
4413 continue; | |
4414 } | |
4415 | |
4416 switch (opt_type) | |
4417 { | |
4418 case SREQ_GLOBAL: | |
4419 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH)) | |
4420 ret = NULL; | |
4421 break; | |
4422 case SREQ_BUF: | |
4423 if (!(ret->indir & PV_BUF)) | |
4424 ret = NULL; | |
4425 break; | |
4426 case SREQ_WIN: | |
4427 if (!(ret->indir & PV_WIN)) | |
4428 ret = NULL; | |
4429 break; | |
4430 default: | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
4431 internal_error("option_iter_next()"); |
5610 | 4432 return NULL; |
4433 } | |
4434 } | |
4435 while (ret == NULL); | |
4436 | |
4437 return (char_u *)ret->fullname; | |
4438 } | |
4350 | 4439 #endif |
4440 | |
7 | 4441 /* |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4442 * 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
|
4443 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4444 long_u |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4445 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
|
4446 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4447 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
|
4448 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4449 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4450 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4451 * 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
|
4452 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4453 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4454 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
|
4455 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4456 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
|
4457 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4458 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4459 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4460 * 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
|
4461 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4462 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4463 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
|
4464 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4465 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
|
4466 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4467 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4468 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4469 * 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
|
4470 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4471 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4472 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
|
4473 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4474 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
|
4475 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4476 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4477 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4478 * 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
|
4479 * local value. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4480 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4481 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4482 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
|
4483 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4484 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
|
4485 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4486 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4487 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4488 * 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
|
4489 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4490 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4491 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
|
4492 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4493 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
|
4494 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4495 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4496 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4497 * 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
|
4498 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4499 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4500 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
|
4501 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4502 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
|
4503 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4504 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4505 #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
|
4506 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4507 * 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
|
4508 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4509 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4510 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
|
4511 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4512 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
|
4513 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4514 #endif |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4515 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4516 /* |
7 | 4517 * Set the value of option "name". |
4518 * 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
|
4519 * |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4520 * Returns NULL on success or an untranslated error message on error. |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4521 */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
4522 char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4523 set_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4524 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4525 long number, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4526 char_u *string, |
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 0 (both) |
7 | 4528 { |
4529 int opt_idx; | |
4530 char_u *varp; | |
835 | 4531 long_u flags; |
7 | 4532 |
4533 opt_idx = findoption(name); | |
838 | 4534 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
|
4535 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4536 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4537 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4538 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
|
4539 && (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
|
4540 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4541 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
|
4542 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4543 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4544 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4545 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
|
4546 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
|
4547 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4548 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4549 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4550 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
|
4551 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
|
4552 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4553 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
|
4554 if (full_screen) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4555 ttest(FALSE); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
4556 redraw_all_later(UPD_CLEAR); |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4557 return NULL; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4558 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4559 |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
4560 semsg(_(e_unknown_option_str_2), name); |
10825
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4561 } |
7 | 4562 else |
4563 { | |
4564 flags = options[opt_idx].flags; | |
4565 #ifdef HAVE_SANDBOX | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4566 // Disallow changing some options in the sandbox |
7 | 4567 if (sandbox > 0 && (flags & P_SECURE)) |
634 | 4568 { |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25176
diff
changeset
|
4569 emsg(_(e_not_allowed_in_sandbox)); |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4570 return NULL; |
634 | 4571 } |
4572 #endif | |
4573 if (flags & P_STRING) | |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4574 return set_string_option(opt_idx, string, opt_flags); |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4575 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4576 varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4577 if (varp != NULL) // hidden option is not changed |
7 | 4578 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4579 if (number == 0 && string != NULL) |
7 | 4580 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4581 int idx; |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4582 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4583 // Either we are given a string or we are setting option |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4584 // to zero. |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4585 for (idx = 0; string[idx] == '0'; ++idx) |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4586 ; |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4587 if (string[idx] != NUL || idx == 0) |
1298 | 4588 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4589 // There's another character after zeros or the string |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4590 // is empty. In both cases, we are trying to set a |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4591 // num option using a string. |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4592 semsg(_(e_number_required_after_str_equal_str), |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4593 name, string); |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4594 return NULL; // do nothing as we hit an error |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4595 |
1298 | 4596 } |
7 | 4597 } |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4598 if (flags & P_NUM) |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4599 return set_num_option(opt_idx, varp, number, |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4600 NULL, 0, opt_flags); |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4601 else |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4602 return set_bool_option(opt_idx, varp, (int)number, opt_flags); |
7 | 4603 } |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
4604 |
7 | 4605 } |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
4606 return NULL; |
7 | 4607 } |
4608 | |
4609 /* | |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4610 * Call set_option_value() and when an error is returned report it. |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4611 */ |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4612 void |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4613 set_option_value_give_err( |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4614 char_u *name, |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4615 long number, |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4616 char_u *string, |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4617 int opt_flags) // OPT_LOCAL or 0 (both) |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4618 { |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4619 char *errmsg = set_option_value(name, number, string, opt_flags); |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4620 |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4621 if (errmsg != NULL) |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4622 emsg(_(errmsg)); |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4623 } |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4624 |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4625 /* |
7 | 4626 * Get the terminal code for a terminal option. |
4627 * Returns NULL when not found. | |
4628 */ | |
4629 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4630 get_term_code(char_u *tname) |
7 | 4631 { |
4632 int opt_idx; | |
4633 char_u *varp; | |
4634 | |
4635 if (tname[0] != 't' || tname[1] != '_' || | |
4636 tname[2] == NUL || tname[3] == NUL) | |
4637 return NULL; | |
4638 if ((opt_idx = findoption(tname)) >= 0) | |
4639 { | |
4640 varp = get_varp(&(options[opt_idx])); | |
4641 if (varp != NULL) | |
4642 varp = *(char_u **)(varp); | |
4643 return varp; | |
4644 } | |
4645 return find_termcode(tname + 2); | |
4646 } | |
4647 | |
4648 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4649 get_highlight_default(void) |
7 | 4650 { |
4651 int i; | |
4652 | |
4653 i = findoption((char_u *)"hl"); | |
4654 if (i >= 0) | |
4655 return options[i].def_val[VI_DEFAULT]; | |
4656 return (char_u *)NULL; | |
4657 } | |
4658 | |
39 | 4659 char_u * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4660 get_encoding_default(void) |
39 | 4661 { |
4662 int i; | |
4663 | |
4664 i = findoption((char_u *)"enc"); | |
4665 if (i >= 0) | |
4666 return options[i].def_val[VI_DEFAULT]; | |
4667 return (char_u *)NULL; | |
4668 } | |
4669 | |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
4670 #if defined(FEAT_QUICKFIX) || defined(PROTO) |
27855
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4671 int |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4672 is_option_allocated(char *name) |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4673 { |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4674 int idx = findoption((char_u *)name); |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4675 |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4676 return idx >= 0 && (options[idx].flags & P_ALLOCED); |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4677 } |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
4678 #endif |
27855
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
4679 |
29497
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4680 #if defined(FEAT_EVAL) || defined(PROTO) |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4681 /* |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4682 * Return TRUE if "name" is a string option. |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4683 * Returns FALSE if option "name" does not exist. |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4684 */ |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4685 int |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4686 is_string_option(char_u *name) |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4687 { |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4688 int idx = findoption(name); |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4689 |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4690 return idx >= 0 && (options[idx].flags & P_STRING); |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4691 } |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4692 #endif |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
4693 |
7 | 4694 /* |
4695 * 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
|
4696 * 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
|
4697 * Returns 0 when the key is not recognized. |
7 | 4698 */ |
4699 static int | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4700 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
|
4701 { |
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4702 int key = 0; |
7 | 4703 int modifiers; |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
4704 char_u *arg = arg_arg; |
7 | 4705 |
4706 /* | |
4707 * Don't use get_special_key_code() for t_xx, we don't want it to call | |
4708 * add_termcap_entry(). | |
4709 */ | |
4710 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
4711 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
|
4712 else if (has_lt) |
7 | 4713 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4714 --arg; // put arg at the '<' |
7 | 4715 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
|
4716 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
|
4717 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
|
4718 if (modifiers) // can't handle modifiers here |
7 | 4719 key = 0; |
4720 } | |
4721 return key; | |
4722 } | |
4723 | |
4724 /* | |
4725 * if 'all' == 0: show changed options | |
4726 * if 'all' == 1: show all normal options | |
4727 * if 'all' == 2: show all terminal options | |
4728 */ | |
4729 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4730 showoptions( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4731 int all, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4732 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 4733 { |
4734 struct vimoption *p; | |
4735 int col; | |
4736 int isterm; | |
4737 char_u *varp; | |
4738 struct vimoption **items; | |
4739 int item_count; | |
4740 int run; | |
4741 int row, rows; | |
4742 int cols; | |
4743 int i; | |
4744 int len; | |
4745 | |
4746 #define INC 20 | |
4747 #define GAP 3 | |
4748 | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4749 items = ALLOC_MULT(struct vimoption *, OPTION_COUNT); |
7 | 4750 if (items == NULL) |
4751 return; | |
4752 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4753 // Highlight title |
7 | 4754 if (all == 2) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4755 msg_puts_title(_("\n--- Terminal codes ---")); |
7 | 4756 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
|
4757 msg_puts_title(_("\n--- Global option values ---")); |
7 | 4758 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
|
4759 msg_puts_title(_("\n--- Local option values ---")); |
7 | 4760 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4761 msg_puts_title(_("\n--- Options ---")); |
7 | 4762 |
4763 /* | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4764 * Do the loop two times: |
7 | 4765 * 1. display the short items |
4766 * 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
|
4767 * When "opt_flags" has OPT_ONECOLUMN do everything in run 2. |
7 | 4768 */ |
4769 for (run = 1; run <= 2 && !got_int; ++run) | |
4770 { | |
4771 /* | |
4772 * collect the items in items[] | |
4773 */ | |
4774 item_count = 0; | |
4775 for (p = &options[0]; p->fullname != NULL; p++) | |
4776 { | |
14968
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4777 // apply :filter /pat/ |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4778 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
|
4779 continue; |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
4780 |
7 | 4781 varp = NULL; |
4782 isterm = istermoption(p); | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4783 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) != 0) |
7 | 4784 { |
4785 if (p->indir != PV_NONE && !isterm) | |
4786 varp = get_varp_scope(p, opt_flags); | |
4787 } | |
4788 else | |
4789 varp = get_varp(p); | |
4790 if (varp != NULL | |
4791 && ((all == 2 && isterm) | |
4792 || (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
|
4793 || (all == 0 && !optval_default(p, varp, p_cp)))) |
7 | 4794 { |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4795 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
|
4796 len = Columns; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
4797 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
|
4798 len = 1; // a toggle option fits always |
7 | 4799 else |
4800 { | |
4801 option_value2string(p, opt_flags); | |
4802 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; | |
4803 } | |
4804 if ((len <= INC - GAP && run == 1) || | |
4805 (len > INC - GAP && run == 2)) | |
4806 items[item_count++] = p; | |
4807 } | |
4808 } | |
4809 | |
4810 /* | |
4811 * display the items | |
4812 */ | |
4813 if (run == 1) | |
4814 { | |
4815 cols = (Columns + GAP - 3) / INC; | |
4816 if (cols == 0) | |
4817 cols = 1; | |
4818 rows = (item_count + cols - 1) / cols; | |
4819 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4820 else // run == 2 |
7 | 4821 rows = item_count; |
4822 for (row = 0; row < rows && !got_int; ++row) | |
4823 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4824 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
|
4825 if (got_int) // 'q' typed in more |
7 | 4826 break; |
4827 col = 0; | |
4828 for (i = row; i < item_count; i += rows) | |
4829 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4830 msg_col = col; // make columns |
7 | 4831 showoneopt(items[i], opt_flags); |
4832 col += INC; | |
4833 } | |
4834 out_flush(); | |
4835 ui_breakcheck(); | |
4836 } | |
4837 } | |
4838 vim_free(items); | |
4839 } | |
4840 | |
4841 /* | |
4842 * Return TRUE if option "p" has its default value. | |
4843 */ | |
4844 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
|
4845 optval_default(struct vimoption *p, char_u *varp, int compatible) |
7 | 4846 { |
4847 int dvi; | |
4848 | |
4849 if (varp == NULL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4850 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
|
4851 dvi = ((p->flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; |
7 | 4852 if (p->flags & P_NUM) |
840 | 4853 return (*(long *)varp == (long)(long_i)p->def_val[dvi]); |
7 | 4854 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
|
4855 // 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
|
4856 // needed for MSVC |
840 | 4857 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
|
4858 // P_STRING |
7 | 4859 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); |
4860 } | |
4861 | |
4862 /* | |
4863 * showoneopt: show the value of one option | |
4864 * must not be called with a hidden option! | |
4865 */ | |
4866 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4867 showoneopt( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4868 struct vimoption *p, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4869 int opt_flags) // OPT_LOCAL or OPT_GLOBAL |
7 | 4870 { |
168 | 4871 char_u *varp; |
4872 int save_silent = silent_mode; | |
4873 | |
4874 silent_mode = FALSE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4875 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
7 | 4876 |
4877 varp = get_varp_scope(p, opt_flags); | |
4878 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4879 // for 'modified' we also need to check if 'ff' or 'fenc' changed. |
7 | 4880 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed |
4881 ? !curbufIsChanged() : !*(int *)varp)) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4882 msg_puts("no"); |
7 | 4883 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
|
4884 msg_puts("--"); |
7 | 4885 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4886 msg_puts(" "); |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
4887 msg_puts(p->fullname); |
7 | 4888 if (!(p->flags & P_BOOL)) |
4889 { | |
4890 msg_putchar('='); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4891 // put value string in NameBuff |
7 | 4892 option_value2string(p, opt_flags); |
4893 msg_outtrans(NameBuff); | |
4894 } | |
168 | 4895 |
4896 silent_mode = save_silent; | |
4897 info_message = FALSE; | |
7 | 4898 } |
4899 | |
4900 /* | |
4901 * Write modified options as ":set" commands to a file. | |
4902 * | |
4903 * There are three values for "opt_flags": | |
4904 * OPT_GLOBAL: Write global option values and fresh values of | |
4905 * buffer-local options (used for start of a session | |
4906 * file). | |
4907 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for | |
4908 * curwin (used for a vimrc file). | |
4909 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh | |
4910 * and local values for window-local options of | |
4911 * curwin. Local values are also written when at the | |
4912 * default value, because a modeline or autocommand | |
4913 * may have set them when doing ":edit file" and the | |
4914 * user has set them back at the default or fresh | |
4915 * value. | |
4916 * When "local_only" is TRUE, don't write fresh | |
4917 * values, only local values (for ":mkview"). | |
4918 * (fresh value = value used for a new buffer or window for a local option). | |
4919 * | |
4920 * Return FAIL on error, OK otherwise. | |
4921 */ | |
4922 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4923 makeset(FILE *fd, int opt_flags, int local_only) |
7 | 4924 { |
4925 struct vimoption *p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4926 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
|
4927 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
|
4928 char_u *varp_local = NULL; // fresh value |
7 | 4929 char *cmd; |
4930 int round; | |
1384 | 4931 int pri; |
7 | 4932 |
4933 /* | |
4934 * The options that don't have a default (terminal name, columns, lines) | |
4935 * are never written. Terminal options are also not written. | |
1384 | 4936 * Do the loop over "options[]" twice: once for options with the |
4937 * P_PRI_MKRC flag and once without. | |
7 | 4938 */ |
1384 | 4939 for (pri = 1; pri >= 0; --pri) |
4940 { | |
4941 for (p = &options[0]; !istermoption(p); p++) | |
4942 if (!(p->flags & P_NO_MKRC) | |
4943 && !istermoption(p) | |
4944 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) | |
7 | 4945 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4946 // skip global option when only doing locals |
7 | 4947 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) |
4948 continue; | |
4949 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4950 // 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
|
4951 // file, they are always buffer-specific. |
7 | 4952 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) |
4953 continue; | |
4954 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4955 // Global values are only written when not at the default value. |
7 | 4956 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
|
4957 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp, p_cp)) |
7 | 4958 continue; |
4959 | |
24476
e79d1475fc89
patch 8.2.2778: problem restoring 'packpath' in session
Bram Moolenaar <Bram@vim.org>
parents:
24464
diff
changeset
|
4960 if ((opt_flags & OPT_SKIPRTP) && (p->var == (char_u *)&p_rtp |
e79d1475fc89
patch 8.2.2778: problem restoring 'packpath' in session
Bram Moolenaar <Bram@vim.org>
parents:
24464
diff
changeset
|
4961 || p->var == (char_u *)&p_pp)) |
24464
a56f9c2ba51c
patch 8.2.2772: problems when restoring 'runtimepath' from a session file
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4962 continue; |
a56f9c2ba51c
patch 8.2.2772: problems when restoring 'runtimepath' from a session file
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4963 |
7 | 4964 round = 2; |
4965 if (p->indir != PV_NONE) | |
4966 { | |
4967 if (p->var == VAR_WIN) | |
4968 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4969 // skip window-local option when only doing globals |
7 | 4970 if (!(opt_flags & OPT_LOCAL)) |
4971 continue; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4972 // 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
|
4973 // default, need to write it too. |
7 | 4974 if (!(opt_flags & OPT_GLOBAL) && !local_only) |
4975 { | |
4976 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
|
4977 if (!optval_default(p, varp_fresh, p_cp)) |
7 | 4978 { |
4979 round = 1; | |
4980 varp_local = varp; | |
4981 varp = varp_fresh; | |
4982 } | |
4983 } | |
4984 } | |
4985 } | |
4986 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4987 // 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
|
4988 // Round 2: other values |
7 | 4989 for ( ; round <= 2; varp = varp_local, ++round) |
4990 { | |
4991 if (round == 1 || (opt_flags & OPT_GLOBAL)) | |
4992 cmd = "set"; | |
4993 else | |
4994 cmd = "setlocal"; | |
4995 | |
4996 if (p->flags & P_BOOL) | |
4997 { | |
4998 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) | |
4999 return FAIL; | |
5000 } | |
5001 else if (p->flags & P_NUM) | |
5002 { | |
5003 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) | |
5004 return FAIL; | |
5005 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5006 else // P_STRING |
7 | 5007 { |
694 | 5008 int do_endif = FALSE; |
5009 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5010 // 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
|
5011 // already right, avoids reloading the syntax file. |
694 | 5012 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
5013 #if defined(FEAT_SYN_HL) |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
5014 p->indir == PV_SYN || |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
5015 #endif |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
5016 p->indir == PV_FT) |
7 | 5017 { |
5018 if (fprintf(fd, "if &%s != '%s'", p->fullname, | |
5019 *(char_u **)(varp)) < 0 | |
5020 || put_eol(fd) < 0) | |
5021 return FAIL; | |
694 | 5022 do_endif = TRUE; |
7 | 5023 } |
5024 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
|
5025 p->flags) == FAIL) |
7 | 5026 return FAIL; |
694 | 5027 if (do_endif) |
7 | 5028 { |
5029 if (put_line(fd, "endif") == FAIL) | |
5030 return FAIL; | |
5031 } | |
5032 } | |
5033 } | |
5034 } | |
1384 | 5035 } |
7 | 5036 return OK; |
5037 } | |
5038 | |
5039 #if defined(FEAT_FOLDING) || defined(PROTO) | |
5040 /* | |
5041 * Generate set commands for the local fold options only. Used when | |
5042 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options". | |
5043 */ | |
5044 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5045 makefoldset(FILE *fd) |
7 | 5046 { |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5047 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, 0) == FAIL |
7 | 5048 # 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
|
5049 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, 0) |
7 | 5050 == FAIL |
5051 # endif | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5052 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, 0) |
7 | 5053 == FAIL |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5054 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, 0) |
7 | 5055 == FAIL |
5056 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL | |
5057 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL | |
5058 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL | |
5059 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL | |
5060 ) | |
5061 return FAIL; | |
5062 | |
5063 return OK; | |
5064 } | |
5065 #endif | |
5066 | |
5067 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5068 put_setstring( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5069 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5070 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5071 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5072 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
|
5073 long_u flags) |
7 | 5074 { |
5075 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
|
5076 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
|
5077 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
|
5078 char_u *p; |
7 | 5079 |
5080 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
5081 return FAIL; | |
5082 if (*valuep != NULL) | |
5083 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5084 // 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
|
5085 // 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
|
5086 // CTRL-V or backslash |
7 | 5087 if (valuep == &p_pt) |
5088 { | |
5089 s = *valuep; | |
5090 while (*s != NUL) | |
30226
b6b803ed4a53
patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
5091 if (put_escstr(fd, str2special(&s, FALSE, FALSE), 2) == FAIL) |
7 | 5092 return FAIL; |
5093 } | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5094 // 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
|
5095 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
|
5096 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5097 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
|
5098 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5099 // 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
|
5100 buf = alloc(size); |
2780 | 5101 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
|
5102 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5103 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
|
5104 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5105 // 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
|
5106 // 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
|
5107 // 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
|
5108 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
|
5109 && 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
|
5110 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5111 part = alloc(size); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5112 if (part == NULL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5113 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5114 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5115 // 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
|
5116 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
|
5117 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5118 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5119 p = buf; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5120 while (*p != NUL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5121 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5122 // 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
|
5123 // 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
|
5124 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
|
5125 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5126 (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
|
5127 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
|
5128 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5129 } |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5130 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5131 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5132 return OK; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5133 } |
7 | 5134 if (put_escstr(fd, buf, 2) == FAIL) |
2780 | 5135 { |
5136 vim_free(buf); | |
7 | 5137 return FAIL; |
2780 | 5138 } |
5139 vim_free(buf); | |
7 | 5140 } |
5141 else if (put_escstr(fd, *valuep, 2) == FAIL) | |
5142 return FAIL; | |
5143 } | |
5144 if (put_eol(fd) < 0) | |
5145 return FAIL; | |
5146 return OK; | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5147 fail: |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5148 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5149 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5150 return FAIL; |
7 | 5151 } |
5152 | |
5153 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5154 put_setnum( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5155 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5156 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5157 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5158 long *valuep) |
7 | 5159 { |
5160 long wc; | |
5161 | |
5162 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
5163 return FAIL; | |
5164 if (wc_use_keyname((char_u *)valuep, &wc)) | |
5165 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5166 // print 'wildchar' and 'wildcharm' as a key name |
7 | 5167 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) |
5168 return FAIL; | |
5169 } | |
5170 else if (fprintf(fd, "%ld", *valuep) < 0) | |
5171 return FAIL; | |
5172 if (put_eol(fd) < 0) | |
5173 return FAIL; | |
5174 return OK; | |
5175 } | |
5176 | |
5177 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5178 put_setbool( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5179 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5180 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5181 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5182 int value) |
7 | 5183 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5184 if (value < 0) // global/local option using global value |
1416 | 5185 return OK; |
7 | 5186 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 |
5187 || put_eol(fd) < 0) | |
5188 return FAIL; | |
5189 return OK; | |
5190 } | |
5191 | |
5192 /* | |
5193 * Clear all the terminal options. | |
5194 * If the option has been allocated, free the memory. | |
5195 * Terminal options are never hidden or indirect. | |
5196 */ | |
5197 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5198 clear_termoptions(void) |
7 | 5199 { |
5200 /* | |
5201 * Reset a few things before clearing the old options. This may cause | |
5202 * outputting a few things that the terminal doesn't understand, but the | |
5203 * screen will be cleared later, so this is OK. | |
5204 */ | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
5205 mch_setmouse(FALSE); // switch mouse off |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5206 mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles |
7 | 5207 #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
|
5208 // 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
|
5209 // After restoring the title, because that will need the display. |
7 | 5210 if (gui.starting) |
5211 clear_xterm_clip(); | |
5212 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5213 stoptermcap(); // stop termcap mode |
7 | 5214 |
359 | 5215 free_termoptions(); |
5216 } | |
5217 | |
5218 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5219 free_termoptions(void) |
359 | 5220 { |
5221 struct vimoption *p; | |
5222 | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
5223 for (p = options; p->fullname != NULL; p++) |
7 | 5224 if (istermoption(p)) |
5225 { | |
5226 if (p->flags & P_ALLOCED) | |
5227 free_string_option(*(char_u **)(p->var)); | |
5228 if (p->flags & P_DEF_ALLOCED) | |
5229 free_string_option(p->def_val[VI_DEFAULT]); | |
5230 *(char_u **)(p->var) = empty_option; | |
5231 p->def_val[VI_DEFAULT] = empty_option; | |
5232 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
|
5233 #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
|
5234 // 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
|
5235 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
|
5236 #endif |
7 | 5237 } |
5238 clear_termcodes(); | |
5239 } | |
5240 | |
5241 /* | |
1941 | 5242 * Free the string for one term option, if it was allocated. |
5243 * Set the string to empty_option and clear allocated flag. | |
5244 * "var" points to the option value. | |
5245 */ | |
5246 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5247 free_one_termoption(char_u *var) |
1941 | 5248 { |
5249 struct vimoption *p; | |
5250 | |
5251 for (p = &options[0]; p->fullname != NULL; p++) | |
5252 if (p->var == var) | |
5253 { | |
5254 if (p->flags & P_ALLOCED) | |
5255 free_string_option(*(char_u **)(p->var)); | |
5256 *(char_u **)(p->var) = empty_option; | |
5257 p->flags &= ~P_ALLOCED; | |
5258 break; | |
5259 } | |
5260 } | |
5261 | |
5262 /* | |
7 | 5263 * Set the terminal option defaults to the current value. |
5264 * Used after setting the terminal name. | |
5265 */ | |
5266 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5267 set_term_defaults(void) |
7 | 5268 { |
5269 struct vimoption *p; | |
5270 | |
5271 for (p = &options[0]; p->fullname != NULL; p++) | |
5272 { | |
5273 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) | |
5274 { | |
5275 if (p->flags & P_DEF_ALLOCED) | |
5276 { | |
5277 free_string_option(p->def_val[VI_DEFAULT]); | |
5278 p->flags &= ~P_DEF_ALLOCED; | |
5279 } | |
5280 p->def_val[VI_DEFAULT] = *(char_u **)(p->var); | |
5281 if (p->flags & P_ALLOCED) | |
5282 { | |
5283 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
|
5284 p->flags &= ~P_ALLOCED; // don't free the value now |
7 | 5285 } |
5286 } | |
5287 } | |
5288 } | |
5289 | |
5290 /* | |
5291 * return TRUE if 'p' starts with 't_' | |
5292 */ | |
5293 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5294 istermoption(struct vimoption *p) |
7 | 5295 { |
5296 return (p->fullname[0] == 't' && p->fullname[1] == '_'); | |
5297 } | |
5298 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5299 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5300 * 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
|
5301 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5302 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5303 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
|
5304 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5305 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
|
5306 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5307 |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
5308 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
7 | 5309 /* |
4350 | 5310 * Unset local option value, similar to ":set opt<". |
5311 */ | |
5312 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5313 unset_global_local_option(char_u *name, void *from) |
4350 | 5314 { |
5315 struct vimoption *p; | |
5316 int opt_idx; | |
4361 | 5317 buf_T *buf = (buf_T *)from; |
4350 | 5318 |
5319 opt_idx = findoption(name); | |
7007 | 5320 if (opt_idx < 0) |
5321 return; | |
4350 | 5322 p = &(options[opt_idx]); |
5323 | |
5324 switch ((int)p->indir) | |
5325 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5326 // global option with local value: use local value if it's been set |
4350 | 5327 case PV_EP: |
4361 | 5328 clear_string_option(&buf->b_p_ep); |
4350 | 5329 break; |
5330 case PV_KP: | |
4361 | 5331 clear_string_option(&buf->b_p_kp); |
4350 | 5332 break; |
5333 case PV_PATH: | |
4361 | 5334 clear_string_option(&buf->b_p_path); |
4350 | 5335 break; |
5336 case PV_AR: | |
5337 buf->b_p_ar = -1; | |
5338 break; | |
6243 | 5339 case PV_BKC: |
5340 clear_string_option(&buf->b_p_bkc); | |
5341 buf->b_bkc_flags = 0; | |
5342 break; | |
4350 | 5343 case PV_TAGS: |
4361 | 5344 clear_string_option(&buf->b_p_tags); |
4350 | 5345 break; |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5346 case PV_TC: |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5347 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
|
5348 buf->b_tc_flags = 0; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
5349 break; |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5350 case PV_SISO: |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5351 curwin->w_p_siso = -1; |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5352 break; |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5353 case PV_SO: |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5354 curwin->w_p_so = -1; |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5355 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5356 # ifdef FEAT_FIND_ID |
4350 | 5357 case PV_DEF: |
4361 | 5358 clear_string_option(&buf->b_p_def); |
4350 | 5359 break; |
5360 case PV_INC: | |
4361 | 5361 clear_string_option(&buf->b_p_inc); |
4350 | 5362 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5363 # endif |
4350 | 5364 case PV_DICT: |
4361 | 5365 clear_string_option(&buf->b_p_dict); |
4350 | 5366 break; |
5367 case PV_TSR: | |
4361 | 5368 clear_string_option(&buf->b_p_tsr); |
4350 | 5369 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5370 # ifdef FEAT_COMPL_FUNC |
25990
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5371 case PV_TSRFU: |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5372 clear_string_option(&buf->b_p_tsrfu); |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5373 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5374 # endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5375 case PV_FP: |
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5376 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
|
5377 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5378 # ifdef FEAT_QUICKFIX |
4350 | 5379 case PV_EFM: |
4361 | 5380 clear_string_option(&buf->b_p_efm); |
4350 | 5381 break; |
5382 case PV_GP: | |
4361 | 5383 clear_string_option(&buf->b_p_gp); |
4350 | 5384 break; |
5385 case PV_MP: | |
4361 | 5386 clear_string_option(&buf->b_p_mp); |
4350 | 5387 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5388 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5389 # if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
4350 | 5390 case PV_BEXPR: |
4361 | 5391 clear_string_option(&buf->b_p_bexpr); |
4350 | 5392 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5393 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5394 # if defined(FEAT_CRYPT) |
4350 | 5395 case PV_CM: |
4361 | 5396 clear_string_option(&buf->b_p_cm); |
4350 | 5397 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5398 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5399 # ifdef FEAT_LINEBREAK |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5400 case PV_SBR: |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5401 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
|
5402 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5403 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5404 # ifdef FEAT_STL_OPT |
4350 | 5405 case PV_STL: |
4361 | 5406 clear_string_option(&((win_T *)from)->w_p_stl); |
4350 | 5407 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5408 # endif |
5446 | 5409 case PV_UL: |
5410 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; | |
5411 break; | |
5712 | 5412 case PV_LW: |
5413 clear_string_option(&buf->b_p_lw); | |
5414 break; | |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
5415 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
|
5416 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
|
5417 break; |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5418 case PV_LCS: |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5419 clear_string_option(&((win_T *)from)->w_p_lcs); |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
5420 set_chars_option((win_T *)from, &((win_T *)from)->w_p_lcs, TRUE); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
5421 redraw_later(UPD_NOT_VALID); |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5422 break; |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5423 case PV_FCS: |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5424 clear_string_option(&((win_T *)from)->w_p_fcs); |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
5425 set_chars_option((win_T *)from, &((win_T *)from)->w_p_fcs, TRUE); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
5426 redraw_later(UPD_NOT_VALID); |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5427 break; |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
5428 case PV_VE: |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5429 clear_string_option(&((win_T *)from)->w_p_ve); |
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5430 ((win_T *)from)->w_ve_flags = 0; |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
5431 break; |
4350 | 5432 } |
5433 } | |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
5434 #endif |
4350 | 5435 |
5436 /* | |
7 | 5437 * Get pointer to option variable, depending on local or global scope. |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
5438 * "scope" can be OPT_LOCAL, OPT_GLOBAL or a combination. |
7 | 5439 */ |
5440 static char_u * | |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
5441 get_varp_scope(struct vimoption *p, int scope) |
7 | 5442 { |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
5443 if ((scope & OPT_GLOBAL) && p->indir != PV_NONE) |
7 | 5444 { |
5445 if (p->var == VAR_WIN) | |
5446 return (char_u *)GLOBAL_WO(get_varp(p)); | |
5447 return p->var; | |
5448 } | |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
5449 if ((scope & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) |
7 | 5450 { |
5451 switch ((int)p->indir) | |
5452 { | |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5453 case PV_FP: return (char_u *)&(curbuf->b_p_fp); |
7 | 5454 #ifdef FEAT_QUICKFIX |
694 | 5455 case PV_EFM: return (char_u *)&(curbuf->b_p_efm); |
5456 case PV_GP: return (char_u *)&(curbuf->b_p_gp); | |
5457 case PV_MP: return (char_u *)&(curbuf->b_p_mp); | |
5458 #endif | |
5459 case PV_EP: return (char_u *)&(curbuf->b_p_ep); | |
5460 case PV_KP: return (char_u *)&(curbuf->b_p_kp); | |
5461 case PV_PATH: return (char_u *)&(curbuf->b_p_path); | |
692 | 5462 case PV_AR: return (char_u *)&(curbuf->b_p_ar); |
694 | 5463 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
|
5464 case PV_TC: return (char_u *)&(curbuf->b_p_tc); |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5465 case PV_SISO: return (char_u *)&(curwin->w_p_siso); |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
5466 case PV_SO: return (char_u *)&(curwin->w_p_so); |
7 | 5467 #ifdef FEAT_FIND_ID |
694 | 5468 case PV_DEF: return (char_u *)&(curbuf->b_p_def); |
5469 case PV_INC: return (char_u *)&(curbuf->b_p_inc); | |
7 | 5470 #endif |
694 | 5471 case PV_DICT: return (char_u *)&(curbuf->b_p_dict); |
5472 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr); | |
25990
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5473 #ifdef FEAT_COMPL_FUNC |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5474 case PV_TSRFU: return (char_u *)&(curbuf->b_p_tsrfu); |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5475 #endif |
790 | 5476 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5477 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr); | |
5478 #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
|
5479 #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
|
5480 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
|
5481 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5482 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5483 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
|
5484 #endif |
40 | 5485 #ifdef FEAT_STL_OPT |
694 | 5486 case PV_STL: return (char_u *)&(curwin->w_p_stl); |
40 | 5487 #endif |
5446 | 5488 case PV_UL: return (char_u *)&(curbuf->b_p_ul); |
5712 | 5489 case PV_LW: return (char_u *)&(curbuf->b_p_lw); |
6243 | 5490 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
|
5491 case PV_MENC: return (char_u *)&(curbuf->b_p_menc); |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
5492 case PV_LCS: return (char_u *)&(curwin->w_p_lcs); |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5493 case PV_FCS: return (char_u *)&(curwin->w_p_fcs); |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5494 case PV_VE: return (char_u *)&(curwin->w_p_ve); |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
5495 |
7 | 5496 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5497 return NULL; // "cannot happen" |
7 | 5498 } |
5499 return get_varp(p); | |
5500 } | |
5501 | |
5502 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5503 * 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
|
5504 * scope. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5505 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5506 char_u * |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
5507 get_option_varp_scope(int opt_idx, int scope) |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5508 { |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
5509 return get_varp_scope(&(options[opt_idx]), scope); |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5510 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5511 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5512 /* |
7 | 5513 * Get pointer to option variable. |
5514 */ | |
5515 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5516 get_varp(struct vimoption *p) |
7 | 5517 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5518 // hidden option, always return NULL |
7 | 5519 if (p->var == NULL) |
5520 return NULL; | |
5521 | |
5522 switch ((int)p->indir) | |
5523 { | |
5524 case PV_NONE: return p->var; | |
5525 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5526 // global option with local value: use local value if it's been set |
694 | 5527 case PV_EP: return *curbuf->b_p_ep != NUL |
7 | 5528 ? (char_u *)&curbuf->b_p_ep : p->var; |
694 | 5529 case PV_KP: return *curbuf->b_p_kp != NUL |
7 | 5530 ? (char_u *)&curbuf->b_p_kp : p->var; |
694 | 5531 case PV_PATH: return *curbuf->b_p_path != NUL |
7 | 5532 ? (char_u *)&(curbuf->b_p_path) : p->var; |
692 | 5533 case PV_AR: return curbuf->b_p_ar >= 0 |
7 | 5534 ? (char_u *)&(curbuf->b_p_ar) : p->var; |
694 | 5535 case PV_TAGS: return *curbuf->b_p_tags != NUL |
7 | 5536 ? (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
|
5537 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
|
5538 ? (char_u *)&(curbuf->b_p_tc) : p->var; |
6243 | 5539 case PV_BKC: return *curbuf->b_p_bkc != NUL |
5540 ? (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
|
5541 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
|
5542 ? (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
|
5543 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
|
5544 ? (char_u *)&(curwin->w_p_so) : p->var; |
7 | 5545 #ifdef FEAT_FIND_ID |
694 | 5546 case PV_DEF: return *curbuf->b_p_def != NUL |
7 | 5547 ? (char_u *)&(curbuf->b_p_def) : p->var; |
694 | 5548 case PV_INC: return *curbuf->b_p_inc != NUL |
7 | 5549 ? (char_u *)&(curbuf->b_p_inc) : p->var; |
5550 #endif | |
694 | 5551 case PV_DICT: return *curbuf->b_p_dict != NUL |
7 | 5552 ? (char_u *)&(curbuf->b_p_dict) : p->var; |
694 | 5553 case PV_TSR: return *curbuf->b_p_tsr != NUL |
7 | 5554 ? (char_u *)&(curbuf->b_p_tsr) : p->var; |
25990
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5555 #ifdef FEAT_COMPL_FUNC |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5556 case PV_TSRFU: return *curbuf->b_p_tsrfu != NUL |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5557 ? (char_u *)&(curbuf->b_p_tsrfu) : p->var; |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
5558 #endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
5559 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
|
5560 ? (char_u *)&(curbuf->b_p_fp) : p->var; |
7 | 5561 #ifdef FEAT_QUICKFIX |
694 | 5562 case PV_EFM: return *curbuf->b_p_efm != NUL |
5563 ? (char_u *)&(curbuf->b_p_efm) : p->var; | |
5564 case PV_GP: return *curbuf->b_p_gp != NUL | |
7 | 5565 ? (char_u *)&(curbuf->b_p_gp) : p->var; |
694 | 5566 case PV_MP: return *curbuf->b_p_mp != NUL |
7 | 5567 ? (char_u *)&(curbuf->b_p_mp) : p->var; |
5568 #endif | |
790 | 5569 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
5570 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL | |
5571 ? (char_u *)&(curbuf->b_p_bexpr) : p->var; | |
5572 #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
|
5573 #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
|
5574 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
|
5575 ? (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
|
5576 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5577 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5578 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
|
5579 ? (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
|
5580 #endif |
40 | 5581 #ifdef FEAT_STL_OPT |
694 | 5582 case PV_STL: return *curwin->w_p_stl != NUL |
40 | 5583 ? (char_u *)&(curwin->w_p_stl) : p->var; |
5584 #endif | |
5446 | 5585 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL |
5586 ? (char_u *)&(curbuf->b_p_ul) : p->var; | |
5712 | 5587 case PV_LW: return *curbuf->b_p_lw != NUL |
5588 ? (char_u *)&(curbuf->b_p_lw) : p->var; | |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
5589 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
|
5590 ? (char_u *)&(curbuf->b_p_menc) : p->var; |
7 | 5591 #ifdef FEAT_ARABIC |
5592 case PV_ARAB: return (char_u *)&(curwin->w_p_arab); | |
5593 #endif | |
5594 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
|
5595 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
|
5596 ? (char_u *)&(curwin->w_p_lcs) : p->var; |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5597 case PV_FCS: return *curwin->w_p_fcs != NUL |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5598 ? (char_u *)&(curwin->w_p_fcs) : p->var; |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5599 case PV_VE: return *curwin->w_p_ve != NUL |
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5600 ? (char_u *)&(curwin->w_p_ve) : p->var; |
744 | 5601 #ifdef FEAT_SPELL |
5602 case PV_SPELL: return (char_u *)&(curwin->w_p_spell); | |
5603 #endif | |
221 | 5604 #ifdef FEAT_SYN_HL |
744 | 5605 case PV_CUC: return (char_u *)&(curwin->w_p_cuc); |
5606 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
|
5607 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
|
5608 case PV_CC: return (char_u *)&(curwin->w_p_cc); |
221 | 5609 #endif |
7 | 5610 #ifdef FEAT_DIFF |
5611 case PV_DIFF: return (char_u *)&(curwin->w_p_diff); | |
5612 #endif | |
5613 #ifdef FEAT_FOLDING | |
5614 case PV_FDC: return (char_u *)&(curwin->w_p_fdc); | |
5615 case PV_FEN: return (char_u *)&(curwin->w_p_fen); | |
5616 case PV_FDI: return (char_u *)&(curwin->w_p_fdi); | |
5617 case PV_FDL: return (char_u *)&(curwin->w_p_fdl); | |
5618 case PV_FDM: return (char_u *)&(curwin->w_p_fdm); | |
5619 case PV_FML: return (char_u *)&(curwin->w_p_fml); | |
5620 case PV_FDN: return (char_u *)&(curwin->w_p_fdn); | |
5621 # ifdef FEAT_EVAL | |
5622 case PV_FDE: return (char_u *)&(curwin->w_p_fde); | |
5623 case PV_FDT: return (char_u *)&(curwin->w_p_fdt); | |
5624 # endif | |
5625 case PV_FMR: return (char_u *)&(curwin->w_p_fmr); | |
5626 #endif | |
5627 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
|
5628 case PV_RNU: return (char_u *)&(curwin->w_p_rnu); |
13 | 5629 #ifdef FEAT_LINEBREAK |
5630 case PV_NUW: return (char_u *)&(curwin->w_p_nuw); | |
5631 #endif | |
7 | 5632 case PV_WFH: return (char_u *)&(curwin->w_p_wfh); |
782 | 5633 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
|
5634 #if defined(FEAT_QUICKFIX) |
7 | 5635 case PV_PVW: return (char_u *)&(curwin->w_p_pvw); |
5636 #endif | |
5637 #ifdef FEAT_RIGHTLEFT | |
5638 case PV_RL: return (char_u *)&(curwin->w_p_rl); | |
5639 case PV_RLC: return (char_u *)&(curwin->w_p_rlc); | |
5640 #endif | |
5641 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr); | |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30417
diff
changeset
|
5642 case PV_SMS: return (char_u *)&(curwin->w_p_sms); |
7 | 5643 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); |
5644 #ifdef FEAT_LINEBREAK | |
5645 case PV_LBR: return (char_u *)&(curwin->w_p_lbr); | |
5995 | 5646 case PV_BRI: return (char_u *)&(curwin->w_p_bri); |
5647 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt); | |
7 | 5648 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5649 case PV_WCR: return (char_u *)&(curwin->w_p_wcr); |
7 | 5650 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
|
5651 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
|
5652 #ifdef FEAT_CONCEAL |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5653 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
|
5654 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
|
5655 #endif |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5656 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5657 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
|
5658 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
|
5659 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
|
5660 #endif |
7 | 5661 |
5662 case PV_AI: return (char_u *)&(curbuf->b_p_ai); | |
5663 case PV_BIN: return (char_u *)&(curbuf->b_p_bin); | |
5664 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); | |
5665 case PV_BH: return (char_u *)&(curbuf->b_p_bh); | |
5666 case PV_BT: return (char_u *)&(curbuf->b_p_bt); | |
5667 case PV_BL: return (char_u *)&(curbuf->b_p_bl); | |
5668 case PV_CI: return (char_u *)&(curbuf->b_p_ci); | |
5669 case PV_CIN: return (char_u *)&(curbuf->b_p_cin); | |
5670 case PV_CINK: return (char_u *)&(curbuf->b_p_cink); | |
5671 case PV_CINO: return (char_u *)&(curbuf->b_p_cino); | |
28353
8bc8071928ed
patch 8.2.4702: C++ scope labels are hard-coded
Bram Moolenaar <Bram@vim.org>
parents:
28337
diff
changeset
|
5672 case PV_CINSD: return (char_u *)&(curbuf->b_p_cinsd); |
7 | 5673 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); |
5674 case PV_COM: return (char_u *)&(curbuf->b_p_com); | |
5675 #ifdef FEAT_FOLDING | |
5676 case PV_CMS: return (char_u *)&(curbuf->b_p_cms); | |
5677 #endif | |
5678 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
|
5679 #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
|
5680 case PV_CSL: return (char_u *)&(curbuf->b_p_csl); |
7 | 5681 #endif |
12 | 5682 #ifdef FEAT_COMPL_FUNC |
5683 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); | |
502 | 5684 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); |
12 | 5685 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
5686 #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
|
5687 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
|
5688 #endif |
30966
685ee8453163
Add missing entry for the 'endoffile' option.
Bram Moolenaar <Bram@vim.org>
parents:
30853
diff
changeset
|
5689 case PV_EOF: return (char_u *)&(curbuf->b_p_eof); |
7 | 5690 case PV_EOL: return (char_u *)&(curbuf->b_p_eol); |
6933 | 5691 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol); |
7 | 5692 case PV_ET: return (char_u *)&(curbuf->b_p_et); |
5693 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); | |
5694 case PV_FF: return (char_u *)&(curbuf->b_p_ff); | |
5695 case PV_FT: return (char_u *)&(curbuf->b_p_ft); | |
5696 case PV_FO: return (char_u *)&(curbuf->b_p_fo); | |
41 | 5697 case PV_FLP: return (char_u *)&(curbuf->b_p_flp); |
7 | 5698 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); |
5699 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); | |
5700 case PV_INF: return (char_u *)&(curbuf->b_p_inf); | |
5701 case PV_ISK: return (char_u *)&(curbuf->b_p_isk); | |
5702 #ifdef FEAT_FIND_ID | |
5703 # ifdef FEAT_EVAL | |
5704 case PV_INEX: return (char_u *)&(curbuf->b_p_inex); | |
5705 # endif | |
5706 #endif | |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
5707 #if defined(FEAT_EVAL) |
7 | 5708 case PV_INDE: return (char_u *)&(curbuf->b_p_inde); |
5709 case PV_INDK: return (char_u *)&(curbuf->b_p_indk); | |
5710 #endif | |
694 | 5711 #ifdef FEAT_EVAL |
667 | 5712 case PV_FEX: return (char_u *)&(curbuf->b_p_fex); |
5713 #endif | |
7 | 5714 #ifdef FEAT_CRYPT |
5715 case PV_KEY: return (char_u *)&(curbuf->b_p_key); | |
5716 #endif | |
5717 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp); | |
30853
40df8a6515f6
patch 9.0.0761: cannot use 'indentexpr' for Lisp indenting
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
5718 case PV_LOP: return (char_u *)&(curbuf->b_p_lop); |
7 | 5719 case PV_ML: return (char_u *)&(curbuf->b_p_ml); |
5720 case PV_MPS: return (char_u *)&(curbuf->b_p_mps); | |
5721 case PV_MA: return (char_u *)&(curbuf->b_p_ma); | |
5722 case PV_MOD: return (char_u *)&(curbuf->b_changed); | |
5723 case PV_NF: return (char_u *)&(curbuf->b_p_nf); | |
5724 case PV_PI: return (char_u *)&(curbuf->b_p_pi); | |
12 | 5725 case PV_QE: return (char_u *)&(curbuf->b_p_qe); |
7 | 5726 case PV_RO: return (char_u *)&(curbuf->b_p_ro); |
5727 case PV_SI: return (char_u *)&(curbuf->b_p_si); | |
5728 case PV_SN: return (char_u *)&(curbuf->b_p_sn); | |
5729 case PV_STS: return (char_u *)&(curbuf->b_p_sts); | |
5730 case PV_SUA: return (char_u *)&(curbuf->b_p_sua); | |
5731 case PV_SWF: return (char_u *)&(curbuf->b_p_swf); | |
5732 #ifdef FEAT_SYN_HL | |
410 | 5733 case PV_SMC: return (char_u *)&(curbuf->b_p_smc); |
744 | 5734 case PV_SYN: return (char_u *)&(curbuf->b_p_syn); |
5735 #endif | |
5736 #ifdef FEAT_SPELL | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
5737 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
|
5738 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
|
5739 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
|
5740 case PV_SPO: return (char_u *)&(curwin->w_s->b_p_spo); |
7 | 5741 #endif |
5742 case PV_SW: return (char_u *)&(curbuf->b_p_sw); | |
5743 case PV_TS: return (char_u *)&(curbuf->b_p_ts); | |
5744 case PV_TW: return (char_u *)&(curbuf->b_p_tw); | |
5745 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
|
5746 #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
|
5747 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
|
5748 #endif |
7 | 5749 case PV_WM: return (char_u *)&(curbuf->b_p_wm); |
5750 #ifdef FEAT_KEYMAP | |
5751 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); | |
5752 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5753 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5754 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
|
5755 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5756 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
5757 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
|
5758 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
|
5759 #endif |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
5760 default: iemsg(_(e_get_varp_error)); |
7 | 5761 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5762 // always return a valid pointer to avoid a crash! |
7 | 5763 return (char_u *)&(curbuf->b_p_wm); |
5764 } | |
5765 | |
5766 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5767 * 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
|
5768 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5769 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5770 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
|
5771 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5772 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
|
5773 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5774 |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
5775 #if defined(FEAT_EVAL) || defined(PROTO) |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5776 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5777 * 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
|
5778 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5779 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5780 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
|
5781 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5782 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
|
5783 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
5784 #endif |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5785 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5786 /* |
7 | 5787 * Get the value of 'equalprg', either the buffer-local one or the global one. |
5788 */ | |
5789 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5790 get_equalprg(void) |
7 | 5791 { |
5792 if (*curbuf->b_p_ep == NUL) | |
5793 return p_ep; | |
5794 return curbuf->b_p_ep; | |
5795 } | |
5796 | |
5797 /* | |
5798 * Copy options from one window to another. | |
5799 * Used when splitting a window. | |
5800 */ | |
5801 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5802 win_copy_options(win_T *wp_from, win_T *wp_to) |
7 | 5803 { |
5804 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); | |
5805 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
|
5806 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
|
5807 } |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5808 |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5809 /* |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5810 * 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
|
5811 */ |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5812 void |
27659
b5ebc885c25c
patch 8.2.4355: unnecessary call to check_colorcolumn()
Bram Moolenaar <Bram@vim.org>
parents:
27509
diff
changeset
|
5813 after_copy_winopt(win_T *wp) |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5814 { |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
5815 #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
|
5816 briopt_check(wp); |
6162 | 5817 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
5818 #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
|
5819 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
|
5820 check_colorcolumn(wp); |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
5821 #endif |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
5822 set_chars_option(wp, &wp->w_p_lcs, TRUE); |
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
5823 set_chars_option(wp, &wp->w_p_fcs, TRUE); |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5824 } |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5825 |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5826 static char_u * |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5827 copy_option_val(char_u *val) |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5828 { |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5829 if (val == empty_option) |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5830 return empty_option; // no need to allocate memory |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5831 return vim_strsave(val); |
7 | 5832 } |
5833 | |
5834 /* | |
5835 * Copy the options from one winopt_T to another. | |
5836 * Doesn't free the old option values in "to", use clear_winopt() for that. | |
5837 * The 'scroll' option is not copied, because it depends on the window height. | |
5838 * The 'previewwindow' option is reset, there can be only one preview window. | |
5839 */ | |
5840 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5841 copy_winopt(winopt_T *from, winopt_T *to) |
7 | 5842 { |
5843 #ifdef FEAT_ARABIC | |
5844 to->wo_arab = from->wo_arab; | |
5845 #endif | |
5846 to->wo_list = from->wo_list; | |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5847 to->wo_lcs = copy_option_val(from->wo_lcs); |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5848 to->wo_fcs = copy_option_val(from->wo_fcs); |
7 | 5849 to->wo_nu = from->wo_nu; |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
5850 to->wo_rnu = from->wo_rnu; |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5851 to->wo_ve = copy_option_val(from->wo_ve); |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5852 to->wo_ve_flags = from->wo_ve_flags; |
13 | 5853 #ifdef FEAT_LINEBREAK |
5854 to->wo_nuw = from->wo_nuw; | |
5855 #endif | |
7 | 5856 #ifdef FEAT_RIGHTLEFT |
5857 to->wo_rl = from->wo_rl; | |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5858 to->wo_rlc = copy_option_val(from->wo_rlc); |
7 | 5859 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5860 #ifdef FEAT_LINEBREAK |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5861 to->wo_sbr = copy_option_val(from->wo_sbr); |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5862 #endif |
40 | 5863 #ifdef FEAT_STL_OPT |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5864 to->wo_stl = copy_option_val(from->wo_stl); |
40 | 5865 #endif |
7 | 5866 to->wo_wrap = from->wo_wrap; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5867 #ifdef FEAT_DIFF |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5868 to->wo_wrap_save = from->wo_wrap_save; |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5869 #endif |
7 | 5870 #ifdef FEAT_LINEBREAK |
5871 to->wo_lbr = from->wo_lbr; | |
5995 | 5872 to->wo_bri = from->wo_bri; |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5873 to->wo_briopt = copy_option_val(from->wo_briopt); |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5874 #endif |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5875 to->wo_wcr = copy_option_val(from->wo_wcr); |
7 | 5876 to->wo_scb = from->wo_scb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5877 to->wo_scb_save = from->wo_scb_save; |
30618
c2031ad5ed54
patch 9.0.0644: 'smoothscroll' is not copied to a new window on :split
Bram Moolenaar <Bram@vim.org>
parents:
30610
diff
changeset
|
5878 to->wo_sms = from->wo_sms; |
2651 | 5879 to->wo_crb = from->wo_crb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5880 to->wo_crb_save = from->wo_crb_save; |
744 | 5881 #ifdef FEAT_SPELL |
5882 to->wo_spell = from->wo_spell; | |
5883 #endif | |
221 | 5884 #ifdef FEAT_SYN_HL |
744 | 5885 to->wo_cuc = from->wo_cuc; |
5886 to->wo_cul = from->wo_cul; | |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5887 to->wo_culopt = copy_option_val(from->wo_culopt); |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5888 to->wo_cc = copy_option_val(from->wo_cc); |
221 | 5889 #endif |
7 | 5890 #ifdef FEAT_DIFF |
5891 to->wo_diff = from->wo_diff; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5892 to->wo_diff_saved = from->wo_diff_saved; |
7 | 5893 #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
|
5894 #ifdef FEAT_CONCEAL |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5895 to->wo_cocu = copy_option_val(from->wo_cocu); |
2379
b67b0b5a93d3
Window split didn't copy the value of 'conceallevel'.
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
5896 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
|
5897 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5898 #ifdef FEAT_TERMINAL |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5899 to->wo_twk = copy_option_val(from->wo_twk); |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5900 to->wo_tws = copy_option_val(from->wo_tws); |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5901 #endif |
7 | 5902 #ifdef FEAT_FOLDING |
5903 to->wo_fdc = from->wo_fdc; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5904 to->wo_fdc_save = from->wo_fdc_save; |
7 | 5905 to->wo_fen = from->wo_fen; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5906 to->wo_fen_save = from->wo_fen_save; |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5907 to->wo_fdi = copy_option_val(from->wo_fdi); |
7 | 5908 to->wo_fml = from->wo_fml; |
5909 to->wo_fdl = from->wo_fdl; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5910 to->wo_fdl_save = from->wo_fdl_save; |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5911 to->wo_fdm = copy_option_val(from->wo_fdm); |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5912 to->wo_fdm_save = from->wo_diff_saved |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5913 ? vim_strsave(from->wo_fdm_save) : empty_option; |
7 | 5914 to->wo_fdn = from->wo_fdn; |
5915 # ifdef FEAT_EVAL | |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5916 to->wo_fde = copy_option_val(from->wo_fde); |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5917 to->wo_fdt = copy_option_val(from->wo_fdt); |
7 | 5918 # endif |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5919 to->wo_fmr = copy_option_val(from->wo_fmr); |
7 | 5920 #endif |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5921 #ifdef FEAT_SIGNS |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5922 to->wo_scl = copy_option_val(from->wo_scl); |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5923 #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
|
5924 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5925 #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
|
5926 // 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
|
5927 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
|
5928 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
|
5929 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5930 check_winopt(to); // don't want NULL pointers |
7 | 5931 } |
5932 | |
5933 /* | |
5934 * Check string options in a window for a NULL value. | |
5935 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
5936 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5937 check_win_options(win_T *win) |
7 | 5938 { |
5939 check_winopt(&win->w_onebuf_opt); | |
5940 check_winopt(&win->w_allbuf_opt); | |
5941 } | |
5942 | |
5943 /* | |
5944 * Check for NULL pointers in a winopt_T and replace them with empty_option. | |
5945 */ | |
5997 | 5946 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5947 check_winopt(winopt_T *wop UNUSED) |
7 | 5948 { |
5949 #ifdef FEAT_FOLDING | |
5950 check_string_option(&wop->wo_fdi); | |
5951 check_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
5952 check_string_option(&wop->wo_fdm_save); |
7 | 5953 # ifdef FEAT_EVAL |
5954 check_string_option(&wop->wo_fde); | |
5955 check_string_option(&wop->wo_fdt); | |
5956 # endif | |
5957 check_string_option(&wop->wo_fmr); | |
5958 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5959 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5960 check_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
5961 #endif |
7 | 5962 #ifdef FEAT_RIGHTLEFT |
5963 check_string_option(&wop->wo_rlc); | |
5964 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5965 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5966 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
|
5967 #endif |
40 | 5968 #ifdef FEAT_STL_OPT |
5969 check_string_option(&wop->wo_stl); | |
5970 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5971 #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
|
5972 check_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5973 check_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
5974 #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
|
5975 #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
|
5976 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
|
5977 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
5978 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
5979 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
|
5980 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
|
5981 #endif |
5995 | 5982 #ifdef FEAT_LINEBREAK |
5983 check_string_option(&wop->wo_briopt); | |
5984 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5985 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
|
5986 check_string_option(&wop->wo_lcs); |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
5987 check_string_option(&wop->wo_fcs); |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
5988 check_string_option(&wop->wo_ve); |
7 | 5989 } |
5990 | |
5991 /* | |
5992 * Free the allocated memory inside a winopt_T. | |
5993 */ | |
5994 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5995 clear_winopt(winopt_T *wop UNUSED) |
7 | 5996 { |
5997 #ifdef FEAT_FOLDING | |
5998 clear_string_option(&wop->wo_fdi); | |
5999 clear_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6000 clear_string_option(&wop->wo_fdm_save); |
7 | 6001 # ifdef FEAT_EVAL |
6002 clear_string_option(&wop->wo_fde); | |
6003 clear_string_option(&wop->wo_fdt); | |
6004 # endif | |
6005 clear_string_option(&wop->wo_fmr); | |
6006 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6007 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6008 clear_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6009 #endif |
5995 | 6010 #ifdef FEAT_LINEBREAK |
6011 clear_string_option(&wop->wo_briopt); | |
6012 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
6013 clear_string_option(&wop->wo_wcr); |
7 | 6014 #ifdef FEAT_RIGHTLEFT |
6015 clear_string_option(&wop->wo_rlc); | |
6016 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6017 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6018 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
|
6019 #endif |
40 | 6020 #ifdef FEAT_STL_OPT |
6021 clear_string_option(&wop->wo_stl); | |
6022 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6023 #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
|
6024 clear_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6025 clear_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6026 #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
|
6027 #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
|
6028 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
|
6029 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
6030 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6031 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
|
6032 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
|
6033 #endif |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
6034 clear_string_option(&wop->wo_lcs); |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6035 clear_string_option(&wop->wo_fcs); |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
6036 clear_string_option(&wop->wo_ve); |
7 | 6037 } |
6038 | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6039 #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
|
6040 // 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
|
6041 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
|
6042 # 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
|
6043 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6044 /* |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6045 * 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
|
6046 */ |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6047 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
|
6048 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
|
6049 { |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6050 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
|
6051 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
|
6052 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6053 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
|
6054 return; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6055 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
|
6056 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
|
6057 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
|
6058 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
|
6059 } |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6060 #else |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6061 # 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
|
6062 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6063 |
7 | 6064 /* |
6065 * Copy global option values to local options for one buffer. | |
6066 * Used when creating a new buffer and sometimes when entering a buffer. | |
6067 * 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
|
6068 * BCO_ENTER We will enter the buffer "buf". |
7 | 6069 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when |
6070 * appropriate. | |
6071 * BCO_NOHELP Don't copy the values to a help buffer. | |
6072 */ | |
6073 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6074 buf_copy_options(buf_T *buf, int flags) |
7 | 6075 { |
6076 int should_copy = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6077 char_u *save_p_isk = NULL; // init for GCC |
7 | 6078 int dont_do_help; |
6079 int did_isk = FALSE; | |
6080 | |
6081 /* | |
6082 * Skip this when the option defaults have not been set yet. Happens when | |
6083 * main() allocates the first buffer. | |
6084 */ | |
6085 if (p_cpo != NULL) | |
6086 { | |
6087 /* | |
6088 * Always copy when entering and 'cpo' contains 'S'. | |
6089 * Don't copy when already initialized. | |
6090 * Don't copy when 'cpo' contains 's' and not entering. | |
6091 * 'S' BCO_ENTER initialized 's' should_copy | |
6092 * yes yes X X TRUE | |
6093 * yes no yes X FALSE | |
6094 * no X yes X FALSE | |
6095 * X no no yes FALSE | |
6096 * X no no no TRUE | |
6097 * no yes no X TRUE | |
6098 */ | |
6099 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) | |
6100 && (buf->b_p_initialized | |
6101 || (!(flags & BCO_ENTER) | |
6102 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
6103 should_copy = FALSE; | |
6104 | |
6105 if (should_copy || (flags & BCO_ALWAYS)) | |
6106 { | |
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
|
6107 #ifdef FEAT_EVAL |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
6108 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
|
6109 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
|
6110 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6111 // 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
|
6112 // 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
|
6113 // (jumping back to a help file with CTRL-T or CTRL-O) |
7 | 6114 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) |
6115 || 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
|
6116 if (dont_do_help) // don't free b_p_isk |
7 | 6117 { |
6118 save_p_isk = buf->b_p_isk; | |
6119 buf->b_p_isk = NULL; | |
6120 } | |
6121 /* | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14381
diff
changeset
|
6122 * 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
|
6123 * reset 'readonly' and copy 'fileformat'. |
7 | 6124 */ |
6125 if (!buf->b_p_initialized) | |
6126 { | |
6127 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
|
6128 buf->b_p_ro = FALSE; // don't copy readonly |
7 | 6129 buf->b_p_tx = p_tx; |
6130 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
|
6131 switch (*p_ffs) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6132 { |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6133 case 'm': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6134 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
|
6135 case 'd': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6136 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
|
6137 case 'u': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6138 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
|
6139 default: |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6140 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
|
6141 } |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6142 if (buf->b_p_ff != NULL) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6143 buf->b_start_ffc = *buf->b_p_ff; |
7 | 6144 buf->b_p_bh = empty_option; |
6145 buf->b_p_bt = empty_option; | |
6146 } | |
6147 else | |
6148 free_buf_options(buf, FALSE); | |
6149 | |
6150 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
|
6151 COPY_OPT_SCTX(buf, BV_AI); |
7 | 6152 buf->b_p_ai_nopaste = p_ai_nopaste; |
6153 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
|
6154 COPY_OPT_SCTX(buf, BV_SW); |
7 | 6155 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
|
6156 COPY_OPT_SCTX(buf, BV_TW); |
7 | 6157 buf->b_p_tw_nopaste = p_tw_nopaste; |
6158 buf->b_p_tw_nobin = p_tw_nobin; | |
6159 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
|
6160 COPY_OPT_SCTX(buf, BV_WM); |
7 | 6161 buf->b_p_wm_nopaste = p_wm_nopaste; |
6162 buf->b_p_wm_nobin = p_wm_nobin; | |
6163 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
|
6164 COPY_OPT_SCTX(buf, BV_BIN); |
402 | 6165 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
|
6166 COPY_OPT_SCTX(buf, BV_BOMB); |
6954 | 6167 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
|
6168 COPY_OPT_SCTX(buf, BV_FIXEOL); |
7 | 6169 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
|
6170 COPY_OPT_SCTX(buf, BV_ET); |
7 | 6171 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
|
6172 buf->b_p_et_nopaste = p_et_nopaste; |
7 | 6173 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
|
6174 COPY_OPT_SCTX(buf, BV_ML); |
7 | 6175 buf->b_p_ml_nobin = p_ml_nobin; |
6176 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
|
6177 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
|
6178 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
|
6179 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
|
6180 else |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6181 { |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6182 buf->b_p_swf = p_swf; |
26550
919ee902079a
patch 8.2.3804: script context not set when copying 'swf' and 'ts'
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
6183 COPY_OPT_SCTX(buf, BV_SWF); |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6184 } |
7 | 6185 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
|
6186 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
|
6187 #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
|
6188 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
|
6189 COPY_OPT_SCTX(buf, BV_CSL); |
7 | 6190 #endif |
12 | 6191 #ifdef FEAT_COMPL_FUNC |
6192 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
|
6193 COPY_OPT_SCTX(buf, BV_CFU); |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
6194 set_buflocal_cfu_callback(buf); |
502 | 6195 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
|
6196 COPY_OPT_SCTX(buf, BV_OFU); |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
6197 set_buflocal_ofu_callback(buf); |
12 | 6198 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
6199 #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
|
6200 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
|
6201 COPY_OPT_SCTX(buf, BV_TFU); |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
6202 set_buflocal_tfu_callback(buf); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
6203 #endif |
7 | 6204 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
|
6205 COPY_OPT_SCTX(buf, BV_STS); |
7 | 6206 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
|
6207 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6208 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
|
6209 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
|
6210 if (p_vsts && p_vsts != empty_option) |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
6211 (void)tabstop_set(p_vsts, &buf->b_p_vsts_array); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6212 else |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
6213 buf->b_p_vsts_array = NULL; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6214 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
|
6215 ? 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
|
6216 #endif |
7 | 6217 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
|
6218 COPY_OPT_SCTX(buf, BV_SN); |
7 | 6219 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
|
6220 COPY_OPT_SCTX(buf, BV_COM); |
7 | 6221 #ifdef FEAT_FOLDING |
6222 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
|
6223 COPY_OPT_SCTX(buf, BV_CMS); |
7 | 6224 #endif |
6225 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
|
6226 COPY_OPT_SCTX(buf, BV_FO); |
41 | 6227 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
|
6228 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
|
6229 // 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
|
6230 // when it is set to 8 bytes in defaults.vim. |
7 | 6231 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
|
6232 COPY_OPT_SCTX(buf, BV_NF); |
7 | 6233 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
|
6234 COPY_OPT_SCTX(buf, BV_MPS); |
7 | 6235 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
|
6236 COPY_OPT_SCTX(buf, BV_SI); |
7 | 6237 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
|
6238 COPY_OPT_SCTX(buf, BV_CI); |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
6239 |
7 | 6240 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
|
6241 COPY_OPT_SCTX(buf, BV_CIN); |
7 | 6242 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
|
6243 COPY_OPT_SCTX(buf, BV_CINK); |
7 | 6244 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
|
6245 COPY_OPT_SCTX(buf, BV_CINO); |
28353
8bc8071928ed
patch 8.2.4702: C++ scope labels are hard-coded
Bram Moolenaar <Bram@vim.org>
parents:
28337
diff
changeset
|
6246 buf->b_p_cinsd = vim_strsave(p_cinsd); |
8bc8071928ed
patch 8.2.4702: C++ scope labels are hard-coded
Bram Moolenaar <Bram@vim.org>
parents:
28337
diff
changeset
|
6247 COPY_OPT_SCTX(buf, BV_CINSD); |
30853
40df8a6515f6
patch 9.0.0761: cannot use 'indentexpr' for Lisp indenting
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
6248 buf->b_p_lop = vim_strsave(p_lop); |
40df8a6515f6
patch 9.0.0761: cannot use 'indentexpr' for Lisp indenting
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
6249 COPY_OPT_SCTX(buf, BV_LOP); |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
6250 |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6251 // Don't copy 'filetype', it must be detected |
7 | 6252 buf->b_p_ft = empty_option; |
6253 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
|
6254 COPY_OPT_SCTX(buf, BV_PI); |
7 | 6255 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
|
6256 COPY_OPT_SCTX(buf, BV_CINW); |
7 | 6257 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
|
6258 COPY_OPT_SCTX(buf, BV_LISP); |
7 | 6259 #ifdef FEAT_SYN_HL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6260 // Don't copy 'syntax', it must be set |
7 | 6261 buf->b_p_syn = empty_option; |
410 | 6262 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
|
6263 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
|
6264 buf->b_s.b_syn_isk = empty_option; |
744 | 6265 #endif |
6266 #ifdef FEAT_SPELL | |
2599 | 6267 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
|
6268 COPY_OPT_SCTX(buf, BV_SPC); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6269 (void)compile_cap_prog(&buf->b_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6270 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
|
6271 COPY_OPT_SCTX(buf, BV_SPF); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6272 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
|
6273 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
|
6274 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
|
6275 COPY_OPT_SCTX(buf, BV_SPO); |
7 | 6276 #endif |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
6277 #if defined(FEAT_EVAL) |
7 | 6278 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
|
6279 COPY_OPT_SCTX(buf, BV_INDE); |
7 | 6280 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
|
6281 COPY_OPT_SCTX(buf, BV_INDK); |
7 | 6282 #endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
6283 buf->b_p_fp = empty_option; |
667 | 6284 #if defined(FEAT_EVAL) |
6285 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
|
6286 COPY_OPT_SCTX(buf, BV_FEX); |
667 | 6287 #endif |
7 | 6288 #ifdef FEAT_CRYPT |
6289 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
|
6290 COPY_OPT_SCTX(buf, BV_KEY); |
7 | 6291 #endif |
6292 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
|
6293 COPY_OPT_SCTX(buf, BV_SUA); |
7 | 6294 #ifdef FEAT_KEYMAP |
6295 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
|
6296 COPY_OPT_SCTX(buf, BV_KMAP); |
7 | 6297 buf->b_kmap_state |= KEYMAP_INIT; |
6298 #endif | |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6299 #ifdef FEAT_TERMINAL |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6300 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
|
6301 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
|
6302 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6303 // 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
|
6304 // state from the current buffer is better than resetting it. |
7 | 6305 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
|
6306 COPY_OPT_SCTX(buf, BV_IMI); |
7 | 6307 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
|
6308 COPY_OPT_SCTX(buf, BV_IMS); |
7 | 6309 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6310 // 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
|
6311 // are not copied, start using the global value |
7 | 6312 buf->b_p_ar = -1; |
5446 | 6313 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
6243 | 6314 buf->b_p_bkc = empty_option; |
6315 buf->b_bkc_flags = 0; | |
7 | 6316 #ifdef FEAT_QUICKFIX |
6317 buf->b_p_gp = empty_option; | |
6318 buf->b_p_mp = empty_option; | |
6319 buf->b_p_efm = empty_option; | |
6320 #endif | |
6321 buf->b_p_ep = empty_option; | |
6322 buf->b_p_kp = empty_option; | |
6323 buf->b_p_path = empty_option; | |
6324 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
|
6325 buf->b_p_tc = empty_option; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
6326 buf->b_tc_flags = 0; |
7 | 6327 #ifdef FEAT_FIND_ID |
6328 buf->b_p_def = empty_option; | |
6329 buf->b_p_inc = empty_option; | |
6330 # ifdef FEAT_EVAL | |
6331 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
|
6332 COPY_OPT_SCTX(buf, BV_INEX); |
7 | 6333 # endif |
6334 #endif | |
6335 buf->b_p_dict = empty_option; | |
6336 buf->b_p_tsr = empty_option; | |
25990
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
6337 #ifdef FEAT_COMPL_FUNC |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
6338 buf->b_p_tsrfu = empty_option; |
ac330e2fecc4
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents:
25984
diff
changeset
|
6339 #endif |
12 | 6340 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
|
6341 COPY_OPT_SCTX(buf, BV_QE); |
790 | 6342 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
6343 buf->b_p_bexpr = empty_option; | |
6344 #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
|
6345 #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
|
6346 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
|
6347 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
6348 #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
|
6349 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
|
6350 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
|
6351 #endif |
5712 | 6352 buf->b_p_lw = empty_option; |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10968
diff
changeset
|
6353 buf->b_p_menc = empty_option; |
7 | 6354 |
6355 /* | |
6356 * Don't copy the options set by ex_help(), use the saved values, | |
6357 * when going from a help buffer to a non-help buffer. | |
6358 * Don't touch these at all when BCO_NOHELP is used and going from | |
6359 * or to a help buffer. | |
6360 */ | |
6361 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
|
6362 { |
7 | 6363 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
|
6364 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6365 if (p_vts && p_vts != empty_option && !buf->b_p_vts_array) |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
6366 (void)tabstop_set(p_vts, &buf->b_p_vts_array); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6367 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6368 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
|
6369 #endif |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6370 } |
7 | 6371 else |
6372 { | |
6373 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
|
6374 COPY_OPT_SCTX(buf, BV_ISK); |
7 | 6375 did_isk = TRUE; |
6376 buf->b_p_ts = p_ts; | |
26550
919ee902079a
patch 8.2.3804: script context not set when copying 'swf' and 'ts'
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
6377 COPY_OPT_SCTX(buf, BV_TS); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6378 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6379 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
|
6380 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
|
6381 if (p_vts && p_vts != empty_option && !buf->b_p_vts_array) |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
6382 (void)tabstop_set(p_vts, &buf->b_p_vts_array); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6383 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6384 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
|
6385 #endif |
7 | 6386 buf->b_help = FALSE; |
6387 if (buf->b_p_bt[0] == 'h') | |
6388 clear_string_option(&buf->b_p_bt); | |
6389 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
|
6390 COPY_OPT_SCTX(buf, BV_MA); |
7 | 6391 } |
6392 } | |
6393 | |
6394 /* | |
6395 * When the options should be copied (ignoring BCO_ALWAYS), set the | |
6396 * flag that indicates that the options have been initialized. | |
6397 */ | |
6398 if (should_copy) | |
6399 buf->b_p_initialized = TRUE; | |
6400 } | |
6401 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6402 check_buf_options(buf); // make sure we don't have NULLs |
7 | 6403 if (did_isk) |
6404 (void)buf_init_chartab(buf, FALSE); | |
6405 } | |
6406 | |
6407 /* | |
6408 * Reset the 'modifiable' option and its default value. | |
6409 */ | |
6410 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6411 reset_modifiable(void) |
7 | 6412 { |
6413 int opt_idx; | |
6414 | |
6415 curbuf->b_p_ma = FALSE; | |
6416 p_ma = FALSE; | |
6417 opt_idx = findoption((char_u *)"ma"); | |
838 | 6418 if (opt_idx >= 0) |
6419 options[opt_idx].def_val[VI_DEFAULT] = FALSE; | |
7 | 6420 } |
6421 | |
6422 /* | |
6423 * Set the global value for 'iminsert' to the local value. | |
6424 */ | |
6425 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6426 set_iminsert_global(void) |
7 | 6427 { |
6428 p_iminsert = curbuf->b_p_iminsert; | |
6429 } | |
6430 | |
6431 /* | |
6432 * Set the global value for 'imsearch' to the local value. | |
6433 */ | |
6434 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6435 set_imsearch_global(void) |
7 | 6436 { |
6437 p_imsearch = curbuf->b_p_imsearch; | |
6438 } | |
6439 | |
6440 static int expand_option_idx = -1; | |
6441 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; | |
6442 static int expand_option_flags = 0; | |
6443 | |
6444 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6445 set_context_in_set_cmd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6446 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6447 char_u *arg, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6448 int opt_flags) // OPT_GLOBAL and/or OPT_LOCAL |
7 | 6449 { |
6450 int nextchar; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6451 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
|
6452 int opt_idx = 0; // init for GCC |
7 | 6453 char_u *p; |
6454 char_u *s; | |
6455 int is_term_option = FALSE; | |
6456 int key; | |
6457 | |
6458 expand_option_flags = opt_flags; | |
6459 | |
6460 xp->xp_context = EXPAND_SETTINGS; | |
6461 if (*arg == NUL) | |
6462 { | |
6463 xp->xp_pattern = arg; | |
6464 return; | |
6465 } | |
6466 p = arg + STRLEN(arg) - 1; | |
6467 if (*p == ' ' && *(p - 1) != '\\') | |
6468 { | |
6469 xp->xp_pattern = p + 1; | |
6470 return; | |
6471 } | |
6472 while (p > arg) | |
6473 { | |
6474 s = p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6475 // count number of backslashes before ' ' or ',' |
7 | 6476 if (*p == ' ' || *p == ',') |
6477 { | |
6478 while (s > arg && *(s - 1) == '\\') | |
6479 --s; | |
6480 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6481 // break at a space with an even number of backslashes |
7 | 6482 if (*p == ' ' && ((p - s) & 1) == 0) |
6483 { | |
6484 ++p; | |
6485 break; | |
6486 } | |
6487 --p; | |
6488 } | |
1911 | 6489 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0) |
7 | 6490 { |
6491 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
6492 p += 2; | |
6493 } | |
6494 if (STRNCMP(p, "inv", 3) == 0) | |
6495 { | |
6496 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
6497 p += 3; | |
6498 } | |
6499 xp->xp_pattern = arg = p; | |
6500 if (*arg == '<') | |
6501 { | |
6502 while (*p != '>') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6503 if (*p++ == NUL) // expand terminal option name |
7 | 6504 return; |
6505 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
|
6506 if (key == 0) // unknown name |
7 | 6507 { |
6508 xp->xp_context = EXPAND_NOTHING; | |
6509 return; | |
6510 } | |
6511 nextchar = *++p; | |
6512 is_term_option = TRUE; | |
6513 expand_option_name[2] = KEY2TERMCAP0(key); | |
6514 expand_option_name[3] = KEY2TERMCAP1(key); | |
6515 } | |
6516 else | |
6517 { | |
6518 if (p[0] == 't' && p[1] == '_') | |
6519 { | |
6520 p += 2; | |
6521 if (*p != NUL) | |
6522 ++p; | |
6523 if (*p == NUL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6524 return; // expand option name |
7 | 6525 nextchar = *++p; |
6526 is_term_option = TRUE; | |
6527 expand_option_name[2] = p[-2]; | |
6528 expand_option_name[3] = p[-1]; | |
6529 } | |
6530 else | |
6531 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6532 // Allow * wildcard |
7 | 6533 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') |
6534 p++; | |
6535 if (*p == NUL) | |
6536 return; | |
6537 nextchar = *p; | |
6538 *p = NUL; | |
6539 opt_idx = findoption(arg); | |
6540 *p = nextchar; | |
6541 if (opt_idx == -1 || options[opt_idx].var == NULL) | |
6542 { | |
6543 xp->xp_context = EXPAND_NOTHING; | |
6544 return; | |
6545 } | |
6546 flags = options[opt_idx].flags; | |
6547 if (flags & P_BOOL) | |
6548 { | |
6549 xp->xp_context = EXPAND_NOTHING; | |
6550 return; | |
6551 } | |
6552 } | |
6553 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6554 // handle "-=" and "+=" |
7 | 6555 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') |
6556 { | |
6557 ++p; | |
6558 nextchar = '='; | |
6559 } | |
6560 if ((nextchar != '=' && nextchar != ':') | |
6561 || xp->xp_context == EXPAND_BOOL_SETTINGS) | |
6562 { | |
6563 xp->xp_context = EXPAND_UNSUCCESSFUL; | |
6564 return; | |
6565 } | |
6566 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) | |
6567 { | |
6568 xp->xp_context = EXPAND_OLD_SETTING; | |
6569 if (is_term_option) | |
6570 expand_option_idx = -1; | |
6571 else | |
6572 expand_option_idx = opt_idx; | |
6573 xp->xp_pattern = p + 1; | |
6574 return; | |
6575 } | |
6576 xp->xp_context = EXPAND_NOTHING; | |
6577 if (is_term_option || (flags & P_NUM)) | |
6578 return; | |
6579 | |
6580 xp->xp_pattern = p + 1; | |
6581 | |
6582 if (flags & P_EXPAND) | |
6583 { | |
6584 p = options[opt_idx].var; | |
6585 if (p == (char_u *)&p_bdir | |
6586 || p == (char_u *)&p_dir | |
6587 || p == (char_u *)&p_path | |
8182
95d59081580f
commit https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
6588 || p == (char_u *)&p_pp |
7 | 6589 || p == (char_u *)&p_rtp |
6590 || p == (char_u *)&p_cdpath | |
6591 #ifdef FEAT_SESSION | |
6592 || p == (char_u *)&p_vdir | |
6593 #endif | |
6594 ) | |
6595 { | |
6596 xp->xp_context = EXPAND_DIRECTORIES; | |
29853
31c598083364
patch 9.0.0265: no good reason why the "gf" command isn't in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
29765
diff
changeset
|
6597 if (p == (char_u *)&p_path || p == (char_u *)&p_cdpath) |
7 | 6598 xp->xp_backslash = XP_BS_THREE; |
6599 else | |
6600 xp->xp_backslash = XP_BS_ONE; | |
6601 } | |
23821
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
6602 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
|
6603 { |
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
6604 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
|
6605 } |
7 | 6606 else |
6607 { | |
6608 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
|
6609 // for 'tags' need three backslashes for a space |
7 | 6610 if (p == (char_u *)&p_tags) |
6611 xp->xp_backslash = XP_BS_THREE; | |
6612 else | |
6613 xp->xp_backslash = XP_BS_ONE; | |
6614 } | |
6615 } | |
6616 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6617 // 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
|
6618 // last file name. |
7 | 6619 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) |
6620 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6621 // count number of backslashes before ' ' or ',' |
7 | 6622 if (*p == ' ' || *p == ',') |
6623 { | |
6624 s = p; | |
6625 while (s > xp->xp_pattern && *(s - 1) == '\\') | |
6626 --s; | |
6627 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) | |
6628 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) | |
6629 { | |
6630 xp->xp_pattern = p + 1; | |
6631 break; | |
6632 } | |
6633 } | |
374 | 6634 |
744 | 6635 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6636 // for 'spellsuggest' start at "file:" |
374 | 6637 if (options[opt_idx].var == (char_u *)&p_sps |
6638 && STRNCMP(p, "file:", 5) == 0) | |
6639 { | |
6640 xp->xp_pattern = p + 5; | |
6641 break; | |
6642 } | |
6643 #endif | |
7 | 6644 } |
6645 } | |
6646 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6647 /* |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6648 * Returns TRUE if 'str' either matches 'regmatch' or fuzzy matches 'pat'. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6649 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6650 * If 'test_only' is TRUE and 'fuzzy' is FALSE and if 'str' matches the regular |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6651 * expression 'regmatch', then returns TRUE. Otherwise returns FALSE. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6652 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6653 * If 'test_only' is FALSE and 'fuzzy' is FALSE and if 'str' matches the |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6654 * regular expression 'regmatch', then stores the match in matches[idx] and |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6655 * returns TRUE. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6656 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6657 * If 'test_only' is TRUE and 'fuzzy' is TRUE and if 'str' fuzzy matches |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6658 * 'fuzzystr', then returns TRUE. Otherwise returns FALSE. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6659 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6660 * If 'test_only' is FALSE and 'fuzzy' is TRUE and if 'str' fuzzy matches |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6661 * 'fuzzystr', then stores the match details in fuzmatch[idx] and returns TRUE. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6662 */ |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6663 static int |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6664 match_str( |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6665 char_u *str, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6666 regmatch_T *regmatch, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6667 char_u **matches, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6668 int idx, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6669 int test_only, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6670 int fuzzy, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6671 char_u *fuzzystr, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6672 fuzmatch_str_T *fuzmatch) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6673 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6674 if (!fuzzy) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6675 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6676 if (vim_regexec(regmatch, str, (colnr_T)0)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6677 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6678 if (!test_only) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6679 matches[idx] = vim_strsave(str); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6680 return TRUE; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6681 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6682 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6683 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6684 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6685 int score; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6686 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6687 score = fuzzy_match_str(str, fuzzystr); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6688 if (score != 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6689 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6690 if (!test_only) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6691 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6692 fuzmatch[idx].idx = idx; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6693 fuzmatch[idx].str = vim_strsave(str); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6694 fuzmatch[idx].score = score; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6695 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6696 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6697 return TRUE; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6698 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6699 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6700 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6701 return FALSE; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6702 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6703 |
7 | 6704 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6705 ExpandSettings( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6706 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6707 regmatch_T *regmatch, |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6708 char_u *fuzzystr, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6709 int *numMatches, |
28786
fd5942a62312
patch 8.2.4917: fuzzy expansion of option names is not right
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
6710 char_u ***matches, |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
6711 int can_fuzzy) |
7 | 6712 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6713 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
|
6714 int num_term = 0; // Nr of matching terminal code settings |
7 | 6715 int opt_idx; |
6716 int match; | |
6717 int count = 0; | |
6718 char_u *str; | |
6719 int loop; | |
6720 int is_term_opt; | |
6721 char_u name_buf[MAX_KEY_NAME_LEN]; | |
6722 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
|
6723 int ic = regmatch->rm_ic; // remember the ignore-case flag |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6724 int fuzzy; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6725 fuzmatch_str_T *fuzmatch = NULL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6726 |
28786
fd5942a62312
patch 8.2.4917: fuzzy expansion of option names is not right
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
6727 fuzzy = can_fuzzy && cmdline_fuzzy_complete(fuzzystr); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6728 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6729 // do this loop twice: |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6730 // 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
|
6731 // loop == 1: copy the matching options into allocated memory |
7 | 6732 for (loop = 0; loop <= 1; ++loop) |
6733 { | |
6734 regmatch->rm_ic = ic; | |
6735 if (xp->xp_context != EXPAND_BOOL_SETTINGS) | |
6736 { | |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
6737 for (match = 0; match < (int)ARRAY_LENGTH(names); ++match) |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6738 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6739 if (match_str((char_u *)names[match], regmatch, *matches, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6740 count, (loop == 0), fuzzy, fuzzystr, fuzmatch)) |
7 | 6741 { |
6742 if (loop == 0) | |
6743 num_normal++; | |
6744 else | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6745 count++; |
7 | 6746 } |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6747 } |
7 | 6748 } |
6749 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; | |
6750 opt_idx++) | |
6751 { | |
6752 if (options[opt_idx].var == NULL) | |
6753 continue; | |
6754 if (xp->xp_context == EXPAND_BOOL_SETTINGS | |
6755 && !(options[opt_idx].flags & P_BOOL)) | |
6756 continue; | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6757 is_term_opt = istermoption_idx(opt_idx); |
7 | 6758 if (is_term_opt && num_normal > 0) |
6759 continue; | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6760 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6761 if (match_str(str, regmatch, *matches, count, (loop == 0), |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6762 fuzzy, fuzzystr, fuzmatch)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6763 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6764 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6765 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6766 if (is_term_opt) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6767 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6768 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6769 num_normal++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6770 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6771 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6772 count++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6773 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6774 else if (!fuzzy && options[opt_idx].shortname != NULL |
7 | 6775 && vim_regexec(regmatch, |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
6776 (char_u *)options[opt_idx].shortname, (colnr_T)0)) |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6777 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6778 // Compare against the abbreviated option name (for regular |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6779 // expression match). Fuzzy matching (previous if) already |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6780 // matches against both the expanded and abbreviated names. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6781 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6782 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6783 if (is_term_opt) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6784 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6785 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6786 num_normal++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6787 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6788 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6789 (*matches)[count++] = vim_strsave(str); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6790 } |
7 | 6791 else if (is_term_opt) |
6792 { | |
6793 name_buf[0] = '<'; | |
6794 name_buf[1] = 't'; | |
6795 name_buf[2] = '_'; | |
6796 name_buf[3] = str[2]; | |
6797 name_buf[4] = str[3]; | |
6798 name_buf[5] = '>'; | |
6799 name_buf[6] = NUL; | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6800 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6801 if (match_str(name_buf, regmatch, *matches, count, (loop == 0), |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6802 fuzzy, fuzzystr, fuzmatch)) |
7 | 6803 { |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6804 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6805 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6806 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6807 count++; |
7 | 6808 } |
6809 } | |
6810 } | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6811 |
7 | 6812 /* |
6813 * Check terminal key codes, these are not in the option table | |
6814 */ | |
6815 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) | |
6816 { | |
6817 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) | |
6818 { | |
6819 if (!isprint(str[0]) || !isprint(str[1])) | |
6820 continue; | |
6821 | |
6822 name_buf[0] = 't'; | |
6823 name_buf[1] = '_'; | |
6824 name_buf[2] = str[0]; | |
6825 name_buf[3] = str[1]; | |
6826 name_buf[4] = NUL; | |
6827 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6828 if (match_str(name_buf, regmatch, *matches, count, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6829 (loop == 0), fuzzy, fuzzystr, fuzmatch)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6830 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6831 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6832 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6833 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6834 count++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6835 } |
7 | 6836 else |
6837 { | |
6838 name_buf[0] = '<'; | |
6839 name_buf[1] = 't'; | |
6840 name_buf[2] = '_'; | |
6841 name_buf[3] = str[0]; | |
6842 name_buf[4] = str[1]; | |
6843 name_buf[5] = '>'; | |
6844 name_buf[6] = NUL; | |
6845 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6846 if (match_str(name_buf, regmatch, *matches, count, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6847 (loop == 0), fuzzy, fuzzystr, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6848 fuzmatch)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6849 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6850 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6851 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6852 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6853 count++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6854 } |
7 | 6855 } |
6856 } | |
6857 | |
6858 /* | |
6859 * Check special key names. | |
6860 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6861 regmatch->rm_ic = TRUE; // ignore case here |
7 | 6862 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) |
6863 { | |
6864 name_buf[0] = '<'; | |
6865 STRCPY(name_buf + 1, str); | |
6866 STRCAT(name_buf, ">"); | |
6867 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6868 if (match_str(name_buf, regmatch, *matches, count, (loop == 0), |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6869 fuzzy, fuzzystr, fuzmatch)) |
7 | 6870 { |
6871 if (loop == 0) | |
6872 num_term++; | |
6873 else | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6874 count++; |
7 | 6875 } |
6876 } | |
6877 } | |
6878 if (loop == 0) | |
6879 { | |
6880 if (num_normal > 0) | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6881 *numMatches = num_normal; |
7 | 6882 else if (num_term > 0) |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6883 *numMatches = num_term; |
7 | 6884 else |
6885 return OK; | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6886 if (!fuzzy) |
7 | 6887 { |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6888 *matches = ALLOC_MULT(char_u *, *numMatches); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6889 if (*matches == NULL) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6890 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6891 *matches = (char_u **)""; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6892 return FAIL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6893 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6894 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6895 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6896 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6897 fuzmatch = ALLOC_MULT(fuzmatch_str_T, *numMatches); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6898 if (fuzmatch == NULL) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6899 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6900 *matches = (char_u **)""; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6901 return FAIL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6902 } |
7 | 6903 } |
6904 } | |
6905 } | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6906 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6907 if (fuzzy && |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6908 fuzzymatches_to_strmatches(fuzmatch, matches, count, FALSE) == FAIL) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6909 return FAIL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
6910 |
7 | 6911 return OK; |
6912 } | |
6913 | |
6914 int | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
6915 ExpandOldSetting(int *numMatches, char_u ***matches) |
7 | 6916 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6917 char_u *var = NULL; // init for GCC |
7 | 6918 char_u *buf; |
6919 | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
6920 *numMatches = 0; |
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
6921 *matches = ALLOC_ONE(char_u *); |
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
6922 if (*matches == NULL) |
7 | 6923 return FAIL; |
6924 | |
6925 /* | |
6926 * For a terminal key code expand_option_idx is < 0. | |
6927 */ | |
6928 if (expand_option_idx < 0) | |
6929 { | |
6930 var = find_termcode(expand_option_name + 2); | |
6931 if (var == NULL) | |
6932 expand_option_idx = findoption(expand_option_name); | |
6933 } | |
6934 | |
6935 if (expand_option_idx >= 0) | |
6936 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6937 // put string of option value in NameBuff |
7 | 6938 option_value2string(&options[expand_option_idx], expand_option_flags); |
6939 var = NameBuff; | |
6940 } | |
6941 else if (var == NULL) | |
6942 var = (char_u *)""; | |
6943 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6944 // 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
|
6945 // what happens in do_set(). |
7 | 6946 buf = vim_strsave_escaped(var, escape_chars); |
6947 | |
6948 if (buf == NULL) | |
6949 { | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
6950 VIM_CLEAR(*matches); |
7 | 6951 return FAIL; |
6952 } | |
6953 | |
6954 #ifdef BACKSLASH_IN_FILENAME | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6955 // 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
|
6956 // 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
|
6957 for (var = buf; *var != NUL; MB_PTR_ADV(var)) |
7 | 6958 if (var[0] == '\\' && var[1] == '\\' |
6959 && expand_option_idx >= 0 | |
6960 && (options[expand_option_idx].flags & P_EXPAND) | |
6961 && vim_isfilec(var[2]) | |
6962 && (var[2] != '\\' || (var == buf && var[4] != '\\'))) | |
1622 | 6963 STRMOVE(var, var + 1); |
7 | 6964 #endif |
6965 | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
6966 *matches[0] = buf; |
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
6967 *numMatches = 1; |
7 | 6968 return OK; |
6969 } | |
6970 | |
6971 /* | |
6972 * Get the value for the numeric or string option *opp in a nice format into | |
6973 * NameBuff[]. Must not be called with a hidden option! | |
6974 */ | |
6975 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6976 option_value2string( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6977 struct vimoption *opp, |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
6978 int scope) // OPT_GLOBAL and/or OPT_LOCAL |
7 | 6979 { |
6980 char_u *varp; | |
6981 | |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
6982 varp = get_varp_scope(opp, scope); |
7 | 6983 |
6984 if (opp->flags & P_NUM) | |
6985 { | |
6986 long wc = 0; | |
6987 | |
6988 if (wc_use_keyname(varp, &wc)) | |
6989 STRCPY(NameBuff, get_special_key_name((int)wc, 0)); | |
6990 else if (wc != 0) | |
6991 STRCPY(NameBuff, transchar((int)wc)); | |
6992 else | |
6993 sprintf((char *)NameBuff, "%ld", *(long *)varp); | |
6994 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6995 else // P_STRING |
7 | 6996 { |
6997 varp = *(char_u **)(varp); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6998 if (varp == NULL) // just in case |
7 | 6999 NameBuff[0] = NUL; |
7000 #ifdef FEAT_CRYPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7001 // don't show the actual value of 'key', only that it's set |
840 | 7002 else if (opp->var == (char_u *)&p_key && *varp) |
7 | 7003 STRCPY(NameBuff, "*****"); |
7004 #endif | |
7005 else if (opp->flags & P_EXPAND) | |
7006 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
|
7007 // Translate 'pastetoggle' into special key names |
7 | 7008 else if ((char_u **)opp->var == &p_pt) |
7009 str2specialbuf(p_pt, NameBuff, MAXPATHL); | |
7010 else | |
419 | 7011 vim_strncpy(NameBuff, varp, MAXPATHL - 1); |
7 | 7012 } |
7013 } | |
7014 | |
7015 /* | |
7016 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be | |
7017 * printed as a keyname. | |
7018 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. | |
7019 */ | |
7020 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7021 wc_use_keyname(char_u *varp, long *wcp) |
7 | 7022 { |
7023 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) | |
7024 { | |
7025 *wcp = *(long *)varp; | |
7026 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0) | |
7027 return TRUE; | |
7028 } | |
7029 return FALSE; | |
7030 } | |
7031 | |
7032 /* | |
7033 * Return TRUE if "x" is present in 'shortmess' option, or | |
7034 * 'shortmess' contains 'a' and "x" is present in SHM_A. | |
7035 */ | |
7036 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7037 shortmess(int x) |
7 | 7038 { |
3384 | 7039 return p_shm != NULL && |
7040 ( vim_strchr(p_shm, x) != NULL | |
7 | 7041 || (vim_strchr(p_shm, 'a') != NULL |
7042 && vim_strchr((char_u *)SHM_A, x) != NULL)); | |
7043 } | |
7044 | |
7045 /* | |
7046 * paste_option_changed() - Called after p_paste was set or reset. | |
7047 */ | |
7048 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7049 paste_option_changed(void) |
7 | 7050 { |
7051 static int old_p_paste = FALSE; | |
7052 static int save_sm = 0; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7053 static int save_sta = 0; |
7 | 7054 static int save_ru = 0; |
7055 #ifdef FEAT_RIGHTLEFT | |
7056 static int save_ri = 0; | |
7057 static int save_hkmap = 0; | |
7058 #endif | |
7059 buf_T *buf; | |
7060 | |
7061 if (p_paste) | |
7062 { | |
7063 /* | |
7064 * Paste switched from off to on. | |
7065 * Save the current values, so they can be restored later. | |
7066 */ | |
7067 if (!old_p_paste) | |
7068 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7069 // save options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7070 FOR_ALL_BUFFERS(buf) |
7 | 7071 { |
7072 buf->b_p_tw_nopaste = buf->b_p_tw; | |
7073 buf->b_p_wm_nopaste = buf->b_p_wm; | |
7074 buf->b_p_sts_nopaste = buf->b_p_sts; | |
7075 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
|
7076 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
|
7077 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7078 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
|
7079 vim_free(buf->b_p_vsts_nopaste); |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
7080 buf->b_p_vsts_nopaste = |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
7081 buf->b_p_vsts && buf->b_p_vsts != empty_option |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
7082 ? vim_strsave(buf->b_p_vsts) : NULL; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7083 #endif |
7 | 7084 } |
7085 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7086 // save global options |
7 | 7087 save_sm = p_sm; |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7088 save_sta = p_sta; |
7 | 7089 save_ru = p_ru; |
7090 #ifdef FEAT_RIGHTLEFT | |
7091 save_ri = p_ri; | |
7092 save_hkmap = p_hkmap; | |
7093 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7094 // 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
|
7095 p_ai_nopaste = p_ai; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7096 p_et_nopaste = p_et; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7097 p_sts_nopaste = p_sts; |
7 | 7098 p_tw_nopaste = p_tw; |
7099 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
|
7100 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7101 if (p_vsts_nopaste) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7102 vim_free(p_vsts_nopaste); |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
7103 p_vsts_nopaste = p_vsts && p_vsts != empty_option |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
7104 ? vim_strsave(p_vsts) : NULL; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7105 #endif |
7 | 7106 } |
7107 | |
7108 /* | |
7109 * Always set the option values, also when 'paste' is set when it is | |
7110 * already on. | |
7111 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7112 // set options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7113 FOR_ALL_BUFFERS(buf) |
7 | 7114 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7115 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
|
7116 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
|
7117 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
|
7118 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
|
7119 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
|
7120 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7121 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
|
7122 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
|
7123 buf->b_p_vsts = empty_option; |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7124 VIM_CLEAR(buf->b_p_vsts_array); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7125 #endif |
7 | 7126 } |
7127 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7128 // set global options |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7129 p_sm = 0; // no showmatch |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7130 p_sta = 0; // no smarttab |
7 | 7131 if (p_ru) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7132 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
|
7133 p_ru = 0; // no ruler |
7 | 7134 #ifdef FEAT_RIGHTLEFT |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7135 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
|
7136 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
|
7137 #endif |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7138 // set global values for local buffer options |
7 | 7139 p_tw = 0; |
7140 p_wm = 0; | |
7141 p_sts = 0; | |
7142 p_ai = 0; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7143 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7144 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7145 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
|
7146 p_vsts = empty_option; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7147 #endif |
7 | 7148 } |
7149 | |
7150 /* | |
7151 * Paste switched from on to off: Restore saved values. | |
7152 */ | |
7153 else if (old_p_paste) | |
7154 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7155 // restore options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7156 FOR_ALL_BUFFERS(buf) |
7 | 7157 { |
7158 buf->b_p_tw = buf->b_p_tw_nopaste; | |
7159 buf->b_p_wm = buf->b_p_wm_nopaste; | |
7160 buf->b_p_sts = buf->b_p_sts_nopaste; | |
7161 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
|
7162 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
|
7163 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7164 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
|
7165 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
|
7166 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
|
7167 ? vim_strsave(buf->b_p_vsts_nopaste) : empty_option; |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7168 vim_free(buf->b_p_vsts_array); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7169 if (buf->b_p_vsts && buf->b_p_vsts != empty_option) |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
7170 (void)tabstop_set(buf->b_p_vsts, &buf->b_p_vsts_array); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7171 else |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7172 buf->b_p_vsts_array = NULL; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7173 #endif |
7 | 7174 } |
7175 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7176 // restore global options |
7 | 7177 p_sm = save_sm; |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7178 p_sta = save_sta; |
7 | 7179 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
|
7180 status_redraw_all(); // redraw to draw the ruler |
7 | 7181 p_ru = save_ru; |
7182 #ifdef FEAT_RIGHTLEFT | |
7183 p_ri = save_ri; | |
7184 p_hkmap = save_hkmap; | |
7185 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7186 // 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
|
7187 p_ai = p_ai_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7188 p_et = p_et_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7189 p_sts = p_sts_nopaste; |
7 | 7190 p_tw = p_tw_nopaste; |
7191 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
|
7192 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7193 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7194 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
|
7195 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
|
7196 #endif |
7 | 7197 } |
7198 | |
7199 old_p_paste = p_paste; | |
7200 } | |
7201 | |
7202 /* | |
7203 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found. | |
7204 * | |
7205 * Reset 'compatible' and set the values for options that didn't get set yet | |
7206 * to the Vim defaults. | |
7207 * Don't do this if the 'compatible' option has been set or reset before. | |
819 | 7208 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet. |
7 | 7209 */ |
7210 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7211 vimrc_found(char_u *fname, char_u *envname) |
819 | 7212 { |
7213 int opt_idx; | |
826 | 7214 int dofree = FALSE; |
819 | 7215 char_u *p; |
7 | 7216 |
7217 if (!option_was_set((char_u *)"cp")) | |
7218 { | |
7219 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
|
7220 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 7221 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF))) |
7222 set_option_default(opt_idx, OPT_FREE, FALSE); | |
7223 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
7224 didset_options2(); |
7 | 7225 } |
819 | 7226 |
7227 if (fname != NULL) | |
7228 { | |
7229 p = vim_getenv(envname, &dofree); | |
7230 if (p == NULL) | |
7231 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7232 // Set $MYVIMRC to the first vimrc file found. |
819 | 7233 p = FullName_save(fname, FALSE); |
7234 if (p != NULL) | |
7235 { | |
7236 vim_setenv(envname, p); | |
7237 vim_free(p); | |
7238 } | |
7239 } | |
7240 else if (dofree) | |
7241 vim_free(p); | |
7242 } | |
7 | 7243 } |
7244 | |
7245 /* | |
7246 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg. | |
7247 */ | |
7248 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7249 change_compatible(int on) |
7 | 7250 { |
838 | 7251 int opt_idx; |
7252 | |
7 | 7253 if (p_cp != on) |
7254 { | |
7255 p_cp = on; | |
7256 compatible_set(); | |
7257 } | |
838 | 7258 opt_idx = findoption((char_u *)"cp"); |
7259 if (opt_idx >= 0) | |
7260 options[opt_idx].flags |= P_WAS_SET; | |
7 | 7261 } |
7262 | |
7263 /* | |
7264 * 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
|
7265 * Only works correctly for global options. |
7 | 7266 */ |
7267 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7268 option_was_set(char_u *name) |
7 | 7269 { |
7270 int idx; | |
7271 | |
7272 idx = findoption(name); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7273 if (idx < 0) // unknown option |
7 | 7274 return FALSE; |
7275 if (options[idx].flags & P_WAS_SET) | |
7276 return TRUE; | |
7277 return FALSE; | |
7278 } | |
7279 | |
7280 /* | |
3980 | 7281 * Reset the flag indicating option "name" was set. |
7282 */ | |
14748
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
7283 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7284 reset_option_was_set(char_u *name) |
3980 | 7285 { |
7286 int idx = findoption(name); | |
7287 | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7288 if (idx < 0) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7289 return FAIL; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7290 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7291 options[idx].flags &= ~P_WAS_SET; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7292 return OK; |
3980 | 7293 } |
7294 | |
7295 /* | |
7 | 7296 * compatible_set() - Called when 'compatible' has been set or unset. |
7297 * | |
7298 * When 'compatible' set: Set all relevant options (those that have the P_VIM) | |
7299 * flag) to a Vi compatible value. | |
7300 * When 'compatible' is unset: Set all options that have a different default | |
7301 * for Vim (without the P_VI_DEF flag) to that default. | |
7302 */ | |
7303 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7304 compatible_set(void) |
7 | 7305 { |
7306 int opt_idx; | |
7307 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7308 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 7309 if ( ((options[opt_idx].flags & P_VIM) && p_cp) |
7310 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp)) | |
7311 set_option_default(opt_idx, OPT_FREE, p_cp); | |
7312 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
7313 didset_options2(); |
7 | 7314 } |
7315 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7316 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
7 | 7317 |
7318 /* | |
7319 * fill_breakat_flags() -- called when 'breakat' changes value. | |
7320 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7321 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7322 fill_breakat_flags(void) |
7 | 7323 { |
500 | 7324 char_u *p; |
7 | 7325 int i; |
7326 | |
7327 for (i = 0; i < 256; i++) | |
7328 breakat_flags[i] = FALSE; | |
7329 | |
7330 if (p_breakat != NULL) | |
500 | 7331 for (p = p_breakat; *p; p++) |
7332 breakat_flags[*p] = TRUE; | |
7 | 7333 } |
7334 #endif | |
7335 | |
7336 /* | |
7337 * Check if backspacing over something is allowed. | |
7338 */ | |
7339 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7340 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
|
7341 int what) // BS_INDENT, BS_EOL, BS_START or BS_NOSTOP |
7 | 7342 { |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
7343 #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
|
7344 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
|
7345 return FALSE; |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
7346 #endif |
7 | 7347 switch (*p_bs) |
7348 { | |
20069
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
7349 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
|
7350 case '2': return (what != BS_NOSTOP); |
7 | 7351 case '1': return (what != BS_START); |
7352 case '0': return FALSE; | |
7353 } | |
7354 return vim_strchr(p_bs, what) != NULL; | |
7355 } | |
7356 | |
7357 /* | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7358 * 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
|
7359 * 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
|
7360 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7361 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7362 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
|
7363 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7364 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
|
7365 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7366 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7367 /* |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7368 * 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
|
7369 * 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
|
7370 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7371 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7372 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
|
7373 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7374 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
|
7375 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7376 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7377 /* |
6243 | 7378 * Get the local or global value of 'backupcopy'. |
7379 */ | |
7380 unsigned int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7381 get_bkc_value(buf_T *buf) |
6243 | 7382 { |
7383 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags; | |
7384 } | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7385 |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
7386 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7387 /* |
27128
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7388 * Get the local or global value of 'formatlistpat'. |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7389 */ |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7390 char_u * |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7391 get_flp_value(buf_T *buf) |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7392 { |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7393 if (buf->b_p_flp == NULL || *buf->b_p_flp == NUL) |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7394 return p_flp; |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7395 return buf->b_p_flp; |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7396 } |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
7397 #endif |
27128
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7398 |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7399 /* |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7400 * Get the local or global value of the 'virtualedit' flags. |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7401 */ |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7402 unsigned int |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7403 get_ve_flags(void) |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7404 { |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
7405 return (curwin->w_ve_flags ? curwin->w_ve_flags : ve_flags) |
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
7406 & ~(VE_NONE | VE_NONEU); |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7407 } |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7408 |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7409 #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
|
7410 /* |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7411 * 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
|
7412 */ |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7413 char_u * |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7414 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
|
7415 { |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7416 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
|
7417 return p_sbr; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7418 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
|
7419 return empty_option; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7420 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
|
7421 } |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7422 #endif |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7423 |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7424 #if defined(FEAT_EVAL) || defined(PROTO) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7425 /* |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7426 * Get window or buffer local options. |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7427 */ |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7428 dict_T * |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7429 get_winbuf_options(int bufopt) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7430 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7431 dict_T *d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7432 int opt_idx; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7433 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7434 d = dict_alloc(); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7435 if (d == NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7436 return NULL; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7437 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7438 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
|
7439 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7440 struct vimoption *opt = &options[opt_idx]; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7441 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7442 if ((bufopt && (opt->indir & PV_BUF)) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7443 || (!bufopt && (opt->indir & PV_WIN))) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7444 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7445 char_u *varp = get_varp(opt); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7446 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7447 if (varp != NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7448 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7449 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
|
7450 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
|
7451 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
|
7452 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
|
7453 else |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14243
diff
changeset
|
7454 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
|
7455 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7456 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7457 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7458 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7459 return d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7460 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
7461 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7462 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7463 #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
|
7464 /* |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7465 * 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
|
7466 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7467 int |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7468 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
|
7469 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7470 char_u *p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7471 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
|
7472 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7473 if (val == NULL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7474 p = wp->w_p_culopt; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7475 else |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7476 p = val; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7477 while (*p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7478 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7479 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
|
7480 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7481 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7482 culopt_flags_new |= CULOPT_LINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7483 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7484 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
|
7485 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7486 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7487 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
|
7488 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7489 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
|
7490 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7491 p += 6; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7492 culopt_flags_new |= CULOPT_NBR; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7493 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7494 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
|
7495 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7496 p += 10; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7497 culopt_flags_new |= CULOPT_SCRLINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7498 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7499 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7500 if (*p != ',' && *p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7501 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7502 if (*p == ',') |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7503 ++p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7504 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7505 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7506 // 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
|
7507 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
|
7508 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7509 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
|
7510 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7511 return OK; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7512 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
7513 #endif |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7514 |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7515 /* |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7516 * 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
|
7517 */ |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7518 int |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7519 magic_isset(void) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7520 { |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7521 switch (magic_overruled) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7522 { |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23467
diff
changeset
|
7523 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
|
7524 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
|
7525 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
|
7526 } |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7527 #ifdef FEAT_EVAL |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7528 if (in_vim9script()) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7529 return TRUE; |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7530 #endif |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7531 return p_magic; |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
7532 } |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7533 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7534 /* |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7535 * Set the callback function value for an option that accepts a function name, |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7536 * lambda, et al. (e.g. 'operatorfunc', 'tagfunc', etc.) |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7537 * Returns OK if the option is successfully set to a function, otherwise |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7538 * returns FAIL. |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7539 */ |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7540 int |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7541 option_set_callback_func(char_u *optval UNUSED, callback_T *optcb UNUSED) |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7542 { |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7543 #ifdef FEAT_EVAL |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7544 typval_T *tv; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7545 callback_T cb; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7546 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7547 if (optval == NULL || *optval == NUL) |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7548 { |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7549 free_callback(optcb); |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7550 return OK; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7551 } |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7552 |
26362
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
7553 if (*optval == '{' || (in_vim9script() && *optval == '(') |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7554 || (STRNCMP(optval, "function(", 9) == 0) |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7555 || (STRNCMP(optval, "funcref(", 8) == 0)) |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7556 // Lambda expression or a funcref |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7557 tv = eval_expr(optval, NULL); |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7558 else |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7559 // treat everything else as a function name string |
26721
9c9b8d95b05f
patch 8.2.3889: duplicate code for translating script-local function name
Bram Moolenaar <Bram@vim.org>
parents:
26618
diff
changeset
|
7560 tv = alloc_string_tv(vim_strsave(optval)); |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7561 if (tv == NULL) |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7562 return FAIL; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7563 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7564 cb = get_callback(tv); |
26452
65b4109a4297
patch 8.2.3756: might crash when callback is not valid
Bram Moolenaar <Bram@vim.org>
parents:
26441
diff
changeset
|
7565 if (cb.cb_name == NULL || *cb.cb_name == NUL) |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7566 { |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7567 free_tv(tv); |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7568 return FAIL; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7569 } |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7570 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7571 free_callback(optcb); |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7572 set_callback(optcb, &cb); |
31313
b6bef244837e
patch 9.0.0990: callback name argument is changed by setqflist()
Bram Moolenaar <Bram@vim.org>
parents:
31259
diff
changeset
|
7573 if (cb.cb_free_name) |
b6bef244837e
patch 9.0.0990: callback name argument is changed by setqflist()
Bram Moolenaar <Bram@vim.org>
parents:
31259
diff
changeset
|
7574 vim_free(cb.cb_name); |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7575 free_tv(tv); |
27285
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27142
diff
changeset
|
7576 |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27142
diff
changeset
|
7577 // when using Vim9 style "import.funcname" it needs to be expanded to |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27142
diff
changeset
|
7578 // "import#funcname". |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27142
diff
changeset
|
7579 expand_autload_callback(optcb); |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27142
diff
changeset
|
7580 |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7581 return OK; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7582 #else |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7583 return FAIL; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7584 #endif |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
7585 } |