Mercurial > vim
annotate src/option.c @ 32377:3efec53797f3 v9.0.1520
patch 9.0.1520: completion for option name includes all bool options
Commit: https://github.com/vim/vim/commit/048d9d25214049dfde04c468c14bd1708fb692b8
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 6 22:21:11 2023 +0100
patch 9.0.1520: completion for option name includes all bool options
Problem: Completion for option name includes all bool options.
Solution: Do not recognize the "noinv" prefix. Prefix "no" or "inv" when
appropriate.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 06 May 2023 23:30:03 +0200 |
parents | 3d4e28569a6d |
children | bb5458706799 |
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 compatible_set(void); |
7 | 70 |
71 /* | |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
72 * Initialize the 'shell' option to a default value. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
73 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
74 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
75 set_init_default_shell(void) |
7 | 76 { |
77 char_u *p; | |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
78 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
79 // Find default value for 'shell' option. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
80 // Don't use it if it is empty. |
161 | 81 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
|
82 #if defined(MSWIN) |
161 | 83 || ((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
|
84 || ((p = (char_u *)default_shell()) != NULL && *p != NUL) |
7 | 85 #endif |
161 | 86 ) |
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
|
87 #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
|
88 { |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
89 // 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
|
90 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
|
91 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
|
92 |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
93 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
|
94 { |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
95 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
|
96 cmd = alloc(len); |
18243
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
97 if (cmd != NULL) |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
98 { |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
99 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
|
100 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
|
101 vim_free(cmd); |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
102 } |
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
|
103 } |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
104 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
|
105 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
|
106 } |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
107 #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
|
108 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
|
109 #endif |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
110 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
111 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
112 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
113 * Set the default for 'backupskip' to include environment variables for |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
114 * temp files. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
115 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
116 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
117 set_init_default_backupskip(void) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
118 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
119 int opt_idx; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
120 long_u n; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
121 char_u *p; |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
122 #ifdef UNIX |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
123 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
|
124 #else |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
125 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"}; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
126 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
127 int len; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
128 garray_T ga; |
32148
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
129 char_u *item; |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
130 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
131 opt_idx = findoption((char_u *)"backupskip"); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
132 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
133 ga_init2(&ga, 1, 100); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
134 for (n = 0; n < (long)ARRAY_LENGTH(names); ++n) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
135 { |
32148
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
136 int mustfree = FALSE; |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
137 #ifdef UNIX |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
138 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
|
139 # ifdef MACOS_X |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
140 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
|
141 # else |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
142 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
|
143 # endif |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
144 else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
145 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
146 p = vim_getenv((char_u *)names[n], &mustfree); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
147 if (p != NULL && *p != NUL) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
148 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
149 // First time count the NUL, otherwise count the ','. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
150 len = (int)STRLEN(p) + 3; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
151 item = alloc(len); |
32148
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
152 if (item != NULL) |
7 | 153 { |
32148
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
154 STRCPY(item, p); |
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
155 add_pathsep(item); |
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
156 STRCAT(item, "*"); |
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
157 if (find_dup_item(ga.ga_data, item, options[opt_idx].flags) |
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
158 == NULL |
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
159 && ga_grow(&ga, len) == OK) |
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
160 { |
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
161 if (ga.ga_len > 0) |
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
162 STRCAT(ga.ga_data, ","); |
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
163 STRCAT(ga.ga_data, item); |
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
164 ga.ga_len += len; |
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
165 } |
46c32a9a1312
patch 9.0.1405: missing check for out-of-memory
Bram Moolenaar <Bram@vim.org>
parents:
32144
diff
changeset
|
166 vim_free(item); |
7 | 167 } |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
168 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
169 if (mustfree) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
170 vim_free(p); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
171 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
172 if (ga.ga_data != NULL) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
173 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
174 set_string_default("bsk", ga.ga_data); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
175 vim_free(ga.ga_data); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
176 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
177 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
178 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
179 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
180 * Initialize the 'maxmemtot' and 'maxmem' options to a default value. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
181 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
182 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
183 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
184 set_init_default_maxmemtot(void) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
185 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
186 int opt_idx; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
187 long_u n; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
188 |
7 | 189 opt_idx = findoption((char_u *)"maxmemtot"); |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
190 if (opt_idx < 0) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
191 return; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
192 |
7 | 193 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
194 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
195 #endif |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
196 { |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
197 #if defined(HAVE_AVAIL_MEM) |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
198 // Use amount of memory available at this moment. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
199 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
|
200 #elif defined(HAVE_TOTAL_MEM) |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
201 // Use amount of memory available to Vim. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
202 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
|
203 #else |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
204 n = (0x7fffffff >> 11); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
205 #endif |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
206 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
207 opt_idx = findoption((char_u *)"maxmem"); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
208 if (opt_idx >= 0) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
209 { |
838 | 210 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
211 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
212 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
213 #endif |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
214 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; |
838 | 215 } |
7 | 216 } |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
217 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
218 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
219 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
220 * Initialize the 'cdpath' option to a default value. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
221 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
222 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
223 set_init_default_cdpath(void) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
224 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
225 int opt_idx; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
226 char_u *cdpath; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
227 char_u *buf; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
228 int i; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
229 int j; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
230 int mustfree = FALSE; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
231 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
232 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
233 if (cdpath == NULL) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
234 return; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
235 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
236 buf = alloc((STRLEN(cdpath) << 1) + 2); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
237 if (buf != NULL) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
238 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
239 buf[0] = ','; // start with ",", current dir first |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
240 j = 1; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
241 for (i = 0; cdpath[i] != NUL; ++i) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
242 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
243 if (vim_ispathlistsep(cdpath[i])) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
244 buf[j++] = ','; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
245 else |
7 | 246 { |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
247 if (cdpath[i] == ' ' || cdpath[i] == ',') |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
248 buf[j++] = '\\'; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
249 buf[j++] = cdpath[i]; |
7 | 250 } |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
251 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
252 buf[j] = NUL; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
253 opt_idx = findoption((char_u *)"cdpath"); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
254 if (opt_idx >= 0) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
255 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
256 options[opt_idx].def_val[VI_DEFAULT] = buf; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
257 options[opt_idx].flags |= P_DEF_ALLOCED; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
258 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
259 else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
260 vim_free(buf); // cannot happen |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
261 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
262 if (mustfree) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
263 vim_free(cdpath); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
264 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
265 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
266 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
267 * Initialize the 'printencoding' option to a default value. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
268 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
269 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
270 set_init_default_printencoding(void) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
271 { |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
272 #if defined(FEAT_POSTSCRIPT) && \ |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
273 (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
|
274 // Set print encoding on platforms that don't default to latin1 |
7 | 275 set_string_default("penc", |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
276 # if defined(MSWIN) |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
277 (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
|
278 # elif defined(VMS) |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
279 (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
|
280 # elif defined(MAC) |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
281 (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
|
282 # else // HPUX |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
283 (char_u *)"hp-roman8" |
7 | 284 # endif |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
285 ); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
286 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
287 } |
7 | 288 |
289 #ifdef FEAT_POSTSCRIPT | |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
290 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
291 * Initialize the 'printexpr' option to a default value. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
292 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
293 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
294 set_init_default_printexpr(void) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
295 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
296 // 'printexpr' must be allocated to be able to evaluate it. |
7 | 297 set_string_default("pexpr", |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
298 # if defined(MSWIN) |
8 | 299 (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
|
300 # elif defined(VMS) |
7 | 301 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)" |
302 | |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
303 # else |
7 | 304 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error" |
305 # endif | |
306 ); | |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
307 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
308 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
309 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
310 #ifdef UNIX |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
311 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
312 * Force restricted-mode on for "nologin" or "false" $SHELL |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
313 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
314 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
315 set_init_restricted_mode(void) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
316 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
317 char_u *p; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
318 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
319 p = get_isolated_shell_name(); |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
320 if (p == NULL) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
321 return; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
322 if (fnamecmp(p, "nologin") == 0 || fnamecmp(p, "false") == 0) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
323 restricted = TRUE; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
324 vim_free(p); |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
325 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
326 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
327 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
328 #ifdef CLEAN_RUNTIMEPATH |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
329 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
330 * When Vim is started with the "--clean" argument, set the default value |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
331 * for the 'runtimepath' and 'packpath' options. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
332 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
333 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
334 set_init_clean_rtp(void) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
335 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
336 int opt_idx; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
337 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
338 opt_idx = findoption((char_u *)"runtimepath"); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
339 if (opt_idx >= 0) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
340 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
341 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
342 p_rtp = (char_u *)CLEAN_RUNTIMEPATH; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
343 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
344 opt_idx = findoption((char_u *)"packpath"); |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
345 if (opt_idx < 0) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
346 return; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
347 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
348 p_pp = (char_u *)CLEAN_RUNTIMEPATH; |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
349 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
350 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
351 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
352 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
353 * Expand environment variables and things like "~" for the defaults. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
354 * If option_expand() returns non-NULL the variable is expanded. This can |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
355 * only happen for non-indirect options. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
356 * Also set the default to the expanded value, so ":set" does not list |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
357 * them. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
358 * Don't set the P_ALLOCED flag, because we don't want to free the |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
359 * default. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
360 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
361 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
362 set_init_expand_env(void) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
363 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
364 int opt_idx; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
365 char_u *p; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
366 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
367 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
368 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
369 if ((options[opt_idx].flags & P_GETTEXT) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
370 && options[opt_idx].var != NULL) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
371 p = (char_u *)_(*(char **)options[opt_idx].var); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
372 else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
373 p = option_expand(opt_idx, NULL); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
374 if (p != NULL && (p = vim_strsave(p)) != NULL) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
375 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
376 *(char_u **)options[opt_idx].var = p; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
377 // VIMEXP |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
378 // Defaults for all expanded options are currently the same for Vi |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
379 // and Vim. When this changes, add some code here! Also need to |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
380 // split P_DEF_ALLOCED in two. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
381 if (options[opt_idx].flags & P_DEF_ALLOCED) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
382 vim_free(options[opt_idx].def_val[VI_DEFAULT]); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
383 options[opt_idx].def_val[VI_DEFAULT] = p; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
384 options[opt_idx].flags |= P_DEF_ALLOCED; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
385 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
386 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
387 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
388 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
389 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
390 * Initialize the 'LANG' environment variable to a default value. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
391 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
392 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
393 set_init_lang_env(void) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
394 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
395 #if defined(MSWIN) && defined(FEAT_GETTEXT) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
396 // If $LANG isn't set, try to get a good value for it. This makes the |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
397 // right language be used automatically. Don't do this for English. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
398 if (mch_getenv((char_u *)"LANG") == NULL) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
399 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
400 char buf[20]; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
401 long_u n; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
402 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
403 // Could use LOCALE_SISO639LANGNAME, but it's not in Win95. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
404 // LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
405 // only the first two. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
406 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
407 (LPTSTR)buf, 20); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
408 if (n >= 2 && STRNICMP(buf, "en", 2) != 0) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
409 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
410 // There are a few exceptions (probably more) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
411 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
412 STRCPY(buf, "zh_TW"); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
413 else if (STRNICMP(buf, "chs", 3) == 0 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
414 || STRNICMP(buf, "zhc", 3) == 0) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
415 STRCPY(buf, "zh_CN"); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
416 else if (STRNICMP(buf, "jp", 2) == 0) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
417 STRCPY(buf, "ja"); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
418 else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
419 buf[2] = NUL; // truncate to two-letter code |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
420 vim_setenv((char_u *)"LANG", (char_u *)buf); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
421 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
422 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
423 #elif defined(MACOS_CONVERT) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
424 // Moved to os_mac_conv.c to avoid dependency problems. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
425 mac_lang_init(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
426 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
427 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
428 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
429 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
430 * Initialize the 'encoding' option to a default value. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
431 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
432 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
433 set_init_default_encoding(void) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
434 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
435 char_u *p; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
436 int opt_idx; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
437 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
438 # ifdef MSWIN |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
439 // MS-Windows has builtin support for conversion to and from Unicode, using |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
440 // "utf-8" for 'encoding' should work best for most users. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
441 p = vim_strsave((char_u *)ENC_DFLT); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
442 # else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
443 // enc_locale() will try to find the encoding of the current locale. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
444 // This works best for properly configured systems, old and new. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
445 p = enc_locale(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
446 # endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
447 if (p == NULL) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
448 return; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
449 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
450 // Try setting 'encoding' and check if the value is valid. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
451 // If not, go back to the default encoding. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
452 char_u *save_enc = p_enc; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
453 p_enc = p; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
454 if (STRCMP(p_enc, "gb18030") == 0) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
455 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
456 // We don't support "gb18030", but "cp936" is a good substitute |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
457 // for practical purposes, thus use that. It's not an alias to |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
458 // still support conversion between gb18030 and utf-8. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
459 p_enc = vim_strsave((char_u *)"cp936"); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
460 vim_free(p); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
461 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
462 if (mb_init() == NULL) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
463 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
464 opt_idx = findoption((char_u *)"encoding"); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
465 if (opt_idx >= 0) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
466 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
467 options[opt_idx].def_val[VI_DEFAULT] = p_enc; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
468 options[opt_idx].flags |= P_DEF_ALLOCED; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
469 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
470 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
471 #if defined(MSWIN) || defined(MACOS_X) || defined(VMS) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
472 if (STRCMP(p_enc, "latin1") == 0 || enc_utf8) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
473 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
474 // Adjust the default for 'isprint' and 'iskeyword' to match |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
475 // latin1. Also set the defaults for when 'nocompatible' is |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
476 // set. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
477 set_string_option_direct((char_u *)"isp", -1, |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
478 ISP_LATIN1, OPT_FREE, SID_NONE); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
479 set_string_option_direct((char_u *)"isk", -1, |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
480 ISK_LATIN1, OPT_FREE, SID_NONE); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
481 opt_idx = findoption((char_u *)"isp"); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
482 if (opt_idx >= 0) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
483 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
484 opt_idx = findoption((char_u *)"isk"); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
485 if (opt_idx >= 0) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
486 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
487 (void)init_chartab(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
488 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
489 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
490 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
491 #if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
492 // Win32 console: When GetACP() returns a different value from |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
493 // GetConsoleCP() set 'termencoding'. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
494 if ( |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
495 # ifdef VIMDLL |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
496 (!gui.in_use && !gui.starting) && |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
497 # endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
498 GetACP() != GetConsoleCP()) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
499 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
500 char buf[50]; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
501 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
502 // Win32 console: In ConPTY, GetConsoleCP() returns zero. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
503 // Use an alternative value. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
504 if (GetConsoleCP() == 0) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
505 sprintf(buf, "cp%ld", (long)GetACP()); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
506 else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
507 sprintf(buf, "cp%ld", (long)GetConsoleCP()); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
508 p_tenc = vim_strsave((char_u *)buf); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
509 if (p_tenc != NULL) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
510 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
511 opt_idx = findoption((char_u *)"termencoding"); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
512 if (opt_idx >= 0) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
513 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
514 options[opt_idx].def_val[VI_DEFAULT] = p_tenc; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
515 options[opt_idx].flags |= P_DEF_ALLOCED; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
516 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
517 convert_setup(&input_conv, p_tenc, p_enc); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
518 convert_setup(&output_conv, p_enc, p_tenc); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
519 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
520 else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
521 p_tenc = empty_option; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
522 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
523 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
524 #if defined(MSWIN) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
525 // $HOME may have characters in active code page. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
526 init_homedir(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
527 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
528 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
529 else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
530 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
531 vim_free(p_enc); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
532 p_enc = save_enc; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
533 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
534 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
535 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
536 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
537 * Initialize the options, first part. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
538 * |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
539 * Called only once from main(), just after creating the first buffer. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
540 * If "clean_arg" is TRUE Vim was started with --clean. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
541 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
542 void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
543 set_init_1(int clean_arg) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
544 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
545 #ifdef FEAT_LANGMAP |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
546 langmap_init(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
547 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
548 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
549 // Be Vi compatible by default |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
550 p_cp = TRUE; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
551 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
552 // Use POSIX compatibility when $VIM_POSIX is set. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
553 if (mch_getenv((char_u *)"VIM_POSIX") != NULL) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
554 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
555 set_string_default("cpo", (char_u *)CPO_ALL); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
556 set_string_default("shm", (char_u *)SHM_POSIX); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
557 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
558 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
559 set_init_default_shell(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
560 set_init_default_backupskip(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
561 set_init_default_maxmemtot(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
562 set_init_default_cdpath(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
563 set_init_default_printencoding(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
564 #ifdef FEAT_POSTSCRIPT |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
565 set_init_default_printexpr(); |
7 | 566 #endif |
567 | |
568 /* | |
569 * Set all the options (except the terminal options) to their default | |
570 * value. Also set the global value for local options. | |
571 */ | |
572 set_options_default(0); | |
573 | |
27509
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
574 #ifdef UNIX |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
575 set_init_restricted_mode(); |
27509
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
576 #endif |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
577 |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
578 #ifdef CLEAN_RUNTIMEPATH |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
579 if (clean_arg) |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
580 set_init_clean_rtp(); |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
581 #endif |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
582 |
7 | 583 #ifdef FEAT_GUI |
584 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
|
585 set_option_value_give_err((char_u *)"bg", 0L, (char_u *)"dark", 0); |
7 | 586 #endif |
587 | |
588 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
|
589 curbuf->b_p_ar = -1; // no local 'autoread' value |
5446 | 590 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
7 | 591 check_buf_options(curbuf); |
592 check_win_options(curwin); | |
593 check_options(); | |
594 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
595 // Must be before option_expand(), because that one needs vim_isIDc() |
7 | 596 didset_options(); |
597 | |
744 | 598 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
599 // 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
|
600 // didset_options() because it only depends on 'encoding'. |
227 | 601 init_spell_chartab(); |
602 #endif | |
603 | |
31962
4efcb5c68112
patch 9.0.1313: some settings use the current codepage instead of 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
31958
diff
changeset
|
604 set_init_default_encoding(); |
4efcb5c68112
patch 9.0.1313: some settings use the current codepage instead of 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
31958
diff
changeset
|
605 |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
606 // Expand environment variables and things like "~" for the defaults. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
607 set_init_expand_env(); |
7 | 608 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
609 save_file_ff(curbuf); // Buffer is unchanged |
7 | 610 |
611 #if defined(FEAT_ARABIC) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
612 // Detect use of mlterm. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
613 // 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
|
614 // abilities (bidi namely). |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
615 // 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
|
616 // instead of an environment variable due to inheritance. |
7 | 617 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
|
618 set_option_value_give_err((char_u *)"tbidi", 1L, NULL, 0); |
7 | 619 #endif |
620 | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
621 didset_options2(); |
7 | 622 |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
623 set_init_lang_env(); |
7 | 624 |
625 #ifdef FEAT_MULTI_LANG | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
626 // Set the default for 'helplang'. |
7 | 627 set_helplang_default(get_mess_lang()); |
628 #endif | |
629 } | |
630 | |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
631 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
|
632 |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
633 /* |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
634 * 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
|
635 * utf-8. |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
636 */ |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
637 void |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
638 set_fencs_unicode(void) |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
639 { |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
640 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
|
641 OPT_FREE, 0); |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
642 } |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
643 |
7 | 644 /* |
645 * Set an option to its default value. | |
646 * This does not take care of side effects! | |
647 */ | |
648 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
649 set_option_default( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
650 int opt_idx, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
651 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
|
652 int compatible) // use Vi default value |
7 | 653 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
654 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
|
655 int dvi; // index in def_val[] |
7 | 656 long_u flags; |
681 | 657 long_u *flagsp; |
7 | 658 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
659 | |
660 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); | |
661 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
|
662 if (varp != NULL) // skip hidden option, nothing to do for it |
7 | 663 { |
664 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; | |
665 if (flags & P_STRING) | |
666 { | |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
667 // '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
|
668 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
|
669 set_fencs_unicode(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
670 // 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
|
671 // 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
|
672 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
|
673 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
|
674 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
|
675 else |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
676 { |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
677 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
|
678 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
|
679 *(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
|
680 options[opt_idx].flags &= ~P_ALLOCED; |
7 | 681 } |
682 } | |
683 else if (flags & P_NUM) | |
684 { | |
1017 | 685 if (options[opt_idx].indir == PV_SCROLL) |
7 | 686 win_comp_scroll(curwin); |
687 else | |
688 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
689 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
|
690 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
691 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
|
692 || (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
|
693 // '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
|
694 // 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
|
695 *(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
|
696 else |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
697 *(long *)varp = def_val; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
698 // May also set global value for local option. |
7 | 699 if (both) |
700 *(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
|
701 def_val; |
7 | 702 } |
703 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
704 else // P_BOOL |
7 | 705 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
706 // 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
|
707 // MSVC |
840 | 708 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; |
1111 | 709 #ifdef UNIX |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
710 // 'modeline' defaults to off for root |
1111 | 711 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) |
712 *(int *)varp = FALSE; | |
713 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
714 // May also set global value for local option. |
7 | 715 if (both) |
716 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | |
717 *(int *)varp; | |
718 } | |
634 | 719 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
720 // The default value is not insecure. |
681 | 721 flagsp = insecure_flag(opt_idx, opt_flags); |
722 *flagsp = *flagsp & ~P_INSECURE; | |
7 | 723 } |
724 | |
725 #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
|
726 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 727 #endif |
728 } | |
729 | |
730 /* | |
731 * 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
|
732 * When "opt_flags" is non-zero skip 'encoding'. |
7 | 733 */ |
734 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
735 set_options_default( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
736 int opt_flags) // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL |
7 | 737 { |
738 int i; | |
739 win_T *wp; | |
671 | 740 tabpage_T *tp; |
7 | 741 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
742 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
|
743 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
|
744 && (opt_flags == 0 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
745 || (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
|
746 # if defined(FEAT_CRYPT) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
747 && 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
|
748 && 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
|
749 # endif |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
750 ))) |
7 | 751 set_option_default(i, opt_flags, p_cp); |
752 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
753 // The 'scroll' option must be computed for all windows. |
671 | 754 FOR_ALL_TAB_WINDOWS(tp, wp) |
7 | 755 win_comp_scroll(wp); |
6205 | 756 parse_cino(curbuf); |
7 | 757 } |
758 | |
759 /* | |
760 * Set the Vi-default value of a string option. | |
761 * 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
|
762 * 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
|
763 */ |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
764 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
|
765 set_string_default_esc(char *name, char_u *val, int escape) |
7 | 766 { |
767 char_u *p; | |
768 int opt_idx; | |
769 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
770 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
|
771 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
|
772 else |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
773 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
|
774 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
|
775 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
776 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
777 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
|
778 if (opt_idx < 0) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
779 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
780 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
781 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
|
782 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
|
783 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
|
784 options[opt_idx].flags |= P_DEF_ALLOCED; |
7 | 785 } |
786 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
787 void |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
788 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
|
789 { |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
790 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
|
791 } |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
792 |
7 | 793 /* |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
794 * 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
|
795 * "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
|
796 */ |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
797 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
|
798 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
|
799 { |
22242
f7871f02ddcd
patch 8.2.1670: a couple of gcc compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
22234
diff
changeset
|
800 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
|
801 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
|
802 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
|
803 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
804 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
|
805 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
|
806 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
807 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
|
808 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
|
809 { |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
810 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
|
811 || 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
|
812 || (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
|
813 && 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
|
814 && (!(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
|
815 || 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
|
816 || 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
|
817 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
|
818 // 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
|
819 // 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
|
820 // 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
|
821 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
|
822 && 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
|
823 && 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
|
824 || (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
|
825 && 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
|
826 ++bs; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
827 else |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
828 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
|
829 } |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
830 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
|
831 } |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
832 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
833 /* |
7 | 834 * Set the Vi-default value of a number option. |
835 * Used for 'lines' and 'columns'. | |
836 */ | |
837 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
838 set_number_default(char *name, long val) |
7 | 839 { |
838 | 840 int opt_idx; |
841 | |
842 opt_idx = findoption((char_u *)name); | |
843 if (opt_idx >= 0) | |
840 | 844 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 845 } |
846 | |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
847 #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
|
848 /* |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
849 * 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
|
850 * 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
|
851 * 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
|
852 */ |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
853 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
|
854 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
|
855 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
856 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
|
857 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
|
858 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
859 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
|
860 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
|
861 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
|
862 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
863 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
|
864 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
865 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
|
866 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
|
867 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
868 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
|
869 && (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
|
870 && !(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
|
871 && !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
|
872 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
|
873 } |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
874 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
875 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
|
876 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
|
877 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
|
878 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
879 #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
|
880 |
359 | 881 #if defined(EXITFREE) || defined(PROTO) |
882 /* | |
883 * Free all options. | |
884 */ | |
885 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
886 free_all_options(void) |
359 | 887 { |
888 int i; | |
889 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
890 for (i = 0; !istermoption_idx(i); i++) |
359 | 891 { |
892 if (options[i].indir == PV_NONE) | |
893 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
894 // 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
|
895 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL) |
359 | 896 free_string_option(*(char_u **)options[i].var); |
897 if (options[i].flags & P_DEF_ALLOCED) | |
898 free_string_option(options[i].def_val[VI_DEFAULT]); | |
899 } | |
900 else if (options[i].var != VAR_WIN | |
901 && (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
|
902 // 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
|
903 clear_string_option((char_u **)options[i].var); |
359 | 904 } |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
905 free_operatorfunc_option(); |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26193
diff
changeset
|
906 free_tagfunc_option(); |
359 | 907 } |
908 #endif | |
909 | |
910 | |
7 | 911 /* |
912 * Initialize the options, part two: After getting Rows and Columns and | |
913 * setting 'term'. | |
914 */ | |
915 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
916 set_init_2(void) |
7 | 917 { |
164 | 918 int idx; |
919 | |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
920 // 'scroll' defaults to half the window height. The stored default is zero, |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
921 // which results in the actual value computed from the window height. |
168 | 922 idx = findoption((char_u *)"scroll"); |
838 | 923 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
168 | 924 set_option_default(idx, OPT_LOCAL, p_cp); |
7 | 925 comp_col(); |
926 | |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
927 // 'window' is only for backwards compatibility with Vi. |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
928 // Default is Rows - 1. |
857 | 929 if (!option_was_set((char_u *)"window")) |
164 | 930 p_window = Rows - 1; |
931 set_number_default("window", Rows - 1); | |
932 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
933 // 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
|
934 #if !((defined(MSWIN)) && !defined(FEAT_GUI)) |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
935 // If 'background' wasn't set by the user, try guessing the value, |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
936 // depending on the terminal name. Only need to check for terminals |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
937 // with a dark background, that can handle color. |
671 | 938 idx = findoption((char_u *)"bg"); |
838 | 939 if (idx >= 0 && !(options[idx].flags & P_WAS_SET) |
940 && *term_bg_default() == 'd') | |
671 | 941 { |
694 | 942 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
|
943 // 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
|
944 // changed again |
671 | 945 options[idx].flags &= ~P_WAS_SET; |
7 | 946 } |
947 #endif | |
440 | 948 |
949 #ifdef CURSOR_SHAPE | |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
950 parse_shape_opt(SHAPE_CURSOR); // set cursor shapes from 'guicursor' |
440 | 951 #endif |
952 #ifdef FEAT_MOUSESHAPE | |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
953 parse_shape_opt(SHAPE_MOUSE); // set mouse shapes from 'mouseshape' |
440 | 954 #endif |
955 #ifdef FEAT_PRINTER | |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
956 (void)parse_printoptions(NULL); // parse 'printoptions' default value |
440 | 957 #endif |
7 | 958 } |
959 | |
960 /* | |
961 * Initialize the options, part three: After reading the .vimrc | |
962 */ | |
963 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
964 set_init_3(void) |
7 | 965 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
966 #if defined(UNIX) || defined(MSWIN) |
7 | 967 /* |
968 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. | |
969 * This is done after other initializations, where 'shell' might have been | |
970 * set, but only if they have not been set before. | |
971 */ | |
972 char_u *p; | |
973 int idx_srr; | |
974 int do_srr; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
975 # ifdef FEAT_QUICKFIX |
7 | 976 int idx_sp; |
977 int do_sp; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
978 # endif |
7 | 979 |
980 idx_srr = findoption((char_u *)"srr"); | |
838 | 981 if (idx_srr < 0) |
982 do_srr = FALSE; | |
983 else | |
984 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
|
985 # ifdef FEAT_QUICKFIX |
7 | 986 idx_sp = findoption((char_u *)"sp"); |
838 | 987 if (idx_sp < 0) |
988 do_sp = FALSE; | |
989 else | |
990 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
|
991 # endif |
5867 | 992 p = get_isolated_shell_name(); |
7 | 993 if (p != NULL) |
994 { | |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
995 // Default for p_sp is "| tee", for p_srr is ">". |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
996 // For known shells it is changed here to include stderr. |
7 | 997 if ( fnamecmp(p, "csh") == 0 |
998 || 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
|
999 # if defined(MSWIN) // also check with .exe extension |
7 | 1000 || fnamecmp(p, "csh.exe") == 0 |
1001 || fnamecmp(p, "tcsh.exe") == 0 | |
1002 # endif | |
1003 ) | |
1004 { | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1005 # if defined(FEAT_QUICKFIX) |
7 | 1006 if (do_sp) |
1007 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
1008 # ifdef MSWIN |
7 | 1009 p_sp = (char_u *)">&"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1010 # else |
7 | 1011 p_sp = (char_u *)"|& tee"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1012 # endif |
7 | 1013 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
1014 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1015 # endif |
7 | 1016 if (do_srr) |
1017 { | |
1018 p_srr = (char_u *)">&"; | |
1019 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
1020 } | |
1021 } | |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1022 # ifdef MSWIN |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
1023 // 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
|
1024 // 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
|
1025 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
|
1026 || 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
|
1027 ) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1028 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1029 # 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
|
1030 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
|
1031 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1032 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
|
1033 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
|
1034 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1035 # endif |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1036 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
|
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_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
|
1039 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
|
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 #endif |
7 | 1043 else |
24600
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
1044 // Always use POSIX shell style redirection if we reach this |
7 | 1045 if ( fnamecmp(p, "sh") == 0 |
1046 || fnamecmp(p, "ksh") == 0 | |
2774 | 1047 || fnamecmp(p, "mksh") == 0 |
1048 || fnamecmp(p, "pdksh") == 0 | |
7 | 1049 || fnamecmp(p, "zsh") == 0 |
836 | 1050 || fnamecmp(p, "zsh-beta") == 0 |
7 | 1051 || fnamecmp(p, "bash") == 0 |
5867 | 1052 || 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
|
1053 || fnamecmp(p, "ash") == 0 |
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
1054 || 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
|
1055 || 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
|
1056 # ifdef MSWIN |
7 | 1057 || fnamecmp(p, "cmd") == 0 |
1058 || fnamecmp(p, "sh.exe") == 0 | |
1059 || fnamecmp(p, "ksh.exe") == 0 | |
2774 | 1060 || fnamecmp(p, "mksh.exe") == 0 |
1061 || fnamecmp(p, "pdksh.exe") == 0 | |
7 | 1062 || fnamecmp(p, "zsh.exe") == 0 |
836 | 1063 || fnamecmp(p, "zsh-beta.exe") == 0 |
7 | 1064 || fnamecmp(p, "bash.exe") == 0 |
1065 || 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
|
1066 || 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
|
1067 || fnamecmp(p, "pwsh.exe") == 0 |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1068 # endif |
7 | 1069 ) |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1070 { |
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1071 # if defined(FEAT_QUICKFIX) |
7 | 1072 if (do_sp) |
1073 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
1074 # ifdef MSWIN |
7 | 1075 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
|
1076 # else |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
1077 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
|
1078 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
|
1079 else |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
1080 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
|
1081 # endif |
7 | 1082 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
1083 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1084 # endif |
7 | 1085 if (do_srr) |
1086 { | |
1087 p_srr = (char_u *)">%s 2>&1"; | |
1088 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
1089 } | |
1090 } | |
1091 vim_free(p); | |
1092 } | |
1093 #endif | |
1094 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
1095 #if defined(MSWIN) |
7 | 1096 /* |
3352 | 1097 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the |
1098 * 'shell' option. | |
7 | 1099 * 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
|
1100 * 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
|
1101 * 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
|
1102 * |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1103 * 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
|
1104 * 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
|
1105 * powershell.exe - "-Command" "\"" |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
1106 * 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
|
1107 * "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
|
1108 * |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1109 * For Win32 p_sxq is set instead of p_shq to include shell redirection. |
7 | 1110 */ |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1111 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
|
1112 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1113 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
|
1114 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1115 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
|
1116 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
|
1117 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1118 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
|
1119 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
|
1120 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1121 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1122 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
|
1123 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
|
1124 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1125 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
|
1126 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
|
1127 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1128 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1129 else if (strstr((char *)gettail(p_sh), "sh") != NULL) |
7 | 1130 { |
1131 int idx3; | |
1132 | |
1133 idx3 = findoption((char_u *)"shcf"); | |
838 | 1134 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 1135 { |
1136 p_shcf = (char_u *)"-c"; | |
1137 options[idx3].def_val[VI_DEFAULT] = p_shcf; | |
1138 } | |
1139 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1140 // Somehow Win32 requires the quotes around the redirection too |
7 | 1141 idx3 = findoption((char_u *)"sxq"); |
838 | 1142 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 1143 { |
1144 p_sxq = (char_u *)"\""; | |
1145 options[idx3].def_val[VI_DEFAULT] = p_sxq; | |
1146 } | |
1147 } | |
3352 | 1148 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL) |
1149 { | |
1150 int idx3; | |
1151 | |
1152 /* | |
1153 * cmd.exe on Windows will strip the first and last double quote given | |
1154 * on the command line, e.g. most of the time things like: | |
1155 * cmd /c "my path/to/echo" "my args to echo" | |
1156 * become: | |
1157 * my path/to/echo" "my args to echo | |
1158 * when executed. | |
1159 * | |
3357 | 1160 * To avoid this, set shellxquote to surround the command in |
1161 * parenthesis. This appears to make most commands work, without | |
1162 * breaking commands that worked previously, such as | |
1163 * '"path with spaces/cmd" "a&b"'. | |
3352 | 1164 */ |
1165 idx3 = findoption((char_u *)"sxq"); | |
1166 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
1167 { | |
3357 | 1168 p_sxq = (char_u *)"("; |
3352 | 1169 options[idx3].def_val[VI_DEFAULT] = p_sxq; |
1170 } | |
1171 | |
1172 idx3 = findoption((char_u *)"shcf"); | |
1173 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
1174 { | |
3357 | 1175 p_shcf = (char_u *)"/c"; |
3352 | 1176 options[idx3].def_val[VI_DEFAULT] = p_shcf; |
1177 } | |
1178 } | |
7 | 1179 #endif |
1180 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11107
diff
changeset
|
1181 if (BUFEMPTY()) |
8659
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1182 { |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1183 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
|
1184 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1185 // 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
|
1186 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
|
1187 set_fileformat(default_fileformat(), OPT_LOCAL); |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1188 } |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1189 |
7 | 1190 set_title_defaults(); |
1191 } | |
1192 | |
1193 #if defined(FEAT_MULTI_LANG) || defined(PROTO) | |
1194 /* | |
1195 * When 'helplang' is still at its default value, set it to "lang". | |
1196 * Only the first two characters of "lang" are used. | |
1197 */ | |
1198 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1199 set_helplang_default(char_u *lang) |
7 | 1200 { |
1201 int idx; | |
1202 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1203 if (lang == NULL || STRLEN(lang) < 2) // safety check |
7 | 1204 return; |
1205 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
|
1206 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
|
1207 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1208 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1209 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
|
1210 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
|
1211 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
|
1212 if (p_hlg == NULL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1213 p_hlg = empty_option; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1214 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1215 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1216 // 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
|
1217 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
|
1218 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1219 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
|
1220 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
|
1221 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1222 // 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
|
1223 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
|
1224 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1225 p_hlg[0] = 'e'; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1226 p_hlg[1] = 'n'; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1227 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1228 p_hlg[2] = NUL; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1229 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1230 options[idx].flags |= P_ALLOCED; |
7 | 1231 } |
1232 #endif | |
1233 | |
1234 /* | |
1235 * 'title' and 'icon' only default to true if they have not been set or reset | |
1236 * in .vimrc and we can read the old value. | |
1237 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if | |
1238 * they can be reset. This reduces startup time when using X on a remote | |
1239 * machine. | |
1240 */ | |
1241 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1242 set_title_defaults(void) |
7 | 1243 { |
1244 int idx1; | |
1245 long val; | |
1246 | |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
1247 // If GUI is (going to be) used, we can always set the window title and |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
1248 // icon name. Saves a bit of time, because the X11 display server does |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
1249 // not need to be contacted. |
7 | 1250 idx1 = findoption((char_u *)"title"); |
838 | 1251 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 1252 { |
1253 #ifdef FEAT_GUI | |
1254 if (gui.starting || gui.in_use) | |
1255 val = TRUE; | |
1256 else | |
1257 #endif | |
1258 val = mch_can_restore_title(); | |
840 | 1259 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 1260 p_title = val; |
1261 } | |
1262 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
|
1263 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
|
1264 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1265 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1266 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1267 |
7 | 1268 #ifdef FEAT_GUI |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1269 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
|
1270 val = TRUE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1271 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1272 #endif |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1273 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
|
1274 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
|
1275 p_icon = val; |
7 | 1276 } |
1277 | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1278 void |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1279 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
|
1280 { |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1281 int flags = 0; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1282 |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1283 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
|
1284 flags = OPT_LOCAL; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1285 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
|
1286 flags = OPT_GLOBAL; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1287 #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
|
1288 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
|
1289 ex_options(eap); |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1290 else |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1291 #endif |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1292 { |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1293 if (eap->forceit) |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1294 flags |= OPT_ONECOLUMN; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1295 (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
|
1296 } |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1297 } |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1298 |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1299 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1300 * :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
|
1301 */ |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1302 typedef enum { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1303 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
|
1304 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
|
1305 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
|
1306 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
|
1307 } 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
|
1308 |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1309 typedef enum { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1310 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
|
1311 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
|
1312 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
|
1313 } 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
|
1314 |
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 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
|
1317 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1318 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
|
1319 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
|
1320 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1321 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
|
1322 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
|
1323 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1324 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
|
1325 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1326 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
|
1327 arg += 2; |
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 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
|
1330 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1331 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
|
1332 arg += 3; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1333 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1334 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1335 *argp = arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1336 return prefix; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1337 } |
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 * 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
|
1341 * 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
|
1342 * 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
|
1343 * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1344 * 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
|
1345 * 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
|
1346 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1347 static int |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1348 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
|
1349 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1350 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
|
1351 int len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1352 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
|
1353 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1354 if (*arg == '<') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1355 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1356 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
|
1357 // 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
|
1358 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
|
1359 len = 5; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1360 else |
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 len = 1; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1363 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
|
1364 ++len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1365 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1366 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
|
1367 return FAIL; |
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 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
|
1370 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
|
1371 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
|
1372 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
|
1373 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
|
1374 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
|
1375 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1376 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1377 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1378 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
|
1379 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1380 len = 0; |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
1381 // The two characters after "t_" may not be alphanumeric. |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1382 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
|
1383 len = 4; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1384 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1385 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
|
1386 ++len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1387 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
|
1388 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
|
1389 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
|
1390 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
|
1391 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
|
1392 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
|
1393 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1394 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1395 *keyp = key; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1396 *lenp = len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1397 *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
|
1398 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1399 return OK; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1400 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1401 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1402 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1403 * 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
|
1404 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1405 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
|
1406 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
|
1407 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1408 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
|
1409 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1410 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
|
1411 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1412 if (*arg == '+') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1413 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
|
1414 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
|
1415 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
|
1416 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
|
1417 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
|
1418 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1419 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1420 return op; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1421 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1422 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1423 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1424 * 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
|
1425 * 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
|
1426 * 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
|
1427 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1428 static int |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1429 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
|
1430 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1431 // 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
|
1432 // 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
|
1433 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
|
1434 && (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
|
1435 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1436 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1437 // 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
|
1438 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
|
1439 && 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
|
1440 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1441 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1442 // 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
|
1443 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
|
1444 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1445 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
|
1446 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1447 *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
|
1448 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1449 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1450 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
|
1451 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1452 *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
|
1453 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1454 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1455 #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
|
1456 // 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
|
1457 // '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
|
1458 // "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
|
1459 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
|
1460 && 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
|
1461 && ( |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1462 # 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
|
1463 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
|
1464 # endif |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1465 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
|
1466 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1467 #endif |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1468 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1469 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1470 #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
|
1471 // 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
|
1472 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
|
1473 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1474 *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
|
1475 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1476 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1477 #endif |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1478 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1479 return OK; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1480 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1481 |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1482 /* |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1483 * Get the Vim/Vi default value for a string option. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1484 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1485 static char_u * |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1486 stropt_get_default_val( |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1487 int opt_idx, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1488 char_u *varp, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1489 int flags, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1490 int cp_val) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1491 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1492 char_u *newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1493 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1494 newval = options[opt_idx].def_val[((flags & P_VI_DEF) || cp_val) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1495 ? VI_DEFAULT : VIM_DEFAULT]; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1496 if ((char_u **)varp == &p_bg) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1497 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1498 // guess the value of 'background' |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1499 #ifdef FEAT_GUI |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1500 if (gui.in_use) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1501 newval = gui_bg_default(); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1502 else |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1503 #endif |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1504 newval = term_bg_default(); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1505 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1506 else if ((char_u **)varp == &p_fencs && enc_utf8) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1507 newval = fencs_utf8_default; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1508 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1509 // expand environment variables and ~ since the default value was |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1510 // already expanded, only required when an environment variable was set |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1511 // later |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1512 if (newval == NULL) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1513 newval = empty_option; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1514 else |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1515 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1516 char_u *s = option_expand(opt_idx, newval); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1517 if (s == NULL) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1518 s = newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1519 newval = vim_strsave(s); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1520 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1521 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1522 return newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1523 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1524 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1525 /* |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1526 * Convert the 'backspace' option number value to a string: for adding, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1527 * prepending and removing string. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1528 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1529 static void |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1530 opt_backspace_nr2str( |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1531 char_u *varp, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1532 char_u **origval_p, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1533 char_u **origval_l_p, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1534 char_u **origval_g_p, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1535 char_u **oldval_p) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1536 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1537 int i = getdigits((char_u **)varp); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1538 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1539 switch (i) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1540 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1541 case 0: |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1542 *(char_u **)varp = empty_option; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1543 break; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1544 case 1: |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1545 *(char_u **)varp = vim_strsave((char_u *)"indent,eol"); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1546 break; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1547 case 2: |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1548 *(char_u **)varp = vim_strsave((char_u *)"indent,eol,start"); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1549 break; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1550 case 3: |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1551 *(char_u **)varp = vim_strsave((char_u *)"indent,eol,nostop"); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1552 break; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1553 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1554 vim_free(*oldval_p); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1555 if (*origval_p == *oldval_p) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1556 *origval_p = *(char_u **)varp; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1557 if (*origval_l_p == *oldval_p) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1558 *origval_l_p = *(char_u **)varp; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1559 if (*origval_g_p == *oldval_p) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1560 *origval_g_p = *(char_u **)varp; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1561 *oldval_p = *(char_u **)varp; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1562 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1563 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1564 /* |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1565 * Convert the 'whichwrap' option number value to a string, for backwards |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1566 * compatibility with Vim 3.0. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1567 * Note: 'argp' is a pointer to a char_u pointer and is updated. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1568 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1569 static char_u * |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1570 opt_whichwrap_nr2str(char_u **argp, char_u *whichwrap) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1571 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1572 *whichwrap = NUL; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1573 int i = getdigits(argp); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1574 if (i & 1) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1575 STRCAT(whichwrap, "b,"); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1576 if (i & 2) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1577 STRCAT(whichwrap, "s,"); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1578 if (i & 4) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1579 STRCAT(whichwrap, "h,l,"); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1580 if (i & 8) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1581 STRCAT(whichwrap, "<,>,"); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1582 if (i & 16) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1583 STRCAT(whichwrap, "[,],"); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1584 if (*whichwrap != NUL) // remove trailing , |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1585 whichwrap[STRLEN(whichwrap) - 1] = NUL; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1586 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1587 return whichwrap; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1588 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1589 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1590 /* |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1591 * Copy the new string value into allocated memory for the option. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1592 * Can't use set_string_option_direct(), because we need to remove the |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1593 * backslashes. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1594 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1595 static char_u * |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1596 stropt_copy_value( |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1597 char_u *origval, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1598 char_u **argp, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1599 set_op_T op, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1600 int flags UNUSED) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1601 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1602 char_u *arg = *argp; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1603 unsigned newlen; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1604 char_u *newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1605 char_u *s = NULL; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1606 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1607 // get a bit too much |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1608 newlen = (unsigned)STRLEN(arg) + 1; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1609 if (op != OP_NONE) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1610 newlen += (unsigned)STRLEN(origval) + 1; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1611 newval = alloc(newlen); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1612 if (newval == NULL) // out of mem, don't change |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1613 return NULL; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1614 s = newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1615 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1616 // Copy the string, skip over escaped chars. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1617 // For MS-DOS and WIN32 backslashes before normal file name characters |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1618 // are not removed, and keep backslash at start, for "\\machine\path", |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1619 // but do remove it for "\\\\machine\\path". |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1620 // The reverse is found in ExpandOldSetting(). |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1621 while (*arg != NUL && !VIM_ISWHITE(*arg)) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1622 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1623 int i; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1624 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1625 if (*arg == '\\' && arg[1] != NUL |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1626 #ifdef BACKSLASH_IN_FILENAME |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1627 && !((flags & P_EXPAND) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1628 && vim_isfilec(arg[1]) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1629 && !VIM_ISWHITE(arg[1]) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1630 && (arg[1] != '\\' |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1631 || (s == newval && arg[2] != '\\'))) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1632 #endif |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1633 ) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1634 ++arg; // remove backslash |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1635 if (has_mbyte && (i = (*mb_ptr2len)(arg)) > 1) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1636 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1637 // copy multibyte char |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1638 mch_memmove(s, arg, (size_t)i); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1639 arg += i; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1640 s += i; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1641 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1642 else |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1643 *s++ = *arg++; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1644 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1645 *s = NUL; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1646 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1647 *argp = arg; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1648 return newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1649 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1650 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1651 /* |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1652 * Expand environment variables and ~ in string option value 'newval'. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1653 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1654 static char_u * |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1655 stropt_expand_envvar( |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1656 int opt_idx, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1657 char_u *origval, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1658 char_u *newval, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1659 set_op_T op) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1660 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1661 char_u *s = option_expand(opt_idx, newval); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1662 if (s == NULL) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1663 return newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1664 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1665 vim_free(newval); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1666 unsigned newlen = (unsigned)STRLEN(s) + 1; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1667 if (op != OP_NONE) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1668 newlen += (unsigned)STRLEN(origval) + 1; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1669 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1670 newval = alloc(newlen); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1671 if (newval == NULL) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1672 return NULL; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1673 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1674 STRCPY(newval, s); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1675 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1676 return newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1677 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1678 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1679 /* |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1680 * Concatenate the original and new values of a string option, adding a "," if |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1681 * needed. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1682 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1683 static void |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1684 stropt_concat_with_comma( |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1685 char_u *origval, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1686 char_u *newval, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1687 set_op_T op, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1688 int flags) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1689 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1690 int len = 0; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1691 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1692 int comma = ((flags & P_COMMA) && *origval != NUL && *newval != NUL); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1693 if (op == OP_ADDING) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1694 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1695 len = (int)STRLEN(origval); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1696 // strip a trailing comma, would get 2 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1697 if (comma && len > 1 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1698 && (flags & P_ONECOMMA) == P_ONECOMMA |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1699 && origval[len - 1] == ',' |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1700 && origval[len - 2] != '\\') |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1701 len--; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1702 mch_memmove(newval + len + comma, newval, STRLEN(newval) + 1); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1703 mch_memmove(newval, origval, (size_t)len); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1704 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1705 else |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1706 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1707 len = (int)STRLEN(newval); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1708 STRMOVE(newval + len + comma, origval); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1709 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1710 if (comma) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1711 newval[len] = ','; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1712 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1713 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1714 /* |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1715 * Remove a value from a string option. Copy string option value in "origval" |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1716 * to "newval" and then remove the string "strval" of length "len". |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1717 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1718 static void |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1719 stropt_remove_val( |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1720 char_u *origval, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1721 char_u *newval, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1722 int flags, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1723 char_u *strval, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1724 int len) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1725 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1726 // Remove newval[] from origval[]. (Note: "len" has been set above |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1727 // and is used here). |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1728 STRCPY(newval, origval); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1729 if (*strval) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1730 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1731 // may need to remove a comma |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1732 if (flags & P_COMMA) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1733 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1734 if (strval == origval) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1735 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1736 // include comma after string |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1737 if (strval[len] == ',') |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1738 ++len; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1739 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1740 else |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1741 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1742 // include comma before string |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1743 --strval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1744 ++len; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1745 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1746 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1747 STRMOVE(newval + (strval - origval), strval + len); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1748 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1749 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1750 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1751 /* |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1752 * Remove flags that appear twice in the string option value 'newval'. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1753 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1754 static void |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1755 stropt_remove_dupflags(char_u *newval, int flags) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1756 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1757 char_u *s = newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1758 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1759 // Remove flags that appear twice. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1760 while (*s) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1761 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1762 // if options have P_FLAGLIST and P_ONECOMMA such as 'whichwrap' |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1763 if (flags & P_ONECOMMA) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1764 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1765 if (*s != ',' && *(s + 1) == ',' && vim_strchr(s + 2, *s) != NULL) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1766 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1767 // Remove the duplicated value and the next comma. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1768 STRMOVE(s, s + 2); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1769 continue; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1770 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1771 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1772 else |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1773 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1774 if ((!(flags & P_COMMA) || *s != ',') |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1775 && vim_strchr(s + 1, *s) != NULL) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1776 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1777 STRMOVE(s, s + 1); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1778 continue; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1779 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1780 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1781 ++s; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1782 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1783 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1784 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1785 /* |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1786 * Get the string value specified for a ":set" command. The following set |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1787 * options are supported: |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1788 * set {opt}& |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1789 * set {opt}< |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1790 * set {opt}={val} |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1791 * set {opt}:{val} |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1792 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1793 static char_u * |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1794 stropt_get_newval( |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1795 int nextchar, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1796 int opt_idx, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1797 char_u **argp, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1798 char_u *varp, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1799 char_u **origval_arg, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1800 char_u **origval_l_arg, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1801 char_u **origval_g_arg, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1802 char_u **oldval_arg, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1803 set_op_T *op_arg, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1804 int flags, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1805 int cp_val) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1806 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1807 char_u *arg = *argp; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1808 char_u *origval = *origval_arg; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1809 char_u *origval_l = *origval_l_arg; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1810 char_u *origval_g = *origval_g_arg; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1811 char_u *oldval = *oldval_arg; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1812 set_op_T op = *op_arg; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1813 char_u *save_arg = NULL; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1814 char_u *newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1815 char_u *s = NULL; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1816 char_u whichwrap[80]; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1817 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1818 if (nextchar == '&') // set to default val |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1819 newval = stropt_get_default_val(opt_idx, varp, flags, cp_val); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1820 else if (nextchar == '<') // set to global val |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1821 newval = vim_strsave(*(char_u **)get_varp_scope( |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1822 &(options[opt_idx]), OPT_GLOBAL)); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1823 else |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1824 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1825 ++arg; // jump to after the '=' or ':' |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1826 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1827 // Set 'keywordprg' to ":help" if an empty |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1828 // value was passed to :set by the user. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1829 if (varp == (char_u *)&p_kp && (*arg == NUL || *arg == ' ')) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1830 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1831 save_arg = arg; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1832 arg = (char_u *)":help"; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1833 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1834 // Convert 'backspace' number to string |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1835 else if (varp == (char_u *)&p_bs && VIM_ISDIGIT(**(char_u **)varp)) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1836 opt_backspace_nr2str(varp, &origval, &origval_l, &origval_g, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1837 &oldval); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1838 else if (varp == (char_u *)&p_ww && VIM_ISDIGIT(*arg)) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1839 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1840 // Convert 'whichwrap' number to string, for backwards |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1841 // compatibility with Vim 3.0. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1842 char_u *t = opt_whichwrap_nr2str(&arg, whichwrap); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1843 save_arg = arg; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1844 arg = t; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1845 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1846 // Remove '>' before 'dir' and 'bdir', for backwards compatibility with |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1847 // version 3.0 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1848 else if (*arg == '>' && (varp == (char_u *)&p_dir |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1849 || varp == (char_u *)&p_bdir)) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1850 ++arg; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1851 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1852 // Copy the new string into allocated memory. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1853 newval = stropt_copy_value(origval, &arg, op, flags); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1854 if (newval == NULL) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1855 goto done; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1856 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1857 // Expand environment variables and ~. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1858 // Don't do it when adding without inserting a comma. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1859 if (op == OP_NONE || (flags & P_COMMA)) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1860 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1861 newval = stropt_expand_envvar(opt_idx, origval, newval, op); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1862 if (newval == NULL) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1863 goto done; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1864 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1865 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1866 // locate newval[] in origval[] when removing it and when adding to |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1867 // avoid duplicates |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1868 int len = 0; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1869 if (op == OP_REMOVING || (flags & P_NODUP)) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1870 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1871 len = (int)STRLEN(newval); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1872 s = find_dup_item(origval, newval, flags); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1873 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1874 // do not add if already there |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1875 if ((op == OP_ADDING || op == OP_PREPENDING) && s != NULL) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1876 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1877 op = OP_NONE; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1878 STRCPY(newval, origval); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1879 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1880 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1881 // if no duplicate, move pointer to end of original value |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1882 if (s == NULL) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1883 s = origval + (int)STRLEN(origval); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1884 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1885 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1886 // concatenate the two strings; add a ',' if needed |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1887 if (op == OP_ADDING || op == OP_PREPENDING) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1888 stropt_concat_with_comma(origval, newval, op, flags); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1889 else if (op == OP_REMOVING) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1890 // Remove newval[] from origval[]. (Note: "len" has been set above |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1891 // and is used here). |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1892 stropt_remove_val(origval, newval, flags, s, len); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1893 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1894 if (flags & P_FLAGLIST) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1895 // Remove flags that appear twice. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1896 stropt_remove_dupflags(newval, flags); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1897 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1898 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1899 done: |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1900 if (save_arg != NULL) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1901 arg = save_arg; // arg was temporarily changed, restore it |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1902 *argp = arg; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1903 *origval_arg = origval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1904 *origval_l_arg = origval_l; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1905 *origval_g_arg = origval_g; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1906 *oldval_arg = oldval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1907 *op_arg = op; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1908 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1909 return newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1910 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1911 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1912 /* |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1913 * 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
|
1914 * 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
|
1915 */ |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1916 static int |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1917 do_set_option_string( |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1918 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
|
1919 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
|
1920 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
|
1921 int nextchar, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1922 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
|
1923 int flags, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1924 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
|
1925 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
|
1926 char *errbuf, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1927 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
|
1928 char **errmsg) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1929 { |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1930 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
|
1931 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
|
1932 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
|
1933 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
|
1934 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
|
1935 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
|
1936 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
|
1937 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
|
1938 #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
|
1939 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
|
1940 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
|
1941 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
|
1942 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
|
1943 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1944 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1945 // 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
|
1946 // 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
|
1947 // 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
|
1948 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
|
1949 && ((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
|
1950 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
|
1951 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1952 // 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
|
1953 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
|
1954 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1955 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
|
1956 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1957 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
|
1958 &(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
|
1959 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
|
1960 &(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
|
1961 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1962 // 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
|
1963 // 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
|
1964 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
|
1965 && 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
|
1966 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
|
1967 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1968 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1969 // 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
|
1970 // 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
|
1971 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
|
1972 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
|
1973 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1974 origval = oldval; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1975 |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1976 // Get the new value for the option |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1977 newval = stropt_get_newval(nextchar, opt_idx, &arg, varp, &origval, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1978 &origval_l, &origval_g, &oldval, &op, flags, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1979 cp_val); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1980 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1981 // Set the new value. |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1982 *(char_u **)(varp) = newval; |
31958
b08c410578a5
patch 9.0.1311: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31952
diff
changeset
|
1983 if (newval == NULL) |
b08c410578a5
patch 9.0.1311: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31952
diff
changeset
|
1984 *(char_u **)(varp) = empty_option; |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1985 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1986 #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
|
1987 if (!starting |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1988 # 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
|
1989 && 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
|
1990 # endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1991 && 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
|
1992 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1993 // 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
|
1994 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
|
1995 // 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
|
1996 // autocommands. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1997 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
|
1998 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
|
1999 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
|
2000 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
|
2001 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
|
2002 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2003 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2004 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2005 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2006 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
|
2007 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
|
2008 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2009 // 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
|
2010 // 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
|
2011 // 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
|
2012 // replaced. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2013 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
|
2014 #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
|
2015 || sandbox != 0 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2016 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2017 || (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
|
2018 secure = 1; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2019 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2020 // 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
|
2021 // 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
|
2022 // 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
|
2023 *errmsg = did_set_string_option( |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
2024 opt_idx, (char_u **)varp, oldval, newval, errbuf, |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2025 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
|
2026 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2027 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
|
2028 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2029 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2030 #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
|
2031 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
|
2032 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
|
2033 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
|
2034 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
|
2035 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
|
2036 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
|
2037 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
|
2038 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2039 |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
2040 *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
|
2041 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
|
2042 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2043 |
7 | 2044 /* |
31908
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
2045 * 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
|
2046 * 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
|
2047 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2048 static char * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2049 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
|
2050 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
|
2051 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
|
2052 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
|
2053 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
|
2054 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
|
2055 int nextchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2056 int afterchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2057 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
|
2058 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2059 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2060 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
|
2061 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2062 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
|
2063 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
|
2064 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
|
2065 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
|
2066 |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2067 // ":set opt!": invert |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2068 // ":set opt&": reset to default value |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2069 // ":set opt<": reset to global value |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2070 if (nextchar == '!') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2071 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
|
2072 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
|
2073 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
|
2074 ((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
|
2075 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
|
2076 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2077 // 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
|
2078 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
|
2079 value = -1; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2080 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2081 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
|
2082 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2083 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2084 { |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2085 // ":set invopt": invert |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2086 // ":set opt" or ":set noopt": set or reset |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2087 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
|
2088 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
|
2089 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
|
2090 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
|
2091 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2092 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
|
2093 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2094 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2095 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
|
2096 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2097 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2098 /* |
31908
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
2099 * 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
|
2100 * 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
|
2101 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2102 static char * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2103 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
|
2104 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
|
2105 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
|
2106 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
|
2107 int nextchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2108 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
|
2109 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
|
2110 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
|
2111 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
|
2112 char *errbuf, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2113 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
|
2114 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2115 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
|
2116 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
|
2117 int i; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2118 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
|
2119 |
31908
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
2120 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
|
2121 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
|
2122 // |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2123 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2124 * 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
|
2125 * & 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
|
2126 * < 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
|
2127 * <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
|
2128 * 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
|
2129 * [-]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
|
2130 * other error |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2131 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2132 ++arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2133 if (nextchar == '&') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2134 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
|
2135 ((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
|
2136 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
|
2137 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2138 // 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
|
2139 // 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
|
2140 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
|
2141 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
|
2142 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2143 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
|
2144 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2145 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
|
2146 && (*arg == '<' |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2147 || *arg == '^' |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2148 || (*arg != NUL |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2149 && (!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
|
2150 && !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
|
2151 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2152 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
|
2153 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
|
2154 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2155 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
|
2156 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2157 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2158 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2159 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
|
2160 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2161 // Allow negative (for 'undolevels'), octal and hex numbers. |
32098
39f4126d2a0d
patch 9.0.1380: CTRL-X on 2**64 subtracts two
Bram Moolenaar <Bram@vim.org>
parents:
32096
diff
changeset
|
2162 vim_str2nr(arg, NULL, &i, STR2NR_ALL, &value, NULL, 0, TRUE, NULL); |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2163 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
|
2164 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2165 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
|
2166 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2167 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2168 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2169 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2170 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2171 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
|
2172 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2173 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2174 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2175 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
|
2176 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
|
2177 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
|
2178 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
|
2179 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
|
2180 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
|
2181 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2182 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
|
2183 opt_flags); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2184 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2185 skip: |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2186 *argp = arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2187 return errmsg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2188 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2189 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2190 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2191 * 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
|
2192 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2193 static char * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2194 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
|
2195 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2196 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
|
2197 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
|
2198 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2199 if (nextchar == '&') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2200 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2201 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
|
2202 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
|
2203 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2204 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2205 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2206 ++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
|
2207 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
|
2208 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
|
2209 ++p; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2210 nextchar = *p; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2211 *p = NUL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2212 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
|
2213 *p = nextchar; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2214 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2215 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
|
2216 ttest(FALSE); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2217 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
|
2218 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2219 *argp = arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2220 return NULL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2221 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2222 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2223 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2224 * 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
|
2225 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2226 static char * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2227 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
|
2228 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
|
2229 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
|
2230 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
|
2231 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
|
2232 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
|
2233 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
|
2234 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
|
2235 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
|
2236 int nextchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2237 int afterchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2238 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
|
2239 int *stopopteval, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2240 char *errbuf, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2241 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
|
2242 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2243 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
|
2244 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
|
2245 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
|
2246 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2247 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
|
2248 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2249 // boolean option |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2250 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
|
2251 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
|
2252 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
|
2253 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2254 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2255 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2256 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2257 // 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
|
2258 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
|
2259 || 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
|
2260 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2261 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
|
2262 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2263 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2264 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2265 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
|
2266 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2267 // numeric option |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2268 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
|
2269 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
|
2270 errbuf, errbuflen); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2271 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
|
2272 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2273 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2274 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
|
2275 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2276 // string option |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
2277 if (do_set_option_string(opt_idx, opt_flags, &arg, nextchar, op, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
2278 flags, cp_val, varp, errbuf, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
2279 &value_checked, &errmsg) == FAIL) |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2280 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2281 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
|
2282 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2283 *stopopteval = TRUE; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2284 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2285 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2286 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2287 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2288 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2289 // 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
|
2290 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
|
2291 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
|
2292 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2293 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2294 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2295 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2296 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
|
2297 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
|
2298 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2299 skip: |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2300 *argp = arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2301 return errmsg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2302 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2303 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2304 /* |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2305 * 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
|
2306 * 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
|
2307 * 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
|
2308 */ |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2309 static char * |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2310 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
|
2311 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
|
2312 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
|
2313 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
|
2314 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
|
2315 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
|
2316 int *stopopteval, |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2317 char *errbuf, |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2318 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
|
2319 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2320 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
|
2321 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
|
2322 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
|
2323 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
|
2324 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
|
2325 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
|
2326 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
|
2327 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
|
2328 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
|
2329 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
|
2330 int key; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2331 int len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2332 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2333 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
|
2334 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
|
2335 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2336 // 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
|
2337 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
|
2338 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
|
2339 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
|
2340 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2341 // 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
|
2342 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
|
2343 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2344 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
|
2345 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2346 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
|
2347 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2348 // 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
|
2349 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
|
2350 || (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
|
2351 && p[1] == '='))) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2352 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2353 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
|
2354 arg = p; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2355 *startarg = p; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2356 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2357 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2358 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2359 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2360 // 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
|
2361 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
|
2362 ++len; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2363 |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2364 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
|
2365 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
|
2366 len++; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2367 |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2368 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
|
2369 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2370 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
|
2371 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2372 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
|
2373 && 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
|
2374 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
|
2375 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2376 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
|
2377 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2378 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2379 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2380 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
|
2381 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2382 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
|
2383 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2384 // 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
|
2385 // 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
|
2386 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
|
2387 && (!(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
|
2388 || nextchar == '?')) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2389 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
|
2390 goto skip; |
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 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2393 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
|
2394 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
|
2395 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2396 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2397 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2398 flags = P_STRING; |
31904
a4358b58d3fb
patch 9.0.1284: compiler warnings for uninitialized variables
Bram Moolenaar <Bram@vim.org>
parents:
31902
diff
changeset
|
2399 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
|
2400 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
|
2401 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2402 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
|
2403 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
|
2404 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2405 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2406 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2407 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
|
2408 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
|
2409 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2410 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2411 |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2412 // 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
|
2413 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
|
2414 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2415 |
31904
a4358b58d3fb
patch 9.0.1284: compiler warnings for uninitialized variables
Bram Moolenaar <Bram@vim.org>
parents:
31902
diff
changeset
|
2416 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
|
2417 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
|
2418 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2419 arg += len; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2420 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
|
2421 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2422 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
|
2423 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2424 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
|
2425 arg += 3; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2426 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2427 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
|
2428 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2429 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
|
2430 arg += 2; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2431 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2432 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2433 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
|
2434 && 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
|
2435 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2436 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
|
2437 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2438 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2439 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2440 |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2441 // Allow '=' and ':' for historical reasons (MSDOS command.com). |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2442 // 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
|
2443 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
|
2444 || (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
|
2445 && 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
|
2446 && !(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
|
2447 { |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2448 // print value |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2449 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
|
2450 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
|
2451 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2452 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2453 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
|
2454 *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
|
2455 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2456 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
|
2457 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2458 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
|
2459 #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
|
2460 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
|
2461 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2462 // 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
|
2463 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
|
2464 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
|
2465 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
|
2466 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
|
2467 (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
|
2468 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
|
2469 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
|
2470 (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
|
2471 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2472 #endif |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2473 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2474 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2475 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2476 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
|
2477 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2478 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
|
2479 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
|
2480 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2481 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
|
2482 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2483 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2484 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2485 (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
|
2486 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2487 if (nextchar != '?' |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2488 && 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
|
2489 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
|
2490 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2491 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2492 { |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2493 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
|
2494 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
|
2495 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
|
2496 errbuflen); |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2497 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2498 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2499 skip: |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2500 *argp = arg; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2501 return errmsg; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2502 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2503 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2504 /* |
7 | 2505 * Parse 'arg' for option settings. |
2506 * | |
2507 * 'arg' may be IObuff, but only when no errors can be present and option | |
2508 * does not need to be expanded with option_expand(). | |
2509 * "opt_flags": | |
2510 * 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
|
2511 * 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
|
2512 * 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
|
2513 * 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
|
2514 * 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
|
2515 * 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
|
2516 * OPT_ONECOLUMN do not use multiple columns |
7 | 2517 * |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2518 * Returns FAIL if an error is detected, OK otherwise. |
7 | 2519 */ |
2520 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2521 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
|
2522 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
|
2523 int opt_flags) |
7 | 2524 { |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
2525 char_u *arg = arg_start; |
7 | 2526 int i; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2527 int did_show = FALSE; // already showed one value |
7 | 2528 |
2529 if (*arg == NUL) | |
2530 { | |
2531 showoptions(0, opt_flags); | |
168 | 2532 did_show = TRUE; |
2533 goto theend; | |
7 | 2534 } |
2535 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2536 while (*arg != NUL) // loop to process all options |
7 | 2537 { |
31766
9f1504e36ae9
patch 9.0.1215: using isalpha() adds dependency on current locale
Bram Moolenaar <Bram@vim.org>
parents:
31752
diff
changeset
|
2538 if (STRNCMP(arg, "all", 3) == 0 && !ASCII_ISALPHA(arg[3]) |
36 | 2539 && !(opt_flags & OPT_MODELINE)) |
7 | 2540 { |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2541 // ":set all" show all options. |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2542 // ":set all&" set all options to their default value. |
7 | 2543 arg += 3; |
2544 if (*arg == '&') | |
2545 { | |
2546 ++arg; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2547 // Only for :set command set global value of local options. |
7 | 2548 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
|
2549 didset_options(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2550 didset_options2(); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
2551 redraw_all_later(UPD_CLEAR); |
7 | 2552 } |
2553 else | |
168 | 2554 { |
7 | 2555 showoptions(1, opt_flags); |
168 | 2556 did_show = TRUE; |
2557 } | |
7 | 2558 } |
36 | 2559 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) |
7 | 2560 { |
2561 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
|
2562 show_termcodes(opt_flags); |
168 | 2563 did_show = TRUE; |
7 | 2564 arg += 7; |
2565 } | |
2566 else | |
2567 { | |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2568 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
|
2569 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
|
2570 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
|
2571 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
|
2572 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2573 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
|
2574 &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
|
2575 sizeof(errbuf)); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2576 if (stopopteval) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2577 break; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2578 |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2579 // Advance to next argument. |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2580 // - skip until a blank found, taking care of backslashes |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2581 // - skip blanks |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2582 // - skip one "=val" argument (for hidden options ":set gfn =xx") |
7 | 2583 for (i = 0; i < 2 ; ++i) |
2584 { | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2585 while (*arg != NUL && !VIM_ISWHITE(*arg)) |
7 | 2586 if (*arg++ == '\\' && *arg != NUL) |
2587 ++arg; | |
2588 arg = skipwhite(arg); | |
2589 if (*arg != '=') | |
2590 break; | |
2591 } | |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2592 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2593 if (errmsg != NULL) |
7 | 2594 { |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2595 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
|
2596 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
|
2597 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
|
2598 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2599 // 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
|
2600 STRCAT(IObuff, ": "); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2601 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
|
2602 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
|
2603 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2604 // 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
|
2605 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
|
2606 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2607 ++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
|
2608 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
|
2609 --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
|
2610 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2611 return FAIL; |
7 | 2612 } |
2613 } | |
2614 | |
2615 arg = skipwhite(arg); | |
2616 } | |
2617 | |
168 | 2618 theend: |
2619 if (silent_mode && did_show) | |
2620 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2621 // After displaying option values in silent mode. |
168 | 2622 silent_mode = FALSE; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2623 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
168 | 2624 msg_putchar('\n'); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2625 cursor_on(); // msg_start() switches it off |
168 | 2626 out_flush(); |
2627 silent_mode = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2628 info_message = FALSE; // use mch_msg(), not mch_errmsg() |
168 | 2629 } |
2630 | |
7 | 2631 return OK; |
2632 } | |
2633 | |
634 | 2634 /* |
2635 * Call this when an option has been given a new value through a user command. | |
2636 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag. | |
2637 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2638 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2639 did_set_option( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2640 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
|
2641 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
|
2642 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
|
2643 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
|
2644 // P_INSECURE flag. |
634 | 2645 { |
681 | 2646 long_u *p; |
2647 | |
634 | 2648 options[opt_idx].flags |= P_WAS_SET; |
2649 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2650 // 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
|
2651 // 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
|
2652 // flag. |
681 | 2653 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
|
2654 if (!value_checked && (secure |
634 | 2655 #ifdef HAVE_SANDBOX |
2656 || sandbox != 0 | |
2657 #endif | |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2658 || (opt_flags & OPT_MODELINE))) |
681 | 2659 *p = *p | P_INSECURE; |
2660 else if (new_value) | |
2661 *p = *p & ~P_INSECURE; | |
634 | 2662 } |
2663 | |
7 | 2664 /* |
2665 * Convert a key name or string into a key value. | |
2666 * 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
|
2667 * 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
|
2668 */ |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2669 int |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2670 string_to_key(char_u *arg, int multi_byte) |
7 | 2671 { |
2672 if (*arg == '<') | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
2673 return find_key_option(arg + 1, TRUE); |
7 | 2674 if (*arg == '^') |
2675 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
|
2676 if (multi_byte) |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2677 return PTR2CHAR(arg); |
7 | 2678 return *arg; |
2679 } | |
2680 | |
2681 /* | |
2682 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call | |
2683 * maketitle() to create and display it. | |
2684 * When switching the title or icon off, call mch_restore_title() to get | |
2685 * the old value back. | |
2686 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2687 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
|
2688 did_set_title(void) |
7 | 2689 { |
2690 if (starting != NO_SCREEN | |
2691 #ifdef FEAT_GUI | |
2692 && !gui.starting | |
2693 #endif | |
2694 ) | |
2695 maketitle(); | |
2696 } | |
2697 | |
2698 /* | |
2699 * set_options_bin - called when 'bin' changes value. | |
2700 */ | |
2701 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2702 set_options_bin( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2703 int oldval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2704 int newval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2705 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 2706 { |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2707 // The option values that are changed when 'bin' changes are |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2708 // copied when 'bin is set and restored when 'bin' is reset. |
7 | 2709 if (newval) |
2710 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2711 if (!oldval) // switched on |
7 | 2712 { |
2713 if (!(opt_flags & OPT_GLOBAL)) | |
2714 { | |
2715 curbuf->b_p_tw_nobin = curbuf->b_p_tw; | |
2716 curbuf->b_p_wm_nobin = curbuf->b_p_wm; | |
2717 curbuf->b_p_ml_nobin = curbuf->b_p_ml; | |
2718 curbuf->b_p_et_nobin = curbuf->b_p_et; | |
2719 } | |
2720 if (!(opt_flags & OPT_LOCAL)) | |
2721 { | |
2722 p_tw_nobin = p_tw; | |
2723 p_wm_nobin = p_wm; | |
2724 p_ml_nobin = p_ml; | |
2725 p_et_nobin = p_et; | |
2726 } | |
2727 } | |
2728 | |
2729 if (!(opt_flags & OPT_GLOBAL)) | |
2730 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2731 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
|
2732 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
|
2733 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
|
2734 curbuf->b_p_et = 0; // no expandtab |
7 | 2735 } |
2736 if (!(opt_flags & OPT_LOCAL)) | |
2737 { | |
2738 p_tw = 0; | |
2739 p_wm = 0; | |
2740 p_ml = FALSE; | |
2741 p_et = FALSE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2742 p_bin = TRUE; // needed when called for the "-b" argument |
7 | 2743 } |
2744 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2745 else if (oldval) // switched off |
7 | 2746 { |
2747 if (!(opt_flags & OPT_GLOBAL)) | |
2748 { | |
2749 curbuf->b_p_tw = curbuf->b_p_tw_nobin; | |
2750 curbuf->b_p_wm = curbuf->b_p_wm_nobin; | |
2751 curbuf->b_p_ml = curbuf->b_p_ml_nobin; | |
2752 curbuf->b_p_et = curbuf->b_p_et_nobin; | |
2753 } | |
2754 if (!(opt_flags & OPT_LOCAL)) | |
2755 { | |
2756 p_tw = p_tw_nobin; | |
2757 p_wm = p_wm_nobin; | |
2758 p_ml = p_ml_nobin; | |
2759 p_et = p_et_nobin; | |
2760 } | |
2761 } | |
2762 } | |
2763 | |
2764 /* | |
2765 * Expand environment variables for some string options. | |
2766 * These string options cannot be indirect! | |
2767 * If "val" is NULL expand the current value of the option. | |
2768 * Return pointer to NameBuff, or NULL when not expanded. | |
2769 */ | |
2770 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2771 option_expand(int opt_idx, char_u *val) |
7 | 2772 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2773 // if option doesn't need expansion nothing to do |
7 | 2774 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) |
2775 return NULL; | |
2776 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2777 // 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
|
2778 // expand_env() would truncate the string. |
7 | 2779 if (val != NULL && STRLEN(val) > MAXPATHL) |
2780 return NULL; | |
2781 | |
2782 if (val == NULL) | |
2783 val = *(char_u **)options[opt_idx].var; | |
2784 | |
2785 /* | |
2786 * Expanding this with NameBuff, expand_env() must not be passed IObuff. | |
2787 * Escape spaces when expanding 'tags', they are used to separate file | |
2788 * names. | |
374 | 2789 * For 'spellsuggest' expand after "file:". |
7 | 2790 */ |
2791 expand_env_esc(val, NameBuff, MAXPATHL, | |
1408 | 2792 (char_u **)options[opt_idx].var == &p_tags, FALSE, |
744 | 2793 #ifdef FEAT_SPELL |
374 | 2794 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : |
2795 #endif | |
2796 NULL); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2797 if (STRCMP(NameBuff, val) == 0) // they are the same |
7 | 2798 return NULL; |
2799 | |
2800 return NameBuff; | |
2801 } | |
2802 | |
2803 /* | |
2804 * After setting various option values: recompute variables that depend on | |
2805 * option values. | |
2806 */ | |
2807 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2808 didset_options(void) |
7 | 2809 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2810 // initialize the table for 'iskeyword' et.al. |
7 | 2811 (void)init_chartab(); |
2812 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2813 didset_string_options(); |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2814 |
744 | 2815 #ifdef FEAT_SPELL |
484 | 2816 (void)spell_check_msm(); |
374 | 2817 (void)spell_check_sps(); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
2818 (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
|
2819 (void)did_set_spell_option(TRUE); |
344 | 2820 #endif |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2821 // set cedit_key |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
2822 (void)did_set_cedit(NULL); |
5995 | 2823 #ifdef FEAT_LINEBREAK |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2824 // initialize the table for 'breakat'. |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
2825 did_set_breakat(NULL); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2826 #endif |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2827 after_copy_winopt(curwin); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2828 } |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2829 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2830 /* |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2831 * More side effects of setting options. |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2832 */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2833 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2834 didset_options2(void) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2835 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2836 // Initialize the highlight_attr[] table. |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2837 (void)highlight_changed(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2838 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2839 // Parse default for 'wildmode' |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2840 check_opt_wim(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2841 |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2842 // Parse default for 'listchars'. |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2843 (void)set_listchars_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
|
2844 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2845 // Parse default for 'fillchars'. |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
2846 (void)set_fillchars_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
|
2847 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2848 #ifdef FEAT_CLIPBOARD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2849 // Parse default for 'clipboard' |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
2850 (void)did_set_clipboard(NULL); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2851 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2852 #ifdef FEAT_VARTABS |
15858
3a45b89639fb
patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2853 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
|
2854 (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
|
2855 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
|
2856 (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
|
2857 #endif |
7 | 2858 } |
2859 | |
2860 /* | |
2861 * Check for string options that are NULL (normally only termcap options). | |
2862 */ | |
2863 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2864 check_options(void) |
7 | 2865 { |
2866 int opt_idx; | |
2867 | |
2868 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) | |
2869 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL) | |
2870 check_string_option((char_u **)get_varp(&(options[opt_idx]))); | |
2871 } | |
2872 | |
2873 /* | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2874 * 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
|
2875 * 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
|
2876 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2877 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2878 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
|
2879 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2880 int opt_idx; |
7 | 2881 |
2882 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) | |
2883 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
|
2884 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
|
2885 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
|
2886 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2887 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2888 /* |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2889 * 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
|
2890 * 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
|
2891 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2892 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2893 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
|
2894 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2895 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
|
2896 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2897 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
|
2898 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
|
2899 return opt_idx; |
7 | 2900 } |
2901 | |
634 | 2902 #if defined(FEAT_EVAL) || defined(PROTO) |
2903 /* | |
2904 * Return TRUE when option "opt" was set from a modeline or in secure mode. | |
2905 * Return FALSE when it wasn't. | |
2906 * Return -1 for an unknown option. | |
2907 */ | |
2908 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2909 was_set_insecurely(char_u *opt, int opt_flags) |
634 | 2910 { |
2911 int idx = findoption(opt); | |
681 | 2912 long_u *flagp; |
634 | 2913 |
2914 if (idx >= 0) | |
681 | 2915 { |
2916 flagp = insecure_flag(idx, opt_flags); | |
2917 return (*flagp & P_INSECURE) != 0; | |
2918 } | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
2919 internal_error("was_set_insecurely()"); |
634 | 2920 return -1; |
2921 } | |
681 | 2922 |
2923 /* | |
2924 * Get a pointer to the flags used for the P_INSECURE flag of option | |
2925 * "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
|
2926 * 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
|
2927 * the option is used. |
681 | 2928 */ |
2929 static long_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2930 insecure_flag(int opt_idx, int opt_flags) |
681 | 2931 { |
2932 if (opt_flags & OPT_LOCAL) | |
2933 switch ((int)options[opt_idx].indir) | |
2934 { | |
2935 #ifdef FEAT_STL_OPT | |
694 | 2936 case PV_STL: return &curwin->w_p_stl_flags; |
681 | 2937 #endif |
2938 #ifdef FEAT_EVAL | |
885 | 2939 # ifdef FEAT_FOLDING |
694 | 2940 case PV_FDE: return &curwin->w_p_fde_flags; |
2941 case PV_FDT: return &curwin->w_p_fdt_flags; | |
885 | 2942 # endif |
790 | 2943 # ifdef FEAT_BEVAL |
2944 case PV_BEXPR: return &curbuf->b_p_bexpr_flags; | |
2945 # endif | |
694 | 2946 case PV_INDE: return &curbuf->b_p_inde_flags; |
2947 case PV_FEX: return &curbuf->b_p_fex_flags; | |
681 | 2948 # ifdef FEAT_FIND_ID |
694 | 2949 case PV_INEX: return &curbuf->b_p_inex_flags; |
681 | 2950 # endif |
2951 #endif | |
2952 } | |
2953 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2954 // Nothing special, return global flags field. |
681 | 2955 return &options[opt_idx].flags; |
2956 } | |
634 | 2957 #endif |
2958 | |
1805 | 2959 /* |
2960 * Redraw the window title and/or tab page text later. | |
2961 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2962 void redraw_titles(void) |
1805 | 2963 { |
2964 need_maketitle = TRUE; | |
2965 redraw_tabline = TRUE; | |
2966 } | |
2967 | |
7 | 2968 /* |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2969 * 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
|
2970 * 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
|
2971 */ |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17845
diff
changeset
|
2972 int |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2973 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
|
2974 { |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2975 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
|
2976 |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2977 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
|
2978 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
|
2979 return FALSE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2980 return TRUE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2981 } |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2982 |
681 | 2983 #if defined(FEAT_EVAL) || defined(PROTO) |
2984 /* | |
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
|
2985 * Set the script_ctx for an option, taking care of setting the buffer- or |
694 | 2986 * window-local value. |
681 | 2987 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2988 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
|
2989 set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx) |
694 | 2990 { |
2991 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; | |
2992 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
|
2993 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
|
2994 |
20269
246101db63a4
patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents:
20237
diff
changeset
|
2995 // 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
|
2996 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
|
2997 new_script_ctx.sc_lnum += SOURCING_LNUM; |
694 | 2998 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2999 // 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
|
3000 // in the buffer or window structure. |
694 | 3001 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
|
3002 options[opt_idx].script_ctx = new_script_ctx; |
694 | 3003 if (both || (opt_flags & OPT_LOCAL)) |
3004 { | |
3005 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
|
3006 curbuf->b_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
694 | 3007 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
|
3008 { |
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
|
3009 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
|
3010 if (both) |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
3011 // 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
|
3012 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
|
3013 new_script_ctx; |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
3014 } |
694 | 3015 } |
681 | 3016 } |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3017 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3018 /* |
27303
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3019 * 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
|
3020 * |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3021 */ |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3022 sctx_T * |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3023 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
|
3024 { |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3025 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
|
3026 |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3027 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
|
3028 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
|
3029 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
|
3030 return NULL; |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3031 } |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3032 |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3033 /* |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3034 * 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
|
3035 * "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
|
3036 * 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
|
3037 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3038 void |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3039 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
|
3040 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3041 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
|
3042 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
|
3043 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3044 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
|
3045 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
|
3046 else |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3047 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3048 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
|
3049 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
|
3050 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
|
3051 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
|
3052 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
|
3053 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
|
3054 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3055 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
|
3056 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
|
3057 } |
681 | 3058 #endif |
3059 | |
19405
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3060 #if defined(FEAT_EVAL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3061 /* |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3062 * Apply the OptionSet autocommand. |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3063 */ |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3064 static void |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3065 apply_optionset_autocmd( |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3066 int opt_idx, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3067 long opt_flags, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3068 long oldval, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3069 long oldval_g, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3070 long newval, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3071 char *errmsg) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3072 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3073 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
|
3074 |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3075 // 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
|
3076 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
|
3077 return; |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3078 |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3079 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
|
3080 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
|
3081 oldval_g); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3082 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
|
3083 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
|
3084 (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
|
3085 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
|
3086 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
|
3087 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
|
3088 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
|
3089 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3090 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
|
3091 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
|
3092 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3093 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
|
3094 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3095 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
|
3096 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
|
3097 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3098 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
|
3099 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3100 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
|
3101 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
|
3102 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
|
3103 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3104 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
|
3105 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3106 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
|
3107 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
|
3108 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3109 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
|
3110 NULL, FALSE, NULL); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3111 reset_v_option_vars(); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3112 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3113 #endif |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3114 |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
3115 #if defined(FEAT_ARABIC) || defined(PROTO) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3116 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3117 * Process the updated 'arabic' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3118 */ |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
3119 char * |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
3120 did_set_arabic(optset_T *args UNUSED) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3121 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3122 char *errmsg = NULL; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3123 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3124 if (curwin->w_p_arab) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3125 { |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
3126 // 'arabic' is set, handle various sub-settings. |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3127 if (!p_tbidi) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3128 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3129 // set rightleft mode |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3130 if (!curwin->w_p_rl) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3131 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3132 curwin->w_p_rl = TRUE; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3133 changed_window_setting(); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3134 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3135 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3136 // Enable Arabic shaping (major part of what Arabic requires) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3137 if (!p_arshape) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3138 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3139 p_arshape = TRUE; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3140 redraw_later_clear(); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3141 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3142 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3143 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3144 // Arabic requires a utf-8 encoding, inform the user if it's not |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3145 // set. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3146 if (STRCMP(p_enc, "utf-8") != 0) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3147 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3148 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3149 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3150 msg_source(HL_ATTR(HLF_W)); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3151 msg_attr(_(w_arabic), HL_ATTR(HLF_W)); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3152 #ifdef FEAT_EVAL |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3153 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3154 #endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3155 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3156 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3157 // set 'delcombine' |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3158 p_deco = TRUE; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3159 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3160 # ifdef FEAT_KEYMAP |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3161 // Force-set the necessary keymap for arabic |
32096
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3162 errmsg = set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3163 OPT_LOCAL); |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3164 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3165 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3166 else |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3167 { |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
3168 // 'arabic' is reset, handle various sub-settings. |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3169 if (!p_tbidi) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3170 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3171 // reset rightleft mode |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3172 if (curwin->w_p_rl) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3173 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3174 curwin->w_p_rl = FALSE; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3175 changed_window_setting(); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3176 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3177 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3178 // 'arabicshape' isn't reset, it is a global option and |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3179 // another window may still need it "on". |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3180 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3181 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3182 // 'delcombine' isn't reset, it is a global option and another |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3183 // window may still want it "on". |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3184 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3185 # ifdef FEAT_KEYMAP |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3186 // Revert to the default keymap |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3187 curbuf->b_p_iminsert = B_IMODE_NONE; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3188 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3189 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3190 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3191 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3192 return errmsg; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3193 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3194 #endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3195 |
32096
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3196 #if defined(FEAT_AUTOCHDIR) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3197 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3198 * Process the updated 'autochdir' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3199 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3200 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3201 did_set_autochdir(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3202 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3203 // Change directories when the 'acd' option is set now. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3204 DO_AUTOCHDIR; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3205 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3206 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3207 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3208 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3209 #if defined(FEAT_BEVAL_GUI) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3210 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3211 * Process the updated 'ballooneval' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3212 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3213 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3214 did_set_ballooneval(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3215 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3216 if (balloonEvalForTerm) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3217 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3218 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3219 if (p_beval && !args->os_oldval.boolean) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3220 gui_mch_enable_beval_area(balloonEval); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3221 else if (!p_beval && args->os_oldval.boolean) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3222 gui_mch_disable_beval_area(balloonEval); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3223 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3224 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3225 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3226 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3227 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3228 #if defined(FEAT_BEVAL_TERM) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3229 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3230 * Process the updated 'balloonevalterm' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3231 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3232 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3233 did_set_balloonevalterm(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3234 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3235 mch_bevalterm_changed(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3236 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3237 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3238 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3239 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3240 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3241 * Process the updated 'binary' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3242 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3243 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3244 did_set_binary(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3245 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3246 // when 'bin' is set also set some other options |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3247 set_options_bin(args->os_oldval.boolean, curbuf->b_p_bin, args->os_flags); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3248 redraw_titles(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3249 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3250 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3251 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3252 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3253 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3254 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3255 * Called when the 'breakat' option changes value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3256 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3257 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3258 did_set_breakat(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3259 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3260 char_u *p; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3261 int i; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3262 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3263 for (i = 0; i < 256; i++) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3264 breakat_flags[i] = FALSE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3265 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3266 if (p_breakat != NULL) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3267 for (p = p_breakat; *p; p++) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3268 breakat_flags[*p] = TRUE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3269 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3270 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3271 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3272 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3273 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3274 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3275 * Process the updated 'buflisted' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3276 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3277 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3278 did_set_buflisted(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3279 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3280 // when 'buflisted' changes, trigger autocommands |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3281 if (args->os_oldval.boolean != curbuf->b_p_bl) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3282 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3283 NULL, NULL, TRUE, curbuf); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3284 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3285 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3286 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3287 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3288 * Process the new 'cmdheight' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3289 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3290 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3291 did_set_cmdheight(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3292 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3293 long old_value = args->os_oldval.number; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3294 char *errmsg = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3295 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3296 // if p_ch changed value, change the command line height |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3297 if (p_ch < 1) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3298 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3299 errmsg = e_argument_must_be_positive; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3300 p_ch = 1; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3301 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3302 if (p_ch > Rows - min_rows() + 1) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3303 p_ch = Rows - min_rows() + 1; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3304 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3305 // Only compute the new window layout when startup has been |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3306 // completed. Otherwise the frame sizes may be wrong. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3307 if ((p_ch != old_value |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3308 || tabline_height() + topframe->fr_height != Rows - p_ch) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3309 && full_screen |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3310 #ifdef FEAT_GUI |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3311 && !gui.starting |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3312 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3313 ) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3314 command_height(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3315 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3316 return errmsg; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3317 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3318 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3319 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3320 * Process the updated 'compatible' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3321 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3322 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3323 did_set_compatible(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3324 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3325 compatible_set(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3326 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3327 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3328 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3329 #if defined(FEAT_CONCEAL) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3330 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3331 * Process the new 'conceallevel' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3332 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3333 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3334 did_set_conceallevel(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3335 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3336 char *errmsg = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3337 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3338 if (curwin->w_p_cole < 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3339 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3340 errmsg = e_argument_must_be_positive; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3341 curwin->w_p_cole = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3342 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3343 else if (curwin->w_p_cole > 3) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3344 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3345 errmsg = e_invalid_argument; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3346 curwin->w_p_cole = 3; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3347 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3348 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3349 return errmsg; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3350 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3351 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3352 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3353 #if defined(FEAT_DIFF) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3354 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3355 * Process the updated 'diff' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3356 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3357 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3358 did_set_diff(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3359 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3360 // May add or remove the buffer from the list of diff buffers. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3361 diff_buf_adjust(curwin); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3362 # ifdef FEAT_FOLDING |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3363 if (foldmethodIsDiff(curwin)) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3364 foldUpdateAll(curwin); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3365 # endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3366 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3367 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3368 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3369 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3370 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3371 * Process the updated 'endoffile' or 'endofline' or 'fixendofline' or 'bomb' |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3372 * option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3373 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3374 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3375 did_set_eof_eol_fixeol_bomb(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3376 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3377 // redraw the window title and tab page text |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3378 redraw_titles(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3379 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3380 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3381 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3382 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3383 * Process the updated 'equalalways' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3384 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3385 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3386 did_set_equalalways(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3387 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3388 if (p_ea && !args->os_oldval.boolean) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3389 win_equal(curwin, FALSE, 0); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3390 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3391 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3392 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3393 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3394 #if defined(FEAT_FOLDING) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3395 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3396 * Process the new 'foldcolumn' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3397 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3398 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3399 did_set_foldcolumn(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3400 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3401 char *errmsg = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3402 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3403 if (curwin->w_p_fdc < 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3404 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3405 errmsg = e_argument_must_be_positive; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3406 curwin->w_p_fdc = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3407 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3408 else if (curwin->w_p_fdc > 12) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3409 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3410 errmsg = e_invalid_argument; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3411 curwin->w_p_fdc = 12; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3412 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3413 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3414 return errmsg; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3415 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3416 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3417 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3418 * Process the new 'foldlevel' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3419 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3420 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3421 did_set_foldlevel(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3422 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3423 if (curwin->w_p_fdl < 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3424 curwin->w_p_fdl = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3425 newFoldLevel(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3426 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3427 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3428 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3429 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3430 * Process the new 'foldminlines' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3431 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3432 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3433 did_set_foldminlines(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3434 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3435 foldUpdateAll(curwin); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3436 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3437 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3438 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3439 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3440 * Process the new 'foldnestmax' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3441 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3442 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3443 did_set_foldnestmax(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3444 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3445 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3446 foldUpdateAll(curwin); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3447 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3448 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3449 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3450 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3451 #if defined(FEAT_SEARCH_EXTRA) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3452 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3453 * Process the updated 'hlsearch' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3454 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3455 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3456 did_set_hlsearch(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3457 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3458 // when 'hlsearch' is set or reset: reset no_hlsearch |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3459 set_no_hlsearch(FALSE); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3460 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3461 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3462 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3463 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3464 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3465 * Process the updated 'ignorecase' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3466 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3467 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3468 did_set_ignorecase(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3469 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3470 // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3471 if (p_hls) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3472 redraw_all_later(UPD_SOME_VALID); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3473 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3474 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3475 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3476 #if defined(HAVE_INPUT_METHOD) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3477 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3478 * Process the updated 'imdisable' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3479 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3480 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3481 did_set_imdisable(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3482 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3483 // Only de-activate it here, it will be enabled when changing mode. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3484 if (p_imdisable) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3485 im_set_active(FALSE); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3486 else if (State & MODE_INSERT) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3487 // When the option is set from an autocommand, it may need to take |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3488 // effect right away. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3489 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3490 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3491 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3492 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3493 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3494 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3495 * Process the new 'iminsert' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3496 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3497 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3498 did_set_iminsert(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3499 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3500 char *errmsg = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3501 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3502 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3503 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3504 errmsg = e_invalid_argument; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3505 curbuf->b_p_iminsert = B_IMODE_NONE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3506 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3507 p_iminsert = curbuf->b_p_iminsert; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3508 if (termcap_active) // don't do this in the alternate screen |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3509 showmode(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3510 #if defined(FEAT_KEYMAP) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3511 // Show/unshow value of 'keymap' in status lines. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3512 status_redraw_curbuf(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3513 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3514 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3515 return errmsg; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3516 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3517 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3518 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3519 * Process the new 'imsearch' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3520 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3521 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3522 did_set_imsearch(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3523 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3524 char *errmsg = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3525 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3526 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3527 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3528 errmsg = e_invalid_argument; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3529 curbuf->b_p_imsearch = B_IMODE_NONE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3530 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3531 p_imsearch = curbuf->b_p_imsearch; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3532 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3533 return errmsg; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3534 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3535 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3536 #if (defined(FEAT_XIM) && defined(FEAT_GUI_GTK)) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3537 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3538 * Process the new 'imstyle' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3539 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3540 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3541 did_set_imstyle(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3542 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3543 char *errmsg = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3544 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3545 if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3546 errmsg = e_invalid_argument; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3547 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3548 return errmsg; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3549 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3550 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3551 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3552 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3553 * Process the updated 'insertmode' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3554 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3555 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3556 did_set_insertmode(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3557 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3558 // when 'insertmode' is set from an autocommand need to do work here |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3559 if (p_im) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3560 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3561 if ((State & MODE_INSERT) == 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3562 need_start_insertmode = TRUE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3563 stop_insert_mode = FALSE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3564 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3565 // only reset if it was set previously |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3566 else if (args->os_oldval.boolean) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3567 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3568 need_start_insertmode = FALSE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3569 stop_insert_mode = TRUE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3570 if (restart_edit != 0 && mode_displayed) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3571 clear_cmdline = TRUE; // remove "(insert)" |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3572 restart_edit = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3573 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3574 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3575 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3576 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3577 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3578 #if defined(FEAT_LANGMAP) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3579 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3580 * Process the updated 'langnoremap' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3581 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3582 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3583 did_set_langnoremap(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3584 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3585 // 'langnoremap' -> !'langremap' |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3586 p_lrm = !p_lnr; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3587 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3588 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3589 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3590 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3591 * Process the updated 'langremap' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3592 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3593 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3594 did_set_langremap(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3595 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3596 // 'langremap' -> !'langnoremap' |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3597 p_lnr = !p_lrm; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3598 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3599 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3600 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3601 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3602 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3603 * Process the new 'laststatus' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3604 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3605 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3606 did_set_laststatus(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3607 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3608 last_status(FALSE); // (re)set last window status line |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3609 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3610 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3611 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3612 #if defined(FEAT_GUI) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3613 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3614 * Process the new 'linespace' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3615 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3616 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3617 did_set_linespace(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3618 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3619 // Recompute gui.char_height and resize the Vim window to keep the |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3620 // same number of lines. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3621 if (gui.in_use && gui_mch_adjust_charheight() == OK) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3622 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3623 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3624 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3625 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3626 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3627 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3628 * Process the updated 'lisp' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3629 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3630 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3631 did_set_lisp(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3632 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3633 // When 'lisp' option changes include/exclude '-' in keyword characters. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3634 (void)buf_init_chartab(curbuf, FALSE); // ignore errors |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3635 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3636 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3637 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3638 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3639 * Process the new 'maxcombine' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3640 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3641 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3642 did_set_maxcombine(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3643 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3644 if (p_mco > MAX_MCO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3645 p_mco = MAX_MCO; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3646 else if (p_mco < 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3647 p_mco = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3648 screenclear(); // will re-allocate the screen |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3649 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3650 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3651 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3652 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3653 * Process the updated 'modifiable' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3654 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3655 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3656 did_set_modifiable(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3657 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3658 // when 'modifiable' is changed, redraw the window title |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3659 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3660 # ifdef FEAT_TERMINAL |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3661 // Cannot set 'modifiable' when in Terminal mode. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3662 if (curbuf->b_p_ma && (term_in_normal_mode() || (bt_terminal(curbuf) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3663 && curbuf->b_term != NULL && !term_is_finished(curbuf)))) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3664 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3665 curbuf->b_p_ma = FALSE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3666 args->os_doskip = TRUE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3667 return e_cannot_make_terminal_with_running_job_modifiable; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3668 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3669 # endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3670 redraw_titles(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3671 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3672 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3673 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3674 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3675 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3676 * Process the updated 'modified' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3677 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3678 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3679 did_set_modified(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3680 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3681 if (!args->os_newval.boolean) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3682 save_file_ff(curbuf); // Buffer is unchanged |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3683 redraw_titles(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3684 modified_was_set = args->os_newval.boolean; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3685 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3686 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3687 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3688 #if defined(FEAT_GUI) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3689 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3690 * Process the updated 'mousehide' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3691 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3692 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3693 did_set_mousehide(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3694 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3695 if (!p_mh) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3696 gui_mch_mousehide(FALSE); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3697 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3698 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3699 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3700 |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3701 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3702 * Process the updated 'number' or 'relativenumber' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3703 */ |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
3704 char * |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
3705 did_set_number_relativenumber(optset_T *args UNUSED) |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
3706 { |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
3707 #if (defined(FEAT_SIGNS) && defined(FEAT_GUI)) || defined(PROTO) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3708 if (gui.in_use |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3709 && (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) == 'u') |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3710 && curbuf->b_signlist != NULL) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3711 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3712 // If the 'number' or 'relativenumber' options are modified and |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3713 // 'signcolumn' is set to 'number', then clear the screen for a full |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3714 // refresh. Otherwise the sign icons are not displayed properly in the |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3715 // number column. If the 'number' option is set and only the |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3716 // 'relativenumber' option is toggled, then don't refresh the screen |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3717 // (optimization). |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
3718 if (!(curwin->w_p_nu && ((int *)args->os_varp == &curwin->w_p_rnu))) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3719 redraw_all_later(UPD_CLEAR); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3720 } |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
3721 #endif |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
3722 return NULL; |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
3723 } |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3724 |
32096
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3725 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3726 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3727 * Process the new 'numberwidth' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3728 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3729 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3730 did_set_numberwidth(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3731 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3732 char *errmsg = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3733 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3734 // 'numberwidth' must be positive |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3735 if (curwin->w_p_nuw < 1) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3736 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3737 errmsg = e_argument_must_be_positive; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3738 curwin->w_p_nuw = 1; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3739 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3740 if (curwin->w_p_nuw > 20) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3741 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3742 errmsg = e_invalid_argument; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3743 curwin->w_p_nuw = 20; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3744 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3745 curwin->w_nrwidth_line_count = 0; // trigger a redraw |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3746 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3747 return errmsg; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3748 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3749 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3750 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3751 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3752 * Process the updated 'paste' option value. Called after p_paste was set or |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3753 * reset. When 'paste' is set or reset also change other options. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3754 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3755 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3756 did_set_paste(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3757 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3758 static int old_p_paste = FALSE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3759 static int save_sm = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3760 static int save_sta = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3761 static int save_ru = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3762 #ifdef FEAT_RIGHTLEFT |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3763 static int save_ri = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3764 static int save_hkmap = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3765 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3766 buf_T *buf; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3767 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3768 if (p_paste) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3769 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3770 // Paste switched from off to on. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3771 // Save the current values, so they can be restored later. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3772 if (!old_p_paste) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3773 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3774 // save options for each buffer |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3775 FOR_ALL_BUFFERS(buf) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3776 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3777 buf->b_p_tw_nopaste = buf->b_p_tw; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3778 buf->b_p_wm_nopaste = buf->b_p_wm; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3779 buf->b_p_sts_nopaste = buf->b_p_sts; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3780 buf->b_p_ai_nopaste = buf->b_p_ai; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3781 buf->b_p_et_nopaste = buf->b_p_et; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3782 #ifdef FEAT_VARTABS |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3783 if (buf->b_p_vsts_nopaste) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3784 vim_free(buf->b_p_vsts_nopaste); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3785 buf->b_p_vsts_nopaste = |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3786 buf->b_p_vsts && buf->b_p_vsts != empty_option |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3787 ? vim_strsave(buf->b_p_vsts) : NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3788 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3789 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3790 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3791 // save global options |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3792 save_sm = p_sm; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3793 save_sta = p_sta; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3794 save_ru = p_ru; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3795 #ifdef FEAT_RIGHTLEFT |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3796 save_ri = p_ri; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3797 save_hkmap = p_hkmap; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3798 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3799 // save global values for local buffer options |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3800 p_ai_nopaste = p_ai; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3801 p_et_nopaste = p_et; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3802 p_sts_nopaste = p_sts; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3803 p_tw_nopaste = p_tw; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3804 p_wm_nopaste = p_wm; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3805 #ifdef FEAT_VARTABS |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3806 if (p_vsts_nopaste) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3807 vim_free(p_vsts_nopaste); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3808 p_vsts_nopaste = p_vsts && p_vsts != empty_option |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3809 ? vim_strsave(p_vsts) : NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3810 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3811 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3812 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3813 // Always set the option values, also when 'paste' is set when it is |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3814 // already on. Set options for each buffer. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3815 FOR_ALL_BUFFERS(buf) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3816 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3817 buf->b_p_tw = 0; // textwidth is 0 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3818 buf->b_p_wm = 0; // wrapmargin is 0 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3819 buf->b_p_sts = 0; // softtabstop is 0 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3820 buf->b_p_ai = 0; // no auto-indent |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3821 buf->b_p_et = 0; // no expandtab |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3822 #ifdef FEAT_VARTABS |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3823 if (buf->b_p_vsts) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3824 free_string_option(buf->b_p_vsts); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3825 buf->b_p_vsts = empty_option; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3826 VIM_CLEAR(buf->b_p_vsts_array); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3827 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3828 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3829 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3830 // set global options |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3831 p_sm = 0; // no showmatch |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3832 p_sta = 0; // no smarttab |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3833 if (p_ru) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3834 status_redraw_all(); // redraw to remove the ruler |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3835 p_ru = 0; // no ruler |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3836 #ifdef FEAT_RIGHTLEFT |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3837 p_ri = 0; // no reverse insert |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3838 p_hkmap = 0; // no Hebrew keyboard |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3839 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3840 // set global values for local buffer options |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3841 p_tw = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3842 p_wm = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3843 p_sts = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3844 p_ai = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3845 #ifdef FEAT_VARTABS |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3846 if (p_vsts) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3847 free_string_option(p_vsts); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3848 p_vsts = empty_option; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3849 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3850 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3851 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3852 // Paste switched from on to off: Restore saved values. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3853 else if (old_p_paste) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3854 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3855 // restore options for each buffer |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3856 FOR_ALL_BUFFERS(buf) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3857 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3858 buf->b_p_tw = buf->b_p_tw_nopaste; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3859 buf->b_p_wm = buf->b_p_wm_nopaste; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3860 buf->b_p_sts = buf->b_p_sts_nopaste; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3861 buf->b_p_ai = buf->b_p_ai_nopaste; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3862 buf->b_p_et = buf->b_p_et_nopaste; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3863 #ifdef FEAT_VARTABS |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3864 if (buf->b_p_vsts) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3865 free_string_option(buf->b_p_vsts); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3866 buf->b_p_vsts = buf->b_p_vsts_nopaste |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3867 ? vim_strsave(buf->b_p_vsts_nopaste) : empty_option; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3868 vim_free(buf->b_p_vsts_array); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3869 if (buf->b_p_vsts && buf->b_p_vsts != empty_option) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3870 (void)tabstop_set(buf->b_p_vsts, &buf->b_p_vsts_array); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3871 else |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3872 buf->b_p_vsts_array = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3873 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3874 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3875 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3876 // restore global options |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3877 p_sm = save_sm; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3878 p_sta = save_sta; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3879 if (p_ru != save_ru) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3880 status_redraw_all(); // redraw to draw the ruler |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3881 p_ru = save_ru; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3882 #ifdef FEAT_RIGHTLEFT |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3883 p_ri = save_ri; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3884 p_hkmap = save_hkmap; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3885 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3886 // set global values for local buffer options |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3887 p_ai = p_ai_nopaste; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3888 p_et = p_et_nopaste; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3889 p_sts = p_sts_nopaste; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3890 p_tw = p_tw_nopaste; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3891 p_wm = p_wm_nopaste; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3892 #ifdef FEAT_VARTABS |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3893 if (p_vsts) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3894 free_string_option(p_vsts); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3895 p_vsts = p_vsts_nopaste ? vim_strsave(p_vsts_nopaste) : empty_option; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3896 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3897 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3898 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3899 old_p_paste = p_paste; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3900 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3901 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3902 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3903 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3904 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3905 #ifdef FEAT_QUICKFIX |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3906 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3907 * Process the updated 'previewwindow' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3908 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3909 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3910 did_set_previewwindow(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3911 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3912 if (!curwin->w_p_pvw) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3913 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3914 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3915 // There can be only one window with 'previewwindow' set. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3916 win_T *win; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3917 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3918 FOR_ALL_WINDOWS(win) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3919 if (win->w_p_pvw && win != curwin) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3920 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3921 curwin->w_p_pvw = FALSE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3922 args->os_doskip = TRUE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3923 return e_preview_window_already_exists; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3924 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3925 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3926 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3927 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3928 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3929 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3930 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3931 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3932 * Process the new 'pyxversion' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3933 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3934 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3935 did_set_pyxversion(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3936 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3937 char *errmsg = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3938 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3939 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3940 errmsg = e_invalid_argument; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3941 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3942 return errmsg; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3943 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3944 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3945 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3946 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3947 * Process the updated 'readonly' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3948 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3949 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3950 did_set_readonly(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3951 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3952 // when 'readonly' is reset globally, also reset readonlymode |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3953 if (!curbuf->b_p_ro && (args->os_flags & OPT_LOCAL) == 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3954 readonlymode = FALSE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3955 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3956 // when 'readonly' is set may give W10 again |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3957 if (curbuf->b_p_ro) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3958 curbuf->b_did_warn = FALSE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3959 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3960 redraw_titles(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3961 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3962 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3963 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3964 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3965 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3966 * Process the updated 'scrollbind' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3967 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3968 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3969 did_set_scrollbind(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3970 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3971 // when 'scrollbind' is set: snapshot the current position to avoid a jump |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3972 // at the end of normal_cmd() |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3973 if (!curwin->w_p_scb) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3974 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3975 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3976 do_check_scrollbind(FALSE); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3977 curwin->w_scbind_pos = curwin->w_topline; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3978 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3979 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3980 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3981 #if defined(BACKSLASH_IN_FILENAME) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3982 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3983 * Process the updated 'shellslash' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3984 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3985 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3986 did_set_shellslash(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3987 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3988 if (p_ssl) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3989 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3990 psepc = '/'; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3991 psepcN = '\\'; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3992 pseps[0] = '/'; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3993 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3994 else |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3995 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3996 psepc = '\\'; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3997 psepcN = '/'; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3998 pseps[0] = '\\'; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
3999 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4000 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4001 // need to adjust the file name arguments and buffer names. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4002 buflist_slash_adjust(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4003 alist_slash_adjust(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4004 # ifdef FEAT_EVAL |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4005 scriptnames_slash_adjust(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4006 # endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4007 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4008 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4009 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4010 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4011 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4012 * Process the new 'shiftwidth' or the 'tabstop' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4013 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4014 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4015 did_set_shiftwidth_tabstop(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4016 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4017 long *pp = (long *)args->os_varp; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4018 char *errmsg = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4019 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4020 if (curbuf->b_p_sw < 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4021 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4022 errmsg = e_argument_must_be_positive; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4023 #ifdef FEAT_VARTABS |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4024 // Use the first 'vartabstop' value, or 'tabstop' if vts isn't in use. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4025 curbuf->b_p_sw = tabstop_count(curbuf->b_p_vts_array) > 0 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4026 ? tabstop_first(curbuf->b_p_vts_array) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4027 : curbuf->b_p_ts; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4028 #else |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4029 curbuf->b_p_sw = curbuf->b_p_ts; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4030 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4031 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4032 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4033 #ifdef FEAT_FOLDING |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4034 if (foldmethodIsIndent(curwin)) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4035 foldUpdateAll(curwin); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4036 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4037 // When 'shiftwidth' changes, or it's zero and 'tabstop' changes: |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4038 // parse 'cinoptions'. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4039 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4040 parse_cino(curbuf); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4041 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4042 return errmsg; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4043 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4044 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4045 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4046 * Process the new 'showtabline' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4047 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4048 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4049 did_set_showtabline(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4050 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4051 shell_new_rows(); // recompute window positions and heights |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4052 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4053 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4054 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4055 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4056 * Process the updated 'smoothscroll' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4057 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4058 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4059 did_set_smoothscroll(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4060 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4061 if (curwin->w_p_sms) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4062 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4063 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4064 curwin->w_skipcol = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4065 changed_line_abv_curs(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4066 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4067 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4068 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4069 #if defined(FEAT_SPELL) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4070 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4071 * Process the updated 'spell' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4072 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4073 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4074 did_set_spell(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4075 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4076 if (curwin->w_p_spell) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4077 return parse_spelllang(curwin); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4078 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4079 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4080 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4081 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4082 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4083 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4084 * Process the updated 'swapfile' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4085 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4086 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4087 did_set_swapfile(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4088 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4089 // when 'swf' is set, create swapfile, when reset remove swapfile |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4090 if (curbuf->b_p_swf && p_uc) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4091 ml_open_file(curbuf); // create the swap file |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4092 else |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4093 // no need to reset curbuf->b_may_swap, ml_open_file() will check |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4094 // buf->b_p_swf |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4095 mf_close_file(curbuf, TRUE); // remove the swap file |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4096 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4097 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4098 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4099 #if defined(FEAT_TERMGUICOLORS) || defined(PROTO) |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4100 char * |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4101 did_set_termguicolors(optset_T *args UNUSED) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4102 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4103 # ifdef FEAT_VTP |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4104 // Do not turn on 'tgc' when 24-bit colors are not supported. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4105 if ( |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4106 # ifdef VIMDLL |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4107 !gui.in_use && !gui.starting && |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4108 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4109 !has_vtp_working()) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4110 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4111 p_tgc = 0; |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4112 args->os_doskip = TRUE; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4113 return e_24_bit_colors_are_not_supported_on_this_environment; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4114 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4115 if (is_term_win32()) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4116 swap_tcap(); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4117 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4118 # ifdef FEAT_GUI |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4119 if (!gui.in_use && !gui.starting) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4120 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4121 highlight_gui_started(); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4122 # ifdef FEAT_VTP |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4123 // reset t_Co |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4124 if (is_term_win32()) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4125 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4126 control_console_color_rgb(); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4127 set_termname(T_NAME); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4128 init_highlight(TRUE, FALSE); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4129 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4130 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4131 # ifdef FEAT_TERMINAL |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4132 term_update_colors_all(); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4133 term_update_palette_all(); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4134 term_update_wincolor_all(); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4135 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4136 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4137 return NULL; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4138 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4139 #endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4140 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
4141 /* |
32096
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4142 * Process the updated 'terse' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4143 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4144 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4145 did_set_terse(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4146 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4147 char_u *p; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4148 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4149 // when 'terse' is set change 'shortmess' |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4150 p = vim_strchr(p_shm, SHM_SEARCH); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4151 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4152 // insert 's' in p_shm |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4153 if (p_terse && p == NULL) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4154 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4155 STRCPY(IObuff, p_shm); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4156 STRCAT(IObuff, "s"); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4157 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4158 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4159 // remove 's' from p_shm |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4160 else if (!p_terse && p != NULL) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4161 STRMOVE(p, p + 1); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4162 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4163 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4164 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4165 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4166 * Process the updated 'textauto' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4167 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4168 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4169 did_set_textauto(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4170 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4171 // when 'textauto' is set or reset also change 'fileformats' |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4172 set_string_option_direct((char_u *)"ffs", -1, |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4173 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4174 OPT_FREE | args->os_flags, 0); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4175 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4176 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4177 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4178 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4179 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4180 * Process the updated 'textmode' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4181 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4182 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4183 did_set_textmode(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4184 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4185 // when 'textmode' is set or reset also change 'fileformat' |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4186 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, args->os_flags); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4187 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4188 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4189 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4190 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4191 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4192 * Process the new 'textwidth' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4193 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4194 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4195 did_set_textwidth(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4196 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4197 char *errmsg = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4198 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4199 if (curbuf->b_p_tw < 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4200 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4201 errmsg = e_argument_must_be_positive; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4202 curbuf->b_p_tw = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4203 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4204 #ifdef FEAT_SYN_HL |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4205 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4206 win_T *wp; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4207 tabpage_T *tp; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4208 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4209 FOR_ALL_TAB_WINDOWS(tp, wp) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4210 check_colorcolumn(wp); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4211 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4212 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4213 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4214 return errmsg; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4215 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4216 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4217 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4218 * Process the updated 'title' or the 'icon' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4219 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4220 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4221 did_set_title_icon(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4222 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4223 // when 'title' changed, may need to change the title; same for 'icon' |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4224 did_set_title(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4225 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4226 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4227 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4228 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4229 * Process the new 'titlelen' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4230 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4231 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4232 did_set_titlelen(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4233 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4234 long old_value = args->os_oldval.number; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4235 char *errmsg = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4236 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4237 // if 'titlelen' has changed, redraw the title |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4238 if (p_titlelen < 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4239 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4240 errmsg = e_argument_must_be_positive; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4241 p_titlelen = 85; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4242 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4243 if (starting != NO_SCREEN && old_value != p_titlelen) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4244 need_maketitle = TRUE; |
7 | 4245 |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
4246 return errmsg; |
7 | 4247 } |
4248 | |
32096
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4249 #if defined(FEAT_PERSISTENT_UNDO) || defined(PROTO) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4250 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4251 * Process the updated 'undofile' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4252 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4253 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4254 did_set_undofile(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4255 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4256 // Only take action when the option was set. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4257 if (!curbuf->b_p_udf && !p_udf) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4258 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4259 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4260 // When reset we do not delete the undo file, the option may be set again |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4261 // without making any changes in between. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4262 char_u hash[UNDO_HASH_SIZE]; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4263 buf_T *save_curbuf = curbuf; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4264 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4265 FOR_ALL_BUFFERS(curbuf) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4266 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4267 // When 'undofile' is set globally: for every buffer, otherwise |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4268 // only for the current buffer: Try to read in the undofile, |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4269 // if one exists, the buffer wasn't changed and the buffer was |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4270 // loaded |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4271 if ((curbuf == save_curbuf |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4272 || (args->os_flags & OPT_GLOBAL) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4273 || args->os_flags == 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4274 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4275 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4276 #ifdef FEAT_CRYPT |
32299
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
32148
diff
changeset
|
4277 if (crypt_method_is_sodium(crypt_get_method_nr(curbuf))) |
32096
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4278 continue; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4279 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4280 u_compute_hash(hash); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4281 u_read_undo(NULL, hash, curbuf->b_fname); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4282 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4283 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4284 curbuf = save_curbuf; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4285 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4286 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4287 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4288 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4289 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4290 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4291 * Process the new global 'undolevels' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4292 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4293 static void |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4294 update_global_undolevels(long value, long old_value) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4295 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4296 // sync undo before 'undolevels' changes |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4297 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4298 // use the old value, otherwise u_sync() may not work properly |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4299 p_ul = old_value; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4300 u_sync(TRUE); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4301 p_ul = value; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4302 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4303 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4304 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4305 * Process the new buffer local 'undolevels' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4306 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4307 static void |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4308 update_buflocal_undolevels(long value, long old_value) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4309 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4310 // use the old value, otherwise u_sync() may not work properly |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4311 curbuf->b_p_ul = old_value; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4312 u_sync(TRUE); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4313 curbuf->b_p_ul = value; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4314 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4315 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4316 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4317 * Process the new 'undolevels' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4318 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4319 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4320 did_set_undolevels(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4321 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4322 long *pp = (long *)args->os_varp; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4323 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4324 if (pp == &p_ul) // global 'undolevels' |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4325 update_global_undolevels(args->os_newval.number, |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4326 args->os_oldval.number); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4327 else if (pp == &curbuf->b_p_ul) // buffer local 'undolevels' |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4328 update_buflocal_undolevels(args->os_newval.number, |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4329 args->os_oldval.number); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4330 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4331 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4332 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4333 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4334 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4335 * Process the new 'updatecount' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4336 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4337 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4338 did_set_updatecount(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4339 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4340 long old_value = args->os_oldval.number; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4341 char *errmsg = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4342 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4343 // when 'updatecount' changes from zero to non-zero, open swap files |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4344 if (p_uc < 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4345 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4346 errmsg = e_argument_must_be_positive; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4347 p_uc = 100; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4348 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4349 if (p_uc && !old_value) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4350 ml_open_files(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4351 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4352 return errmsg; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4353 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4354 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4355 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4356 * Process the updated 'weirdinvert' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4357 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4358 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4359 did_set_weirdinvert(optset_T *args) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4360 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4361 // When 'weirdinvert' changed, set/reset 't_xs'. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4362 // Then set 'weirdinvert' according to value of 't_xs'. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4363 if (p_wiv && !args->os_oldval.boolean) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4364 T_XS = (char_u *)"y"; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4365 else if (!p_wiv && args->os_oldval.boolean) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4366 T_XS = empty_option; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4367 p_wiv = (*T_XS != NUL); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4368 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4369 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4370 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4371 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4372 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4373 * Process the new 'window' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4374 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4375 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4376 did_set_window(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4377 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4378 if (p_window < 1) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4379 p_window = 1; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4380 else if (p_window >= Rows) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4381 p_window = Rows - 1; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4382 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4383 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4384 |
7 | 4385 /* |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4386 * Process the new 'winheight' or the 'helpheight' option value. |
7 | 4387 */ |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4388 char * |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4389 did_set_winheight_helpheight(optset_T *args) |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4390 { |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4391 long *pp = (long *)args->os_varp; |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4392 char *errmsg = NULL; |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4393 |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4394 if (p_wh < 1) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4395 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4396 errmsg = e_argument_must_be_positive; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4397 p_wh = 1; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4398 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4399 if (p_wmh > p_wh) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4400 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4401 errmsg = e_winheight_cannot_be_smaller_than_winminheight; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4402 p_wh = p_wmh; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4403 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4404 if (p_hh < 0) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4405 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4406 errmsg = e_argument_must_be_positive; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4407 p_hh = 0; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4408 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4409 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4410 // Change window height NOW |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4411 if (!ONE_WINDOW) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4412 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4413 if (pp == &p_wh && curwin->w_height < p_wh) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4414 win_setheight((int)p_wh); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4415 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4416 win_setheight((int)p_hh); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4417 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4418 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4419 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4420 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4421 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4422 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4423 * Process the new 'winminheight' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4424 */ |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4425 char * |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4426 did_set_winminheight(optset_T *args UNUSED) |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4427 { |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4428 char *errmsg = NULL; |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4429 |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4430 if (p_wmh < 0) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4431 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4432 errmsg = e_argument_must_be_positive; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4433 p_wmh = 0; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4434 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4435 if (p_wmh > p_wh) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4436 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4437 errmsg = e_winheight_cannot_be_smaller_than_winminheight; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4438 p_wmh = p_wh; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4439 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4440 win_setminheight(); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4441 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4442 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4443 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4444 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4445 /* |
32096
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4446 * Process the new 'winminwidth' option value. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4447 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4448 char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4449 did_set_winminwidth(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4450 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4451 char *errmsg = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4452 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4453 if (p_wmw < 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4454 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4455 errmsg = e_argument_must_be_positive; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4456 p_wmw = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4457 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4458 if (p_wmw > p_wiw) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4459 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4460 errmsg = e_winwidth_cannot_be_smaller_than_winminwidth; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4461 p_wmw = p_wiw; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4462 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4463 win_setminwidth(); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4464 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4465 return errmsg; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4466 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4467 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4468 /* |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4469 * Process the new 'winwidth' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4470 */ |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4471 char * |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4472 did_set_winwidth(optset_T *args UNUSED) |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4473 { |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4474 char *errmsg = NULL; |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4475 |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4476 if (p_wiw < 1) |
7 | 4477 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4478 errmsg = e_argument_must_be_positive; |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4479 p_wiw = 1; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4480 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4481 if (p_wmw > p_wiw) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4482 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4483 errmsg = e_winwidth_cannot_be_smaller_than_winminwidth; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4484 p_wiw = p_wmw; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4485 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4486 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4487 // Change window width NOW |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4488 if (!ONE_WINDOW && curwin->w_width < p_wiw) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4489 win_setwidth((int)p_wiw); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4490 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4491 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4492 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4493 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4494 /* |
32096
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4495 * Process the updated 'wrap' option value. |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4496 */ |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4497 char * |
32096
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4498 did_set_wrap(optset_T *args UNUSED) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4499 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4500 // If 'wrap' is set, set w_leftcol to zero. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4501 if (curwin->w_p_wrap) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4502 curwin->w_leftcol = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4503 return NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4504 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4505 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4506 /* |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4507 * Set the value of a boolean option, and take care of side effects. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4508 * Returns NULL for success, or an error message for an error. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4509 */ |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4510 static char * |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4511 set_bool_option( |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4512 int opt_idx, // index in options[] table |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4513 char_u *varp, // pointer to the option variable |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4514 int value, // new value |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4515 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4516 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4517 int old_value = *(int *)varp; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4518 #if defined(FEAT_EVAL) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4519 int old_global_value = 0; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4520 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4521 char *errmsg = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4522 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4523 // Disallow changing some options from secure mode |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4524 if ((secure |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4525 #ifdef HAVE_SANDBOX |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4526 || sandbox != 0 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4527 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4528 ) && (options[opt_idx].flags & P_SECURE)) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4529 return e_not_allowed_here; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4530 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4531 #if defined(FEAT_EVAL) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4532 // Save the global value before changing anything. This is needed as for |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4533 // a global-only option setting the "local value" in fact sets the global |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4534 // value (since there is only one value). |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4535 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4536 old_global_value = *(int *)get_varp_scope(&(options[opt_idx]), |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4537 OPT_GLOBAL); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4538 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4539 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4540 *(int *)varp = value; // set the new value |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4541 #ifdef FEAT_EVAL |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4542 // Remember where the option was set. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4543 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4544 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4545 |
7 | 4546 #ifdef FEAT_GUI |
32096
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4547 need_mouse_correct = TRUE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4548 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4549 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4550 // May set global value for local option. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4551 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4552 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4553 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4554 // Handle side effects of changing a bool option. |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4555 if (options[opt_idx].opt_did_set_cb != NULL) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4556 { |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4557 optset_T args; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4558 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4559 CLEAR_FIELD(args); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4560 args.os_varp = varp; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4561 args.os_flags = opt_flags; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4562 args.os_oldval.boolean = old_value; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4563 args.os_newval.boolean = value; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4564 args.os_errbuf = NULL; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4565 errmsg = options[opt_idx].opt_did_set_cb(&args); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4566 if (args.os_doskip) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4567 return errmsg; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4568 } |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4569 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4570 // after handling side effects, call autocommand |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4571 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4572 options[opt_idx].flags |= P_WAS_SET; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4573 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4574 #if defined(FEAT_EVAL) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4575 apply_optionset_autocmd(opt_idx, opt_flags, |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4576 (long)(old_value ? TRUE : FALSE), |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4577 (long)(old_global_value ? TRUE : FALSE), |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4578 (long)(value ? TRUE : FALSE), NULL); |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4579 #endif |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4580 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4581 comp_col(); // in case 'ruler' or 'showcmd' changed |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4582 if (curwin->w_curswant != MAXCOL |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4583 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4584 curwin->w_set_curswant = TRUE; |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4585 |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4586 if ((opt_flags & OPT_NO_REDRAW) == 0) |
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4587 check_redraw(options[opt_idx].flags); |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4588 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4589 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4590 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4591 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4592 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4593 * Check the bounds of numeric options. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4594 */ |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4595 static char * |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4596 check_num_option_bounds( |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4597 long *pp, |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4598 long old_value, |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4599 long old_Rows, |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4600 long old_Columns, |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4601 char *errbuf, |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4602 size_t errbuflen, |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4603 char *errmsg) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4604 { |
7 | 4605 if (Rows < min_rows() && full_screen) |
4606 { | |
4607 if (errbuf != NULL) | |
4608 { | |
27426
41e0dcf38521
patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents:
27303
diff
changeset
|
4609 vim_snprintf(errbuf, errbuflen, |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4610 _(e_need_at_least_nr_lines), min_rows()); |
7 | 4611 errmsg = errbuf; |
4612 } | |
4613 Rows = min_rows(); | |
4614 } | |
4615 if (Columns < MIN_COLUMNS && full_screen) | |
4616 { | |
4617 if (errbuf != NULL) | |
4618 { | |
27426
41e0dcf38521
patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents:
27303
diff
changeset
|
4619 vim_snprintf(errbuf, errbuflen, |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4620 _(e_need_at_least_nr_columns), MIN_COLUMNS); |
7 | 4621 errmsg = errbuf; |
4622 } | |
4623 Columns = MIN_COLUMNS; | |
4624 } | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
5039
diff
changeset
|
4625 limit_screen_size(); |
7 | 4626 |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
4627 // If the screen (shell) height has been changed, assume it is the |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
4628 // physical screenheight. |
7 | 4629 if (old_Rows != Rows || old_Columns != Columns) |
4630 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4631 // Changing the screen size is not allowed while updating the screen. |
7 | 4632 if (updating_screen) |
4633 *pp = old_value; | |
4634 else if (full_screen | |
4635 #ifdef FEAT_GUI | |
4636 && !gui.starting | |
4637 #endif | |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4638 ) |
7 | 4639 set_shellsize((int)Columns, (int)Rows, TRUE); |
4640 else | |
4641 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4642 // 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
|
4643 // messages. |
7 | 4644 check_shellsize(); |
4645 if (cmdline_row > Rows - p_ch && Rows > p_ch) | |
4646 cmdline_row = Rows - p_ch; | |
4647 } | |
857 | 4648 if (p_window >= Rows || !option_was_set((char_u *)"window")) |
164 | 4649 p_window = Rows - 1; |
7 | 4650 } |
4651 | |
4652 if (curbuf->b_p_ts <= 0) | |
4653 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4654 errmsg = e_argument_must_be_positive; |
7 | 4655 curbuf->b_p_ts = 8; |
4656 } | |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
4657 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
|
4658 { |
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
4659 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
|
4660 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
|
4661 } |
7 | 4662 if (p_tm < 0) |
4663 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4664 errmsg = e_argument_must_be_positive; |
7 | 4665 p_tm = 0; |
4666 } | |
4667 if ((curwin->w_p_scr <= 0 | |
4668 || (curwin->w_p_scr > curwin->w_height | |
4669 && curwin->w_height > 0)) | |
4670 && full_screen) | |
4671 { | |
4672 if (pp == &(curwin->w_p_scr)) | |
4673 { | |
4674 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
|
4675 errmsg = e_invalid_scroll_size; |
7 | 4676 win_comp_scroll(curwin); |
4677 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4678 // 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
|
4679 // it. |
7 | 4680 else if (curwin->w_p_scr <= 0) |
4681 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
|
4682 else // curwin->w_p_scr > curwin->w_height |
7 | 4683 curwin->w_p_scr = curwin->w_height; |
4684 } | |
1726 | 4685 if (p_hi < 0) |
4686 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4687 errmsg = e_argument_must_be_positive; |
1726 | 4688 p_hi = 0; |
4689 } | |
5991 | 4690 else if (p_hi > 10000) |
4691 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
4692 errmsg = e_invalid_argument; |
5991 | 4693 p_hi = 10000; |
4694 } | |
4444 | 4695 if (p_re < 0 || p_re > 2) |
4696 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
4697 errmsg = e_invalid_argument; |
4444 | 4698 p_re = 0; |
4699 } | |
7 | 4700 if (p_report < 0) |
4701 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4702 errmsg = e_argument_must_be_positive; |
7 | 4703 p_report = 1; |
4704 } | |
532 | 4705 if ((p_sj < -100 || p_sj >= Rows) && full_screen) |
7 | 4706 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4707 if (Rows != old_Rows) // Rows changed, just adjust p_sj |
7 | 4708 p_sj = Rows / 2; |
4709 else | |
4710 { | |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25176
diff
changeset
|
4711 errmsg = e_invalid_scroll_size; |
7 | 4712 p_sj = 1; |
4713 } | |
4714 } | |
4715 if (p_so < 0 && full_screen) | |
4716 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4717 errmsg = e_argument_must_be_positive; |
7 | 4718 p_so = 0; |
4719 } | |
4720 if (p_siso < 0 && full_screen) | |
4721 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4722 errmsg = e_argument_must_be_positive; |
7 | 4723 p_siso = 0; |
4724 } | |
4725 if (p_cwh < 1) | |
4726 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4727 errmsg = e_argument_must_be_positive; |
7 | 4728 p_cwh = 1; |
4729 } | |
4730 if (p_ut < 0) | |
4731 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4732 errmsg = e_argument_must_be_positive; |
7 | 4733 p_ut = 2000; |
4734 } | |
4735 if (p_ss < 0) | |
4736 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4737 errmsg = e_argument_must_be_positive; |
7 | 4738 p_ss = 0; |
4739 } | |
4740 | |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4741 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4742 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4743 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4744 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4745 * Set the value of a number option, and take care of side effects. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4746 * Returns NULL for success, or an error message for an error. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4747 */ |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4748 static char * |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4749 set_num_option( |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4750 int opt_idx, // index in options[] table |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4751 char_u *varp, // pointer to the option variable |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4752 long value, // new value |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4753 char *errbuf, // buffer for error messages |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4754 size_t errbuflen, // length of "errbuf" |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4755 int opt_flags) // OPT_LOCAL, OPT_GLOBAL, |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4756 // OPT_MODELINE, etc. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4757 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4758 char *errmsg = NULL; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4759 long old_value = *(long *)varp; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4760 #if defined(FEAT_EVAL) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4761 long old_global_value = 0; // only used when setting a local and |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4762 // global option |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4763 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4764 long old_Rows = Rows; // remember old Rows |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4765 long old_Columns = Columns; // remember old Columns |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4766 long *pp = (long *)varp; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4767 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4768 // Disallow changing some options from secure mode. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4769 if ((secure |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4770 #ifdef HAVE_SANDBOX |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4771 || sandbox != 0 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4772 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4773 ) && (options[opt_idx].flags & P_SECURE)) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4774 return e_not_allowed_here; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4775 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4776 #if defined(FEAT_EVAL) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4777 // Save the global value before changing anything. This is needed as for |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4778 // a global-only option setting the "local value" in fact sets the global |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4779 // value (since there is only one value). |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4780 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4781 old_global_value = *(long *)get_varp_scope(&(options[opt_idx]), |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4782 OPT_GLOBAL); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4783 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4784 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4785 *pp = value; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4786 #ifdef FEAT_EVAL |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4787 // Remember where the option was set. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4788 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4789 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4790 #ifdef FEAT_GUI |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4791 need_mouse_correct = TRUE; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4792 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4793 |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4794 // Invoke the option specific callback function to validate and apply the |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4795 // new value. |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4796 if (options[opt_idx].opt_did_set_cb != NULL) |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4797 { |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4798 optset_T args; |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4799 |
32096
e7ab58f57ea3
patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents:
32076
diff
changeset
|
4800 CLEAR_FIELD(args); |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4801 args.os_varp = varp; |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4802 args.os_flags = opt_flags; |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4803 args.os_oldval.number = old_value; |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4804 args.os_newval.number = value; |
32043
6095218c9056
patch 9.0.1353: too many "else if" statements to handle option values
Bram Moolenaar <Bram@vim.org>
parents:
31996
diff
changeset
|
4805 args.os_errbuf = NULL; |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4806 errmsg = options[opt_idx].opt_did_set_cb(&args); |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4807 } |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4808 |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
4809 // Check the bounds for numeric options here |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4810 errmsg = check_num_option_bounds(pp, old_value, old_Rows, old_Columns, |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4811 errbuf, errbuflen, errmsg); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4812 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4813 // May set global value for local option. |
7 | 4814 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
4815 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; | |
4816 | |
4817 options[opt_idx].flags |= P_WAS_SET; | |
4818 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4819 #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
|
4820 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
|
4821 value, errmsg); |
6935 | 4822 #endif |
4823 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4824 comp_col(); // in case 'columns' or 'ls' changed |
3443 | 4825 if (curwin->w_curswant != MAXCOL |
6669 | 4826 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 4827 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
|
4828 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
|
4829 check_redraw(options[opt_idx].flags); |
7 | 4830 |
4831 return errmsg; | |
4832 } | |
4833 | |
4834 /* | |
4835 * Called after an option changed: check if something needs to be redrawn. | |
4836 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4837 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4838 check_redraw(long_u flags) |
7 | 4839 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4840 // Careful: P_RCLR and P_RALL are a combination of other P_ flags |
3263 | 4841 int doclear = (flags & P_RCLR) == P_RCLR; |
4842 int all = ((flags & P_RALL) == P_RALL || doclear); | |
7 | 4843 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4844 if ((flags & P_RSTAT) || all) // mark all status lines dirty |
7 | 4845 status_redraw_all(); |
4846 | |
4847 if ((flags & P_RBUF) || (flags & P_RWIN) || all) | |
4848 changed_window_setting(); | |
4849 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
|
4850 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
|
4851 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
|
4852 redraw_later(UPD_NOT_VALID); |
3263 | 4853 if (doclear) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
4854 redraw_all_later(UPD_CLEAR); |
7 | 4855 else if (all) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
4856 redraw_all_later(UPD_NOT_VALID); |
7 | 4857 } |
4858 | |
4859 /* | |
4860 * Find index for option 'arg'. | |
4861 * Return -1 if not found. | |
4862 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4863 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4864 findoption(char_u *arg) |
7 | 4865 { |
4866 int opt_idx; | |
4867 char *s, *p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4868 static short quick_tab[27] = {0, 0}; // quick access table |
7 | 4869 int is_term_opt; |
4870 | |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
4871 // For first call: Initialize the quick-access table. |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
4872 // It contains the index for the first option that starts with a certain |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
4873 // letter. There are 26 letters, plus the first "t_" option. |
7 | 4874 if (quick_tab[1] == 0) |
4875 { | |
4876 p = options[0].fullname; | |
4877 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
4878 { | |
4879 if (s[0] != p[0]) | |
4880 { | |
4881 if (s[0] == 't' && s[1] == '_') | |
4882 quick_tab[26] = opt_idx; | |
4883 else | |
4884 quick_tab[CharOrdLow(s[0])] = opt_idx; | |
4885 } | |
4886 p = s; | |
4887 } | |
4888 } | |
4889 | |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
4890 // Check for name starting with an illegal character. |
7 | 4891 if (arg[0] < 'a' || arg[0] > 'z') |
4892 return -1; | |
4893 | |
4894 is_term_opt = (arg[0] == 't' && arg[1] == '_'); | |
4895 if (is_term_opt) | |
4896 opt_idx = quick_tab[26]; | |
4897 else | |
4898 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
4899 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
4900 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4901 if (STRCMP(arg, s) == 0) // match full name |
7 | 4902 break; |
4903 } | |
4904 if (s == NULL && !is_term_opt) | |
4905 { | |
4906 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
4907 for ( ; options[opt_idx].fullname != NULL; opt_idx++) | |
4908 { | |
4909 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
|
4910 if (s != NULL && STRCMP(arg, s) == 0) // match short name |
7 | 4911 break; |
4912 s = NULL; | |
4913 } | |
4914 } | |
4915 if (s == NULL) | |
4916 opt_idx = -1; | |
4917 return opt_idx; | |
4918 } | |
4919 | |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
4920 #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
|
4921 || defined(FEAT_SPELL) || defined(PROTO) |
7 | 4922 /* |
4923 * Get the value for an option. | |
4924 * | |
4925 * Returns: | |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4926 * 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
|
4927 * 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
|
4928 * 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
|
4929 * 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
|
4930 * 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
|
4931 * 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
|
4932 * 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
|
4933 * |
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
|
4934 * "flagsp" (if not NULL) is set to the option flags (P_xxxx). |
7 | 4935 */ |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4936 getoption_T |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4937 get_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4938 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4939 long *numval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4940 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
|
4941 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
|
4942 int scope) |
7 | 4943 { |
4944 int opt_idx; | |
4945 char_u *varp; | |
4946 | |
4947 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
|
4948 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
|
4949 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4950 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4951 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4952 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
|
4953 && (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
|
4954 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4955 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
|
4956 char_u *p; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4957 |
26802
f6b10a501a0e
patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
4958 if (flagsp != NULL) |
f6b10a501a0e
patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
4959 *flagsp = 0; // terminal option has no flags |
f6b10a501a0e
patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
4960 |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4961 // 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
|
4962 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4963 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4964 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
|
4965 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
|
4966 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4967 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4968 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4969 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
|
4970 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
|
4971 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4972 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
|
4973 if (p != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4974 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4975 if (stringval != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4976 *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
|
4977 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
|
4978 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4979 } |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4980 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
|
4981 } |
7 | 4982 |
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
|
4983 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
|
4984 |
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
|
4985 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
|
4986 // 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
|
4987 *flagsp = options[opt_idx].flags; |
7 | 4988 |
4989 if (options[opt_idx].flags & P_STRING) | |
4990 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4991 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
|
4992 return gov_hidden_string; |
7 | 4993 if (stringval != NULL) |
4994 { | |
28804
12bbd8a31cac
patch 8.2.4926: #ifdef for crypt feature around too many lines
Bram Moolenaar <Bram@vim.org>
parents:
28800
diff
changeset
|
4995 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
|
4996 *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
|
4997 FALSE); |
7 | 4998 #ifdef FEAT_CRYPT |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4999 // 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
|
5000 else if ((char_u **)varp == &curbuf->b_p_key |
1622 | 5001 && **(char_u **)(varp) != NUL) |
7 | 5002 *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
|
5003 #endif |
7 | 5004 else |
5005 *stringval = vim_strsave(*(char_u **)(varp)); | |
5006 } | |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
5007 return gov_string; |
7 | 5008 } |
5009 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5010 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
|
5011 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
|
5012 ? gov_hidden_number : gov_hidden_bool; |
7 | 5013 if (options[opt_idx].flags & P_NUM) |
5014 *numval = *(long *)varp; | |
5015 else | |
5016 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5017 // 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
|
5018 // it set when 'ff' or 'fenc' changed. |
7 | 5019 if ((int *)varp == &curbuf->b_changed) |
5020 *numval = curbufIsChanged(); | |
5021 else | |
9395
beab399e3883
commit https://github.com/vim/vim/commit/2acfbed9dbea990f129535de7ff3df360365130b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
5022 *numval = (long) *(int *)varp; |
7 | 5023 } |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
5024 return (options[opt_idx].flags & P_NUM) ? gov_number : gov_bool; |
7 | 5025 } |
5026 #endif | |
5027 | |
5610 | 5028 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
4350 | 5029 /* |
5030 * Returns the option attributes and its value. Unlike the above function it | |
5031 * will return either global value or local value of the option depending on | |
5032 * what was requested, but it will never return global value if it was | |
5033 * requested to return local one and vice versa. Neither it will return | |
5034 * buffer-local value if it was requested to return window-local one. | |
5035 * | |
5036 * Pretends that option is absent if it is not present in the requested scope | |
5037 * (i.e. has no global, window-local or buffer-local value depending on | |
5038 * opt_type). Uses | |
5039 * | |
5040 * Returned flags: | |
5867 | 5041 * 0 hidden or unknown option, also option that does not have requested |
5042 * type (see SREQ_* in vim.h) | |
4350 | 5043 * see SOPT_* in vim.h for other flags |
5044 * | |
5045 * Possible opt_type values: see SREQ_* in vim.h | |
5046 */ | |
5047 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5048 get_option_value_strict( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5049 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5050 long *numval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5051 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
|
5052 int opt_type, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5053 void *from) |
4350 | 5054 { |
5055 int opt_idx; | |
4367 | 5056 char_u *varp = NULL; |
4350 | 5057 struct vimoption *p; |
5058 int r = 0; | |
5059 | |
5060 opt_idx = findoption(name); | |
5061 if (opt_idx < 0) | |
5062 return 0; | |
5063 | |
5064 p = &(options[opt_idx]); | |
5065 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5066 // Hidden option |
4350 | 5067 if (p->var == NULL) |
5068 return 0; | |
5069 | |
5070 if (p->flags & P_BOOL) | |
5071 r |= SOPT_BOOL; | |
5072 else if (p->flags & P_NUM) | |
5073 r |= SOPT_NUM; | |
5074 else if (p->flags & P_STRING) | |
5075 r |= SOPT_STRING; | |
5076 | |
5077 if (p->indir == PV_NONE) | |
5078 { | |
5079 if (opt_type == SREQ_GLOBAL) | |
5080 r |= SOPT_GLOBAL; | |
5081 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5082 return 0; // Did not request global-only option |
4350 | 5083 } |
5084 else | |
5085 { | |
5086 if (p->indir & PV_BOTH) | |
5087 r |= SOPT_GLOBAL; | |
5088 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
|
5089 return 0; // Requested global option |
4350 | 5090 |
5091 if (p->indir & PV_WIN) | |
5092 { | |
5093 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
|
5094 return 0; // Did not request window-local option |
4350 | 5095 else |
5096 r |= SOPT_WIN; | |
5097 } | |
5098 else if (p->indir & PV_BUF) | |
5099 { | |
5100 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
|
5101 return 0; // Did not request buffer-local option |
4350 | 5102 else |
5103 r |= SOPT_BUF; | |
5104 } | |
5105 } | |
5106 | |
5107 if (stringval == NULL) | |
5108 return r; | |
5109 | |
5110 if (opt_type == SREQ_GLOBAL) | |
5111 varp = p->var; | |
5112 else | |
5113 { | |
5114 if (opt_type == SREQ_BUF) | |
5115 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5116 // 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
|
5117 // consider it set when 'ff' or 'fenc' changed. |
4350 | 5118 if (p->indir == PV_MOD) |
5119 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
5120 *numval = bufIsChanged((buf_T *)from); |
4350 | 5121 varp = NULL; |
5122 } | |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5123 # ifdef FEAT_CRYPT |
4350 | 5124 else if (p->indir == PV_KEY) |
5125 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5126 // never return the value of the crypt key |
4350 | 5127 *stringval = NULL; |
5128 varp = NULL; | |
5129 } | |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5130 # endif |
4350 | 5131 else |
5132 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
5133 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
|
5134 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
5135 // 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
|
5136 curbuf = (buf_T *)from; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
5137 curwin->w_buffer = curbuf; |
4350 | 5138 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
|
5139 curbuf = save_curbuf; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
5140 curwin->w_buffer = curbuf; |
4350 | 5141 } |
5142 } | |
5143 else if (opt_type == SREQ_WIN) | |
5144 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
5145 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
|
5146 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
5147 curwin = (win_T *)from; |
4350 | 5148 curbuf = curwin->w_buffer; |
5149 varp = get_varp(p); | |
5150 curwin = save_curwin; | |
5151 curbuf = curwin->w_buffer; | |
5152 } | |
5153 if (varp == p->var) | |
5154 return (r | SOPT_UNSET); | |
5155 } | |
5156 | |
5157 if (varp != NULL) | |
5158 { | |
5159 if (p->flags & P_STRING) | |
5160 *stringval = vim_strsave(*(char_u **)(varp)); | |
5161 else if (p->flags & P_NUM) | |
5162 *numval = *(long *) varp; | |
5163 else | |
5164 *numval = *(int *)varp; | |
5165 } | |
5166 | |
5167 return r; | |
5168 } | |
5610 | 5169 |
5170 /* | |
6243 | 5171 * Iterate over options. First argument is a pointer to a pointer to a |
5172 * structure inside options[] array, second is option type like in the above | |
5173 * function. | |
5610 | 5174 * |
6243 | 5175 * If first argument points to NULL it is assumed that iteration just started |
5610 | 5176 * and caller needs the very first value. |
6243 | 5177 * If first argument points to the end marker function returns NULL and sets |
5610 | 5178 * first argument to NULL. |
5179 * | |
5180 * Returns full option name for current option on each call. | |
5181 */ | |
5182 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5183 option_iter_next(void **option, int opt_type) |
5610 | 5184 { |
5185 struct vimoption *ret = NULL; | |
5186 do | |
5187 { | |
5188 if (*option == NULL) | |
5189 *option = (void *) options; | |
5190 else if (((struct vimoption *) (*option))->fullname == NULL) | |
5191 { | |
5192 *option = NULL; | |
5193 return NULL; | |
5194 } | |
5195 else | |
5196 *option = (void *) (((struct vimoption *) (*option)) + 1); | |
5197 | |
5198 ret = ((struct vimoption *) (*option)); | |
5199 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5200 // Hidden option |
5610 | 5201 if (ret->var == NULL) |
5202 { | |
5203 ret = NULL; | |
5204 continue; | |
5205 } | |
5206 | |
5207 switch (opt_type) | |
5208 { | |
5209 case SREQ_GLOBAL: | |
5210 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH)) | |
5211 ret = NULL; | |
5212 break; | |
5213 case SREQ_BUF: | |
5214 if (!(ret->indir & PV_BUF)) | |
5215 ret = NULL; | |
5216 break; | |
5217 case SREQ_WIN: | |
5218 if (!(ret->indir & PV_WIN)) | |
5219 ret = NULL; | |
5220 break; | |
5221 default: | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
5222 internal_error("option_iter_next()"); |
5610 | 5223 return NULL; |
5224 } | |
5225 } | |
5226 while (ret == NULL); | |
5227 | |
5228 return (char_u *)ret->fullname; | |
5229 } | |
4350 | 5230 #endif |
5231 | |
7 | 5232 /* |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5233 * 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
|
5234 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5235 long_u |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5236 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
|
5237 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5238 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
|
5239 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5240 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5241 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5242 * 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
|
5243 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5244 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5245 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
|
5246 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5247 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
|
5248 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5249 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5250 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5251 * 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
|
5252 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5253 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5254 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
|
5255 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5256 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
|
5257 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5258 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5259 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5260 * 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
|
5261 * local value. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5262 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5263 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5264 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
|
5265 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5266 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
|
5267 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5268 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5269 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5270 * 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
|
5271 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5272 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5273 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
|
5274 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5275 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
|
5276 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5277 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5278 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5279 * 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
|
5280 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5281 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5282 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
|
5283 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5284 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
|
5285 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5286 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5287 #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
|
5288 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5289 * 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
|
5290 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5291 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5292 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
|
5293 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5294 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
|
5295 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5296 #endif |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5297 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5298 /* |
7 | 5299 * Set the value of option "name". |
5300 * 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
|
5301 * |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5302 * 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
|
5303 */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
5304 char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5305 set_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5306 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5307 long number, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5308 char_u *string, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5309 int opt_flags) // OPT_LOCAL or 0 (both) |
7 | 5310 { |
5311 int opt_idx; | |
5312 char_u *varp; | |
835 | 5313 long_u flags; |
31950
b0717fcca5eb
patch 9.0.1307: setting 'formatoptions' with :let doesn't check for errors
Bram Moolenaar <Bram@vim.org>
parents:
31926
diff
changeset
|
5314 static char errbuf[80]; |
7 | 5315 |
5316 opt_idx = findoption(name); | |
838 | 5317 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
|
5318 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5319 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5320 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5321 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
|
5322 && (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
|
5323 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5324 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
|
5325 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5326 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5327 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5328 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
|
5329 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
|
5330 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5331 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5332 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5333 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
|
5334 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
|
5335 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5336 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
|
5337 if (full_screen) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5338 ttest(FALSE); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
5339 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
|
5340 return NULL; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5341 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5342 |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
5343 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
|
5344 } |
7 | 5345 else |
5346 { | |
5347 flags = options[opt_idx].flags; | |
5348 #ifdef HAVE_SANDBOX | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5349 // Disallow changing some options in the sandbox |
7 | 5350 if (sandbox > 0 && (flags & P_SECURE)) |
634 | 5351 { |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25176
diff
changeset
|
5352 emsg(_(e_not_allowed_in_sandbox)); |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
5353 return NULL; |
634 | 5354 } |
5355 #endif | |
5356 if (flags & P_STRING) | |
31950
b0717fcca5eb
patch 9.0.1307: setting 'formatoptions' with :let doesn't check for errors
Bram Moolenaar <Bram@vim.org>
parents:
31926
diff
changeset
|
5357 return set_string_option(opt_idx, string, opt_flags, errbuf); |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5358 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5359 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
|
5360 if (varp != NULL) // hidden option is not changed |
7 | 5361 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5362 if (number == 0 && string != NULL) |
7 | 5363 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5364 int idx; |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5365 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5366 // 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
|
5367 // to zero. |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5368 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
|
5369 ; |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5370 if (string[idx] != NUL || idx == 0) |
1298 | 5371 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5372 // 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
|
5373 // 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
|
5374 // 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
|
5375 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
|
5376 name, string); |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5377 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
|
5378 |
1298 | 5379 } |
7 | 5380 } |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5381 if (flags & P_NUM) |
31950
b0717fcca5eb
patch 9.0.1307: setting 'formatoptions' with :let doesn't check for errors
Bram Moolenaar <Bram@vim.org>
parents:
31926
diff
changeset
|
5382 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5383 return set_num_option(opt_idx, varp, number, |
31950
b0717fcca5eb
patch 9.0.1307: setting 'formatoptions' with :let doesn't check for errors
Bram Moolenaar <Bram@vim.org>
parents:
31926
diff
changeset
|
5384 errbuf, sizeof(errbuf), opt_flags); |
b0717fcca5eb
patch 9.0.1307: setting 'formatoptions' with :let doesn't check for errors
Bram Moolenaar <Bram@vim.org>
parents:
31926
diff
changeset
|
5385 } |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5386 else |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5387 return set_bool_option(opt_idx, varp, (int)number, opt_flags); |
7 | 5388 } |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5389 |
7 | 5390 } |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
5391 return NULL; |
7 | 5392 } |
5393 | |
5394 /* | |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5395 * 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
|
5396 */ |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5397 void |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5398 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
|
5399 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
|
5400 long number, |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5401 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
|
5402 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
|
5403 { |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5404 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
|
5405 |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5406 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
|
5407 emsg(_(errmsg)); |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5408 } |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5409 |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5410 /* |
7 | 5411 * Get the terminal code for a terminal option. |
5412 * Returns NULL when not found. | |
5413 */ | |
5414 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5415 get_term_code(char_u *tname) |
7 | 5416 { |
5417 int opt_idx; | |
5418 char_u *varp; | |
5419 | |
5420 if (tname[0] != 't' || tname[1] != '_' || | |
5421 tname[2] == NUL || tname[3] == NUL) | |
5422 return NULL; | |
5423 if ((opt_idx = findoption(tname)) >= 0) | |
5424 { | |
5425 varp = get_varp(&(options[opt_idx])); | |
5426 if (varp != NULL) | |
5427 varp = *(char_u **)(varp); | |
5428 return varp; | |
5429 } | |
5430 return find_termcode(tname + 2); | |
5431 } | |
5432 | |
5433 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5434 get_highlight_default(void) |
7 | 5435 { |
5436 int i; | |
5437 | |
5438 i = findoption((char_u *)"hl"); | |
5439 if (i >= 0) | |
5440 return options[i].def_val[VI_DEFAULT]; | |
5441 return (char_u *)NULL; | |
5442 } | |
5443 | |
39 | 5444 char_u * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5445 get_encoding_default(void) |
39 | 5446 { |
5447 int i; | |
5448 | |
5449 i = findoption((char_u *)"enc"); | |
5450 if (i >= 0) | |
5451 return options[i].def_val[VI_DEFAULT]; | |
5452 return (char_u *)NULL; | |
5453 } | |
5454 | |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
5455 #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
|
5456 int |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
5457 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
|
5458 { |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
5459 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
|
5460 |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
5461 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
|
5462 } |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
5463 #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
|
5464 |
29497
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5465 #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
|
5466 /* |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5467 * 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
|
5468 * 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
|
5469 */ |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5470 int |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5471 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
|
5472 { |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5473 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
|
5474 |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5475 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
|
5476 } |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5477 #endif |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5478 |
7 | 5479 /* |
5480 * 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
|
5481 * 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
|
5482 * Returns 0 when the key is not recognized. |
7 | 5483 */ |
5484 static int | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
5485 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
|
5486 { |
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
5487 int key = 0; |
7 | 5488 int modifiers; |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
5489 char_u *arg = arg_arg; |
7 | 5490 |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
5491 // Don't use get_special_key_code() for t_xx, we don't want it to call |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
5492 // add_termcap_entry(). |
7 | 5493 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) |
5494 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
|
5495 else if (has_lt) |
7 | 5496 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5497 --arg; // put arg at the '<' |
7 | 5498 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
|
5499 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
|
5500 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
|
5501 if (modifiers) // can't handle modifiers here |
7 | 5502 key = 0; |
5503 } | |
5504 return key; | |
5505 } | |
5506 | |
5507 /* | |
5508 * if 'all' == 0: show changed options | |
5509 * if 'all' == 1: show all normal options | |
5510 * if 'all' == 2: show all terminal options | |
5511 */ | |
5512 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5513 showoptions( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5514 int all, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5515 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 5516 { |
5517 struct vimoption *p; | |
5518 int col; | |
5519 int isterm; | |
5520 char_u *varp; | |
5521 struct vimoption **items; | |
5522 int item_count; | |
5523 int run; | |
5524 int row, rows; | |
5525 int cols; | |
5526 int i; | |
5527 int len; | |
5528 | |
5529 #define INC 20 | |
5530 #define GAP 3 | |
5531 | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5532 items = ALLOC_MULT(struct vimoption *, OPTION_COUNT); |
7 | 5533 if (items == NULL) |
5534 return; | |
5535 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5536 // Highlight title |
7 | 5537 if (all == 2) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
5538 msg_puts_title(_("\n--- Terminal codes ---")); |
7 | 5539 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
|
5540 msg_puts_title(_("\n--- Global option values ---")); |
7 | 5541 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
|
5542 msg_puts_title(_("\n--- Local option values ---")); |
7 | 5543 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
5544 msg_puts_title(_("\n--- Options ---")); |
7 | 5545 |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
5546 // Do the loop two times: |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
5547 // 1. display the short items |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
5548 // 2. display the long items (only strings and numbers) |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
5549 // When "opt_flags" has OPT_ONECOLUMN do everything in run 2. |
7 | 5550 for (run = 1; run <= 2 && !got_int; ++run) |
5551 { | |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
5552 // collect the items in items[] |
7 | 5553 item_count = 0; |
5554 for (p = &options[0]; p->fullname != NULL; p++) | |
5555 { | |
14968
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
5556 // apply :filter /pat/ |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5557 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
|
5558 continue; |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
5559 |
7 | 5560 varp = NULL; |
5561 isterm = istermoption(p); | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5562 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) != 0) |
7 | 5563 { |
5564 if (p->indir != PV_NONE && !isterm) | |
5565 varp = get_varp_scope(p, opt_flags); | |
5566 } | |
5567 else | |
5568 varp = get_varp(p); | |
5569 if (varp != NULL | |
5570 && ((all == 2 && isterm) | |
5571 || (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
|
5572 || (all == 0 && !optval_default(p, varp, p_cp)))) |
7 | 5573 { |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5574 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
|
5575 len = Columns; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5576 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
|
5577 len = 1; // a toggle option fits always |
7 | 5578 else |
5579 { | |
5580 option_value2string(p, opt_flags); | |
5581 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; | |
5582 } | |
5583 if ((len <= INC - GAP && run == 1) || | |
5584 (len > INC - GAP && run == 2)) | |
5585 items[item_count++] = p; | |
5586 } | |
5587 } | |
5588 | |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
5589 // display the items |
7 | 5590 if (run == 1) |
5591 { | |
5592 cols = (Columns + GAP - 3) / INC; | |
5593 if (cols == 0) | |
5594 cols = 1; | |
5595 rows = (item_count + cols - 1) / cols; | |
5596 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5597 else // run == 2 |
7 | 5598 rows = item_count; |
5599 for (row = 0; row < rows && !got_int; ++row) | |
5600 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5601 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
|
5602 if (got_int) // 'q' typed in more |
7 | 5603 break; |
5604 col = 0; | |
5605 for (i = row; i < item_count; i += rows) | |
5606 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5607 msg_col = col; // make columns |
7 | 5608 showoneopt(items[i], opt_flags); |
5609 col += INC; | |
5610 } | |
5611 out_flush(); | |
5612 ui_breakcheck(); | |
5613 } | |
5614 } | |
5615 vim_free(items); | |
5616 } | |
5617 | |
5618 /* | |
5619 * Return TRUE if option "p" has its default value. | |
5620 */ | |
5621 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
|
5622 optval_default(struct vimoption *p, char_u *varp, int compatible) |
7 | 5623 { |
5624 int dvi; | |
5625 | |
5626 if (varp == NULL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5627 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
|
5628 dvi = ((p->flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; |
7 | 5629 if (p->flags & P_NUM) |
840 | 5630 return (*(long *)varp == (long)(long_i)p->def_val[dvi]); |
7 | 5631 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
|
5632 // 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
|
5633 // needed for MSVC |
840 | 5634 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
|
5635 // P_STRING |
7 | 5636 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); |
5637 } | |
5638 | |
5639 /* | |
5640 * showoneopt: show the value of one option | |
5641 * must not be called with a hidden option! | |
5642 */ | |
5643 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5644 showoneopt( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5645 struct vimoption *p, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5646 int opt_flags) // OPT_LOCAL or OPT_GLOBAL |
7 | 5647 { |
168 | 5648 char_u *varp; |
5649 int save_silent = silent_mode; | |
5650 | |
5651 silent_mode = FALSE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5652 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
7 | 5653 |
5654 varp = get_varp_scope(p, opt_flags); | |
5655 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5656 // for 'modified' we also need to check if 'ff' or 'fenc' changed. |
7 | 5657 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed |
5658 ? !curbufIsChanged() : !*(int *)varp)) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
5659 msg_puts("no"); |
7 | 5660 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
|
5661 msg_puts("--"); |
7 | 5662 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
5663 msg_puts(" "); |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
5664 msg_puts(p->fullname); |
7 | 5665 if (!(p->flags & P_BOOL)) |
5666 { | |
5667 msg_putchar('='); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5668 // put value string in NameBuff |
7 | 5669 option_value2string(p, opt_flags); |
5670 msg_outtrans(NameBuff); | |
5671 } | |
168 | 5672 |
5673 silent_mode = save_silent; | |
5674 info_message = FALSE; | |
7 | 5675 } |
5676 | |
5677 /* | |
5678 * Write modified options as ":set" commands to a file. | |
5679 * | |
5680 * There are three values for "opt_flags": | |
5681 * OPT_GLOBAL: Write global option values and fresh values of | |
5682 * buffer-local options (used for start of a session | |
5683 * file). | |
5684 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for | |
5685 * curwin (used for a vimrc file). | |
5686 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh | |
5687 * and local values for window-local options of | |
5688 * curwin. Local values are also written when at the | |
5689 * default value, because a modeline or autocommand | |
5690 * may have set them when doing ":edit file" and the | |
5691 * user has set them back at the default or fresh | |
5692 * value. | |
5693 * When "local_only" is TRUE, don't write fresh | |
5694 * values, only local values (for ":mkview"). | |
5695 * (fresh value = value used for a new buffer or window for a local option). | |
5696 * | |
5697 * Return FAIL on error, OK otherwise. | |
5698 */ | |
5699 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5700 makeset(FILE *fd, int opt_flags, int local_only) |
7 | 5701 { |
5702 struct vimoption *p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5703 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
|
5704 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
|
5705 char_u *varp_local = NULL; // fresh value |
7 | 5706 char *cmd; |
5707 int round; | |
1384 | 5708 int pri; |
7 | 5709 |
5710 /* | |
5711 * The options that don't have a default (terminal name, columns, lines) | |
5712 * are never written. Terminal options are also not written. | |
1384 | 5713 * Do the loop over "options[]" twice: once for options with the |
5714 * P_PRI_MKRC flag and once without. | |
7 | 5715 */ |
1384 | 5716 for (pri = 1; pri >= 0; --pri) |
5717 { | |
5718 for (p = &options[0]; !istermoption(p); p++) | |
5719 if (!(p->flags & P_NO_MKRC) | |
5720 && !istermoption(p) | |
5721 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) | |
7 | 5722 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5723 // skip global option when only doing locals |
7 | 5724 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) |
5725 continue; | |
5726 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5727 // 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
|
5728 // file, they are always buffer-specific. |
7 | 5729 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) |
5730 continue; | |
5731 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5732 // Global values are only written when not at the default value. |
7 | 5733 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
|
5734 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp, p_cp)) |
7 | 5735 continue; |
5736 | |
24476
e79d1475fc89
patch 8.2.2778: problem restoring 'packpath' in session
Bram Moolenaar <Bram@vim.org>
parents:
24464
diff
changeset
|
5737 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
|
5738 || 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
|
5739 continue; |
a56f9c2ba51c
patch 8.2.2772: problems when restoring 'runtimepath' from a session file
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
5740 |
7 | 5741 round = 2; |
5742 if (p->indir != PV_NONE) | |
5743 { | |
5744 if (p->var == VAR_WIN) | |
5745 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5746 // skip window-local option when only doing globals |
7 | 5747 if (!(opt_flags & OPT_LOCAL)) |
5748 continue; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5749 // 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
|
5750 // default, need to write it too. |
7 | 5751 if (!(opt_flags & OPT_GLOBAL) && !local_only) |
5752 { | |
5753 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
|
5754 if (!optval_default(p, varp_fresh, p_cp)) |
7 | 5755 { |
5756 round = 1; | |
5757 varp_local = varp; | |
5758 varp = varp_fresh; | |
5759 } | |
5760 } | |
5761 } | |
5762 } | |
5763 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5764 // 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
|
5765 // Round 2: other values |
7 | 5766 for ( ; round <= 2; varp = varp_local, ++round) |
5767 { | |
5768 if (round == 1 || (opt_flags & OPT_GLOBAL)) | |
5769 cmd = "set"; | |
5770 else | |
5771 cmd = "setlocal"; | |
5772 | |
5773 if (p->flags & P_BOOL) | |
5774 { | |
5775 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) | |
5776 return FAIL; | |
5777 } | |
5778 else if (p->flags & P_NUM) | |
5779 { | |
5780 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) | |
5781 return FAIL; | |
5782 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5783 else // P_STRING |
7 | 5784 { |
694 | 5785 int do_endif = FALSE; |
5786 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5787 // 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
|
5788 // already right, avoids reloading the syntax file. |
694 | 5789 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
5790 #if defined(FEAT_SYN_HL) |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
5791 p->indir == PV_SYN || |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
5792 #endif |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
5793 p->indir == PV_FT) |
7 | 5794 { |
5795 if (fprintf(fd, "if &%s != '%s'", p->fullname, | |
5796 *(char_u **)(varp)) < 0 | |
5797 || put_eol(fd) < 0) | |
5798 return FAIL; | |
694 | 5799 do_endif = TRUE; |
7 | 5800 } |
5801 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
|
5802 p->flags) == FAIL) |
7 | 5803 return FAIL; |
694 | 5804 if (do_endif) |
7 | 5805 { |
5806 if (put_line(fd, "endif") == FAIL) | |
5807 return FAIL; | |
5808 } | |
5809 } | |
5810 } | |
5811 } | |
1384 | 5812 } |
7 | 5813 return OK; |
5814 } | |
5815 | |
5816 #if defined(FEAT_FOLDING) || defined(PROTO) | |
5817 /* | |
5818 * Generate set commands for the local fold options only. Used when | |
5819 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options". | |
5820 */ | |
5821 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5822 makefoldset(FILE *fd) |
7 | 5823 { |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5824 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, 0) == FAIL |
7 | 5825 # 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
|
5826 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, 0) |
7 | 5827 == FAIL |
5828 # endif | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5829 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, 0) |
7 | 5830 == FAIL |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5831 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, 0) |
7 | 5832 == FAIL |
5833 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL | |
5834 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL | |
5835 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL | |
5836 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL | |
5837 ) | |
5838 return FAIL; | |
5839 | |
5840 return OK; | |
5841 } | |
5842 #endif | |
5843 | |
5844 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5845 put_setstring( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5846 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5847 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5848 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5849 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
|
5850 long_u flags) |
7 | 5851 { |
5852 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
|
5853 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
|
5854 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
|
5855 char_u *p; |
7 | 5856 |
5857 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
5858 return FAIL; | |
5859 if (*valuep != NULL) | |
5860 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5861 // 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
|
5862 // 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
|
5863 // CTRL-V or backslash |
7 | 5864 if (valuep == &p_pt) |
5865 { | |
5866 s = *valuep; | |
5867 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
|
5868 if (put_escstr(fd, str2special(&s, FALSE, FALSE), 2) == FAIL) |
7 | 5869 return FAIL; |
5870 } | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5871 // 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
|
5872 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
|
5873 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5874 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
|
5875 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5876 // 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
|
5877 buf = alloc(size); |
2780 | 5878 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
|
5879 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5880 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
|
5881 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5882 // 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
|
5883 // 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
|
5884 // 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
|
5885 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
|
5886 && 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
|
5887 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5888 part = alloc(size); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5889 if (part == NULL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5890 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5891 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5892 // 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
|
5893 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
|
5894 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5895 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5896 p = buf; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5897 while (*p != NUL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5898 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5899 // 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
|
5900 // 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
|
5901 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
|
5902 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5903 (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
|
5904 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
|
5905 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5906 } |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5907 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5908 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5909 return OK; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5910 } |
7 | 5911 if (put_escstr(fd, buf, 2) == FAIL) |
2780 | 5912 { |
5913 vim_free(buf); | |
7 | 5914 return FAIL; |
2780 | 5915 } |
5916 vim_free(buf); | |
7 | 5917 } |
5918 else if (put_escstr(fd, *valuep, 2) == FAIL) | |
5919 return FAIL; | |
5920 } | |
5921 if (put_eol(fd) < 0) | |
5922 return FAIL; | |
5923 return OK; | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5924 fail: |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5925 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5926 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5927 return FAIL; |
7 | 5928 } |
5929 | |
5930 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5931 put_setnum( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5932 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5933 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5934 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5935 long *valuep) |
7 | 5936 { |
5937 long wc; | |
5938 | |
5939 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
5940 return FAIL; | |
5941 if (wc_use_keyname((char_u *)valuep, &wc)) | |
5942 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5943 // print 'wildchar' and 'wildcharm' as a key name |
7 | 5944 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) |
5945 return FAIL; | |
5946 } | |
5947 else if (fprintf(fd, "%ld", *valuep) < 0) | |
5948 return FAIL; | |
5949 if (put_eol(fd) < 0) | |
5950 return FAIL; | |
5951 return OK; | |
5952 } | |
5953 | |
5954 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5955 put_setbool( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5956 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5957 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5958 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5959 int value) |
7 | 5960 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5961 if (value < 0) // global/local option using global value |
1416 | 5962 return OK; |
7 | 5963 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 |
5964 || put_eol(fd) < 0) | |
5965 return FAIL; | |
5966 return OK; | |
5967 } | |
5968 | |
5969 /* | |
5970 * Clear all the terminal options. | |
5971 * If the option has been allocated, free the memory. | |
5972 * Terminal options are never hidden or indirect. | |
5973 */ | |
5974 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5975 clear_termoptions(void) |
7 | 5976 { |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
5977 // Reset a few things before clearing the old options. This may cause |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
5978 // outputting a few things that the terminal doesn't understand, but the |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
5979 // screen will be cleared later, so this is OK. |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
5980 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
|
5981 mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles |
7 | 5982 #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
|
5983 // 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
|
5984 // After restoring the title, because that will need the display. |
7 | 5985 if (gui.starting) |
5986 clear_xterm_clip(); | |
5987 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5988 stoptermcap(); // stop termcap mode |
7 | 5989 |
359 | 5990 free_termoptions(); |
5991 } | |
5992 | |
5993 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5994 free_termoptions(void) |
359 | 5995 { |
5996 struct vimoption *p; | |
5997 | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
5998 for (p = options; p->fullname != NULL; p++) |
7 | 5999 if (istermoption(p)) |
6000 { | |
6001 if (p->flags & P_ALLOCED) | |
6002 free_string_option(*(char_u **)(p->var)); | |
6003 if (p->flags & P_DEF_ALLOCED) | |
6004 free_string_option(p->def_val[VI_DEFAULT]); | |
6005 *(char_u **)(p->var) = empty_option; | |
6006 p->def_val[VI_DEFAULT] = empty_option; | |
6007 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
|
6008 #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
|
6009 // 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
|
6010 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
|
6011 #endif |
7 | 6012 } |
6013 clear_termcodes(); | |
6014 } | |
6015 | |
6016 /* | |
1941 | 6017 * Free the string for one term option, if it was allocated. |
6018 * Set the string to empty_option and clear allocated flag. | |
6019 * "var" points to the option value. | |
6020 */ | |
6021 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6022 free_one_termoption(char_u *var) |
1941 | 6023 { |
6024 struct vimoption *p; | |
6025 | |
6026 for (p = &options[0]; p->fullname != NULL; p++) | |
6027 if (p->var == var) | |
6028 { | |
6029 if (p->flags & P_ALLOCED) | |
6030 free_string_option(*(char_u **)(p->var)); | |
6031 *(char_u **)(p->var) = empty_option; | |
6032 p->flags &= ~P_ALLOCED; | |
6033 break; | |
6034 } | |
6035 } | |
6036 | |
6037 /* | |
7 | 6038 * Set the terminal option defaults to the current value. |
6039 * Used after setting the terminal name. | |
6040 */ | |
6041 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6042 set_term_defaults(void) |
7 | 6043 { |
6044 struct vimoption *p; | |
6045 | |
6046 for (p = &options[0]; p->fullname != NULL; p++) | |
6047 { | |
6048 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) | |
6049 { | |
6050 if (p->flags & P_DEF_ALLOCED) | |
6051 { | |
6052 free_string_option(p->def_val[VI_DEFAULT]); | |
6053 p->flags &= ~P_DEF_ALLOCED; | |
6054 } | |
6055 p->def_val[VI_DEFAULT] = *(char_u **)(p->var); | |
6056 if (p->flags & P_ALLOCED) | |
6057 { | |
6058 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
|
6059 p->flags &= ~P_ALLOCED; // don't free the value now |
7 | 6060 } |
6061 } | |
6062 } | |
6063 } | |
6064 | |
6065 /* | |
6066 * return TRUE if 'p' starts with 't_' | |
6067 */ | |
6068 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6069 istermoption(struct vimoption *p) |
7 | 6070 { |
6071 return (p->fullname[0] == 't' && p->fullname[1] == '_'); | |
6072 } | |
6073 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6074 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6075 * 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
|
6076 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6077 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6078 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
|
6079 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6080 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
|
6081 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6082 |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
6083 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
7 | 6084 /* |
4350 | 6085 * Unset local option value, similar to ":set opt<". |
6086 */ | |
6087 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6088 unset_global_local_option(char_u *name, void *from) |
4350 | 6089 { |
6090 struct vimoption *p; | |
6091 int opt_idx; | |
4361 | 6092 buf_T *buf = (buf_T *)from; |
4350 | 6093 |
6094 opt_idx = findoption(name); | |
7007 | 6095 if (opt_idx < 0) |
6096 return; | |
4350 | 6097 p = &(options[opt_idx]); |
6098 | |
6099 switch ((int)p->indir) | |
6100 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6101 // global option with local value: use local value if it's been set |
4350 | 6102 case PV_EP: |
4361 | 6103 clear_string_option(&buf->b_p_ep); |
4350 | 6104 break; |
6105 case PV_KP: | |
4361 | 6106 clear_string_option(&buf->b_p_kp); |
4350 | 6107 break; |
6108 case PV_PATH: | |
4361 | 6109 clear_string_option(&buf->b_p_path); |
4350 | 6110 break; |
6111 case PV_AR: | |
6112 buf->b_p_ar = -1; | |
6113 break; | |
6243 | 6114 case PV_BKC: |
6115 clear_string_option(&buf->b_p_bkc); | |
6116 buf->b_bkc_flags = 0; | |
6117 break; | |
4350 | 6118 case PV_TAGS: |
4361 | 6119 clear_string_option(&buf->b_p_tags); |
4350 | 6120 break; |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
6121 case PV_TC: |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
6122 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
|
6123 buf->b_tc_flags = 0; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
6124 break; |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
6125 case PV_SISO: |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
6126 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
|
6127 break; |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
6128 case PV_SO: |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
6129 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
|
6130 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6131 # ifdef FEAT_FIND_ID |
4350 | 6132 case PV_DEF: |
4361 | 6133 clear_string_option(&buf->b_p_def); |
4350 | 6134 break; |
6135 case PV_INC: | |
4361 | 6136 clear_string_option(&buf->b_p_inc); |
4350 | 6137 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6138 # endif |
4350 | 6139 case PV_DICT: |
4361 | 6140 clear_string_option(&buf->b_p_dict); |
4350 | 6141 break; |
6142 case PV_TSR: | |
4361 | 6143 clear_string_option(&buf->b_p_tsr); |
4350 | 6144 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6145 # 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
|
6146 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
|
6147 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
|
6148 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6149 # endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
6150 case PV_FP: |
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
6151 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
|
6152 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6153 # ifdef FEAT_QUICKFIX |
4350 | 6154 case PV_EFM: |
4361 | 6155 clear_string_option(&buf->b_p_efm); |
4350 | 6156 break; |
6157 case PV_GP: | |
4361 | 6158 clear_string_option(&buf->b_p_gp); |
4350 | 6159 break; |
6160 case PV_MP: | |
4361 | 6161 clear_string_option(&buf->b_p_mp); |
4350 | 6162 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6163 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6164 # if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
4350 | 6165 case PV_BEXPR: |
4361 | 6166 clear_string_option(&buf->b_p_bexpr); |
4350 | 6167 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6168 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6169 # if defined(FEAT_CRYPT) |
4350 | 6170 case PV_CM: |
4361 | 6171 clear_string_option(&buf->b_p_cm); |
4350 | 6172 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6173 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6174 # 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
|
6175 case PV_SBR: |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6176 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
|
6177 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6178 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6179 # ifdef FEAT_STL_OPT |
4350 | 6180 case PV_STL: |
4361 | 6181 clear_string_option(&((win_T *)from)->w_p_stl); |
4350 | 6182 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6183 # endif |
5446 | 6184 case PV_UL: |
6185 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; | |
6186 break; | |
5712 | 6187 case PV_LW: |
6188 clear_string_option(&buf->b_p_lw); | |
6189 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
|
6190 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
|
6191 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
|
6192 break; |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
6193 case PV_LCS: |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
6194 clear_string_option(&((win_T *)from)->w_p_lcs); |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
6195 set_listchars_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
|
6196 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
|
6197 break; |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6198 case PV_FCS: |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6199 clear_string_option(&((win_T *)from)->w_p_fcs); |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
6200 set_fillchars_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
|
6201 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
|
6202 break; |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
6203 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
|
6204 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
|
6205 ((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
|
6206 break; |
4350 | 6207 } |
6208 } | |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
6209 #endif |
4350 | 6210 |
6211 /* | |
7 | 6212 * 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
|
6213 * "scope" can be OPT_LOCAL, OPT_GLOBAL or a combination. |
7 | 6214 */ |
6215 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
|
6216 get_varp_scope(struct vimoption *p, int scope) |
7 | 6217 { |
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
|
6218 if ((scope & OPT_GLOBAL) && p->indir != PV_NONE) |
7 | 6219 { |
6220 if (p->var == VAR_WIN) | |
6221 return (char_u *)GLOBAL_WO(get_varp(p)); | |
6222 return p->var; | |
6223 } | |
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
|
6224 if ((scope & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) |
7 | 6225 { |
6226 switch ((int)p->indir) | |
6227 { | |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
6228 case PV_FP: return (char_u *)&(curbuf->b_p_fp); |
7 | 6229 #ifdef FEAT_QUICKFIX |
694 | 6230 case PV_EFM: return (char_u *)&(curbuf->b_p_efm); |
6231 case PV_GP: return (char_u *)&(curbuf->b_p_gp); | |
6232 case PV_MP: return (char_u *)&(curbuf->b_p_mp); | |
6233 #endif | |
6234 case PV_EP: return (char_u *)&(curbuf->b_p_ep); | |
6235 case PV_KP: return (char_u *)&(curbuf->b_p_kp); | |
6236 case PV_PATH: return (char_u *)&(curbuf->b_p_path); | |
692 | 6237 case PV_AR: return (char_u *)&(curbuf->b_p_ar); |
694 | 6238 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
|
6239 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
|
6240 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
|
6241 case PV_SO: return (char_u *)&(curwin->w_p_so); |
7 | 6242 #ifdef FEAT_FIND_ID |
694 | 6243 case PV_DEF: return (char_u *)&(curbuf->b_p_def); |
6244 case PV_INC: return (char_u *)&(curbuf->b_p_inc); | |
7 | 6245 #endif |
694 | 6246 case PV_DICT: return (char_u *)&(curbuf->b_p_dict); |
6247 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
|
6248 #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
|
6249 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
|
6250 #endif |
790 | 6251 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
6252 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr); | |
6253 #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
|
6254 #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
|
6255 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
|
6256 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6257 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6258 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
|
6259 #endif |
40 | 6260 #ifdef FEAT_STL_OPT |
694 | 6261 case PV_STL: return (char_u *)&(curwin->w_p_stl); |
40 | 6262 #endif |
5446 | 6263 case PV_UL: return (char_u *)&(curbuf->b_p_ul); |
5712 | 6264 case PV_LW: return (char_u *)&(curbuf->b_p_lw); |
6243 | 6265 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
|
6266 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
|
6267 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
|
6268 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
|
6269 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
|
6270 |
7 | 6271 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6272 return NULL; // "cannot happen" |
7 | 6273 } |
6274 return get_varp(p); | |
6275 } | |
6276 | |
6277 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6278 * 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
|
6279 * scope. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6280 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6281 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
|
6282 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
|
6283 { |
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
|
6284 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
|
6285 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6286 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6287 /* |
7 | 6288 * Get pointer to option variable. |
6289 */ | |
6290 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6291 get_varp(struct vimoption *p) |
7 | 6292 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6293 // hidden option, always return NULL |
7 | 6294 if (p->var == NULL) |
6295 return NULL; | |
6296 | |
6297 switch ((int)p->indir) | |
6298 { | |
6299 case PV_NONE: return p->var; | |
6300 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6301 // global option with local value: use local value if it's been set |
694 | 6302 case PV_EP: return *curbuf->b_p_ep != NUL |
7 | 6303 ? (char_u *)&curbuf->b_p_ep : p->var; |
694 | 6304 case PV_KP: return *curbuf->b_p_kp != NUL |
7 | 6305 ? (char_u *)&curbuf->b_p_kp : p->var; |
694 | 6306 case PV_PATH: return *curbuf->b_p_path != NUL |
7 | 6307 ? (char_u *)&(curbuf->b_p_path) : p->var; |
692 | 6308 case PV_AR: return curbuf->b_p_ar >= 0 |
7 | 6309 ? (char_u *)&(curbuf->b_p_ar) : p->var; |
694 | 6310 case PV_TAGS: return *curbuf->b_p_tags != NUL |
7 | 6311 ? (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
|
6312 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
|
6313 ? (char_u *)&(curbuf->b_p_tc) : p->var; |
6243 | 6314 case PV_BKC: return *curbuf->b_p_bkc != NUL |
6315 ? (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
|
6316 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
|
6317 ? (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
|
6318 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
|
6319 ? (char_u *)&(curwin->w_p_so) : p->var; |
7 | 6320 #ifdef FEAT_FIND_ID |
694 | 6321 case PV_DEF: return *curbuf->b_p_def != NUL |
7 | 6322 ? (char_u *)&(curbuf->b_p_def) : p->var; |
694 | 6323 case PV_INC: return *curbuf->b_p_inc != NUL |
7 | 6324 ? (char_u *)&(curbuf->b_p_inc) : p->var; |
6325 #endif | |
694 | 6326 case PV_DICT: return *curbuf->b_p_dict != NUL |
7 | 6327 ? (char_u *)&(curbuf->b_p_dict) : p->var; |
694 | 6328 case PV_TSR: return *curbuf->b_p_tsr != NUL |
7 | 6329 ? (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
|
6330 #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
|
6331 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
|
6332 ? (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
|
6333 #endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
6334 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
|
6335 ? (char_u *)&(curbuf->b_p_fp) : p->var; |
7 | 6336 #ifdef FEAT_QUICKFIX |
694 | 6337 case PV_EFM: return *curbuf->b_p_efm != NUL |
6338 ? (char_u *)&(curbuf->b_p_efm) : p->var; | |
6339 case PV_GP: return *curbuf->b_p_gp != NUL | |
7 | 6340 ? (char_u *)&(curbuf->b_p_gp) : p->var; |
694 | 6341 case PV_MP: return *curbuf->b_p_mp != NUL |
7 | 6342 ? (char_u *)&(curbuf->b_p_mp) : p->var; |
6343 #endif | |
790 | 6344 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
6345 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL | |
6346 ? (char_u *)&(curbuf->b_p_bexpr) : p->var; | |
6347 #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
|
6348 #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
|
6349 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
|
6350 ? (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
|
6351 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6352 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6353 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
|
6354 ? (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
|
6355 #endif |
40 | 6356 #ifdef FEAT_STL_OPT |
694 | 6357 case PV_STL: return *curwin->w_p_stl != NUL |
40 | 6358 ? (char_u *)&(curwin->w_p_stl) : p->var; |
6359 #endif | |
5446 | 6360 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL |
6361 ? (char_u *)&(curbuf->b_p_ul) : p->var; | |
5712 | 6362 case PV_LW: return *curbuf->b_p_lw != NUL |
6363 ? (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
|
6364 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
|
6365 ? (char_u *)&(curbuf->b_p_menc) : p->var; |
7 | 6366 #ifdef FEAT_ARABIC |
6367 case PV_ARAB: return (char_u *)&(curwin->w_p_arab); | |
6368 #endif | |
6369 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
|
6370 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
|
6371 ? (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
|
6372 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
|
6373 ? (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
|
6374 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
|
6375 ? (char_u *)&(curwin->w_p_ve) : p->var; |
744 | 6376 #ifdef FEAT_SPELL |
6377 case PV_SPELL: return (char_u *)&(curwin->w_p_spell); | |
6378 #endif | |
221 | 6379 #ifdef FEAT_SYN_HL |
744 | 6380 case PV_CUC: return (char_u *)&(curwin->w_p_cuc); |
6381 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
|
6382 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
|
6383 case PV_CC: return (char_u *)&(curwin->w_p_cc); |
221 | 6384 #endif |
7 | 6385 #ifdef FEAT_DIFF |
6386 case PV_DIFF: return (char_u *)&(curwin->w_p_diff); | |
6387 #endif | |
6388 #ifdef FEAT_FOLDING | |
6389 case PV_FDC: return (char_u *)&(curwin->w_p_fdc); | |
6390 case PV_FEN: return (char_u *)&(curwin->w_p_fen); | |
6391 case PV_FDI: return (char_u *)&(curwin->w_p_fdi); | |
6392 case PV_FDL: return (char_u *)&(curwin->w_p_fdl); | |
6393 case PV_FDM: return (char_u *)&(curwin->w_p_fdm); | |
6394 case PV_FML: return (char_u *)&(curwin->w_p_fml); | |
6395 case PV_FDN: return (char_u *)&(curwin->w_p_fdn); | |
6396 # ifdef FEAT_EVAL | |
6397 case PV_FDE: return (char_u *)&(curwin->w_p_fde); | |
6398 case PV_FDT: return (char_u *)&(curwin->w_p_fdt); | |
6399 # endif | |
6400 case PV_FMR: return (char_u *)&(curwin->w_p_fmr); | |
6401 #endif | |
6402 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
|
6403 case PV_RNU: return (char_u *)&(curwin->w_p_rnu); |
13 | 6404 #ifdef FEAT_LINEBREAK |
6405 case PV_NUW: return (char_u *)&(curwin->w_p_nuw); | |
6406 #endif | |
7 | 6407 case PV_WFH: return (char_u *)&(curwin->w_p_wfh); |
782 | 6408 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
|
6409 #if defined(FEAT_QUICKFIX) |
7 | 6410 case PV_PVW: return (char_u *)&(curwin->w_p_pvw); |
6411 #endif | |
6412 #ifdef FEAT_RIGHTLEFT | |
6413 case PV_RL: return (char_u *)&(curwin->w_p_rl); | |
6414 case PV_RLC: return (char_u *)&(curwin->w_p_rlc); | |
6415 #endif | |
6416 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
|
6417 case PV_SMS: return (char_u *)&(curwin->w_p_sms); |
7 | 6418 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); |
6419 #ifdef FEAT_LINEBREAK | |
6420 case PV_LBR: return (char_u *)&(curwin->w_p_lbr); | |
5995 | 6421 case PV_BRI: return (char_u *)&(curwin->w_p_bri); |
6422 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt); | |
7 | 6423 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
6424 case PV_WCR: return (char_u *)&(curwin->w_p_wcr); |
7 | 6425 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
|
6426 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
|
6427 #ifdef FEAT_CONCEAL |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
6428 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
|
6429 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
|
6430 #endif |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
6431 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6432 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
|
6433 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
|
6434 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
|
6435 #endif |
7 | 6436 |
6437 case PV_AI: return (char_u *)&(curbuf->b_p_ai); | |
6438 case PV_BIN: return (char_u *)&(curbuf->b_p_bin); | |
6439 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); | |
6440 case PV_BH: return (char_u *)&(curbuf->b_p_bh); | |
6441 case PV_BT: return (char_u *)&(curbuf->b_p_bt); | |
6442 case PV_BL: return (char_u *)&(curbuf->b_p_bl); | |
6443 case PV_CI: return (char_u *)&(curbuf->b_p_ci); | |
6444 case PV_CIN: return (char_u *)&(curbuf->b_p_cin); | |
6445 case PV_CINK: return (char_u *)&(curbuf->b_p_cink); | |
6446 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
|
6447 case PV_CINSD: return (char_u *)&(curbuf->b_p_cinsd); |
7 | 6448 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); |
6449 case PV_COM: return (char_u *)&(curbuf->b_p_com); | |
6450 #ifdef FEAT_FOLDING | |
6451 case PV_CMS: return (char_u *)&(curbuf->b_p_cms); | |
6452 #endif | |
6453 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
|
6454 #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
|
6455 case PV_CSL: return (char_u *)&(curbuf->b_p_csl); |
7 | 6456 #endif |
12 | 6457 #ifdef FEAT_COMPL_FUNC |
6458 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); | |
502 | 6459 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); |
12 | 6460 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
6461 #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
|
6462 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
|
6463 #endif |
30966
685ee8453163
Add missing entry for the 'endoffile' option.
Bram Moolenaar <Bram@vim.org>
parents:
30853
diff
changeset
|
6464 case PV_EOF: return (char_u *)&(curbuf->b_p_eof); |
7 | 6465 case PV_EOL: return (char_u *)&(curbuf->b_p_eol); |
6933 | 6466 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol); |
7 | 6467 case PV_ET: return (char_u *)&(curbuf->b_p_et); |
6468 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); | |
6469 case PV_FF: return (char_u *)&(curbuf->b_p_ff); | |
6470 case PV_FT: return (char_u *)&(curbuf->b_p_ft); | |
6471 case PV_FO: return (char_u *)&(curbuf->b_p_fo); | |
41 | 6472 case PV_FLP: return (char_u *)&(curbuf->b_p_flp); |
7 | 6473 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); |
6474 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); | |
6475 case PV_INF: return (char_u *)&(curbuf->b_p_inf); | |
6476 case PV_ISK: return (char_u *)&(curbuf->b_p_isk); | |
6477 #ifdef FEAT_FIND_ID | |
6478 # ifdef FEAT_EVAL | |
6479 case PV_INEX: return (char_u *)&(curbuf->b_p_inex); | |
6480 # endif | |
6481 #endif | |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
6482 #if defined(FEAT_EVAL) |
7 | 6483 case PV_INDE: return (char_u *)&(curbuf->b_p_inde); |
6484 case PV_INDK: return (char_u *)&(curbuf->b_p_indk); | |
6485 #endif | |
694 | 6486 #ifdef FEAT_EVAL |
667 | 6487 case PV_FEX: return (char_u *)&(curbuf->b_p_fex); |
6488 #endif | |
7 | 6489 #ifdef FEAT_CRYPT |
6490 case PV_KEY: return (char_u *)&(curbuf->b_p_key); | |
6491 #endif | |
6492 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
|
6493 case PV_LOP: return (char_u *)&(curbuf->b_p_lop); |
7 | 6494 case PV_ML: return (char_u *)&(curbuf->b_p_ml); |
6495 case PV_MPS: return (char_u *)&(curbuf->b_p_mps); | |
6496 case PV_MA: return (char_u *)&(curbuf->b_p_ma); | |
6497 case PV_MOD: return (char_u *)&(curbuf->b_changed); | |
6498 case PV_NF: return (char_u *)&(curbuf->b_p_nf); | |
6499 case PV_PI: return (char_u *)&(curbuf->b_p_pi); | |
12 | 6500 case PV_QE: return (char_u *)&(curbuf->b_p_qe); |
7 | 6501 case PV_RO: return (char_u *)&(curbuf->b_p_ro); |
6502 case PV_SI: return (char_u *)&(curbuf->b_p_si); | |
6503 case PV_SN: return (char_u *)&(curbuf->b_p_sn); | |
6504 case PV_STS: return (char_u *)&(curbuf->b_p_sts); | |
6505 case PV_SUA: return (char_u *)&(curbuf->b_p_sua); | |
6506 case PV_SWF: return (char_u *)&(curbuf->b_p_swf); | |
6507 #ifdef FEAT_SYN_HL | |
410 | 6508 case PV_SMC: return (char_u *)&(curbuf->b_p_smc); |
744 | 6509 case PV_SYN: return (char_u *)&(curbuf->b_p_syn); |
6510 #endif | |
6511 #ifdef FEAT_SPELL | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6512 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
|
6513 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
|
6514 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
|
6515 case PV_SPO: return (char_u *)&(curwin->w_s->b_p_spo); |
7 | 6516 #endif |
6517 case PV_SW: return (char_u *)&(curbuf->b_p_sw); | |
6518 case PV_TS: return (char_u *)&(curbuf->b_p_ts); | |
6519 case PV_TW: return (char_u *)&(curbuf->b_p_tw); | |
6520 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
|
6521 #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
|
6522 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
|
6523 #endif |
7 | 6524 case PV_WM: return (char_u *)&(curbuf->b_p_wm); |
6525 #ifdef FEAT_KEYMAP | |
6526 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); | |
6527 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6528 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6529 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
|
6530 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6531 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6532 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
|
6533 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
|
6534 #endif |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
6535 default: iemsg(_(e_get_varp_error)); |
7 | 6536 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6537 // always return a valid pointer to avoid a crash! |
7 | 6538 return (char_u *)&(curbuf->b_p_wm); |
6539 } | |
6540 | |
6541 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6542 * 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
|
6543 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6544 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6545 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
|
6546 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6547 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
|
6548 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6549 |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
6550 #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
|
6551 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6552 * 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
|
6553 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6554 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6555 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
|
6556 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6557 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
|
6558 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
6559 #endif |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6560 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6561 /* |
31996
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
6562 * Return the did_set callback function for the option at 'opt_idx' |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
6563 */ |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
6564 opt_did_set_cb_T |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
6565 get_option_did_set_cb(int opt_idx) |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
6566 { |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
6567 return options[opt_idx].opt_did_set_cb; |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
6568 } |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
6569 |
ca6bc7c04163
patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents:
31962
diff
changeset
|
6570 /* |
7 | 6571 * Get the value of 'equalprg', either the buffer-local one or the global one. |
6572 */ | |
6573 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6574 get_equalprg(void) |
7 | 6575 { |
6576 if (*curbuf->b_p_ep == NUL) | |
6577 return p_ep; | |
6578 return curbuf->b_p_ep; | |
6579 } | |
6580 | |
6581 /* | |
6582 * Copy options from one window to another. | |
6583 * Used when splitting a window. | |
6584 */ | |
6585 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6586 win_copy_options(win_T *wp_from, win_T *wp_to) |
7 | 6587 { |
6588 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); | |
6589 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
|
6590 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
|
6591 } |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
6592 |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
6593 /* |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
6594 * 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
|
6595 */ |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
6596 void |
27659
b5ebc885c25c
patch 8.2.4355: unnecessary call to check_colorcolumn()
Bram Moolenaar <Bram@vim.org>
parents:
27509
diff
changeset
|
6597 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
|
6598 { |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
6599 #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
|
6600 briopt_check(wp); |
6162 | 6601 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6602 #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
|
6603 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
|
6604 check_colorcolumn(wp); |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6605 #endif |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
6606 set_listchars_option(wp, wp->w_p_lcs, TRUE); |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
6607 set_fillchars_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
|
6608 } |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6609 |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6610 static char_u * |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6611 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
|
6612 { |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6613 if (val == empty_option) |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6614 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
|
6615 return vim_strsave(val); |
7 | 6616 } |
6617 | |
6618 /* | |
6619 * Copy the options from one winopt_T to another. | |
6620 * Doesn't free the old option values in "to", use clear_winopt() for that. | |
6621 * The 'scroll' option is not copied, because it depends on the window height. | |
6622 * The 'previewwindow' option is reset, there can be only one preview window. | |
6623 */ | |
6624 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6625 copy_winopt(winopt_T *from, winopt_T *to) |
7 | 6626 { |
6627 #ifdef FEAT_ARABIC | |
6628 to->wo_arab = from->wo_arab; | |
6629 #endif | |
6630 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
|
6631 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
|
6632 to->wo_fcs = copy_option_val(from->wo_fcs); |
7 | 6633 to->wo_nu = from->wo_nu; |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
6634 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
|
6635 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
|
6636 to->wo_ve_flags = from->wo_ve_flags; |
13 | 6637 #ifdef FEAT_LINEBREAK |
6638 to->wo_nuw = from->wo_nuw; | |
6639 #endif | |
7 | 6640 #ifdef FEAT_RIGHTLEFT |
6641 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
|
6642 to->wo_rlc = copy_option_val(from->wo_rlc); |
7 | 6643 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6644 #ifdef FEAT_LINEBREAK |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6645 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
|
6646 #endif |
40 | 6647 #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
|
6648 to->wo_stl = copy_option_val(from->wo_stl); |
40 | 6649 #endif |
7 | 6650 to->wo_wrap = from->wo_wrap; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6651 #ifdef FEAT_DIFF |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6652 to->wo_wrap_save = from->wo_wrap_save; |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6653 #endif |
7 | 6654 #ifdef FEAT_LINEBREAK |
6655 to->wo_lbr = from->wo_lbr; | |
5995 | 6656 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
|
6657 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
|
6658 #endif |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6659 to->wo_wcr = copy_option_val(from->wo_wcr); |
7 | 6660 to->wo_scb = from->wo_scb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6661 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
|
6662 to->wo_sms = from->wo_sms; |
2651 | 6663 to->wo_crb = from->wo_crb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6664 to->wo_crb_save = from->wo_crb_save; |
744 | 6665 #ifdef FEAT_SPELL |
6666 to->wo_spell = from->wo_spell; | |
6667 #endif | |
221 | 6668 #ifdef FEAT_SYN_HL |
744 | 6669 to->wo_cuc = from->wo_cuc; |
6670 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
|
6671 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
|
6672 to->wo_cc = copy_option_val(from->wo_cc); |
221 | 6673 #endif |
7 | 6674 #ifdef FEAT_DIFF |
6675 to->wo_diff = from->wo_diff; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6676 to->wo_diff_saved = from->wo_diff_saved; |
7 | 6677 #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
|
6678 #ifdef FEAT_CONCEAL |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6679 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
|
6680 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
|
6681 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
6682 #ifdef FEAT_TERMINAL |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6683 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
|
6684 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
|
6685 #endif |
7 | 6686 #ifdef FEAT_FOLDING |
6687 to->wo_fdc = from->wo_fdc; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6688 to->wo_fdc_save = from->wo_fdc_save; |
7 | 6689 to->wo_fen = from->wo_fen; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6690 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
|
6691 to->wo_fdi = copy_option_val(from->wo_fdi); |
7 | 6692 to->wo_fml = from->wo_fml; |
6693 to->wo_fdl = from->wo_fdl; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6694 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
|
6695 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
|
6696 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
|
6697 ? vim_strsave(from->wo_fdm_save) : empty_option; |
7 | 6698 to->wo_fdn = from->wo_fdn; |
6699 # ifdef FEAT_EVAL | |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6700 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
|
6701 to->wo_fdt = copy_option_val(from->wo_fdt); |
7 | 6702 # endif |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6703 to->wo_fmr = copy_option_val(from->wo_fmr); |
7 | 6704 #endif |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6705 #ifdef FEAT_SIGNS |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6706 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
|
6707 #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
|
6708 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6709 #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
|
6710 // 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
|
6711 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
|
6712 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
|
6713 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6714 check_winopt(to); // don't want NULL pointers |
7 | 6715 } |
6716 | |
6717 /* | |
6718 * Check string options in a window for a NULL value. | |
6719 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
6720 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6721 check_win_options(win_T *win) |
7 | 6722 { |
6723 check_winopt(&win->w_onebuf_opt); | |
6724 check_winopt(&win->w_allbuf_opt); | |
6725 } | |
6726 | |
6727 /* | |
6728 * Check for NULL pointers in a winopt_T and replace them with empty_option. | |
6729 */ | |
5997 | 6730 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6731 check_winopt(winopt_T *wop UNUSED) |
7 | 6732 { |
6733 #ifdef FEAT_FOLDING | |
6734 check_string_option(&wop->wo_fdi); | |
6735 check_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6736 check_string_option(&wop->wo_fdm_save); |
7 | 6737 # ifdef FEAT_EVAL |
6738 check_string_option(&wop->wo_fde); | |
6739 check_string_option(&wop->wo_fdt); | |
6740 # endif | |
6741 check_string_option(&wop->wo_fmr); | |
6742 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6743 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6744 check_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6745 #endif |
7 | 6746 #ifdef FEAT_RIGHTLEFT |
6747 check_string_option(&wop->wo_rlc); | |
6748 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6749 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6750 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
|
6751 #endif |
40 | 6752 #ifdef FEAT_STL_OPT |
6753 check_string_option(&wop->wo_stl); | |
6754 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6755 #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
|
6756 check_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6757 check_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6758 #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
|
6759 #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
|
6760 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
|
6761 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
6762 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6763 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
|
6764 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
|
6765 #endif |
5995 | 6766 #ifdef FEAT_LINEBREAK |
6767 check_string_option(&wop->wo_briopt); | |
6768 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
6769 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
|
6770 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
|
6771 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
|
6772 check_string_option(&wop->wo_ve); |
7 | 6773 } |
6774 | |
6775 /* | |
6776 * Free the allocated memory inside a winopt_T. | |
6777 */ | |
6778 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6779 clear_winopt(winopt_T *wop UNUSED) |
7 | 6780 { |
6781 #ifdef FEAT_FOLDING | |
6782 clear_string_option(&wop->wo_fdi); | |
6783 clear_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6784 clear_string_option(&wop->wo_fdm_save); |
7 | 6785 # ifdef FEAT_EVAL |
6786 clear_string_option(&wop->wo_fde); | |
6787 clear_string_option(&wop->wo_fdt); | |
6788 # endif | |
6789 clear_string_option(&wop->wo_fmr); | |
6790 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6791 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6792 clear_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6793 #endif |
5995 | 6794 #ifdef FEAT_LINEBREAK |
6795 clear_string_option(&wop->wo_briopt); | |
6796 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
6797 clear_string_option(&wop->wo_wcr); |
7 | 6798 #ifdef FEAT_RIGHTLEFT |
6799 clear_string_option(&wop->wo_rlc); | |
6800 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6801 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6802 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
|
6803 #endif |
40 | 6804 #ifdef FEAT_STL_OPT |
6805 clear_string_option(&wop->wo_stl); | |
6806 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6807 #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
|
6808 clear_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6809 clear_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6810 #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
|
6811 #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
|
6812 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
|
6813 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
6814 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6815 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
|
6816 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
|
6817 #endif |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
6818 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
|
6819 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
|
6820 clear_string_option(&wop->wo_ve); |
7 | 6821 } |
6822 | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6823 #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
|
6824 // 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
|
6825 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
|
6826 # 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
|
6827 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6828 /* |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6829 * 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
|
6830 */ |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6831 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
|
6832 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
|
6833 { |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6834 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
|
6835 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
|
6836 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6837 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
|
6838 return; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6839 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
|
6840 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
|
6841 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
|
6842 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
|
6843 } |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6844 #else |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6845 # 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
|
6846 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6847 |
7 | 6848 /* |
6849 * Copy global option values to local options for one buffer. | |
6850 * Used when creating a new buffer and sometimes when entering a buffer. | |
6851 * 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
|
6852 * BCO_ENTER We will enter the buffer "buf". |
7 | 6853 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when |
6854 * appropriate. | |
6855 * BCO_NOHELP Don't copy the values to a help buffer. | |
6856 */ | |
6857 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6858 buf_copy_options(buf_T *buf, int flags) |
7 | 6859 { |
6860 int should_copy = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6861 char_u *save_p_isk = NULL; // init for GCC |
7 | 6862 int dont_do_help; |
6863 int did_isk = FALSE; | |
6864 | |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
6865 // Skip this when the option defaults have not been set yet. Happens when |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
6866 // main() allocates the first buffer. |
7 | 6867 if (p_cpo != NULL) |
6868 { | |
6869 /* | |
6870 * Always copy when entering and 'cpo' contains 'S'. | |
6871 * Don't copy when already initialized. | |
6872 * Don't copy when 'cpo' contains 's' and not entering. | |
6873 * 'S' BCO_ENTER initialized 's' should_copy | |
6874 * yes yes X X TRUE | |
6875 * yes no yes X FALSE | |
6876 * no X yes X FALSE | |
6877 * X no no yes FALSE | |
6878 * X no no no TRUE | |
6879 * no yes no X TRUE | |
6880 */ | |
6881 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) | |
6882 && (buf->b_p_initialized | |
6883 || (!(flags & BCO_ENTER) | |
6884 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
6885 should_copy = FALSE; | |
6886 | |
6887 if (should_copy || (flags & BCO_ALWAYS)) | |
6888 { | |
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
|
6889 #ifdef FEAT_EVAL |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
6890 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
|
6891 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
|
6892 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6893 // 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
|
6894 // 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
|
6895 // (jumping back to a help file with CTRL-T or CTRL-O) |
7 | 6896 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) |
6897 || 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
|
6898 if (dont_do_help) // don't free b_p_isk |
7 | 6899 { |
6900 save_p_isk = buf->b_p_isk; | |
6901 buf->b_p_isk = NULL; | |
6902 } | |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
6903 // Always free the allocated strings. If not already initialized, |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
6904 // reset 'readonly' and copy 'fileformat'. |
7 | 6905 if (!buf->b_p_initialized) |
6906 { | |
6907 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
|
6908 buf->b_p_ro = FALSE; // don't copy readonly |
7 | 6909 buf->b_p_tx = p_tx; |
6910 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
|
6911 switch (*p_ffs) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6912 { |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6913 case 'm': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6914 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
|
6915 case 'd': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6916 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
|
6917 case 'u': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6918 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
|
6919 default: |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6920 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
|
6921 } |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6922 if (buf->b_p_ff != NULL) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6923 buf->b_start_ffc = *buf->b_p_ff; |
7 | 6924 buf->b_p_bh = empty_option; |
6925 buf->b_p_bt = empty_option; | |
6926 } | |
6927 else | |
6928 free_buf_options(buf, FALSE); | |
6929 | |
6930 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
|
6931 COPY_OPT_SCTX(buf, BV_AI); |
7 | 6932 buf->b_p_ai_nopaste = p_ai_nopaste; |
6933 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
|
6934 COPY_OPT_SCTX(buf, BV_SW); |
7 | 6935 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
|
6936 COPY_OPT_SCTX(buf, BV_TW); |
7 | 6937 buf->b_p_tw_nopaste = p_tw_nopaste; |
6938 buf->b_p_tw_nobin = p_tw_nobin; | |
6939 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
|
6940 COPY_OPT_SCTX(buf, BV_WM); |
7 | 6941 buf->b_p_wm_nopaste = p_wm_nopaste; |
6942 buf->b_p_wm_nobin = p_wm_nobin; | |
6943 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
|
6944 COPY_OPT_SCTX(buf, BV_BIN); |
402 | 6945 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
|
6946 COPY_OPT_SCTX(buf, BV_BOMB); |
6954 | 6947 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
|
6948 COPY_OPT_SCTX(buf, BV_FIXEOL); |
7 | 6949 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
|
6950 COPY_OPT_SCTX(buf, BV_ET); |
7 | 6951 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
|
6952 buf->b_p_et_nopaste = p_et_nopaste; |
7 | 6953 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
|
6954 COPY_OPT_SCTX(buf, BV_ML); |
7 | 6955 buf->b_p_ml_nobin = p_ml_nobin; |
6956 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
|
6957 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
|
6958 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
|
6959 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
|
6960 else |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6961 { |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6962 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
|
6963 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
|
6964 } |
7 | 6965 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
|
6966 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
|
6967 #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
|
6968 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
|
6969 COPY_OPT_SCTX(buf, BV_CSL); |
7 | 6970 #endif |
12 | 6971 #ifdef FEAT_COMPL_FUNC |
6972 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
|
6973 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
|
6974 set_buflocal_cfu_callback(buf); |
502 | 6975 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
|
6976 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
|
6977 set_buflocal_ofu_callback(buf); |
12 | 6978 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
6979 #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
|
6980 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
|
6981 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
|
6982 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
|
6983 #endif |
7 | 6984 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
|
6985 COPY_OPT_SCTX(buf, BV_STS); |
7 | 6986 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
|
6987 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6988 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
|
6989 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
|
6990 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
|
6991 (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
|
6992 else |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
6993 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
|
6994 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
|
6995 ? 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
|
6996 #endif |
7 | 6997 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
|
6998 COPY_OPT_SCTX(buf, BV_SN); |
7 | 6999 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
|
7000 COPY_OPT_SCTX(buf, BV_COM); |
7 | 7001 #ifdef FEAT_FOLDING |
7002 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
|
7003 COPY_OPT_SCTX(buf, BV_CMS); |
7 | 7004 #endif |
7005 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
|
7006 COPY_OPT_SCTX(buf, BV_FO); |
41 | 7007 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
|
7008 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
|
7009 // 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
|
7010 // when it is set to 8 bytes in defaults.vim. |
7 | 7011 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
|
7012 COPY_OPT_SCTX(buf, BV_NF); |
7 | 7013 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
|
7014 COPY_OPT_SCTX(buf, BV_MPS); |
7 | 7015 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
|
7016 COPY_OPT_SCTX(buf, BV_SI); |
7 | 7017 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
|
7018 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
|
7019 |
7 | 7020 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
|
7021 COPY_OPT_SCTX(buf, BV_CIN); |
7 | 7022 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
|
7023 COPY_OPT_SCTX(buf, BV_CINK); |
7 | 7024 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
|
7025 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
|
7026 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
|
7027 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
|
7028 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
|
7029 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
|
7030 |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
7031 // Don't copy 'filetype', it must be detected |
7 | 7032 buf->b_p_ft = empty_option; |
7033 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
|
7034 COPY_OPT_SCTX(buf, BV_PI); |
7 | 7035 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
|
7036 COPY_OPT_SCTX(buf, BV_CINW); |
7 | 7037 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
|
7038 COPY_OPT_SCTX(buf, BV_LISP); |
7 | 7039 #ifdef FEAT_SYN_HL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7040 // Don't copy 'syntax', it must be set |
7 | 7041 buf->b_p_syn = empty_option; |
410 | 7042 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
|
7043 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
|
7044 buf->b_s.b_syn_isk = empty_option; |
744 | 7045 #endif |
7046 #ifdef FEAT_SPELL | |
2599 | 7047 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
|
7048 COPY_OPT_SCTX(buf, BV_SPC); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7049 (void)compile_cap_prog(&buf->b_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7050 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
|
7051 COPY_OPT_SCTX(buf, BV_SPF); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
7052 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
|
7053 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
|
7054 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
|
7055 COPY_OPT_SCTX(buf, BV_SPO); |
7 | 7056 #endif |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
7057 #if defined(FEAT_EVAL) |
7 | 7058 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
|
7059 COPY_OPT_SCTX(buf, BV_INDE); |
7 | 7060 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
|
7061 COPY_OPT_SCTX(buf, BV_INDK); |
7 | 7062 #endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
7063 buf->b_p_fp = empty_option; |
667 | 7064 #if defined(FEAT_EVAL) |
7065 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
|
7066 COPY_OPT_SCTX(buf, BV_FEX); |
667 | 7067 #endif |
7 | 7068 #ifdef FEAT_CRYPT |
7069 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
|
7070 COPY_OPT_SCTX(buf, BV_KEY); |
7 | 7071 #endif |
7072 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
|
7073 COPY_OPT_SCTX(buf, BV_SUA); |
7 | 7074 #ifdef FEAT_KEYMAP |
7075 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
|
7076 COPY_OPT_SCTX(buf, BV_KMAP); |
7 | 7077 buf->b_kmap_state |= KEYMAP_INIT; |
7078 #endif | |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
7079 #ifdef FEAT_TERMINAL |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
7080 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
|
7081 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
|
7082 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7083 // 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
|
7084 // state from the current buffer is better than resetting it. |
7 | 7085 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
|
7086 COPY_OPT_SCTX(buf, BV_IMI); |
7 | 7087 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
|
7088 COPY_OPT_SCTX(buf, BV_IMS); |
7 | 7089 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7090 // 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
|
7091 // are not copied, start using the global value |
7 | 7092 buf->b_p_ar = -1; |
5446 | 7093 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
6243 | 7094 buf->b_p_bkc = empty_option; |
7095 buf->b_bkc_flags = 0; | |
7 | 7096 #ifdef FEAT_QUICKFIX |
7097 buf->b_p_gp = empty_option; | |
7098 buf->b_p_mp = empty_option; | |
7099 buf->b_p_efm = empty_option; | |
7100 #endif | |
7101 buf->b_p_ep = empty_option; | |
7102 buf->b_p_kp = empty_option; | |
7103 buf->b_p_path = empty_option; | |
7104 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
|
7105 buf->b_p_tc = empty_option; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
7106 buf->b_tc_flags = 0; |
7 | 7107 #ifdef FEAT_FIND_ID |
7108 buf->b_p_def = empty_option; | |
7109 buf->b_p_inc = empty_option; | |
7110 # ifdef FEAT_EVAL | |
7111 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
|
7112 COPY_OPT_SCTX(buf, BV_INEX); |
7 | 7113 # endif |
7114 #endif | |
7115 buf->b_p_dict = empty_option; | |
7116 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
|
7117 #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
|
7118 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
|
7119 #endif |
12 | 7120 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
|
7121 COPY_OPT_SCTX(buf, BV_QE); |
790 | 7122 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
7123 buf->b_p_bexpr = empty_option; | |
7124 #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
|
7125 #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
|
7126 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
|
7127 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
7128 #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
|
7129 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
|
7130 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
|
7131 #endif |
5712 | 7132 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
|
7133 buf->b_p_menc = empty_option; |
7 | 7134 |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
7135 // Don't copy the options set by ex_help(), use the saved values, |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
7136 // when going from a help buffer to a non-help buffer. |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
7137 // Don't touch these at all when BCO_NOHELP is used and going from |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
7138 // or to a help buffer. |
7 | 7139 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
|
7140 { |
7 | 7141 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
|
7142 #ifdef FEAT_VARTABS |
32120
97255d909654
patch 9.0.1391: "clear" macros are not always used
Bram Moolenaar <Bram@vim.org>
parents:
32098
diff
changeset
|
7143 if (p_vts && *p_vts != NUL && !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
|
7144 (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
|
7145 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7146 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
|
7147 #endif |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7148 } |
7 | 7149 else |
7150 { | |
7151 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
|
7152 COPY_OPT_SCTX(buf, BV_ISK); |
7 | 7153 did_isk = TRUE; |
7154 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
|
7155 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
|
7156 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7157 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
|
7158 COPY_OPT_SCTX(buf, BV_VTS); |
32120
97255d909654
patch 9.0.1391: "clear" macros are not always used
Bram Moolenaar <Bram@vim.org>
parents:
32098
diff
changeset
|
7159 if (p_vts && *p_vts != NUL && !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
|
7160 (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
|
7161 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7162 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
|
7163 #endif |
7 | 7164 buf->b_help = FALSE; |
7165 if (buf->b_p_bt[0] == 'h') | |
7166 clear_string_option(&buf->b_p_bt); | |
7167 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
|
7168 COPY_OPT_SCTX(buf, BV_MA); |
7 | 7169 } |
7170 } | |
7171 | |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
7172 // When the options should be copied (ignoring BCO_ALWAYS), set the |
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
7173 // flag that indicates that the options have been initialized. |
7 | 7174 if (should_copy) |
7175 buf->b_p_initialized = TRUE; | |
7176 } | |
7177 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7178 check_buf_options(buf); // make sure we don't have NULLs |
7 | 7179 if (did_isk) |
7180 (void)buf_init_chartab(buf, FALSE); | |
7181 } | |
7182 | |
7183 /* | |
7184 * Reset the 'modifiable' option and its default value. | |
7185 */ | |
7186 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7187 reset_modifiable(void) |
7 | 7188 { |
7189 int opt_idx; | |
7190 | |
7191 curbuf->b_p_ma = FALSE; | |
7192 p_ma = FALSE; | |
7193 opt_idx = findoption((char_u *)"ma"); | |
838 | 7194 if (opt_idx >= 0) |
7195 options[opt_idx].def_val[VI_DEFAULT] = FALSE; | |
7 | 7196 } |
7197 | |
7198 /* | |
7199 * Set the global value for 'iminsert' to the local value. | |
7200 */ | |
7201 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7202 set_iminsert_global(void) |
7 | 7203 { |
7204 p_iminsert = curbuf->b_p_iminsert; | |
7205 } | |
7206 | |
7207 /* | |
7208 * Set the global value for 'imsearch' to the local value. | |
7209 */ | |
7210 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7211 set_imsearch_global(void) |
7 | 7212 { |
7213 p_imsearch = curbuf->b_p_imsearch; | |
7214 } | |
7215 | |
7216 static int expand_option_idx = -1; | |
7217 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; | |
7218 static int expand_option_flags = 0; | |
7219 | |
7220 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7221 set_context_in_set_cmd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7222 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7223 char_u *arg, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7224 int opt_flags) // OPT_GLOBAL and/or OPT_LOCAL |
7 | 7225 { |
7226 int nextchar; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7227 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
|
7228 int opt_idx = 0; // init for GCC |
7 | 7229 char_u *p; |
7230 char_u *s; | |
7231 int is_term_option = FALSE; | |
7232 int key; | |
7233 | |
7234 expand_option_flags = opt_flags; | |
7235 | |
7236 xp->xp_context = EXPAND_SETTINGS; | |
7237 if (*arg == NUL) | |
7238 { | |
7239 xp->xp_pattern = arg; | |
7240 return; | |
7241 } | |
7242 p = arg + STRLEN(arg) - 1; | |
7243 if (*p == ' ' && *(p - 1) != '\\') | |
7244 { | |
7245 xp->xp_pattern = p + 1; | |
7246 return; | |
7247 } | |
7248 while (p > arg) | |
7249 { | |
7250 s = p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7251 // count number of backslashes before ' ' or ',' |
7 | 7252 if (*p == ' ' || *p == ',') |
7253 { | |
7254 while (s > arg && *(s - 1) == '\\') | |
7255 --s; | |
7256 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7257 // break at a space with an even number of backslashes |
7 | 7258 if (*p == ' ' && ((p - s) & 1) == 0) |
7259 { | |
7260 ++p; | |
7261 break; | |
7262 } | |
7263 --p; | |
7264 } | |
1911 | 7265 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0) |
7 | 7266 { |
7267 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
32377
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
7268 xp->xp_prefix = XP_PREFIX_NO; |
7 | 7269 p += 2; |
7270 } | |
32377
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
7271 else if (STRNCMP(p, "inv", 3) == 0) |
7 | 7272 { |
7273 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
32377
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
7274 xp->xp_prefix = XP_PREFIX_INV; |
7 | 7275 p += 3; |
7276 } | |
7277 xp->xp_pattern = arg = p; | |
7278 if (*arg == '<') | |
7279 { | |
7280 while (*p != '>') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7281 if (*p++ == NUL) // expand terminal option name |
7 | 7282 return; |
7283 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
|
7284 if (key == 0) // unknown name |
7 | 7285 { |
7286 xp->xp_context = EXPAND_NOTHING; | |
7287 return; | |
7288 } | |
7289 nextchar = *++p; | |
7290 is_term_option = TRUE; | |
7291 expand_option_name[2] = KEY2TERMCAP0(key); | |
7292 expand_option_name[3] = KEY2TERMCAP1(key); | |
7293 } | |
7294 else | |
7295 { | |
7296 if (p[0] == 't' && p[1] == '_') | |
7297 { | |
7298 p += 2; | |
7299 if (*p != NUL) | |
7300 ++p; | |
7301 if (*p == NUL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7302 return; // expand option name |
7 | 7303 nextchar = *++p; |
7304 is_term_option = TRUE; | |
7305 expand_option_name[2] = p[-2]; | |
7306 expand_option_name[3] = p[-1]; | |
7307 } | |
7308 else | |
7309 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7310 // Allow * wildcard |
7 | 7311 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') |
7312 p++; | |
7313 if (*p == NUL) | |
7314 return; | |
7315 nextchar = *p; | |
7316 *p = NUL; | |
7317 opt_idx = findoption(arg); | |
7318 *p = nextchar; | |
7319 if (opt_idx == -1 || options[opt_idx].var == NULL) | |
7320 { | |
7321 xp->xp_context = EXPAND_NOTHING; | |
7322 return; | |
7323 } | |
7324 flags = options[opt_idx].flags; | |
7325 if (flags & P_BOOL) | |
7326 { | |
7327 xp->xp_context = EXPAND_NOTHING; | |
7328 return; | |
7329 } | |
7330 } | |
7331 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7332 // handle "-=" and "+=" |
7 | 7333 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') |
7334 { | |
7335 ++p; | |
7336 nextchar = '='; | |
7337 } | |
7338 if ((nextchar != '=' && nextchar != ':') | |
7339 || xp->xp_context == EXPAND_BOOL_SETTINGS) | |
7340 { | |
7341 xp->xp_context = EXPAND_UNSUCCESSFUL; | |
7342 return; | |
7343 } | |
7344 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) | |
7345 { | |
7346 xp->xp_context = EXPAND_OLD_SETTING; | |
7347 if (is_term_option) | |
7348 expand_option_idx = -1; | |
7349 else | |
7350 expand_option_idx = opt_idx; | |
7351 xp->xp_pattern = p + 1; | |
7352 return; | |
7353 } | |
7354 xp->xp_context = EXPAND_NOTHING; | |
7355 if (is_term_option || (flags & P_NUM)) | |
7356 return; | |
7357 | |
7358 xp->xp_pattern = p + 1; | |
7359 | |
7360 if (flags & P_EXPAND) | |
7361 { | |
7362 p = options[opt_idx].var; | |
7363 if (p == (char_u *)&p_bdir | |
7364 || p == (char_u *)&p_dir | |
7365 || p == (char_u *)&p_path | |
8182
95d59081580f
commit https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
7366 || p == (char_u *)&p_pp |
7 | 7367 || p == (char_u *)&p_rtp |
7368 || p == (char_u *)&p_cdpath | |
7369 #ifdef FEAT_SESSION | |
7370 || p == (char_u *)&p_vdir | |
7371 #endif | |
7372 ) | |
7373 { | |
7374 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
|
7375 if (p == (char_u *)&p_path || p == (char_u *)&p_cdpath) |
7 | 7376 xp->xp_backslash = XP_BS_THREE; |
7377 else | |
7378 xp->xp_backslash = XP_BS_ONE; | |
7379 } | |
23821
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
7380 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
|
7381 { |
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
7382 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
|
7383 } |
7 | 7384 else |
7385 { | |
7386 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
|
7387 // for 'tags' need three backslashes for a space |
7 | 7388 if (p == (char_u *)&p_tags) |
7389 xp->xp_backslash = XP_BS_THREE; | |
7390 else | |
7391 xp->xp_backslash = XP_BS_ONE; | |
7392 } | |
7393 } | |
7394 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7395 // 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
|
7396 // last file name. |
7 | 7397 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) |
7398 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7399 // count number of backslashes before ' ' or ',' |
7 | 7400 if (*p == ' ' || *p == ',') |
7401 { | |
7402 s = p; | |
7403 while (s > xp->xp_pattern && *(s - 1) == '\\') | |
7404 --s; | |
7405 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) | |
7406 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) | |
7407 { | |
7408 xp->xp_pattern = p + 1; | |
7409 break; | |
7410 } | |
7411 } | |
374 | 7412 |
744 | 7413 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7414 // for 'spellsuggest' start at "file:" |
374 | 7415 if (options[opt_idx].var == (char_u *)&p_sps |
7416 && STRNCMP(p, "file:", 5) == 0) | |
7417 { | |
7418 xp->xp_pattern = p + 5; | |
7419 break; | |
7420 } | |
7421 #endif | |
7 | 7422 } |
7423 } | |
7424 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7425 /* |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7426 * 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
|
7427 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7428 * 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
|
7429 * 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
|
7430 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7431 * 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
|
7432 * 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
|
7433 * returns TRUE. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7434 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7435 * 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
|
7436 * '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
|
7437 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7438 * 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
|
7439 * '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
|
7440 */ |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7441 static int |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7442 match_str( |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7443 char_u *str, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7444 regmatch_T *regmatch, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7445 char_u **matches, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7446 int idx, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7447 int test_only, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7448 int fuzzy, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7449 char_u *fuzzystr, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7450 fuzmatch_str_T *fuzmatch) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7451 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7452 if (!fuzzy) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7453 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7454 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
|
7455 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7456 if (!test_only) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7457 matches[idx] = vim_strsave(str); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7458 return TRUE; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7459 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7460 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7461 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7462 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7463 int score; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7464 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7465 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
|
7466 if (score != 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7467 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7468 if (!test_only) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7469 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7470 fuzmatch[idx].idx = idx; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7471 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
|
7472 fuzmatch[idx].score = score; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7473 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7474 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7475 return TRUE; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7476 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7477 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7478 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7479 return FALSE; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7480 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7481 |
7 | 7482 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7483 ExpandSettings( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7484 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7485 regmatch_T *regmatch, |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7486 char_u *fuzzystr, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7487 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
|
7488 char_u ***matches, |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
7489 int can_fuzzy) |
7 | 7490 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7491 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
|
7492 int num_term = 0; // Nr of matching terminal code settings |
7 | 7493 int opt_idx; |
7494 int match; | |
7495 int count = 0; | |
7496 char_u *str; | |
7497 int loop; | |
7498 int is_term_opt; | |
7499 char_u name_buf[MAX_KEY_NAME_LEN]; | |
7500 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
|
7501 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
|
7502 int fuzzy; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7503 fuzmatch_str_T *fuzmatch = NULL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7504 |
28786
fd5942a62312
patch 8.2.4917: fuzzy expansion of option names is not right
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
7505 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
|
7506 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7507 // do this loop twice: |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7508 // 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
|
7509 // loop == 1: copy the matching options into allocated memory |
7 | 7510 for (loop = 0; loop <= 1; ++loop) |
7511 { | |
7512 regmatch->rm_ic = ic; | |
7513 if (xp->xp_context != EXPAND_BOOL_SETTINGS) | |
7514 { | |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
7515 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
|
7516 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7517 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
|
7518 count, (loop == 0), fuzzy, fuzzystr, fuzmatch)) |
7 | 7519 { |
7520 if (loop == 0) | |
7521 num_normal++; | |
7522 else | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7523 count++; |
7 | 7524 } |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7525 } |
7 | 7526 } |
7527 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; | |
7528 opt_idx++) | |
7529 { | |
7530 if (options[opt_idx].var == NULL) | |
7531 continue; | |
7532 if (xp->xp_context == EXPAND_BOOL_SETTINGS | |
32377
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
7533 && !(options[opt_idx].flags & P_BOOL)) |
7 | 7534 continue; |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7535 is_term_opt = istermoption_idx(opt_idx); |
7 | 7536 if (is_term_opt && num_normal > 0) |
7537 continue; | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7538 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7539 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
|
7540 fuzzy, fuzzystr, fuzmatch)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7541 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7542 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7543 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7544 if (is_term_opt) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7545 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7546 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7547 num_normal++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7548 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7549 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7550 count++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7551 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7552 else if (!fuzzy && options[opt_idx].shortname != NULL |
7 | 7553 && vim_regexec(regmatch, |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
7554 (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
|
7555 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7556 // 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
|
7557 // 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
|
7558 // 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
|
7559 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7560 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7561 if (is_term_opt) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7562 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7563 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7564 num_normal++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7565 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7566 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7567 (*matches)[count++] = vim_strsave(str); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7568 } |
7 | 7569 else if (is_term_opt) |
7570 { | |
7571 name_buf[0] = '<'; | |
7572 name_buf[1] = 't'; | |
7573 name_buf[2] = '_'; | |
7574 name_buf[3] = str[2]; | |
7575 name_buf[4] = str[3]; | |
7576 name_buf[5] = '>'; | |
7577 name_buf[6] = NUL; | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7578 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7579 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
|
7580 fuzzy, fuzzystr, fuzmatch)) |
7 | 7581 { |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7582 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7583 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7584 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7585 count++; |
7 | 7586 } |
7587 } | |
7588 } | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7589 |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
7590 // Check terminal key codes, these are not in the option table |
7 | 7591 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) |
7592 { | |
7593 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) | |
7594 { | |
7595 if (!isprint(str[0]) || !isprint(str[1])) | |
7596 continue; | |
7597 | |
7598 name_buf[0] = 't'; | |
7599 name_buf[1] = '_'; | |
7600 name_buf[2] = str[0]; | |
7601 name_buf[3] = str[1]; | |
7602 name_buf[4] = NUL; | |
7603 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7604 if (match_str(name_buf, regmatch, *matches, count, |
32377
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
7605 (loop == 0), fuzzy, fuzzystr, fuzmatch)) |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7606 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7607 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7608 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7609 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7610 count++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7611 } |
7 | 7612 else |
7613 { | |
7614 name_buf[0] = '<'; | |
7615 name_buf[1] = 't'; | |
7616 name_buf[2] = '_'; | |
7617 name_buf[3] = str[0]; | |
7618 name_buf[4] = str[1]; | |
7619 name_buf[5] = '>'; | |
7620 name_buf[6] = NUL; | |
7621 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7622 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
|
7623 (loop == 0), fuzzy, fuzzystr, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7624 fuzmatch)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7625 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7626 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7627 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7628 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7629 count++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7630 } |
7 | 7631 } |
7632 } | |
7633 | |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
7634 // Check special key names. |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7635 regmatch->rm_ic = TRUE; // ignore case here |
7 | 7636 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) |
7637 { | |
7638 name_buf[0] = '<'; | |
7639 STRCPY(name_buf + 1, str); | |
7640 STRCAT(name_buf, ">"); | |
7641 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7642 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
|
7643 fuzzy, fuzzystr, fuzmatch)) |
7 | 7644 { |
7645 if (loop == 0) | |
7646 num_term++; | |
7647 else | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7648 count++; |
7 | 7649 } |
7650 } | |
7651 } | |
7652 if (loop == 0) | |
7653 { | |
7654 if (num_normal > 0) | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7655 *numMatches = num_normal; |
7 | 7656 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
|
7657 *numMatches = num_term; |
7 | 7658 else |
7659 return OK; | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7660 if (!fuzzy) |
7 | 7661 { |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7662 *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
|
7663 if (*matches == NULL) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7664 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7665 *matches = (char_u **)""; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7666 return FAIL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7667 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7668 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7669 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7670 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7671 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
|
7672 if (fuzmatch == NULL) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7673 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7674 *matches = (char_u **)""; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7675 return FAIL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7676 } |
7 | 7677 } |
7678 } | |
7679 } | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7680 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7681 if (fuzzy && |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7682 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
|
7683 return FAIL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7684 |
7 | 7685 return OK; |
7686 } | |
7687 | |
7688 int | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
7689 ExpandOldSetting(int *numMatches, char_u ***matches) |
7 | 7690 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7691 char_u *var = NULL; // init for GCC |
7 | 7692 char_u *buf; |
7693 | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
7694 *numMatches = 0; |
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
7695 *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
|
7696 if (*matches == NULL) |
7 | 7697 return FAIL; |
7698 | |
32076
32acf287a9ae
patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents:
32043
diff
changeset
|
7699 // For a terminal key code expand_option_idx is < 0. |
7 | 7700 if (expand_option_idx < 0) |
7701 { | |
7702 var = find_termcode(expand_option_name + 2); | |
7703 if (var == NULL) | |
7704 expand_option_idx = findoption(expand_option_name); | |
7705 } | |
7706 | |
7707 if (expand_option_idx >= 0) | |
7708 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7709 // put string of option value in NameBuff |
7 | 7710 option_value2string(&options[expand_option_idx], expand_option_flags); |
7711 var = NameBuff; | |
7712 } | |
7713 else if (var == NULL) | |
7714 var = (char_u *)""; | |
7715 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7716 // 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
|
7717 // what happens in do_set(). |
7 | 7718 buf = vim_strsave_escaped(var, escape_chars); |
7719 | |
7720 if (buf == NULL) | |
7721 { | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
7722 VIM_CLEAR(*matches); |
7 | 7723 return FAIL; |
7724 } | |
7725 | |
7726 #ifdef BACKSLASH_IN_FILENAME | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7727 // 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
|
7728 // 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
|
7729 for (var = buf; *var != NUL; MB_PTR_ADV(var)) |
7 | 7730 if (var[0] == '\\' && var[1] == '\\' |
7731 && expand_option_idx >= 0 | |
7732 && (options[expand_option_idx].flags & P_EXPAND) | |
7733 && vim_isfilec(var[2]) | |
7734 && (var[2] != '\\' || (var == buf && var[4] != '\\'))) | |
1622 | 7735 STRMOVE(var, var + 1); |
7 | 7736 #endif |
7737 | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
7738 *matches[0] = buf; |
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
7739 *numMatches = 1; |
7 | 7740 return OK; |
7741 } | |
7742 | |
7743 /* | |
7744 * Get the value for the numeric or string option *opp in a nice format into | |
7745 * NameBuff[]. Must not be called with a hidden option! | |
7746 */ | |
7747 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7748 option_value2string( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7749 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
|
7750 int scope) // OPT_GLOBAL and/or OPT_LOCAL |
7 | 7751 { |
7752 char_u *varp; | |
7753 | |
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
|
7754 varp = get_varp_scope(opp, scope); |
7 | 7755 |
7756 if (opp->flags & P_NUM) | |
7757 { | |
7758 long wc = 0; | |
7759 | |
7760 if (wc_use_keyname(varp, &wc)) | |
7761 STRCPY(NameBuff, get_special_key_name((int)wc, 0)); | |
7762 else if (wc != 0) | |
7763 STRCPY(NameBuff, transchar((int)wc)); | |
7764 else | |
7765 sprintf((char *)NameBuff, "%ld", *(long *)varp); | |
7766 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7767 else // P_STRING |
7 | 7768 { |
7769 varp = *(char_u **)(varp); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7770 if (varp == NULL) // just in case |
7 | 7771 NameBuff[0] = NUL; |
7772 #ifdef FEAT_CRYPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7773 // don't show the actual value of 'key', only that it's set |
840 | 7774 else if (opp->var == (char_u *)&p_key && *varp) |
7 | 7775 STRCPY(NameBuff, "*****"); |
7776 #endif | |
7777 else if (opp->flags & P_EXPAND) | |
7778 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
|
7779 // Translate 'pastetoggle' into special key names |
7 | 7780 else if ((char_u **)opp->var == &p_pt) |
7781 str2specialbuf(p_pt, NameBuff, MAXPATHL); | |
7782 else | |
419 | 7783 vim_strncpy(NameBuff, varp, MAXPATHL - 1); |
7 | 7784 } |
7785 } | |
7786 | |
7787 /* | |
7788 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be | |
7789 * printed as a keyname. | |
7790 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. | |
7791 */ | |
7792 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7793 wc_use_keyname(char_u *varp, long *wcp) |
7 | 7794 { |
7795 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) | |
7796 { | |
7797 *wcp = *(long *)varp; | |
7798 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0) | |
7799 return TRUE; | |
7800 } | |
7801 return FALSE; | |
7802 } | |
7803 | |
7804 /* | |
7805 * Return TRUE if "x" is present in 'shortmess' option, or | |
7806 * 'shortmess' contains 'a' and "x" is present in SHM_A. | |
7807 */ | |
7808 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7809 shortmess(int x) |
7 | 7810 { |
3384 | 7811 return p_shm != NULL && |
7812 ( vim_strchr(p_shm, x) != NULL | |
7 | 7813 || (vim_strchr(p_shm, 'a') != NULL |
7814 && vim_strchr((char_u *)SHM_A, x) != NULL)); | |
7815 } | |
7816 | |
7817 /* | |
7818 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found. | |
7819 * | |
7820 * Reset 'compatible' and set the values for options that didn't get set yet | |
7821 * to the Vim defaults. | |
7822 * Don't do this if the 'compatible' option has been set or reset before. | |
819 | 7823 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet. |
7 | 7824 */ |
7825 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7826 vimrc_found(char_u *fname, char_u *envname) |
819 | 7827 { |
7828 int opt_idx; | |
826 | 7829 int dofree = FALSE; |
819 | 7830 char_u *p; |
7 | 7831 |
7832 if (!option_was_set((char_u *)"cp")) | |
7833 { | |
7834 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
|
7835 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 7836 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF))) |
7837 set_option_default(opt_idx, OPT_FREE, FALSE); | |
7838 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
7839 didset_options2(); |
7 | 7840 } |
819 | 7841 |
7842 if (fname != NULL) | |
7843 { | |
7844 p = vim_getenv(envname, &dofree); | |
7845 if (p == NULL) | |
7846 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7847 // Set $MYVIMRC to the first vimrc file found. |
819 | 7848 p = FullName_save(fname, FALSE); |
7849 if (p != NULL) | |
7850 { | |
7851 vim_setenv(envname, p); | |
7852 vim_free(p); | |
7853 } | |
7854 } | |
7855 else if (dofree) | |
7856 vim_free(p); | |
7857 } | |
7 | 7858 } |
7859 | |
7860 /* | |
7861 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg. | |
7862 */ | |
7863 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7864 change_compatible(int on) |
7 | 7865 { |
838 | 7866 int opt_idx; |
7867 | |
7 | 7868 if (p_cp != on) |
7869 { | |
7870 p_cp = on; | |
7871 compatible_set(); | |
7872 } | |
838 | 7873 opt_idx = findoption((char_u *)"cp"); |
7874 if (opt_idx >= 0) | |
7875 options[opt_idx].flags |= P_WAS_SET; | |
7 | 7876 } |
7877 | |
7878 /* | |
7879 * 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
|
7880 * Only works correctly for global options. |
7 | 7881 */ |
7882 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7883 option_was_set(char_u *name) |
7 | 7884 { |
7885 int idx; | |
7886 | |
7887 idx = findoption(name); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7888 if (idx < 0) // unknown option |
7 | 7889 return FALSE; |
7890 if (options[idx].flags & P_WAS_SET) | |
7891 return TRUE; | |
7892 return FALSE; | |
7893 } | |
7894 | |
7895 /* | |
3980 | 7896 * Reset the flag indicating option "name" was set. |
7897 */ | |
14748
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
7898 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7899 reset_option_was_set(char_u *name) |
3980 | 7900 { |
7901 int idx = findoption(name); | |
7902 | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7903 if (idx < 0) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7904 return FAIL; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7905 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7906 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
|
7907 return OK; |
3980 | 7908 } |
7909 | |
7910 /* | |
7 | 7911 * compatible_set() - Called when 'compatible' has been set or unset. |
7912 * | |
7913 * When 'compatible' set: Set all relevant options (those that have the P_VIM) | |
7914 * flag) to a Vi compatible value. | |
7915 * When 'compatible' is unset: Set all options that have a different default | |
7916 * for Vim (without the P_VI_DEF flag) to that default. | |
7917 */ | |
7918 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7919 compatible_set(void) |
7 | 7920 { |
7921 int opt_idx; | |
7922 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7923 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 7924 if ( ((options[opt_idx].flags & P_VIM) && p_cp) |
7925 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp)) | |
7926 set_option_default(opt_idx, OPT_FREE, p_cp); | |
7927 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
7928 didset_options2(); |
7 | 7929 } |
7930 | |
7931 /* | |
7932 * Check if backspacing over something is allowed. | |
7933 */ | |
7934 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7935 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
|
7936 int what) // BS_INDENT, BS_EOL, BS_START or BS_NOSTOP |
7 | 7937 { |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
7938 #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
|
7939 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
|
7940 return FALSE; |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
7941 #endif |
7 | 7942 switch (*p_bs) |
7943 { | |
20069
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
7944 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
|
7945 case '2': return (what != BS_NOSTOP); |
7 | 7946 case '1': return (what != BS_START); |
7947 case '0': return FALSE; | |
7948 } | |
7949 return vim_strchr(p_bs, what) != NULL; | |
7950 } | |
7951 | |
7952 /* | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7953 * 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
|
7954 * 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
|
7955 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7956 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7957 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
|
7958 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7959 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
|
7960 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7961 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7962 /* |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7963 * 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
|
7964 * 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
|
7965 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7966 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7967 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
|
7968 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7969 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
|
7970 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7971 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
7972 /* |
6243 | 7973 * Get the local or global value of 'backupcopy'. |
7974 */ | |
7975 unsigned int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7976 get_bkc_value(buf_T *buf) |
6243 | 7977 { |
7978 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags; | |
7979 } | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
7980 |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
7981 #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
|
7982 /* |
27128
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7983 * 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
|
7984 */ |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7985 char_u * |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7986 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
|
7987 { |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7988 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
|
7989 return p_flp; |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7990 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
|
7991 } |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
7992 #endif |
27128
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7993 |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
7994 /* |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7995 * 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
|
7996 */ |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7997 unsigned int |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7998 get_ve_flags(void) |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
7999 { |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
8000 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
|
8001 & ~(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
|
8002 } |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
8003 |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8004 #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
|
8005 /* |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8006 * 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
|
8007 */ |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8008 char_u * |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8009 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
|
8010 { |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8011 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
|
8012 return p_sbr; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8013 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
|
8014 return empty_option; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8015 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
|
8016 } |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8017 #endif |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8018 |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8019 #if defined(FEAT_EVAL) || defined(PROTO) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8020 /* |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8021 * Get window or buffer local options. |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8022 */ |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8023 dict_T * |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8024 get_winbuf_options(int bufopt) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8025 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8026 dict_T *d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8027 int opt_idx; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8028 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8029 d = dict_alloc(); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8030 if (d == NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8031 return NULL; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8032 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
8033 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
|
8034 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8035 struct vimoption *opt = &options[opt_idx]; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8036 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8037 if ((bufopt && (opt->indir & PV_BUF)) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8038 || (!bufopt && (opt->indir & PV_WIN))) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8039 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8040 char_u *varp = get_varp(opt); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8041 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8042 if (varp != NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8043 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8044 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
|
8045 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
|
8046 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
|
8047 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
|
8048 else |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14243
diff
changeset
|
8049 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
|
8050 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8051 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8052 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8053 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8054 return d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8055 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8056 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8057 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
8058 #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
|
8059 /* |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8060 * 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
|
8061 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
8062 int |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8063 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
|
8064 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8065 char_u *p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8066 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
|
8067 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8068 if (val == NULL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8069 p = wp->w_p_culopt; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8070 else |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8071 p = val; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8072 while (*p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8073 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8074 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
|
8075 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8076 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8077 culopt_flags_new |= CULOPT_LINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8078 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8079 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
|
8080 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8081 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8082 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
|
8083 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8084 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
|
8085 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8086 p += 6; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8087 culopt_flags_new |= CULOPT_NBR; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8088 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8089 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
|
8090 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8091 p += 10; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8092 culopt_flags_new |= CULOPT_SCRLINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8093 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8094 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8095 if (*p != ',' && *p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8096 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8097 if (*p == ',') |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8098 ++p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8099 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8100 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8101 // 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
|
8102 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
|
8103 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8104 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
|
8105 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8106 return OK; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8107 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8108 #endif |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8109 |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8110 /* |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8111 * 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
|
8112 */ |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8113 int |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8114 magic_isset(void) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8115 { |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8116 switch (magic_overruled) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8117 { |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23467
diff
changeset
|
8118 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
|
8119 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
|
8120 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
|
8121 } |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8122 #ifdef FEAT_EVAL |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8123 if (in_vim9script()) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8124 return TRUE; |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8125 #endif |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8126 return p_magic; |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8127 } |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8128 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8129 /* |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8130 * 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
|
8131 * 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
|
8132 * 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
|
8133 * returns FAIL. |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8134 */ |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8135 int |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8136 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
|
8137 { |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8138 #ifdef FEAT_EVAL |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8139 typval_T *tv; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8140 callback_T cb; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8141 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8142 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
|
8143 { |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8144 free_callback(optcb); |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8145 return OK; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8146 } |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8147 |
26362
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
8148 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
|
8149 || (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
|
8150 || (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
|
8151 // 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
|
8152 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
|
8153 else |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8154 // 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
|
8155 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
|
8156 if (tv == NULL) |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8157 return FAIL; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8158 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8159 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
|
8160 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
|
8161 { |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8162 free_tv(tv); |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8163 return FAIL; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8164 } |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8165 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8166 free_callback(optcb); |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8167 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
|
8168 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
|
8169 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
|
8170 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
|
8171 |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27142
diff
changeset
|
8172 // 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
|
8173 // "import#funcname". |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27142
diff
changeset
|
8174 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
|
8175 |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8176 return OK; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8177 #else |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8178 return FAIL; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8179 #endif |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8180 } |