Mercurial > vim
annotate src/option.c @ 32031:e9b8deedab60 v9.0.1347
patch 9.0.1347: "gr CTRL-O" stays in Insert mode
Commit: https://github.com/vim/vim/commit/2824d1ee325ea61855c26f77e7a4e095b9606720
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Feb 23 20:13:04 2023 +0000
patch 9.0.1347: "gr CTRL-O" stays in Insert mode
Problem: "gr CTRL-O" stays in Insert mode. (Pierre Ganty)
Solution: Do not set restart_edit when "cmdchar" is 'v'. (closes https://github.com/vim/vim/issues/12045)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 23 Feb 2023 21:15:03 +0100 |
parents | ca6bc7c04163 |
children | 6095218c9056 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9959
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * Code to handle user-settable options. This is all pretty much table- | |
12 * driven. Checklist for adding a new option: | |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
13 * - Put it in the options array in optiondefs.h (copy an existing entry). |
7 | 14 * - For a global option: Add a variable for it in option.h. |
15 * - For a buffer or window local option: | |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
16 * - Add a PV_XX macro definition to the optiondefs.h file. |
7 | 17 * - Add a variable to the window or buffer struct in structs.h. |
18 * - For a window option, add some code to copy_winopt(). | |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
19 * - For a window string option, add code to check_win_options() and |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
20 * clear_winopt(). |
7 | 21 * - For a buffer option, add some code to buf_copy_options(). |
22 * - For a buffer string option, add code to check_buf_options(). | |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
23 * - If it's a numeric option, add any necessary bounds checks to |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
24 * set_num_option(). |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
25 * - If it's a list of flags, add some code in did_set_string_option(), search |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
26 * for WW_ALL. |
7 | 27 * - When adding an option with expansion (P_EXPAND), but with a different |
28 * default for Vi and Vim (no P_VI_DEF), add some code at VIMEXP. | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10205
diff
changeset
|
29 * - Add documentation! One line in doc/quickref.txt, full description in |
7 | 30 * options.txt, and any other related places. |
31 * - Add an entry in runtime/optwin.vim. | |
32 * When making changes: | |
33 * - Adjust the help for the option in doc/option.txt. | |
34 * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a | |
35 * comment at the help for the 'compatible' option. | |
36 */ | |
37 | |
38 #define IN_OPTION_C | |
39 #include "vim.h" | |
18054
88b5c2b4e3d2
patch 8.1.2022: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18047
diff
changeset
|
40 #include "optiondefs.h" |
7 | 41 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
42 static void set_options_default(int opt_flags); |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
43 static void set_string_default_esc(char *name, char_u *val, int escape); |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
44 static char_u *find_dup_item(char_u *origval, char_u *newval, long_u flags); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
45 static char_u *option_expand(int opt_idx, char_u *val); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
46 static void didset_options(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
47 static void didset_options2(void); |
681 | 48 #if defined(FEAT_EVAL) || defined(PROTO) |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
49 static long_u *insecure_flag(int opt_idx, int opt_flags); |
681 | 50 #else |
51 # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags) | |
52 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
53 static char *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags); |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
54 static char *set_num_option(int opt_idx, char_u *varp, long value, char *errbuf, size_t errbuflen, int opt_flags); |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
55 static int find_key_option(char_u *arg_arg, int has_lt); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
56 static void showoptions(int all, int opt_flags); |
16843
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
57 static int optval_default(struct vimoption *, char_u *varp, int compatible); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
58 static void showoneopt(struct vimoption *, int opt_flags); |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
59 static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, long_u flags); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
60 static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
61 static int put_setbool(FILE *fd, char *cmd, char *name, int value); |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
62 static int istermoption(struct vimoption *p); |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
63 static char_u *get_varp_scope(struct vimoption *p, int scope); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
64 static char_u *get_varp(struct vimoption *); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
65 static void check_win_options(win_T *win); |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
66 static void option_value2string(struct vimoption *, int scope); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
67 static void check_winopt(winopt_T *wop); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
68 static int wc_use_keyname(char_u *varp, long *wcp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
69 static void paste_option_changed(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
70 static void compatible_set(void); |
7 | 71 |
72 /* | |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
73 * 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
|
74 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
75 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
76 set_init_default_shell(void) |
7 | 77 { |
78 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
|
79 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
80 // 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
|
81 // Don't use it if it is empty. |
161 | 82 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
|
83 #if defined(MSWIN) |
161 | 84 || ((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
|
85 || ((p = (char_u *)default_shell()) != NULL && *p != NUL) |
7 | 86 #endif |
161 | 87 ) |
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
|
88 #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
|
89 { |
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 // 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
|
91 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
|
92 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
|
93 |
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 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
|
95 { |
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 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
|
97 cmd = alloc(len); |
18243
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
98 if (cmd != NULL) |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
99 { |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
100 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
|
101 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
|
102 vim_free(cmd); |
463da8586749
patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18241
diff
changeset
|
103 } |
18241
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
104 } |
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 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
|
106 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
|
107 } |
85160a3649b9
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents:
18225
diff
changeset
|
108 #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
|
109 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
|
110 #endif |
31926
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 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
114 * 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
|
115 * temp files. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
116 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
117 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
118 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
|
119 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
120 int opt_idx; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
121 long_u n; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
122 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
|
123 #ifdef UNIX |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
124 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
|
125 #else |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
126 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
|
127 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
128 int len; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
129 garray_T ga; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
130 int mustfree; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
131 char_u *item; |
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 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
|
134 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
135 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
|
136 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
|
137 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
138 mustfree = FALSE; |
29879
77141226eb2e
patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
139 #ifdef UNIX |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
140 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
|
141 # 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
|
142 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
|
143 # else |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
144 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
|
145 # endif |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
146 else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
147 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
148 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
|
149 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
|
150 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
151 // 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
|
152 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
|
153 item = alloc(len); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
154 STRCPY(item, p); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
155 add_pathsep(item); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
156 STRCAT(item, "*"); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
157 if (find_dup_item(ga.ga_data, item, options[opt_idx].flags) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
158 == NULL |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
159 && ga_grow(&ga, len) == OK) |
7 | 160 { |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
161 if (ga.ga_len > 0) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
162 STRCAT(ga.ga_data, ","); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
163 STRCAT(ga.ga_data, item); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
164 ga.ga_len += len; |
7 | 165 } |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
166 vim_free(item); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
167 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
168 if (mustfree) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
169 vim_free(p); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
170 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
171 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
|
172 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
173 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
|
174 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
|
175 } |
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 * 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
|
180 * '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
|
181 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
182 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
183 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
|
184 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
185 int opt_idx; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
186 long_u n; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
187 |
7 | 188 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
|
189 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
|
190 return; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
191 |
7 | 192 #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
|
193 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
|
194 #endif |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
195 { |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
196 #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
|
197 // 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
|
198 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
|
199 #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
|
200 // 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
|
201 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
|
202 #else |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
203 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
|
204 #endif |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
205 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
|
206 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
|
207 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
|
208 { |
838 | 209 #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
|
210 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
|
211 || (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
|
212 #endif |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
213 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; |
838 | 214 } |
7 | 215 } |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
216 } |
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 * 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
|
220 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
221 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
222 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
|
223 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
224 int opt_idx; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
225 char_u *cdpath; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
226 char_u *buf; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
227 int i; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
228 int j; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
229 int mustfree = FALSE; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
230 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
231 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
|
232 if (cdpath == NULL) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
233 return; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
234 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
235 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
|
236 if (buf != NULL) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
237 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
238 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
|
239 j = 1; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
240 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
|
241 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
242 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
|
243 buf[j++] = ','; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
244 else |
7 | 245 { |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
246 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
|
247 buf[j++] = '\\'; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
248 buf[j++] = cdpath[i]; |
7 | 249 } |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
250 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
251 buf[j] = NUL; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
252 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
|
253 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
|
254 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
255 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
|
256 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
|
257 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
258 else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
259 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
|
260 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
261 if (mustfree) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
262 vim_free(cdpath); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
263 } |
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 * 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
|
267 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
268 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
269 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
|
270 { |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
271 #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
|
272 (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
|
273 // Set print encoding on platforms that don't default to latin1 |
7 | 274 set_string_default("penc", |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
275 # 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
|
276 (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
|
277 # 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
|
278 (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
|
279 # 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
|
280 (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
|
281 # else // HPUX |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
282 (char_u *)"hp-roman8" |
7 | 283 # endif |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
284 ); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
285 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
286 } |
7 | 287 |
288 #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
|
289 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
290 * 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
|
291 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
292 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
293 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
|
294 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
295 // 'printexpr' must be allocated to be able to evaluate it. |
7 | 296 set_string_default("pexpr", |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
297 # if defined(MSWIN) |
8 | 298 (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
|
299 # elif defined(VMS) |
7 | 300 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)" |
301 | |
28337
1cd053ebb5fc
patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
302 # else |
7 | 303 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error" |
304 # endif | |
305 ); | |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
306 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
307 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
308 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
309 #ifdef UNIX |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
310 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
311 * 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
|
312 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
313 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
314 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
|
315 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
316 char_u *p; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
317 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
318 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
|
319 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
|
320 return; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
321 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
|
322 restricted = TRUE; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
323 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
|
324 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
325 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
326 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
327 #ifdef CLEAN_RUNTIMEPATH |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
328 /* |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
329 * 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
|
330 * 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
|
331 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
332 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
333 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
|
334 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
335 int opt_idx; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
336 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
337 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
|
338 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
|
339 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
340 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
|
341 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
|
342 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
343 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
|
344 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
|
345 return; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
346 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
|
347 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
|
348 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
349 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
350 |
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 * 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
|
353 * 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
|
354 * 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
|
355 * 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
|
356 * them. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
357 * 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
|
358 * default. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
359 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
360 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
361 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
|
362 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
363 int opt_idx; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
364 char_u *p; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
365 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
366 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
|
367 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
368 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
|
369 && 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
|
370 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
|
371 else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
372 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
|
373 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
|
374 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
375 *(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
|
376 // VIMEXP |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
377 // 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
|
378 // 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
|
379 // 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
|
380 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
|
381 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
|
382 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
|
383 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
|
384 } |
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 * 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
|
390 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
391 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
392 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
|
393 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
394 #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
|
395 // 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
|
396 // 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
|
397 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
|
398 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
399 char buf[20]; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
400 long_u n; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
401 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
402 // 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
|
403 // 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
|
404 // 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
|
405 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
|
406 (LPTSTR)buf, 20); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
407 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
|
408 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
409 // 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
|
410 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
|
411 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
|
412 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
|
413 || 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
|
414 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
|
415 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
|
416 STRCPY(buf, "ja"); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
417 else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
418 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
|
419 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
|
420 } |
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 #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
|
423 // 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
|
424 mac_lang_init(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
425 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
426 } |
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 * 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
|
430 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
431 static void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
432 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
|
433 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
434 char_u *p; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
435 int opt_idx; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
436 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
437 # ifdef MSWIN |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
438 // 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
|
439 // "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
|
440 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
|
441 # else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
442 // 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
|
443 // 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
|
444 p = enc_locale(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
445 # endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
446 if (p == NULL) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
447 return; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
448 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
449 // 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
|
450 // 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
|
451 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
|
452 p_enc = p; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
453 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
|
454 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
455 // 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
|
456 // 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
|
457 // 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
|
458 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
|
459 vim_free(p); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
460 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
461 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
|
462 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
463 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
|
464 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
|
465 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
466 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
|
467 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
|
468 } |
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 #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
|
471 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
|
472 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
473 // 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
|
474 // 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
|
475 // set. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
476 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
|
477 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
|
478 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
|
479 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
|
480 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
|
481 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
|
482 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
|
483 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
|
484 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
|
485 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
|
486 (void)init_chartab(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
487 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
488 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
489 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
490 #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
|
491 // 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
|
492 // GetConsoleCP() set 'termencoding'. |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
493 if ( |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
494 # ifdef VIMDLL |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
495 (!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
|
496 # endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
497 GetACP() != GetConsoleCP()) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
498 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
499 char buf[50]; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
500 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
501 // 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
|
502 // 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
|
503 if (GetConsoleCP() == 0) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
504 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
|
505 else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
506 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
|
507 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
|
508 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
|
509 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
510 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
|
511 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
|
512 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
513 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
|
514 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
|
515 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
516 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
|
517 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
|
518 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
519 else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
520 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
|
521 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
522 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
523 #if defined(MSWIN) |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
524 // $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
|
525 init_homedir(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
526 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
527 } |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
528 else |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
529 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
530 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
|
531 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
|
532 } |
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 * 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
|
537 * |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
538 * 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
|
539 * 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
|
540 */ |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
541 void |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
542 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
|
543 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
544 #ifdef FEAT_LANGMAP |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
545 langmap_init(); |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
546 #endif |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
547 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
548 // 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
|
549 p_cp = TRUE; |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
550 |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
551 // 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
|
552 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
|
553 { |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
554 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
|
555 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
|
556 } |
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 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
|
559 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
|
560 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
|
561 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
|
562 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
|
563 #ifdef FEAT_POSTSCRIPT |
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
564 set_init_default_printexpr(); |
7 | 565 #endif |
566 | |
567 /* | |
568 * Set all the options (except the terminal options) to their default | |
569 * value. Also set the global value for local options. | |
570 */ | |
571 set_options_default(0); | |
572 | |
27509
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
573 #ifdef UNIX |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
574 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
|
575 #endif |
ef32ea9fbe6c
patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
576 |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
577 #ifdef CLEAN_RUNTIMEPATH |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
578 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
|
579 set_init_clean_rtp(); |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
580 #endif |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13314
diff
changeset
|
581 |
7 | 582 #ifdef FEAT_GUI |
583 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
|
584 set_option_value_give_err((char_u *)"bg", 0L, (char_u *)"dark", 0); |
7 | 585 #endif |
586 | |
587 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
|
588 curbuf->b_p_ar = -1; // no local 'autoread' value |
5446 | 589 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
7 | 590 check_buf_options(curbuf); |
591 check_win_options(curwin); | |
592 check_options(); | |
593 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
594 // Must be before option_expand(), because that one needs vim_isIDc() |
7 | 595 didset_options(); |
596 | |
744 | 597 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
598 // 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
|
599 // didset_options() because it only depends on 'encoding'. |
227 | 600 init_spell_chartab(); |
601 #endif | |
602 | |
31962
4efcb5c68112
patch 9.0.1313: some settings use the current codepage instead of 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
31958
diff
changeset
|
603 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
|
604 |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
605 // 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
|
606 set_init_expand_env(); |
7 | 607 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
608 save_file_ff(curbuf); // Buffer is unchanged |
7 | 609 |
610 #if defined(FEAT_ARABIC) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
611 // Detect use of mlterm. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
612 // 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
|
613 // abilities (bidi namely). |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
614 // 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
|
615 // instead of an environment variable due to inheritance. |
7 | 616 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
|
617 set_option_value_give_err((char_u *)"tbidi", 1L, NULL, 0); |
7 | 618 #endif |
619 | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
620 didset_options2(); |
7 | 621 |
31926
6072c1d9fe2a
patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31924
diff
changeset
|
622 set_init_lang_env(); |
7 | 623 |
624 #ifdef FEAT_MULTI_LANG | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
625 // Set the default for 'helplang'. |
7 | 626 set_helplang_default(get_mess_lang()); |
627 #endif | |
628 } | |
629 | |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
630 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
|
631 |
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 * 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
|
634 * utf-8. |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
635 */ |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
636 void |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
637 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
|
638 { |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
639 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
|
640 OPT_FREE, 0); |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
641 } |
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
642 |
7 | 643 /* |
644 * Set an option to its default value. | |
645 * This does not take care of side effects! | |
646 */ | |
647 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
648 set_option_default( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
649 int opt_idx, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
650 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
|
651 int compatible) // use Vi default value |
7 | 652 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
653 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
|
654 int dvi; // index in def_val[] |
7 | 655 long_u flags; |
681 | 656 long_u *flagsp; |
7 | 657 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
658 | |
659 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); | |
660 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
|
661 if (varp != NULL) // skip hidden option, nothing to do for it |
7 | 662 { |
663 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; | |
664 if (flags & P_STRING) | |
665 { | |
24912
02fa8d72e4e3
patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
666 // '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
|
667 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
|
668 set_fencs_unicode(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
669 // 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
|
670 // 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
|
671 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
|
672 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
|
673 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
|
674 else |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
675 { |
f22db93bd887
patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
676 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
|
677 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
|
678 *(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
|
679 options[opt_idx].flags &= ~P_ALLOCED; |
7 | 680 } |
681 } | |
682 else if (flags & P_NUM) | |
683 { | |
1017 | 684 if (options[opt_idx].indir == PV_SCROLL) |
7 | 685 win_comp_scroll(curwin); |
686 else | |
687 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
688 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
|
689 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
690 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
|
691 || (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
|
692 // '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
|
693 // 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
|
694 *(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
|
695 else |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
696 *(long *)varp = def_val; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
697 // May also set global value for local option. |
7 | 698 if (both) |
699 *(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
|
700 def_val; |
7 | 701 } |
702 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
703 else // P_BOOL |
7 | 704 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
705 // 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
|
706 // MSVC |
840 | 707 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; |
1111 | 708 #ifdef UNIX |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
709 // 'modeline' defaults to off for root |
1111 | 710 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) |
711 *(int *)varp = FALSE; | |
712 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
713 // May also set global value for local option. |
7 | 714 if (both) |
715 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | |
716 *(int *)varp; | |
717 } | |
634 | 718 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
719 // The default value is not insecure. |
681 | 720 flagsp = insecure_flag(opt_idx, opt_flags); |
721 *flagsp = *flagsp & ~P_INSECURE; | |
7 | 722 } |
723 | |
724 #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
|
725 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 726 #endif |
727 } | |
728 | |
729 /* | |
730 * 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
|
731 * When "opt_flags" is non-zero skip 'encoding'. |
7 | 732 */ |
733 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
734 set_options_default( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
735 int opt_flags) // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL |
7 | 736 { |
737 int i; | |
738 win_T *wp; | |
671 | 739 tabpage_T *tp; |
7 | 740 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
741 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
|
742 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
|
743 && (opt_flags == 0 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
744 || (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
|
745 # if defined(FEAT_CRYPT) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
746 && 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
|
747 && 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
|
748 # endif |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
749 ))) |
7 | 750 set_option_default(i, opt_flags, p_cp); |
751 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
752 // The 'scroll' option must be computed for all windows. |
671 | 753 FOR_ALL_TAB_WINDOWS(tp, wp) |
7 | 754 win_comp_scroll(wp); |
6205 | 755 parse_cino(curbuf); |
7 | 756 } |
757 | |
758 /* | |
759 * Set the Vi-default value of a string option. | |
760 * 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
|
761 * 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
|
762 */ |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
763 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
|
764 set_string_default_esc(char *name, char_u *val, int escape) |
7 | 765 { |
766 char_u *p; | |
767 int opt_idx; | |
768 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
769 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
|
770 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
|
771 else |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
772 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
|
773 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
|
774 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
775 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
776 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
|
777 if (opt_idx < 0) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
778 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
779 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
780 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
|
781 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
|
782 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
|
783 options[opt_idx].flags |= P_DEF_ALLOCED; |
7 | 784 } |
785 | |
13162
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
786 void |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
787 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
|
788 { |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
789 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
|
790 } |
51521b8a370c
patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents:
13154
diff
changeset
|
791 |
7 | 792 /* |
22234
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
793 * 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
|
794 * "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
|
795 */ |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
796 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
|
797 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
|
798 { |
22242
f7871f02ddcd
patch 8.2.1670: a couple of gcc compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
22234
diff
changeset
|
799 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
|
800 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
|
801 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
|
802 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
803 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
|
804 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
|
805 |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
806 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
|
807 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
|
808 { |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
809 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
|
810 || 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
|
811 || (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
|
812 && 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
|
813 && (!(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
|
814 || 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
|
815 || 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
|
816 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
|
817 // 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
|
818 // 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
|
819 // 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
|
820 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
|
821 && 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
|
822 && 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
|
823 || (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
|
824 && 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
|
825 ++bs; |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
826 else |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
827 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
|
828 } |
b5abb88d5700
patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents:
21672
diff
changeset
|
829 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
|
830 } |
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 /* |
7 | 833 * Set the Vi-default value of a number option. |
834 * Used for 'lines' and 'columns'. | |
835 */ | |
836 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
837 set_number_default(char *name, long val) |
7 | 838 { |
838 | 839 int opt_idx; |
840 | |
841 opt_idx = findoption((char_u *)name); | |
842 if (opt_idx >= 0) | |
840 | 843 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 844 } |
845 | |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
846 #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
|
847 /* |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
848 * 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
|
849 * 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
|
850 * 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
|
851 */ |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
852 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
|
853 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
|
854 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
855 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
|
856 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
|
857 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
858 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
|
859 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
|
860 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
|
861 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
862 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
|
863 { |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
864 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
|
865 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
|
866 |
283037126560
patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
867 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
|
868 && (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
|
869 && !(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
|
870 && !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
|
871 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
|
872 } |
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 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
|
875 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
|
876 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
|
877 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
878 #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
|
879 |
359 | 880 #if defined(EXITFREE) || defined(PROTO) |
881 /* | |
882 * Free all options. | |
883 */ | |
884 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
885 free_all_options(void) |
359 | 886 { |
887 int i; | |
888 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
889 for (i = 0; !istermoption_idx(i); i++) |
359 | 890 { |
891 if (options[i].indir == PV_NONE) | |
892 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
893 // 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
|
894 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL) |
359 | 895 free_string_option(*(char_u **)options[i].var); |
896 if (options[i].flags & P_DEF_ALLOCED) | |
897 free_string_option(options[i].def_val[VI_DEFAULT]); | |
898 } | |
899 else if (options[i].var != VAR_WIN | |
900 && (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
|
901 // 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
|
902 clear_string_option((char_u **)options[i].var); |
359 | 903 } |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
904 free_operatorfunc_option(); |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26193
diff
changeset
|
905 free_tagfunc_option(); |
359 | 906 } |
907 #endif | |
908 | |
909 | |
7 | 910 /* |
911 * Initialize the options, part two: After getting Rows and Columns and | |
912 * setting 'term'. | |
913 */ | |
914 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
915 set_init_2(void) |
7 | 916 { |
164 | 917 int idx; |
918 | |
7 | 919 /* |
12718
f8f505ffc0a6
patch 8.0.1237: ":set scroll&" often gives an error
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
920 * 'scroll' defaults to half the window height. The stored default is zero, |
f8f505ffc0a6
patch 8.0.1237: ":set scroll&" often gives an error
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
921 * which results in the actual value computed from the window height. |
7 | 922 */ |
168 | 923 idx = findoption((char_u *)"scroll"); |
838 | 924 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
168 | 925 set_option_default(idx, OPT_LOCAL, p_cp); |
7 | 926 comp_col(); |
927 | |
164 | 928 /* |
929 * 'window' is only for backwards compatibility with Vi. | |
930 * Default is Rows - 1. | |
931 */ | |
857 | 932 if (!option_was_set((char_u *)"window")) |
164 | 933 p_window = Rows - 1; |
934 set_number_default("window", Rows - 1); | |
935 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
936 // 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
|
937 #if !((defined(MSWIN)) && !defined(FEAT_GUI)) |
671 | 938 /* |
939 * If 'background' wasn't set by the user, try guessing the value, | |
940 * depending on the terminal name. Only need to check for terminals | |
941 * with a dark background, that can handle color. | |
942 */ | |
943 idx = findoption((char_u *)"bg"); | |
838 | 944 if (idx >= 0 && !(options[idx].flags & P_WAS_SET) |
945 && *term_bg_default() == 'd') | |
671 | 946 { |
694 | 947 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
|
948 // 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
|
949 // changed again |
671 | 950 options[idx].flags &= ~P_WAS_SET; |
7 | 951 } |
952 #endif | |
440 | 953 |
954 #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
|
955 parse_shape_opt(SHAPE_CURSOR); // set cursor shapes from 'guicursor' |
440 | 956 #endif |
957 #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
|
958 parse_shape_opt(SHAPE_MOUSE); // set mouse shapes from 'mouseshape' |
440 | 959 #endif |
960 #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
|
961 (void)parse_printoptions(NULL); // parse 'printoptions' default value |
440 | 962 #endif |
7 | 963 } |
964 | |
965 /* | |
966 * Initialize the options, part three: After reading the .vimrc | |
967 */ | |
968 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
969 set_init_3(void) |
7 | 970 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
971 #if defined(UNIX) || defined(MSWIN) |
7 | 972 /* |
973 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. | |
974 * This is done after other initializations, where 'shell' might have been | |
975 * set, but only if they have not been set before. | |
976 */ | |
977 char_u *p; | |
978 int idx_srr; | |
979 int do_srr; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
980 # ifdef FEAT_QUICKFIX |
7 | 981 int idx_sp; |
982 int do_sp; | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
983 # endif |
7 | 984 |
985 idx_srr = findoption((char_u *)"srr"); | |
838 | 986 if (idx_srr < 0) |
987 do_srr = FALSE; | |
988 else | |
989 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
|
990 # ifdef FEAT_QUICKFIX |
7 | 991 idx_sp = findoption((char_u *)"sp"); |
838 | 992 if (idx_sp < 0) |
993 do_sp = FALSE; | |
994 else | |
995 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
|
996 # endif |
5867 | 997 p = get_isolated_shell_name(); |
7 | 998 if (p != NULL) |
999 { | |
1000 /* | |
1001 * Default for p_sp is "| tee", for p_srr is ">". | |
1002 * For known shells it is changed here to include stderr. | |
1003 */ | |
1004 if ( fnamecmp(p, "csh") == 0 | |
1005 || 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
|
1006 # if defined(MSWIN) // also check with .exe extension |
7 | 1007 || fnamecmp(p, "csh.exe") == 0 |
1008 || fnamecmp(p, "tcsh.exe") == 0 | |
1009 # endif | |
1010 ) | |
1011 { | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1012 # if defined(FEAT_QUICKFIX) |
7 | 1013 if (do_sp) |
1014 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
1015 # ifdef MSWIN |
7 | 1016 p_sp = (char_u *)">&"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1017 # else |
7 | 1018 p_sp = (char_u *)"|& tee"; |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1019 # endif |
7 | 1020 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
1021 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1022 # endif |
7 | 1023 if (do_srr) |
1024 { | |
1025 p_srr = (char_u *)">&"; | |
1026 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
1027 } | |
1028 } | |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1029 # ifdef MSWIN |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
1030 // 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
|
1031 // 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
|
1032 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
|
1033 || 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
|
1034 ) |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1035 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1036 # 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
|
1037 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
|
1038 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1039 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
|
1040 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
|
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 |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1043 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
|
1044 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1045 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
|
1046 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
|
1047 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1048 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1049 #endif |
7 | 1050 else |
24600
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
1051 // Always use POSIX shell style redirection if we reach this |
7 | 1052 if ( fnamecmp(p, "sh") == 0 |
1053 || fnamecmp(p, "ksh") == 0 | |
2774 | 1054 || fnamecmp(p, "mksh") == 0 |
1055 || fnamecmp(p, "pdksh") == 0 | |
7 | 1056 || fnamecmp(p, "zsh") == 0 |
836 | 1057 || fnamecmp(p, "zsh-beta") == 0 |
7 | 1058 || fnamecmp(p, "bash") == 0 |
5867 | 1059 || 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
|
1060 || fnamecmp(p, "ash") == 0 |
cb4cb3ff5736
patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents:
24476
diff
changeset
|
1061 || 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
|
1062 || 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
|
1063 # ifdef MSWIN |
7 | 1064 || fnamecmp(p, "cmd") == 0 |
1065 || fnamecmp(p, "sh.exe") == 0 | |
1066 || fnamecmp(p, "ksh.exe") == 0 | |
2774 | 1067 || fnamecmp(p, "mksh.exe") == 0 |
1068 || fnamecmp(p, "pdksh.exe") == 0 | |
7 | 1069 || fnamecmp(p, "zsh.exe") == 0 |
836 | 1070 || fnamecmp(p, "zsh-beta.exe") == 0 |
7 | 1071 || fnamecmp(p, "bash.exe") == 0 |
1072 || 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
|
1073 || 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
|
1074 || fnamecmp(p, "pwsh.exe") == 0 |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1075 # endif |
7 | 1076 ) |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1077 { |
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1078 # if defined(FEAT_QUICKFIX) |
7 | 1079 if (do_sp) |
1080 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
1081 # ifdef MSWIN |
7 | 1082 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
|
1083 # else |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
1084 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
|
1085 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
|
1086 else |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
1087 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
|
1088 # endif |
7 | 1089 options[idx_sp].def_val[VI_DEFAULT] = p_sp; |
1090 } | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7334
diff
changeset
|
1091 # endif |
7 | 1092 if (do_srr) |
1093 { | |
1094 p_srr = (char_u *)">%s 2>&1"; | |
1095 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | |
1096 } | |
1097 } | |
1098 vim_free(p); | |
1099 } | |
1100 #endif | |
1101 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15858
diff
changeset
|
1102 #if defined(MSWIN) |
7 | 1103 /* |
3352 | 1104 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the |
1105 * 'shell' option. | |
7 | 1106 * 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
|
1107 * 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
|
1108 * 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
|
1109 * |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1110 * 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
|
1111 * 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
|
1112 * powershell.exe - "-Command" "\"" |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
1113 * 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
|
1114 * "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
|
1115 * |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1116 * For Win32 p_sxq is set instead of p_shq to include shell redirection. |
7 | 1117 */ |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1118 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
|
1119 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1120 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
|
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 *)"shcf"); |
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_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
|
1126 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
|
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 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
|
1130 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
|
1131 { |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1132 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
|
1133 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
|
1134 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1135 } |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
1136 else if (strstr((char *)gettail(p_sh), "sh") != NULL) |
7 | 1137 { |
1138 int idx3; | |
1139 | |
1140 idx3 = findoption((char_u *)"shcf"); | |
838 | 1141 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 1142 { |
1143 p_shcf = (char_u *)"-c"; | |
1144 options[idx3].def_val[VI_DEFAULT] = p_shcf; | |
1145 } | |
1146 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1147 // Somehow Win32 requires the quotes around the redirection too |
7 | 1148 idx3 = findoption((char_u *)"sxq"); |
838 | 1149 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
7 | 1150 { |
1151 p_sxq = (char_u *)"\""; | |
1152 options[idx3].def_val[VI_DEFAULT] = p_sxq; | |
1153 } | |
1154 } | |
3352 | 1155 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL) |
1156 { | |
1157 int idx3; | |
1158 | |
1159 /* | |
1160 * cmd.exe on Windows will strip the first and last double quote given | |
1161 * on the command line, e.g. most of the time things like: | |
1162 * cmd /c "my path/to/echo" "my args to echo" | |
1163 * become: | |
1164 * my path/to/echo" "my args to echo | |
1165 * when executed. | |
1166 * | |
3357 | 1167 * To avoid this, set shellxquote to surround the command in |
1168 * parenthesis. This appears to make most commands work, without | |
1169 * breaking commands that worked previously, such as | |
1170 * '"path with spaces/cmd" "a&b"'. | |
3352 | 1171 */ |
1172 idx3 = findoption((char_u *)"sxq"); | |
1173 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
1174 { | |
3357 | 1175 p_sxq = (char_u *)"("; |
3352 | 1176 options[idx3].def_val[VI_DEFAULT] = p_sxq; |
1177 } | |
1178 | |
1179 idx3 = findoption((char_u *)"shcf"); | |
1180 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
1181 { | |
3357 | 1182 p_shcf = (char_u *)"/c"; |
3352 | 1183 options[idx3].def_val[VI_DEFAULT] = p_shcf; |
1184 } | |
1185 } | |
7 | 1186 #endif |
1187 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11107
diff
changeset
|
1188 if (BUFEMPTY()) |
8659
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1189 { |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1190 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
|
1191 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1192 // 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
|
1193 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
|
1194 set_fileformat(default_fileformat(), OPT_LOCAL); |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1195 } |
72e2f387466f
commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1196 |
7 | 1197 set_title_defaults(); |
1198 } | |
1199 | |
1200 #if defined(FEAT_MULTI_LANG) || defined(PROTO) | |
1201 /* | |
1202 * When 'helplang' is still at its default value, set it to "lang". | |
1203 * Only the first two characters of "lang" are used. | |
1204 */ | |
1205 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1206 set_helplang_default(char_u *lang) |
7 | 1207 { |
1208 int idx; | |
1209 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
1210 if (lang == NULL || STRLEN(lang) < 2) // safety check |
7 | 1211 return; |
1212 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
|
1213 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
|
1214 return; |
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 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
|
1217 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
|
1218 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
|
1219 if (p_hlg == NULL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1220 p_hlg = empty_option; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1221 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1222 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1223 // 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
|
1224 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
|
1225 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1226 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
|
1227 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
|
1228 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1229 // 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
|
1230 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
|
1231 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1232 p_hlg[0] = 'e'; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1233 p_hlg[1] = 'n'; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1234 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1235 p_hlg[2] = NUL; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1236 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1237 options[idx].flags |= P_ALLOCED; |
7 | 1238 } |
1239 #endif | |
1240 | |
1241 /* | |
1242 * 'title' and 'icon' only default to true if they have not been set or reset | |
1243 * in .vimrc and we can read the old value. | |
1244 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if | |
1245 * they can be reset. This reduces startup time when using X on a remote | |
1246 * machine. | |
1247 */ | |
1248 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1249 set_title_defaults(void) |
7 | 1250 { |
1251 int idx1; | |
1252 long val; | |
1253 | |
1254 /* | |
1255 * If GUI is (going to be) used, we can always set the window title and | |
1256 * icon name. Saves a bit of time, because the X11 display server does | |
1257 * not need to be contacted. | |
1258 */ | |
1259 idx1 = findoption((char_u *)"title"); | |
838 | 1260 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) |
7 | 1261 { |
1262 #ifdef FEAT_GUI | |
1263 if (gui.starting || gui.in_use) | |
1264 val = TRUE; | |
1265 else | |
1266 #endif | |
1267 val = mch_can_restore_title(); | |
840 | 1268 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; |
7 | 1269 p_title = val; |
1270 } | |
1271 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
|
1272 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
|
1273 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1274 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1275 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1276 |
7 | 1277 #ifdef FEAT_GUI |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1278 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
|
1279 val = TRUE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1280 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1281 #endif |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
1282 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
|
1283 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
|
1284 p_icon = val; |
7 | 1285 } |
1286 | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1287 void |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1288 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
|
1289 { |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1290 int flags = 0; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1291 |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1292 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
|
1293 flags = OPT_LOCAL; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1294 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
|
1295 flags = OPT_GLOBAL; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1296 #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
|
1297 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
|
1298 ex_options(eap); |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1299 else |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1300 #endif |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1301 { |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1302 if (eap->forceit) |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1303 flags |= OPT_ONECOLUMN; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1304 (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
|
1305 } |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1306 } |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
1307 |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1308 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1309 * :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
|
1310 */ |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1311 typedef enum { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1312 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
|
1313 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
|
1314 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
|
1315 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
|
1316 } 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
|
1317 |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1318 typedef enum { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1319 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
|
1320 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
|
1321 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
|
1322 } 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
|
1323 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1324 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1325 * 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
|
1326 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1327 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
|
1328 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
|
1329 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1330 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
|
1331 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
|
1332 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1333 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
|
1334 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1335 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
|
1336 arg += 2; |
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 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
|
1339 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1340 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
|
1341 arg += 3; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1342 } |
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 *argp = arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1345 return prefix; |
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 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1348 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1349 * 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
|
1350 * 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
|
1351 * 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
|
1352 * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1353 * 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
|
1354 * 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
|
1355 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1356 static int |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1357 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
|
1358 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1359 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
|
1360 int len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1361 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
|
1362 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1363 if (*arg == '<') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1364 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1365 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
|
1366 // 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
|
1367 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
|
1368 len = 5; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1369 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1370 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1371 len = 1; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1372 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
|
1373 ++len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1374 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1375 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
|
1376 return FAIL; |
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 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
|
1379 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
|
1380 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
|
1381 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
|
1382 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
|
1383 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
|
1384 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1385 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1386 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1387 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
|
1388 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1389 len = 0; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1390 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1391 * The two characters after "t_" may not be alphanumeric. |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1392 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1393 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
|
1394 len = 4; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1395 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1396 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
|
1397 ++len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1398 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
|
1399 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
|
1400 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
|
1401 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
|
1402 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
|
1403 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
|
1404 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1405 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1406 *keyp = key; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1407 *lenp = len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1408 *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
|
1409 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1410 return OK; |
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 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1413 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1414 * 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
|
1415 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1416 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
|
1417 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
|
1418 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1419 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
|
1420 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1421 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
|
1422 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1423 if (*arg == '+') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1424 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
|
1425 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
|
1426 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
|
1427 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
|
1428 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
|
1429 } |
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 return op; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1432 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1433 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1434 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1435 * 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
|
1436 * 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
|
1437 * 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
|
1438 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1439 static int |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1440 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
|
1441 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1442 // 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
|
1443 // 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
|
1444 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
|
1445 && (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
|
1446 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1447 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1448 // 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
|
1449 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
|
1450 && 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
|
1451 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1452 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1453 // 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
|
1454 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
|
1455 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1456 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
|
1457 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1458 *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
|
1459 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1460 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1461 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
|
1462 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1463 *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
|
1464 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1465 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1466 #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
|
1467 // 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
|
1468 // '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
|
1469 // "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
|
1470 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
|
1471 && 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
|
1472 && ( |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1473 # 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
|
1474 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
|
1475 # endif |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1476 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
|
1477 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1478 #endif |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1479 } |
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 #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
|
1482 // 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
|
1483 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
|
1484 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1485 *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
|
1486 return FAIL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1487 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1488 #endif |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1489 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1490 return OK; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1491 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
1492 |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1493 /* |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1494 * 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
|
1495 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1496 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
|
1497 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
|
1498 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
|
1499 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
|
1500 int flags, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1501 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
|
1502 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1503 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
|
1504 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1505 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
|
1506 ? 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
|
1507 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
|
1508 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1509 // 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
|
1510 #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
|
1511 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
|
1512 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
|
1513 else |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1514 #endif |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1515 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
|
1516 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1517 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
|
1518 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
|
1519 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1520 // 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
|
1521 // 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
|
1522 // later |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1523 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
|
1524 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
|
1525 else |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1526 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1527 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
|
1528 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
|
1529 s = newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1530 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
|
1531 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1532 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1533 return newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1534 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1535 |
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 * 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
|
1538 * 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
|
1539 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1540 static void |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1541 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
|
1542 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
|
1543 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
|
1544 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
|
1545 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
|
1546 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
|
1547 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1548 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
|
1549 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1550 switch (i) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1551 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1552 case 0: |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1553 *(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
|
1554 break; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1555 case 1: |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1556 *(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
|
1557 break; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1558 case 2: |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1559 *(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
|
1560 break; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1561 case 3: |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1562 *(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
|
1563 break; |
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 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
|
1566 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
|
1567 *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
|
1568 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
|
1569 *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
|
1570 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
|
1571 *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
|
1572 *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
|
1573 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1574 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1575 /* |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1576 * 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
|
1577 * 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
|
1578 * 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
|
1579 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1580 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
|
1581 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
|
1582 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1583 *whichwrap = NUL; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1584 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
|
1585 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
|
1586 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
|
1587 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
|
1588 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
|
1589 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
|
1590 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
|
1591 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
|
1592 STRCAT(whichwrap, "<,>,"); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1593 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
|
1594 STRCAT(whichwrap, "[,],"); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1595 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
|
1596 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
|
1597 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1598 return whichwrap; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1599 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1600 |
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 * 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
|
1603 * 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
|
1604 * backslashes. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1605 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1606 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
|
1607 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
|
1608 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
|
1609 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
|
1610 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
|
1611 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
|
1612 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1613 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
|
1614 unsigned newlen; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1615 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
|
1616 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
|
1617 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1618 // 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
|
1619 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
|
1620 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
|
1621 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
|
1622 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
|
1623 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
|
1624 return NULL; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1625 s = newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1626 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1627 // 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
|
1628 // 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
|
1629 // 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
|
1630 // 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
|
1631 // 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
|
1632 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
|
1633 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1634 int i; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1635 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1636 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
|
1637 #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
|
1638 && !((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
|
1639 && 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
|
1640 && !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
|
1641 && (arg[1] != '\\' |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1642 || (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
|
1643 #endif |
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 ++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
|
1646 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
|
1647 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1648 // 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
|
1649 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
|
1650 arg += i; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1651 s += i; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1652 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1653 else |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1654 *s++ = *arg++; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1655 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1656 *s = NUL; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1657 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1658 *argp = arg; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1659 return newval; |
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 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1662 /* |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1663 * 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
|
1664 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1665 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
|
1666 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
|
1667 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
|
1668 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
|
1669 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
|
1670 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
|
1671 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1672 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
|
1673 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
|
1674 return newval; |
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 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
|
1677 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
|
1678 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
|
1679 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
|
1680 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1681 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
|
1682 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
|
1683 return NULL; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1684 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1685 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
|
1686 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1687 return newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1688 } |
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 /* |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1691 * 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
|
1692 * needed. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1693 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1694 static void |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1695 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
|
1696 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
|
1697 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
|
1698 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
|
1699 int flags) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1700 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1701 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
|
1702 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1703 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
|
1704 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
|
1705 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1706 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
|
1707 // 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
|
1708 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
|
1709 && (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
|
1710 && 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
|
1711 && 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
|
1712 len--; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1713 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
|
1714 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
|
1715 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1716 else |
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 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
|
1719 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
|
1720 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1721 if (comma) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1722 newval[len] = ','; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1723 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1724 |
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 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
|
1727 * 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
|
1728 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1729 static void |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1730 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
|
1731 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
|
1732 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
|
1733 int flags, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1734 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
|
1735 int len) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1736 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1737 // 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
|
1738 // 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
|
1739 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
|
1740 if (*strval) |
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 // 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
|
1743 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
|
1744 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1745 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
|
1746 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1747 // 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
|
1748 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
|
1749 ++len; |
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 else |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1752 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1753 // 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
|
1754 --strval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1755 ++len; |
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 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1758 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
|
1759 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1760 } |
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 /* |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1763 * 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
|
1764 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1765 static void |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1766 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
|
1767 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1768 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
|
1769 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1770 // 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
|
1771 while (*s) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1772 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1773 // 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
|
1774 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
|
1775 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1776 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
|
1777 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1778 // 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
|
1779 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
|
1780 continue; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1781 } |
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 else |
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 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
|
1786 && 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
|
1787 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1788 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
|
1789 continue; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1790 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1791 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1792 ++s; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1793 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1794 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1795 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1796 /* |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1797 * 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
|
1798 * 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
|
1799 * set {opt}& |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1800 * set {opt}< |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1801 * 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
|
1802 * 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
|
1803 */ |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1804 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
|
1805 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
|
1806 int nextchar, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1807 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
|
1808 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
|
1809 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
|
1810 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
|
1811 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
|
1812 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
|
1813 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
|
1814 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
|
1815 int flags, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1816 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
|
1817 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1818 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
|
1819 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
|
1820 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
|
1821 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
|
1822 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
|
1823 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
|
1824 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
|
1825 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
|
1826 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
|
1827 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
|
1828 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1829 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
|
1830 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
|
1831 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
|
1832 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
|
1833 &(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
|
1834 else |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1835 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1836 ++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
|
1837 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1838 // 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
|
1839 // 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
|
1840 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
|
1841 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1842 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
|
1843 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
|
1844 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1845 // 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
|
1846 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
|
1847 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
|
1848 &oldval); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1849 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
|
1850 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1851 // 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
|
1852 // 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
|
1853 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
|
1854 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
|
1855 arg = t; |
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 // 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
|
1858 // 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
|
1859 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
|
1860 || 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
|
1861 ++arg; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1862 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1863 // 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
|
1864 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
|
1865 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
|
1866 goto done; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1867 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1868 // 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
|
1869 // 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
|
1870 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
|
1871 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1872 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
|
1873 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
|
1874 goto done; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1875 } |
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 // 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
|
1878 // avoid duplicates |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1879 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
|
1880 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
|
1881 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1882 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
|
1883 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
|
1884 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1885 // 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
|
1886 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
|
1887 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1888 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
|
1889 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
|
1890 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1891 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1892 // 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
|
1893 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
|
1894 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
|
1895 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1896 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1897 // 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
|
1898 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
|
1899 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
|
1900 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
|
1901 // 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
|
1902 // 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
|
1903 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
|
1904 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1905 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
|
1906 // 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
|
1907 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
|
1908 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1909 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1910 done: |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1911 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
|
1912 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
|
1913 *argp = arg; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1914 *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
|
1915 *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
|
1916 *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
|
1917 *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
|
1918 *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
|
1919 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1920 return newval; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1921 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1922 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1923 /* |
30403
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1924 * 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
|
1925 * 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
|
1926 */ |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1927 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
|
1928 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
|
1929 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
|
1930 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
|
1931 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
|
1932 int nextchar, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1933 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
|
1934 int flags, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1935 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
|
1936 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
|
1937 char *errbuf, |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1938 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
|
1939 char **errmsg) |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1940 { |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
1941 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
|
1942 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
|
1943 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
|
1944 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
|
1945 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
|
1946 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
|
1947 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
|
1948 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
|
1949 #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
|
1950 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
|
1951 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
|
1952 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
|
1953 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
|
1954 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1955 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1956 // 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
|
1957 // 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
|
1958 // 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
|
1959 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
|
1960 && ((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
|
1961 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
|
1962 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1963 // 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
|
1964 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
|
1965 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1966 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
|
1967 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1968 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
|
1969 &(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
|
1970 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
|
1971 &(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
|
1972 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1973 // 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
|
1974 // 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
|
1975 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
|
1976 && 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
|
1977 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
|
1978 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1979 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1980 // 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
|
1981 // 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
|
1982 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
|
1983 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
|
1984 else |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1985 origval = oldval; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1986 |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1987 // 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
|
1988 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
|
1989 &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
|
1990 cp_val); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1991 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
1992 // 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
|
1993 *(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
|
1994 if (newval == NULL) |
b08c410578a5
patch 9.0.1311: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31952
diff
changeset
|
1995 *(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
|
1996 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1997 #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
|
1998 if (!starting |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
1999 # 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
|
2000 && 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
|
2001 # endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2002 && 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
|
2003 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2004 // 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
|
2005 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
|
2006 // 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
|
2007 // autocommands. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2008 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
|
2009 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
|
2010 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
|
2011 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
|
2012 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
|
2013 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2014 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2015 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2016 { |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2017 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
|
2018 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
|
2019 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2020 // 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
|
2021 // 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
|
2022 // 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
|
2023 // replaced. |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2024 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
|
2025 #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
|
2026 || sandbox != 0 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2027 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2028 || (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
|
2029 secure = 1; |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2030 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2031 // 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
|
2032 // 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
|
2033 // 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
|
2034 *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
|
2035 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
|
2036 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
|
2037 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2038 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
|
2039 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2040 |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2041 #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
|
2042 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
|
2043 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
|
2044 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
|
2045 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
|
2046 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
|
2047 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
|
2048 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
|
2049 #endif |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2050 |
30409
aea53db7eeec
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents:
30403
diff
changeset
|
2051 *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
|
2052 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
|
2053 } |
42d592459521
patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
30226
diff
changeset
|
2054 |
7 | 2055 /* |
31908
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
2056 * 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
|
2057 * 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
|
2058 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2059 static char * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2060 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
|
2061 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
|
2062 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
|
2063 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
|
2064 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
|
2065 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
|
2066 int nextchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2067 int afterchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2068 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
|
2069 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2070 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2071 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
|
2072 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2073 if (nextchar == '=' || nextchar == ':') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2074 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
|
2075 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
|
2076 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
|
2077 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2078 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2079 * ":set opt!": invert |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2080 * ":set opt&": reset to default value |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2081 * ":set opt<": reset to global value |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2082 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2083 if (nextchar == '!') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2084 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
|
2085 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
|
2086 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
|
2087 ((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
|
2088 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
|
2089 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2090 // 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
|
2091 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
|
2092 value = -1; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2093 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2094 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
|
2095 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2096 else |
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 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2099 * ":set invopt": invert |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2100 * ":set opt" or ":set noopt": set or reset |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2101 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2102 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
|
2103 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
|
2104 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
|
2105 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
|
2106 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2107 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
|
2108 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2109 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2110 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
|
2111 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2112 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2113 /* |
31908
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
2114 * 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
|
2115 * 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
|
2116 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2117 static char * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2118 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
|
2119 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
|
2120 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
|
2121 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
|
2122 int nextchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2123 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
|
2124 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
|
2125 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
|
2126 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
|
2127 char *errbuf, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2128 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
|
2129 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2130 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
|
2131 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
|
2132 int i; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2133 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
|
2134 |
31908
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
2135 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
|
2136 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
|
2137 // |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2138 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2139 * 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
|
2140 * & 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
|
2141 * < 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
|
2142 * <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
|
2143 * 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
|
2144 * [-]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
|
2145 * other error |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2146 */ |
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 if (nextchar == '&') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2149 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
|
2150 ((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
|
2151 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
|
2152 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2153 // 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
|
2154 // 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
|
2155 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
|
2156 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
|
2157 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2158 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
|
2159 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2160 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
|
2161 && (*arg == '<' |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2162 || *arg == '^' |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2163 || (*arg != NUL |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2164 && (!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
|
2165 && !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
|
2166 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2167 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
|
2168 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
|
2169 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2170 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
|
2171 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2172 } |
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 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
|
2175 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2176 // Allow negative (for 'undolevels'), octal and hex numbers. |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2177 vim_str2nr(arg, NULL, &i, STR2NR_ALL, &value, NULL, 0, TRUE); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2178 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
|
2179 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2180 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
|
2181 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2182 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2183 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2184 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2185 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2186 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
|
2187 goto skip; |
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 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
|
2191 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
|
2192 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
|
2193 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
|
2194 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
|
2195 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
|
2196 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2197 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
|
2198 opt_flags); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2199 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2200 skip: |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2201 *argp = arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2202 return errmsg; |
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 |
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 * 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
|
2207 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2208 static char * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2209 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
|
2210 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2211 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
|
2212 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
|
2213 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2214 if (nextchar == '&') |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2215 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2216 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
|
2217 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
|
2218 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2219 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2220 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2221 ++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
|
2222 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
|
2223 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
|
2224 ++p; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2225 nextchar = *p; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2226 *p = NUL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2227 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
|
2228 *p = nextchar; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2229 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2230 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
|
2231 ttest(FALSE); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2232 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
|
2233 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2234 *argp = arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2235 return NULL; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2236 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2237 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2238 /* |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2239 * 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
|
2240 */ |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2241 static char * |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2242 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
|
2243 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
|
2244 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
|
2245 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
|
2246 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
|
2247 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
|
2248 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
|
2249 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
|
2250 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
|
2251 int nextchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2252 int afterchar, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2253 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
|
2254 int *stopopteval, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2255 char *errbuf, |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2256 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
|
2257 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2258 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
|
2259 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
|
2260 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
|
2261 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2262 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
|
2263 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2264 // boolean option |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2265 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
|
2266 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
|
2267 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
|
2268 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2269 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2270 else |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2271 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2272 // 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
|
2273 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
|
2274 || 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
|
2275 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2276 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
|
2277 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2278 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2279 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2280 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
|
2281 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2282 // numeric option |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2283 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
|
2284 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
|
2285 errbuf, errbuflen); |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2286 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
|
2287 goto skip; |
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 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
|
2290 { |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2291 // 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
|
2292 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
|
2293 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
|
2294 &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
|
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 (errmsg != NULL) |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2297 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2298 *stopopteval = TRUE; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2299 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2300 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2301 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2302 else |
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 // 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
|
2305 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
|
2306 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
|
2307 goto skip; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2308 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2309 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2310 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2311 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
|
2312 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
|
2313 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2314 skip: |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2315 *argp = arg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2316 return errmsg; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2317 } |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2318 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2319 /* |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2320 * 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
|
2321 * 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
|
2322 * 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
|
2323 */ |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2324 static char * |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2325 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
|
2326 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
|
2327 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
|
2328 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
|
2329 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
|
2330 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
|
2331 int *stopopteval, |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2332 char *errbuf, |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2333 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
|
2334 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2335 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
|
2336 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
|
2337 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
|
2338 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
|
2339 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
|
2340 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
|
2341 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
|
2342 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
|
2343 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
|
2344 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
|
2345 int key; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2346 int len; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2347 |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2348 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
|
2349 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
|
2350 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2351 // 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
|
2352 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
|
2353 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
|
2354 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
|
2355 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2356 // 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
|
2357 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
|
2358 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2359 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
|
2360 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2361 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
|
2362 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2363 // 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
|
2364 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
|
2365 || (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
|
2366 && p[1] == '='))) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2367 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2368 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
|
2369 arg = p; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2370 *startarg = p; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2371 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2372 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2373 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2374 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2375 // 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
|
2376 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
|
2377 ++len; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2378 |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2379 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
|
2380 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
|
2381 len++; |
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2382 |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2383 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
|
2384 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2385 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
|
2386 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2387 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
|
2388 && 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
|
2389 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
|
2390 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2391 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
|
2392 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2393 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2394 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2395 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
|
2396 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2397 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
|
2398 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2399 // 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
|
2400 // 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
|
2401 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
|
2402 && (!(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
|
2403 || nextchar == '?')) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2404 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
|
2405 goto skip; |
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 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2408 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
|
2409 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
|
2410 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2411 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2412 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2413 flags = P_STRING; |
31904
a4358b58d3fb
patch 9.0.1284: compiler warnings for uninitialized variables
Bram Moolenaar <Bram@vim.org>
parents:
31902
diff
changeset
|
2414 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
|
2415 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
|
2416 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2417 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
|
2418 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
|
2419 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2420 else |
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 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
|
2423 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
|
2424 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2425 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2426 |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2427 // 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
|
2428 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
|
2429 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2430 |
31904
a4358b58d3fb
patch 9.0.1284: compiler warnings for uninitialized variables
Bram Moolenaar <Bram@vim.org>
parents:
31902
diff
changeset
|
2431 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
|
2432 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
|
2433 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2434 arg += len; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2435 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
|
2436 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2437 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
|
2438 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2439 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
|
2440 arg += 3; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2441 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2442 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
|
2443 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2444 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
|
2445 arg += 2; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2446 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2447 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2448 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
|
2449 && 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
|
2450 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2451 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
|
2452 goto skip; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2453 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2454 } |
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 /* |
31908
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
2457 * Allow '=' and ':' for historical reasons (MSDOS command.com). |
1ae3ad2e3d03
patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
31904
diff
changeset
|
2458 * 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
|
2459 */ |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2460 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
|
2461 || (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
|
2462 && 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
|
2463 && !(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
|
2464 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2465 /* |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2466 * print value |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2467 */ |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2468 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
|
2469 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
|
2470 else |
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 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
|
2473 *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
|
2474 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2475 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
|
2476 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2477 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
|
2478 #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
|
2479 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
|
2480 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2481 // 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
|
2482 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
|
2483 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
|
2484 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
|
2485 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
|
2486 (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
|
2487 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
|
2488 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
|
2489 (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
|
2490 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2491 #endif |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2492 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2493 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2494 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2495 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
|
2496 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2497 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
|
2498 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
|
2499 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2500 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
|
2501 goto skip; |
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 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2504 (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
|
2505 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2506 if (nextchar != '?' |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2507 && 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
|
2508 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
|
2509 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2510 else |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2511 { |
31902
1c5ef864fe4c
patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31886
diff
changeset
|
2512 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
|
2513 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
|
2514 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
|
2515 errbuflen); |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2516 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2517 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2518 skip: |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2519 *argp = arg; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2520 return errmsg; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2521 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2522 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2523 /* |
7 | 2524 * Parse 'arg' for option settings. |
2525 * | |
2526 * 'arg' may be IObuff, but only when no errors can be present and option | |
2527 * does not need to be expanded with option_expand(). | |
2528 * "opt_flags": | |
2529 * 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
|
2530 * 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
|
2531 * 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
|
2532 * 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
|
2533 * 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
|
2534 * 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
|
2535 * OPT_ONECOLUMN do not use multiple columns |
7 | 2536 * |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2537 * Returns FAIL if an error is detected, OK otherwise. |
7 | 2538 */ |
2539 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2540 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
|
2541 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
|
2542 int opt_flags) |
7 | 2543 { |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
2544 char_u *arg = arg_start; |
7 | 2545 int i; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2546 int did_show = FALSE; // already showed one value |
7 | 2547 |
2548 if (*arg == NUL) | |
2549 { | |
2550 showoptions(0, opt_flags); | |
168 | 2551 did_show = TRUE; |
2552 goto theend; | |
7 | 2553 } |
2554 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2555 while (*arg != NUL) // loop to process all options |
7 | 2556 { |
31766
9f1504e36ae9
patch 9.0.1215: using isalpha() adds dependency on current locale
Bram Moolenaar <Bram@vim.org>
parents:
31752
diff
changeset
|
2557 if (STRNCMP(arg, "all", 3) == 0 && !ASCII_ISALPHA(arg[3]) |
36 | 2558 && !(opt_flags & OPT_MODELINE)) |
7 | 2559 { |
2560 /* | |
2561 * ":set all" show all options. | |
2562 * ":set all&" set all options to their default value. | |
2563 */ | |
2564 arg += 3; | |
2565 if (*arg == '&') | |
2566 { | |
2567 ++arg; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2568 // Only for :set command set global value of local options. |
7 | 2569 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
|
2570 didset_options(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2571 didset_options2(); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
2572 redraw_all_later(UPD_CLEAR); |
7 | 2573 } |
2574 else | |
168 | 2575 { |
7 | 2576 showoptions(1, opt_flags); |
168 | 2577 did_show = TRUE; |
2578 } | |
7 | 2579 } |
36 | 2580 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) |
7 | 2581 { |
2582 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
|
2583 show_termcodes(opt_flags); |
168 | 2584 did_show = TRUE; |
7 | 2585 arg += 7; |
2586 } | |
2587 else | |
2588 { | |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2589 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
|
2590 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
|
2591 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
|
2592 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
|
2593 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2594 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
|
2595 &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
|
2596 sizeof(errbuf)); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2597 if (stopopteval) |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2598 break; |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2599 |
7 | 2600 /* |
2601 * Advance to next argument. | |
2602 * - skip until a blank found, taking care of backslashes | |
2603 * - skip blanks | |
2604 * - skip one "=val" argument (for hidden options ":set gfn =xx") | |
2605 */ | |
2606 for (i = 0; i < 2 ; ++i) | |
2607 { | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2608 while (*arg != NUL && !VIM_ISWHITE(*arg)) |
7 | 2609 if (*arg++ == '\\' && *arg != NUL) |
2610 ++arg; | |
2611 arg = skipwhite(arg); | |
2612 if (*arg != '=') | |
2613 break; | |
2614 } | |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2615 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2616 if (errmsg != NULL) |
7 | 2617 { |
31886
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2618 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
|
2619 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
|
2620 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
|
2621 { |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2622 // 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
|
2623 STRCAT(IObuff, ": "); |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2624 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
|
2625 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
|
2626 } |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2627 // 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
|
2628 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
|
2629 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2630 ++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
|
2631 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
|
2632 --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
|
2633 |
b741e5243e58
patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
2634 return FAIL; |
7 | 2635 } |
2636 } | |
2637 | |
2638 arg = skipwhite(arg); | |
2639 } | |
2640 | |
168 | 2641 theend: |
2642 if (silent_mode && did_show) | |
2643 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2644 // After displaying option values in silent mode. |
168 | 2645 silent_mode = FALSE; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2646 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
168 | 2647 msg_putchar('\n'); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2648 cursor_on(); // msg_start() switches it off |
168 | 2649 out_flush(); |
2650 silent_mode = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2651 info_message = FALSE; // use mch_msg(), not mch_errmsg() |
168 | 2652 } |
2653 | |
7 | 2654 return OK; |
2655 } | |
2656 | |
634 | 2657 /* |
2658 * Call this when an option has been given a new value through a user command. | |
2659 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag. | |
2660 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2661 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2662 did_set_option( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2663 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
|
2664 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
|
2665 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
|
2666 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
|
2667 // P_INSECURE flag. |
634 | 2668 { |
681 | 2669 long_u *p; |
2670 | |
634 | 2671 options[opt_idx].flags |= P_WAS_SET; |
2672 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2673 // 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
|
2674 // 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
|
2675 // flag. |
681 | 2676 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
|
2677 if (!value_checked && (secure |
634 | 2678 #ifdef HAVE_SANDBOX |
2679 || sandbox != 0 | |
2680 #endif | |
15066
40d9218b2b12
patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2681 || (opt_flags & OPT_MODELINE))) |
681 | 2682 *p = *p | P_INSECURE; |
2683 else if (new_value) | |
2684 *p = *p & ~P_INSECURE; | |
634 | 2685 } |
2686 | |
7 | 2687 /* |
2688 * Convert a key name or string into a key value. | |
2689 * 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
|
2690 * 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
|
2691 */ |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2692 int |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2693 string_to_key(char_u *arg, int multi_byte) |
7 | 2694 { |
2695 if (*arg == '<') | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
2696 return find_key_option(arg + 1, TRUE); |
7 | 2697 if (*arg == '^') |
2698 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
|
2699 if (multi_byte) |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2700 return PTR2CHAR(arg); |
7 | 2701 return *arg; |
2702 } | |
2703 | |
2704 /* | |
2705 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call | |
2706 * maketitle() to create and display it. | |
2707 * When switching the title or icon off, call mch_restore_title() to get | |
2708 * the old value back. | |
2709 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2710 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
|
2711 did_set_title(void) |
7 | 2712 { |
2713 if (starting != NO_SCREEN | |
2714 #ifdef FEAT_GUI | |
2715 && !gui.starting | |
2716 #endif | |
2717 ) | |
2718 maketitle(); | |
2719 } | |
2720 | |
2721 /* | |
2722 * set_options_bin - called when 'bin' changes value. | |
2723 */ | |
2724 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2725 set_options_bin( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2726 int oldval, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2727 int newval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2728 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 2729 { |
2730 /* | |
2731 * The option values that are changed when 'bin' changes are | |
2732 * copied when 'bin is set and restored when 'bin' is reset. | |
2733 */ | |
2734 if (newval) | |
2735 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2736 if (!oldval) // switched on |
7 | 2737 { |
2738 if (!(opt_flags & OPT_GLOBAL)) | |
2739 { | |
2740 curbuf->b_p_tw_nobin = curbuf->b_p_tw; | |
2741 curbuf->b_p_wm_nobin = curbuf->b_p_wm; | |
2742 curbuf->b_p_ml_nobin = curbuf->b_p_ml; | |
2743 curbuf->b_p_et_nobin = curbuf->b_p_et; | |
2744 } | |
2745 if (!(opt_flags & OPT_LOCAL)) | |
2746 { | |
2747 p_tw_nobin = p_tw; | |
2748 p_wm_nobin = p_wm; | |
2749 p_ml_nobin = p_ml; | |
2750 p_et_nobin = p_et; | |
2751 } | |
2752 } | |
2753 | |
2754 if (!(opt_flags & OPT_GLOBAL)) | |
2755 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2756 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
|
2757 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
|
2758 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
|
2759 curbuf->b_p_et = 0; // no expandtab |
7 | 2760 } |
2761 if (!(opt_flags & OPT_LOCAL)) | |
2762 { | |
2763 p_tw = 0; | |
2764 p_wm = 0; | |
2765 p_ml = FALSE; | |
2766 p_et = FALSE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2767 p_bin = TRUE; // needed when called for the "-b" argument |
7 | 2768 } |
2769 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2770 else if (oldval) // switched off |
7 | 2771 { |
2772 if (!(opt_flags & OPT_GLOBAL)) | |
2773 { | |
2774 curbuf->b_p_tw = curbuf->b_p_tw_nobin; | |
2775 curbuf->b_p_wm = curbuf->b_p_wm_nobin; | |
2776 curbuf->b_p_ml = curbuf->b_p_ml_nobin; | |
2777 curbuf->b_p_et = curbuf->b_p_et_nobin; | |
2778 } | |
2779 if (!(opt_flags & OPT_LOCAL)) | |
2780 { | |
2781 p_tw = p_tw_nobin; | |
2782 p_wm = p_wm_nobin; | |
2783 p_ml = p_ml_nobin; | |
2784 p_et = p_et_nobin; | |
2785 } | |
2786 } | |
2787 } | |
2788 | |
2789 /* | |
2790 * Expand environment variables for some string options. | |
2791 * These string options cannot be indirect! | |
2792 * If "val" is NULL expand the current value of the option. | |
2793 * Return pointer to NameBuff, or NULL when not expanded. | |
2794 */ | |
2795 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2796 option_expand(int opt_idx, char_u *val) |
7 | 2797 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2798 // if option doesn't need expansion nothing to do |
7 | 2799 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) |
2800 return NULL; | |
2801 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2802 // 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
|
2803 // expand_env() would truncate the string. |
7 | 2804 if (val != NULL && STRLEN(val) > MAXPATHL) |
2805 return NULL; | |
2806 | |
2807 if (val == NULL) | |
2808 val = *(char_u **)options[opt_idx].var; | |
2809 | |
2810 /* | |
2811 * Expanding this with NameBuff, expand_env() must not be passed IObuff. | |
2812 * Escape spaces when expanding 'tags', they are used to separate file | |
2813 * names. | |
374 | 2814 * For 'spellsuggest' expand after "file:". |
7 | 2815 */ |
2816 expand_env_esc(val, NameBuff, MAXPATHL, | |
1408 | 2817 (char_u **)options[opt_idx].var == &p_tags, FALSE, |
744 | 2818 #ifdef FEAT_SPELL |
374 | 2819 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : |
2820 #endif | |
2821 NULL); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2822 if (STRCMP(NameBuff, val) == 0) // they are the same |
7 | 2823 return NULL; |
2824 | |
2825 return NameBuff; | |
2826 } | |
2827 | |
2828 /* | |
2829 * After setting various option values: recompute variables that depend on | |
2830 * option values. | |
2831 */ | |
2832 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2833 didset_options(void) |
7 | 2834 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2835 // initialize the table for 'iskeyword' et.al. |
7 | 2836 (void)init_chartab(); |
2837 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2838 didset_string_options(); |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2839 |
744 | 2840 #ifdef FEAT_SPELL |
484 | 2841 (void)spell_check_msm(); |
374 | 2842 (void)spell_check_sps(); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
2843 (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
|
2844 (void)did_set_spell_option(TRUE); |
344 | 2845 #endif |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2846 // 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
|
2847 (void)did_set_cedit(NULL); |
5995 | 2848 #ifdef FEAT_LINEBREAK |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2849 // 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
|
2850 did_set_breakat(NULL); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2851 #endif |
18156
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
2852 after_copy_winopt(curwin); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2853 } |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2854 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2855 /* |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2856 * More side effects of setting options. |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2857 */ |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2858 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2859 didset_options2(void) |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2860 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2861 // Initialize the highlight_attr[] table. |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2862 (void)highlight_changed(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2863 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2864 // Parse default for 'wildmode' |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2865 check_opt_wim(); |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2866 |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2867 // Parse default for 'listchars'. |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2868 (void)set_chars_option(curwin, &curwin->w_p_lcs, TRUE); |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
2869 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2870 // Parse default for 'fillchars'. |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
2871 (void)set_chars_option(curwin, &curwin->w_p_fcs, TRUE); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2872 |
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2873 #ifdef FEAT_CLIPBOARD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2874 // 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
|
2875 (void)did_set_clipboard(NULL); |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
2876 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
2877 #ifdef FEAT_VARTABS |
15858
3a45b89639fb
patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2878 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
|
2879 (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
|
2880 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
|
2881 (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
|
2882 #endif |
7 | 2883 } |
2884 | |
2885 /* | |
2886 * Check for string options that are NULL (normally only termcap options). | |
2887 */ | |
2888 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2889 check_options(void) |
7 | 2890 { |
2891 int opt_idx; | |
2892 | |
2893 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) | |
2894 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL) | |
2895 check_string_option((char_u **)get_varp(&(options[opt_idx]))); | |
2896 } | |
2897 | |
2898 /* | |
14867
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 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
|
2900 * 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
|
2901 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2902 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2903 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
|
2904 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2905 int opt_idx; |
7 | 2906 |
2907 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) | |
2908 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
|
2909 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
|
2910 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
|
2911 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2912 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2913 /* |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2914 * 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
|
2915 * 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
|
2916 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2917 int |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2918 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
|
2919 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2920 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
|
2921 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
2922 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
|
2923 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
|
2924 return opt_idx; |
7 | 2925 } |
2926 | |
634 | 2927 #if defined(FEAT_EVAL) || defined(PROTO) |
2928 /* | |
2929 * Return TRUE when option "opt" was set from a modeline or in secure mode. | |
2930 * Return FALSE when it wasn't. | |
2931 * Return -1 for an unknown option. | |
2932 */ | |
2933 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2934 was_set_insecurely(char_u *opt, int opt_flags) |
634 | 2935 { |
2936 int idx = findoption(opt); | |
681 | 2937 long_u *flagp; |
634 | 2938 |
2939 if (idx >= 0) | |
681 | 2940 { |
2941 flagp = insecure_flag(idx, opt_flags); | |
2942 return (*flagp & P_INSECURE) != 0; | |
2943 } | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
2944 internal_error("was_set_insecurely()"); |
634 | 2945 return -1; |
2946 } | |
681 | 2947 |
2948 /* | |
2949 * Get a pointer to the flags used for the P_INSECURE flag of option | |
2950 * "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
|
2951 * 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
|
2952 * the option is used. |
681 | 2953 */ |
2954 static long_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2955 insecure_flag(int opt_idx, int opt_flags) |
681 | 2956 { |
2957 if (opt_flags & OPT_LOCAL) | |
2958 switch ((int)options[opt_idx].indir) | |
2959 { | |
2960 #ifdef FEAT_STL_OPT | |
694 | 2961 case PV_STL: return &curwin->w_p_stl_flags; |
681 | 2962 #endif |
2963 #ifdef FEAT_EVAL | |
885 | 2964 # ifdef FEAT_FOLDING |
694 | 2965 case PV_FDE: return &curwin->w_p_fde_flags; |
2966 case PV_FDT: return &curwin->w_p_fdt_flags; | |
885 | 2967 # endif |
790 | 2968 # ifdef FEAT_BEVAL |
2969 case PV_BEXPR: return &curbuf->b_p_bexpr_flags; | |
2970 # endif | |
694 | 2971 case PV_INDE: return &curbuf->b_p_inde_flags; |
2972 case PV_FEX: return &curbuf->b_p_fex_flags; | |
681 | 2973 # ifdef FEAT_FIND_ID |
694 | 2974 case PV_INEX: return &curbuf->b_p_inex_flags; |
681 | 2975 # endif |
2976 #endif | |
2977 } | |
2978 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
2979 // Nothing special, return global flags field. |
681 | 2980 return &options[opt_idx].flags; |
2981 } | |
634 | 2982 #endif |
2983 | |
1805 | 2984 /* |
2985 * Redraw the window title and/or tab page text later. | |
2986 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
2987 void redraw_titles(void) |
1805 | 2988 { |
2989 need_maketitle = TRUE; | |
2990 redraw_tabline = TRUE; | |
2991 } | |
2992 | |
7 | 2993 /* |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2994 * 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
|
2995 * 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
|
2996 */ |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17845
diff
changeset
|
2997 int |
16277
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2998 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
|
2999 { |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
3000 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
|
3001 |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
3002 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
|
3003 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
|
3004 return FALSE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
3005 return TRUE; |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
3006 } |
5ef25fa57f71
patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
3007 |
681 | 3008 #if defined(FEAT_EVAL) || defined(PROTO) |
3009 /* | |
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
|
3010 * Set the script_ctx for an option, taking care of setting the buffer- or |
694 | 3011 * window-local value. |
681 | 3012 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
3013 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
|
3014 set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx) |
694 | 3015 { |
3016 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; | |
3017 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
|
3018 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
|
3019 |
20269
246101db63a4
patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents:
20237
diff
changeset
|
3020 // 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
|
3021 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
|
3022 new_script_ctx.sc_lnum += SOURCING_LNUM; |
694 | 3023 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3024 // 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
|
3025 // in the buffer or window structure. |
694 | 3026 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
|
3027 options[opt_idx].script_ctx = new_script_ctx; |
694 | 3028 if (both || (opt_flags & OPT_LOCAL)) |
3029 { | |
3030 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
|
3031 curbuf->b_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
694 | 3032 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
|
3033 { |
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
|
3034 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
|
3035 if (both) |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
3036 // 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
|
3037 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
|
3038 new_script_ctx; |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
3039 } |
694 | 3040 } |
681 | 3041 } |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3042 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3043 /* |
27303
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3044 * 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
|
3045 * |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3046 */ |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3047 sctx_T * |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3048 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
|
3049 { |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3050 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
|
3051 |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3052 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
|
3053 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
|
3054 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
|
3055 return NULL; |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3056 } |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3057 |
9e0ac05f579a
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
3058 /* |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3059 * 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
|
3060 * "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
|
3061 * 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
|
3062 */ |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3063 void |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3064 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
|
3065 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3066 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
|
3067 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
|
3068 |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3069 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
|
3070 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
|
3071 else |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3072 { |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3073 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
|
3074 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
|
3075 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
|
3076 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
|
3077 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
|
3078 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
|
3079 } |
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
3080 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
|
3081 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
|
3082 } |
681 | 3083 #endif |
3084 | |
19405
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3085 #if defined(FEAT_EVAL) |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3086 /* |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3087 * Apply the OptionSet autocommand. |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3088 */ |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3089 static void |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3090 apply_optionset_autocmd( |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3091 int opt_idx, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3092 long opt_flags, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3093 long oldval, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3094 long oldval_g, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3095 long newval, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3096 char *errmsg) |
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 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
|
3099 |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3100 // 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
|
3101 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
|
3102 return; |
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 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
|
3105 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
|
3106 oldval_g); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3107 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
|
3108 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
|
3109 (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
|
3110 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
|
3111 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
|
3112 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
|
3113 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
|
3114 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3115 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
|
3116 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
|
3117 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3118 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
|
3119 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3120 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
|
3121 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
|
3122 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3123 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
|
3124 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3125 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
|
3126 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
|
3127 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
|
3128 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3129 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
|
3130 { |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3131 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
|
3132 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
|
3133 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3134 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
|
3135 NULL, FALSE, NULL); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3136 reset_v_option_vars(); |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3137 } |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3138 #endif |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3139 |
7 | 3140 /* |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3141 * Process the updated 'compatible' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3142 */ |
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
|
3143 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
|
3144 did_set_compatible(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
|
3145 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3146 compatible_set(); |
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
|
3147 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
|
3148 } |
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
|
3149 |
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
|
3150 #if defined(FEAT_LANGMAP) || 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
|
3151 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3152 * Process the updated 'langremap' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3153 */ |
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
|
3154 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
|
3155 did_set_langremap(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
|
3156 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3157 // 'langremap' -> !'langnoremap' |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3158 p_lnr = !p_lrm; |
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
|
3159 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3160 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3161 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3162 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3163 * Process the updated 'langnoremap' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3164 */ |
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
|
3165 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
|
3166 did_set_langnoremap(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
|
3167 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3168 // 'langnoremap' -> !'langremap' |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3169 p_lrm = !p_lnr; |
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
|
3170 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
|
3171 } |
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
|
3172 #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
|
3173 |
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
|
3174 #if defined(FEAT_PERSISTENT_UNDO) || 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
|
3175 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3176 * Process the updated 'undofile' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3177 */ |
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
|
3178 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
|
3179 did_set_undofile(optset_T *args) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3180 { |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3181 // Only take action when the option was set. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3182 if (!curbuf->b_p_udf && !p_udf) |
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
|
3183 return NULL; |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3184 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3185 // When reset we do not delete the undo file, the option may be set again |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3186 // without making any changes in between. |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3187 char_u hash[UNDO_HASH_SIZE]; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3188 buf_T *save_curbuf = curbuf; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3189 |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3190 FOR_ALL_BUFFERS(curbuf) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3191 { |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3192 // When 'undofile' is set globally: for every buffer, otherwise |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3193 // only for the current buffer: Try to read in the undofile, |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3194 // if one exists, the buffer wasn't changed and the buffer was |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3195 // loaded |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3196 if ((curbuf == save_curbuf |
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
|
3197 || (args->os_flags & OPT_GLOBAL) |
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
|
3198 || args->os_flags == 0) |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3199 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3200 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3201 #ifdef FEAT_CRYPT |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3202 if (crypt_get_method_nr(curbuf) == CRYPT_M_SOD) |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3203 continue; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3204 #endif |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3205 u_compute_hash(hash); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3206 u_read_undo(NULL, hash, curbuf->b_fname); |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3207 } |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3208 } |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3209 curbuf = save_curbuf; |
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
|
3210 |
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
|
3211 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3212 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3213 #endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3214 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3215 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3216 * Process the updated 'readonly' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3217 */ |
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
|
3218 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
|
3219 did_set_readonly(optset_T *args) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3220 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3221 // when 'readonly' is reset globally, also reset readonlymode |
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
|
3222 if (!curbuf->b_p_ro && (args->os_flags & OPT_LOCAL) == 0) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3223 readonlymode = FALSE; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3224 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3225 // when 'readonly' is set may give W10 again |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3226 if (curbuf->b_p_ro) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3227 curbuf->b_did_warn = FALSE; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3228 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3229 redraw_titles(); |
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
|
3230 |
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
|
3231 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
|
3232 } |
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
|
3233 |
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
|
3234 #if 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
|
3235 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3236 * Process the updated 'mousehide' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3237 */ |
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
|
3238 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
|
3239 did_set_mousehide(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
|
3240 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3241 if (!p_mh) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3242 gui_mch_mousehide(FALSE); |
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
|
3243 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3244 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3245 #endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3246 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3247 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3248 * Process the updated 'modifiable' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3249 */ |
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
|
3250 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
|
3251 did_set_modifiable(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
|
3252 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3253 // when 'modifiable' is changed, redraw the window title |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3254 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3255 # 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
|
3256 // Cannot set 'modifiable' when in Terminal mode. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3257 if (curbuf->b_p_ma && (term_in_normal_mode() || (bt_terminal(curbuf) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3258 && curbuf->b_term != NULL && !term_is_finished(curbuf)))) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3259 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3260 curbuf->b_p_ma = FALSE; |
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
|
3261 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
|
3262 return e_cannot_make_terminal_with_running_job_modifiable; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3263 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3264 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3265 redraw_titles(); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3266 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3267 return NULL; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3268 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3269 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3270 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3271 * Process the updated 'endoffile' or 'endofline' or 'fixendofline' or 'bomb' |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3272 * option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3273 */ |
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
|
3274 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
|
3275 did_set_eof_eol_fixeol_bomb(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
|
3276 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3277 // redraw the window title and tab page text |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3278 redraw_titles(); |
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
|
3279 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3280 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3281 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3282 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3283 * Process the updated 'binary' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3284 */ |
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
|
3285 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
|
3286 did_set_binary(optset_T *args) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3287 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3288 // when 'bin' is set also set some other options |
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
|
3289 set_options_bin(args->os_oldval.boolean, curbuf->b_p_bin, args->os_flags); |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3290 redraw_titles(); |
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
|
3291 |
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
|
3292 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3293 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3294 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3295 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3296 * Process the updated 'buflisted' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3297 */ |
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
|
3298 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
|
3299 did_set_buflisted(optset_T *args) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3300 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3301 // when 'buflisted' changes, trigger autocommands |
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
|
3302 if (args->os_oldval.boolean != curbuf->b_p_bl) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3303 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3304 NULL, NULL, TRUE, curbuf); |
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
|
3305 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3306 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3307 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3308 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3309 * Process the updated 'swapfile' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3310 */ |
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
|
3311 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
|
3312 did_set_swapfile(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
|
3313 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3314 // when 'swf' is set, create swapfile, when reset remove swapfile |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3315 if (curbuf->b_p_swf && p_uc) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3316 ml_open_file(curbuf); // create the swap file |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3317 else |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3318 // no need to reset curbuf->b_may_swap, ml_open_file() will check |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3319 // buf->b_p_swf |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3320 mf_close_file(curbuf, TRUE); // remove the swap file |
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
|
3321 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3322 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3323 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3324 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3325 * Process the updated 'terse' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3326 */ |
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
|
3327 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
|
3328 did_set_terse(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
|
3329 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3330 char_u *p; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3331 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3332 // when 'terse' is set change 'shortmess' |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3333 p = vim_strchr(p_shm, SHM_SEARCH); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3334 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3335 // insert 's' in p_shm |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3336 if (p_terse && p == NULL) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3337 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3338 STRCPY(IObuff, p_shm); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3339 STRCAT(IObuff, "s"); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3340 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3341 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3342 // remove 's' from p_shm |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3343 else if (!p_terse && p != NULL) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3344 STRMOVE(p, p + 1); |
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
|
3345 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3346 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3347 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3348 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3349 * Process the updated 'paste' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3350 */ |
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
|
3351 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
|
3352 did_set_paste(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
|
3353 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3354 // when 'paste' is set or reset also change other options |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3355 paste_option_changed(); |
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
|
3356 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3357 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3358 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3359 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3360 * Process the updated 'insertmode' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3361 */ |
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
|
3362 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
|
3363 did_set_insertmode(optset_T *args) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3364 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3365 // when 'insertmode' is set from an autocommand need to do work here |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3366 if (p_im) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3367 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3368 if ((State & MODE_INSERT) == 0) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3369 need_start_insertmode = TRUE; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3370 stop_insert_mode = FALSE; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3371 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3372 // only reset if it was set previously |
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
|
3373 else if (args->os_oldval.boolean) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3374 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3375 need_start_insertmode = FALSE; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3376 stop_insert_mode = TRUE; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3377 if (restart_edit != 0 && mode_displayed) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3378 clear_cmdline = TRUE; // remove "(insert)" |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3379 restart_edit = 0; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3380 } |
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
|
3381 |
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
|
3382 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3383 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3384 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3385 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3386 * Process the updated 'ignorecase' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3387 */ |
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
|
3388 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
|
3389 did_set_ignorecase(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
|
3390 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3391 // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3392 if (p_hls) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3393 redraw_all_later(UPD_SOME_VALID); |
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
|
3394 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
|
3395 } |
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
|
3396 |
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
|
3397 #if defined(FEAT_SEARCH_EXTRA) || 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
|
3398 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3399 * Process the updated 'hlsearch' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3400 */ |
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
|
3401 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
|
3402 did_set_hlsearch(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
|
3403 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3404 // when 'hlsearch' is set or reset: reset no_hlsearch |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3405 set_no_hlsearch(FALSE); |
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
|
3406 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3407 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3408 #endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3409 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3410 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3411 * Process the updated 'scrollbind' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3412 */ |
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
|
3413 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
|
3414 did_set_scrollbind(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
|
3415 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3416 // when 'scrollbind' is set: snapshot the current position to avoid a jump |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3417 // at the end of normal_cmd() |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3418 if (!curwin->w_p_scb) |
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
|
3419 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
|
3420 |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3421 do_check_scrollbind(FALSE); |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3422 curwin->w_scbind_pos = curwin->w_topline; |
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
|
3423 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3424 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3425 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3426 #ifdef FEAT_QUICKFIX |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3427 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3428 * Process the updated 'previewwindow' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3429 */ |
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
|
3430 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
|
3431 did_set_previewwindow(optset_T *args) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3432 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3433 if (!curwin->w_p_pvw) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3434 return NULL; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3435 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3436 // There can be only one window with 'previewwindow' set. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3437 win_T *win; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3438 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3439 FOR_ALL_WINDOWS(win) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3440 if (win->w_p_pvw && win != curwin) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3441 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3442 curwin->w_p_pvw = FALSE; |
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
|
3443 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
|
3444 return e_preview_window_already_exists; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3445 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3446 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3447 return NULL; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3448 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3449 #endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3450 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3451 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3452 * Process the updated 'smoothscroll' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3453 */ |
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
|
3454 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
|
3455 did_set_smoothscroll(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
|
3456 { |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3457 if (curwin->w_p_sms) |
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
|
3458 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
|
3459 |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3460 curwin->w_skipcol = 0; |
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3461 changed_line_abv_curs(); |
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
|
3462 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3463 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3464 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3465 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3466 * Process the updated 'textmode' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3467 */ |
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
|
3468 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
|
3469 did_set_textmode(optset_T *args) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3470 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3471 // when 'textmode' is set or reset also change 'fileformat' |
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
|
3472 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, args->os_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
|
3473 |
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
|
3474 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3475 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3476 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3477 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3478 * Process the updated 'textauto' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3479 */ |
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
|
3480 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
|
3481 did_set_textauto(optset_T *args) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3482 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3483 // when 'textauto' is set or reset also change 'fileformats' |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3484 set_string_option_direct((char_u *)"ffs", -1, |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3485 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", |
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
|
3486 OPT_FREE | args->os_flags, 0); |
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
|
3487 |
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
|
3488 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3489 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3490 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3491 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3492 * Process the updated 'lisp' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3493 */ |
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
|
3494 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
|
3495 did_set_lisp(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
|
3496 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3497 // When 'lisp' option changes include/exclude '-' in keyword characters. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3498 (void)buf_init_chartab(curbuf, FALSE); // ignore errors |
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
|
3499 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3500 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3501 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3502 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3503 * Process the updated 'title' or the 'icon' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3504 */ |
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
|
3505 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
|
3506 did_set_title_icon(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
|
3507 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3508 // when 'title' changed, may need to change the title; same for 'icon' |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3509 did_set_title(); |
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
|
3510 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3511 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3512 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3513 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3514 * Process the updated 'modified' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3515 */ |
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
|
3516 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
|
3517 did_set_modified(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
|
3518 { |
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
|
3519 if (!args->os_newval.boolean) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3520 save_file_ff(curbuf); // Buffer is unchanged |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3521 redraw_titles(); |
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
|
3522 modified_was_set = args->os_newval.boolean; |
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
|
3523 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
|
3524 } |
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
|
3525 |
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
|
3526 #if defined(BACKSLASH_IN_FILENAME) || 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
|
3527 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3528 * Process the updated 'shellslash' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3529 */ |
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
|
3530 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
|
3531 did_set_shellslash(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
|
3532 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3533 if (p_ssl) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3534 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3535 psepc = '/'; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3536 psepcN = '\\'; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3537 pseps[0] = '/'; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3538 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3539 else |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3540 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3541 psepc = '\\'; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3542 psepcN = '/'; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3543 pseps[0] = '\\'; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3544 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3545 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3546 // need to adjust the file name arguments and buffer names. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3547 buflist_slash_adjust(); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3548 alist_slash_adjust(); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3549 # 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
|
3550 scriptnames_slash_adjust(); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3551 # endif |
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
|
3552 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3553 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3554 #endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3555 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3556 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3557 * Process the updated 'wrap' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3558 */ |
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
|
3559 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
|
3560 did_set_wrap(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
|
3561 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3562 // If 'wrap' is set, set w_leftcol to zero. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3563 if (curwin->w_p_wrap) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3564 curwin->w_leftcol = 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
|
3565 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3566 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3567 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3568 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3569 * Process the updated 'equalalways' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3570 */ |
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
|
3571 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
|
3572 did_set_equalalways(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
|
3573 { |
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
|
3574 if (p_ea && !args->os_oldval.boolean) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3575 win_equal(curwin, FALSE, 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
|
3576 |
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
|
3577 return NULL; |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3578 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3579 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3580 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3581 * Process the updated 'weirdinvert' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3582 */ |
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
|
3583 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
|
3584 did_set_weirdinvert(optset_T *args) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3585 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3586 // When 'weirdinvert' changed, set/reset 't_xs'. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3587 // Then set 'weirdinvert' according to value of 't_xs'. |
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
|
3588 if (p_wiv && !args->os_oldval.boolean) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3589 T_XS = (char_u *)"y"; |
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
|
3590 else if (!p_wiv && args->os_oldval.boolean) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3591 T_XS = empty_option; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3592 p_wiv = (*T_XS != NUL); |
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
|
3593 |
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
|
3594 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
|
3595 } |
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
|
3596 |
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
|
3597 #if defined(FEAT_BEVAL_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
|
3598 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3599 * Process the updated 'ballooneval' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3600 */ |
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
|
3601 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
|
3602 did_set_ballooneval(optset_T *args) |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3603 { |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3604 if (balloonEvalForTerm) |
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
|
3605 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
|
3606 |
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
|
3607 if (p_beval && !args->os_oldval.boolean) |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3608 gui_mch_enable_beval_area(balloonEval); |
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
|
3609 else if (!p_beval && args->os_oldval.boolean) |
31952
360efef7e5df
patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
31950
diff
changeset
|
3610 gui_mch_disable_beval_area(balloonEval); |
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
|
3611 |
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
|
3612 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
|
3613 } |
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
|
3614 #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
|
3615 |
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
|
3616 #if defined(FEAT_BEVAL_TERM) || 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
|
3617 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3618 * Process the updated 'balloonevalterm' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3619 */ |
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
|
3620 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
|
3621 did_set_balloonevalterm(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
|
3622 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3623 mch_bevalterm_changed(); |
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
|
3624 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
|
3625 } |
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
|
3626 #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
|
3627 |
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
|
3628 #if defined(FEAT_AUTOCHDIR) || 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
|
3629 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3630 * Process the updated 'autochdir' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3631 */ |
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
|
3632 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
|
3633 did_set_autochdir(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
|
3634 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3635 // Change directories when the 'acd' option is set now. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3636 DO_AUTOCHDIR; |
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
|
3637 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
|
3638 } |
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
|
3639 #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
|
3640 |
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
|
3641 #if defined(FEAT_DIFF) || 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
|
3642 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3643 * Process the updated 'diff' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3644 */ |
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
|
3645 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
|
3646 did_set_diff(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
|
3647 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3648 // May add or remove the buffer from the list of diff buffers. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3649 diff_buf_adjust(curwin); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3650 # ifdef FEAT_FOLDING |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3651 if (foldmethodIsDiff(curwin)) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3652 foldUpdateAll(curwin); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3653 # endif |
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
|
3654 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
|
3655 } |
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
|
3656 #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
|
3657 |
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
|
3658 #if defined(HAVE_INPUT_METHOD) || 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
|
3659 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3660 * Process the updated 'imdisable' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3661 */ |
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
|
3662 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
|
3663 did_set_imdisable(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
|
3664 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3665 // Only de-activate it here, it will be enabled when changing mode. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3666 if (p_imdisable) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3667 im_set_active(FALSE); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3668 else if (State & MODE_INSERT) |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3669 // When the option is set from an autocommand, it may need to take |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3670 // effect right away. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3671 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); |
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
|
3672 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
|
3673 } |
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
|
3674 #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
|
3675 |
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
|
3676 #if defined(FEAT_SPELL) || 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
|
3677 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3678 * Process the updated 'spell' option value. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3679 */ |
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
|
3680 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
|
3681 did_set_spell(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
|
3682 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3683 if (curwin->w_p_spell) |
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
|
3684 return parse_spelllang(curwin); |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3685 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3686 return NULL; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3687 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3688 #endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3689 |
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
|
3690 #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
|
3691 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3692 * 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
|
3693 */ |
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
|
3694 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
|
3695 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
|
3696 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3697 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
|
3698 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3699 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
|
3700 { |
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 * 'arabic' is set, handle various sub-settings. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3703 */ |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3704 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
|
3705 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3706 // 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
|
3707 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
|
3708 { |
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_rl = TRUE; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3710 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
|
3711 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3712 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3713 // 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
|
3714 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
|
3715 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3716 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
|
3717 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
|
3718 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3719 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3720 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3721 // 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
|
3722 // set. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3723 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
|
3724 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3725 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
|
3726 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3727 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
|
3728 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
|
3729 #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
|
3730 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
|
3731 #endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3732 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3733 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3734 // set 'delcombine' |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3735 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
|
3736 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3737 # 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
|
3738 // Force-set the necessary keymap for arabic |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3739 errmsg = set_option_value((char_u *)"keymap", |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3740 0L, (char_u *)"arabic", OPT_LOCAL); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3741 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3742 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3743 else |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3744 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3745 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3746 * 'arabic' is reset, handle various sub-settings. |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3747 */ |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3748 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
|
3749 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3750 // 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
|
3751 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
|
3752 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3753 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
|
3754 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
|
3755 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3756 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3757 // '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
|
3758 // 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
|
3759 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3760 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3761 // '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
|
3762 // 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
|
3763 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3764 # 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
|
3765 // 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
|
3766 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
|
3767 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
|
3768 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3769 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3770 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3771 return errmsg; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3772 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3773 #endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3774 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3775 /* |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3776 * 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
|
3777 */ |
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
|
3778 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
|
3779 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
|
3780 { |
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
|
3781 #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
|
3782 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
|
3783 && (*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
|
3784 && 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
|
3785 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3786 // 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
|
3787 // '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
|
3788 // 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
|
3789 // 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
|
3790 // '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
|
3791 // (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
|
3792 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
|
3793 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
|
3794 } |
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
|
3795 #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
|
3796 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
|
3797 } |
31924
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3798 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3799 #ifdef FEAT_TERMGUICOLORS |
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
|
3800 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
|
3801 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
|
3802 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3803 # 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
|
3804 // 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
|
3805 if ( |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3806 # ifdef VIMDLL |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3807 !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
|
3808 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3809 !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
|
3810 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3811 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
|
3812 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
|
3813 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
|
3814 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3815 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
|
3816 swap_tcap(); |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3817 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3818 # 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
|
3819 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
|
3820 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3821 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
|
3822 # 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
|
3823 // 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
|
3824 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
|
3825 { |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3826 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
|
3827 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
|
3828 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
|
3829 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3830 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3831 # 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
|
3832 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
|
3833 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
|
3834 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
|
3835 # endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3836 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3837 return NULL; |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3838 } |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3839 #endif |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3840 |
4789a9d20e7c
patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
31922
diff
changeset
|
3841 /* |
7 | 3842 * Set the value of a boolean option, and take care of side effects. |
3843 * Returns NULL for success, or an error message for an error. | |
3844 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
3845 static char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3846 set_bool_option( |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3847 int opt_idx, // index in options[] table |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3848 char_u *varp, // pointer to the option variable |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3849 int value, // new value |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3850 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 3851 { |
3852 int old_value = *(int *)varp; | |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3853 #if defined(FEAT_EVAL) |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3854 int old_global_value = 0; |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3855 #endif |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
3856 char *errmsg = NULL; |
7 | 3857 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3858 // Disallow changing some options from secure mode |
7 | 3859 if ((secure |
3860 #ifdef HAVE_SANDBOX | |
3861 || sandbox != 0 | |
3862 #endif | |
3863 ) && (options[opt_idx].flags & P_SECURE)) | |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3864 return e_not_allowed_here; |
7 | 3865 |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3866 #if defined(FEAT_EVAL) |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3867 // Save the global value before changing anything. This is needed as for |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3868 // a global-only option setting the "local value" in fact sets the global |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3869 // value (since there is only one value). |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3870 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3871 old_global_value = *(int *)get_varp_scope(&(options[opt_idx]), |
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3872 OPT_GLOBAL); |
17115
1c2d05cb4d1d
patch 8.1.1557: compiler warning for unused variables in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17085
diff
changeset
|
3873 #endif |
17085
620e9011b685
patch 8.1.1542: an OptionSet autocommand does not get enough info
Bram Moolenaar <Bram@vim.org>
parents:
17039
diff
changeset
|
3874 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3875 *(int *)varp = value; // set the new value |
7 | 3876 #ifdef FEAT_EVAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3877 // Remember where the option was set. |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3878 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
7 | 3879 #endif |
3880 | |
634 | 3881 #ifdef FEAT_GUI |
3882 need_mouse_correct = TRUE; | |
3883 #endif | |
3884 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3885 // May set global value for local option. |
7 | 3886 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
3887 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; | |
3888 | |
3889 /* | |
3890 * Handle side effects of changing a bool option. | |
3891 */ | |
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
|
3892 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
|
3893 { |
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
|
3894 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
|
3895 |
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
|
3896 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
|
3897 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
|
3898 args.os_oldval.boolean = 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
|
3899 args.os_newval.boolean = 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
|
3900 args.os_doskip = FALSE; |
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
|
3901 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
|
3902 if (args.os_doskip) |
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
|
3903 return errmsg; |
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
|
3904 } |
7 | 3905 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3906 // after handling side effects, call autocommand |
6935 | 3907 |
7 | 3908 options[opt_idx].flags |= P_WAS_SET; |
3909 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
3910 #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
|
3911 apply_optionset_autocmd(opt_idx, opt_flags, |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3912 (long)(old_value ? TRUE : FALSE), |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3913 (long)(old_global_value ? TRUE : FALSE), |
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3914 (long)(value ? TRUE : FALSE), NULL); |
6935 | 3915 #endif |
3916 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
3917 comp_col(); // in case 'ruler' or 'showcmd' changed |
3443 | 3918 if (curwin->w_curswant != MAXCOL |
6669 | 3919 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 3920 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
|
3921 |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
23952
diff
changeset
|
3922 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
|
3923 check_redraw(options[opt_idx].flags); |
7 | 3924 |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
3925 return errmsg; |
7 | 3926 } |
3927 | |
3928 /* | |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3929 * Process the new 'winheight' or the 'helpheight' option value. |
7 | 3930 */ |
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
|
3931 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
|
3932 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
|
3933 { |
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
|
3934 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
|
3935 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
|
3936 |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3937 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
|
3938 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3939 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
|
3940 p_wh = 1; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3941 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3942 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
|
3943 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3944 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
|
3945 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
|
3946 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3947 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
|
3948 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3949 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
|
3950 p_hh = 0; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3951 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3952 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3953 // 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
|
3954 if (!ONE_WINDOW) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3955 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3956 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
|
3957 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
|
3958 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
|
3959 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
|
3960 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3961 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3962 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3963 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3964 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3965 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3966 * 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
|
3967 */ |
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
|
3968 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
|
3969 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
|
3970 { |
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
|
3971 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
|
3972 |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3973 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
|
3974 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3975 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
|
3976 p_wmh = 0; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3977 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3978 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
|
3979 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3980 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
|
3981 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
|
3982 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3983 win_setminheight(); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3984 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3985 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3986 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3987 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3988 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3989 * 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
|
3990 */ |
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
|
3991 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
|
3992 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
|
3993 { |
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
|
3994 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
|
3995 |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
3996 if (p_wiw < 1) |
7 | 3997 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
3998 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
|
3999 p_wiw = 1; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4000 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4001 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
|
4002 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4003 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
|
4004 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
|
4005 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4006 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4007 // 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
|
4008 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
|
4009 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
|
4010 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4011 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4012 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4013 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4014 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4015 * Process the new 'winminwidth' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4016 */ |
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
|
4017 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
|
4018 did_set_winminwidth(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
|
4019 { |
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
|
4020 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
|
4021 |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4022 if (p_wmw < 0) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4023 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4024 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
|
4025 p_wmw = 0; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4026 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4027 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
|
4028 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4029 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
|
4030 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
|
4031 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4032 win_setminwidth(); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4033 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4034 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4035 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4036 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4037 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4038 * Process the new 'laststatus' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4039 */ |
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
|
4040 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
|
4041 did_set_laststatus(optset_T *args UNUSED) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4042 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4043 last_status(FALSE); // (re)set last window status line |
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
|
4044 return NULL; |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4045 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4046 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4047 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4048 * Process the new 'showtabline' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4049 */ |
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
|
4050 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
|
4051 did_set_showtabline(optset_T *args UNUSED) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4052 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4053 shell_new_rows(); // recompute window positions and heights |
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
|
4054 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
|
4055 } |
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
|
4056 |
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
|
4057 #if defined(FEAT_GUI) || defined(PROTO) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4058 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4059 * Process the new 'linespace' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4060 */ |
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
|
4061 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
|
4062 did_set_linespace(optset_T *args UNUSED) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4063 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4064 // Recompute gui.char_height and resize the Vim window to keep the |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4065 // same number of lines. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4066 if (gui.in_use && gui_mch_adjust_charheight() == OK) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4067 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); |
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
|
4068 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
|
4069 } |
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
|
4070 #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
|
4071 |
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
|
4072 #if defined(FEAT_FOLDING) || defined(PROTO) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4073 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4074 * Process the new 'foldlevel' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4075 */ |
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
|
4076 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
|
4077 did_set_foldlevel(optset_T *args UNUSED) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4078 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4079 if (curwin->w_p_fdl < 0) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4080 curwin->w_p_fdl = 0; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4081 newFoldLevel(); |
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
|
4082 return NULL; |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4083 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4084 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4085 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4086 * Process the new 'foldminlines' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4087 */ |
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
|
4088 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
|
4089 did_set_foldminlines(optset_T *args UNUSED) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4090 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4091 foldUpdateAll(curwin); |
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
|
4092 return NULL; |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4093 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4094 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4095 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4096 * Process the new 'foldnestmax' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4097 */ |
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
|
4098 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
|
4099 did_set_foldnestmax(optset_T *args UNUSED) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4100 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4101 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) |
7 | 4102 foldUpdateAll(curwin); |
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
|
4103 return NULL; |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4104 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4105 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4106 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4107 * Process the new 'foldcolumn' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4108 */ |
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
|
4109 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
|
4110 did_set_foldcolumn(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
|
4111 { |
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 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
|
4113 |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4114 if (curwin->w_p_fdc < 0) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4115 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4116 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
|
4117 curwin->w_p_fdc = 0; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4118 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4119 else if (curwin->w_p_fdc > 12) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4120 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4121 errmsg = e_invalid_argument; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4122 curwin->w_p_fdc = 12; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4123 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4124 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4125 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4126 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4127 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4128 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4129 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4130 * Process the new 'shiftwidth' or the 'tabstop' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4131 */ |
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
|
4132 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
|
4133 did_set_shiftwidth_tabstop(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
|
4134 { |
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
|
4135 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
|
4136 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
|
4137 |
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
|
4138 if (curbuf->b_p_sw < 0) |
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
|
4139 { |
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
|
4140 errmsg = e_argument_must_be_positive; |
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
|
4141 #ifdef FEAT_VARTABS |
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
|
4142 // Use the first 'vartabstop' value, or 'tabstop' if vts isn't in use. |
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
|
4143 curbuf->b_p_sw = tabstop_count(curbuf->b_p_vts_array) > 0 |
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
|
4144 ? tabstop_first(curbuf->b_p_vts_array) |
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
|
4145 : curbuf->b_p_ts; |
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
|
4146 #else |
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
|
4147 curbuf->b_p_sw = curbuf->b_p_ts; |
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
|
4148 #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
|
4149 } |
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
|
4150 |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
4151 #ifdef FEAT_FOLDING |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4152 if (foldmethodIsIndent(curwin)) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4153 foldUpdateAll(curwin); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4154 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4155 // When 'shiftwidth' changes, or it's zero and 'tabstop' changes: |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4156 // parse 'cinoptions'. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4157 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4158 parse_cino(curbuf); |
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
|
4159 |
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
|
4160 return errmsg; |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4161 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4162 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4163 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4164 * Process the new 'maxcombine' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4165 */ |
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
|
4166 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
|
4167 did_set_maxcombine(optset_T *args UNUSED) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4168 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4169 if (p_mco > MAX_MCO) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4170 p_mco = MAX_MCO; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4171 else if (p_mco < 0) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4172 p_mco = 0; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4173 screenclear(); // will re-allocate the screen |
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
|
4174 return NULL; |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4175 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4176 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4177 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4178 * Process the new 'iminsert' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4179 */ |
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
|
4180 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
|
4181 did_set_iminsert(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
|
4182 { |
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
|
4183 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
|
4184 |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4185 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4186 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4187 errmsg = e_invalid_argument; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4188 curbuf->b_p_iminsert = B_IMODE_NONE; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4189 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4190 p_iminsert = curbuf->b_p_iminsert; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4191 if (termcap_active) // don't do this in the alternate screen |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4192 showmode(); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12469
diff
changeset
|
4193 #if defined(FEAT_KEYMAP) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4194 // Show/unshow value of 'keymap' in status lines. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4195 status_redraw_curbuf(); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4196 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4197 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4198 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4199 } |
7 | 4200 |
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
|
4201 #if (defined(FEAT_XIM) && defined(FEAT_GUI_GTK)) || defined(PROTO) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4202 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4203 * Process the new 'imstyle' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4204 */ |
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
|
4205 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
|
4206 did_set_imstyle(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
|
4207 { |
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
|
4208 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
|
4209 |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4210 if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4211 errmsg = e_invalid_argument; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4212 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4213 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4214 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4215 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4216 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4217 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4218 * Process the new 'window' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4219 */ |
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
|
4220 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
|
4221 did_set_window(optset_T *args UNUSED) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4222 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4223 if (p_window < 1) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4224 p_window = 1; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4225 else if (p_window >= Rows) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4226 p_window = Rows - 1; |
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
|
4227 return NULL; |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4228 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4229 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4230 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4231 * Process the new 'imsearch' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4232 */ |
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
|
4233 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
|
4234 did_set_imsearch(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
|
4235 { |
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
|
4236 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
|
4237 |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4238 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4239 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4240 errmsg = e_invalid_argument; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4241 curbuf->b_p_imsearch = B_IMODE_NONE; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4242 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4243 p_imsearch = curbuf->b_p_imsearch; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4244 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4245 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4246 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4247 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4248 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4249 * Process the new 'titlelen' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4250 */ |
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
|
4251 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
|
4252 did_set_titlelen(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
|
4253 { |
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
|
4254 long old_value = args->os_oldval.number; |
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
|
4255 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
|
4256 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4257 // if 'titlelen' has changed, redraw the title |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4258 if (p_titlelen < 0) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4259 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4260 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
|
4261 p_titlelen = 85; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4262 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4263 if (starting != NO_SCREEN && old_value != p_titlelen) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4264 need_maketitle = TRUE; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4265 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4266 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4267 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4268 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4269 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4270 * Process the new 'cmdheight' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4271 */ |
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
|
4272 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
|
4273 did_set_cmdheight(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
|
4274 { |
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
|
4275 long old_value = args->os_oldval.number; |
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
|
4276 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
|
4277 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4278 // if p_ch changed value, change the command line height |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4279 if (p_ch < 1) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4280 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4281 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
|
4282 p_ch = 1; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4283 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4284 if (p_ch > Rows - min_rows() + 1) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4285 p_ch = Rows - min_rows() + 1; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4286 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4287 // Only compute the new window layout when startup has been |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4288 // completed. Otherwise the frame sizes may be wrong. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4289 if ((p_ch != old_value |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4290 || tabline_height() + topframe->fr_height != Rows - p_ch) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4291 && full_screen |
7 | 4292 #ifdef FEAT_GUI |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4293 && !gui.starting |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4294 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4295 ) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4296 command_height(); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4297 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4298 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4299 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4300 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4301 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4302 * Process the new 'updatecount' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4303 */ |
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
|
4304 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
|
4305 did_set_updatecount(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
|
4306 { |
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
|
4307 long old_value = args->os_oldval.number; |
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
|
4308 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
|
4309 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4310 // when 'updatecount' changes from zero to non-zero, open swap files |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4311 if (p_uc < 0) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4312 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4313 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
|
4314 p_uc = 100; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4315 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4316 if (p_uc && !old_value) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4317 ml_open_files(); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4318 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4319 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4320 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4321 |
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
|
4322 #if defined(FEAT_CONCEAL) || defined(PROTO) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4323 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4324 * Process the new 'conceallevel' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4325 */ |
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
|
4326 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
|
4327 did_set_conceallevel(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
|
4328 { |
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
|
4329 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
|
4330 |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4331 if (curwin->w_p_cole < 0) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4332 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4333 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
|
4334 curwin->w_p_cole = 0; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4335 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4336 else if (curwin->w_p_cole > 3) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4337 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4338 errmsg = e_invalid_argument; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4339 curwin->w_p_cole = 3; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4340 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4341 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4342 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4343 } |
14 | 4344 #endif |
7 | 4345 |
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
|
4346 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4347 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4348 * Process the new 'pyxversion' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4349 */ |
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
|
4350 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
|
4351 did_set_pyxversion(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
|
4352 { |
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
|
4353 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
|
4354 |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4355 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4356 errmsg = e_invalid_argument; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4357 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4358 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4359 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4360 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4361 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4362 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4363 * Process the new global 'undolevels' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4364 */ |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4365 static void |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4366 did_set_global_undolevels(long value, long old_value) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4367 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4368 // sync undo before 'undolevels' changes |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4369 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4370 // use the old value, otherwise u_sync() may not work properly |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4371 p_ul = old_value; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4372 u_sync(TRUE); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4373 p_ul = value; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4374 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4375 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4376 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4377 * Process the new buffer local 'undolevels' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4378 */ |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4379 static void |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4380 did_set_buflocal_undolevels(long value, long old_value) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4381 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4382 // use the old value, otherwise u_sync() may not work properly |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4383 curbuf->b_p_ul = old_value; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4384 u_sync(TRUE); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4385 curbuf->b_p_ul = value; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4386 } |
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 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4389 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4390 * Process the new 'numberwidth' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4391 */ |
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
|
4392 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
|
4393 did_set_numberwidth(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
|
4394 { |
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
|
4395 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
|
4396 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4397 // 'numberwidth' 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
|
4398 if (curwin->w_p_nuw < 1) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4399 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4400 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
|
4401 curwin->w_p_nuw = 1; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4402 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4403 if (curwin->w_p_nuw > 20) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4404 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4405 errmsg = e_invalid_argument; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4406 curwin->w_p_nuw = 20; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4407 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4408 curwin->w_nrwidth_line_count = 0; // trigger a redraw |
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 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4411 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4412 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4413 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4414 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4415 * Process the new 'textwidth' option value. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4416 */ |
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
|
4417 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
|
4418 did_set_textwidth(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
|
4419 { |
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
|
4420 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
|
4421 |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4422 if (curbuf->b_p_tw < 0) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4423 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4424 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
|
4425 curbuf->b_p_tw = 0; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4426 } |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
4427 #ifdef FEAT_SYN_HL |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4428 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4429 win_T *wp; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4430 tabpage_T *tp; |
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 FOR_ALL_TAB_WINDOWS(tp, wp) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4433 check_colorcolumn(wp); |
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 #endif |
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 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4438 } |
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 /* |
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
|
4441 * Process the new 'undolevels' option 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
|
4442 */ |
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
|
4443 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
|
4444 did_set_undolevels(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
|
4445 { |
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
|
4446 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
|
4447 |
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
|
4448 if (pp == &p_ul) // global 'undolevels' |
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
|
4449 did_set_global_undolevels(args->os_newval.number, |
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
|
4450 args->os_oldval.number); |
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
|
4451 else if (pp == &curbuf->b_p_ul) // buffer local 'undolevels' |
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
|
4452 did_set_buflocal_undolevels(args->os_newval.number, |
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
|
4453 args->os_oldval.number); |
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
|
4454 |
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
|
4455 return NULL; |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4456 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4457 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4458 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4459 * 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
|
4460 */ |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4461 static char * |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4462 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
|
4463 long *pp, |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4464 long old_value, |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4465 long old_Rows, |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4466 long old_Columns, |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4467 char *errbuf, |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4468 size_t errbuflen, |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4469 char *errmsg) |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4470 { |
7 | 4471 if (Rows < min_rows() && full_screen) |
4472 { | |
4473 if (errbuf != NULL) | |
4474 { | |
27426
41e0dcf38521
patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents:
27303
diff
changeset
|
4475 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
|
4476 _(e_need_at_least_nr_lines), min_rows()); |
7 | 4477 errmsg = errbuf; |
4478 } | |
4479 Rows = min_rows(); | |
4480 } | |
4481 if (Columns < MIN_COLUMNS && full_screen) | |
4482 { | |
4483 if (errbuf != NULL) | |
4484 { | |
27426
41e0dcf38521
patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents:
27303
diff
changeset
|
4485 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
|
4486 _(e_need_at_least_nr_columns), MIN_COLUMNS); |
7 | 4487 errmsg = errbuf; |
4488 } | |
4489 Columns = MIN_COLUMNS; | |
4490 } | |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
5039
diff
changeset
|
4491 limit_screen_size(); |
7 | 4492 |
4493 /* | |
4494 * If the screen (shell) height has been changed, assume it is the | |
4495 * physical screenheight. | |
4496 */ | |
4497 if (old_Rows != Rows || old_Columns != Columns) | |
4498 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4499 // Changing the screen size is not allowed while updating the screen. |
7 | 4500 if (updating_screen) |
4501 *pp = old_value; | |
4502 else if (full_screen | |
4503 #ifdef FEAT_GUI | |
4504 && !gui.starting | |
4505 #endif | |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4506 ) |
7 | 4507 set_shellsize((int)Columns, (int)Rows, TRUE); |
4508 else | |
4509 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4510 // 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
|
4511 // messages. |
7 | 4512 check_shellsize(); |
4513 if (cmdline_row > Rows - p_ch && Rows > p_ch) | |
4514 cmdline_row = Rows - p_ch; | |
4515 } | |
857 | 4516 if (p_window >= Rows || !option_was_set((char_u *)"window")) |
164 | 4517 p_window = Rows - 1; |
7 | 4518 } |
4519 | |
4520 if (curbuf->b_p_ts <= 0) | |
4521 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4522 errmsg = e_argument_must_be_positive; |
7 | 4523 curbuf->b_p_ts = 8; |
4524 } | |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
4525 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
|
4526 { |
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
4527 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
|
4528 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
|
4529 } |
7 | 4530 if (p_tm < 0) |
4531 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4532 errmsg = e_argument_must_be_positive; |
7 | 4533 p_tm = 0; |
4534 } | |
4535 if ((curwin->w_p_scr <= 0 | |
4536 || (curwin->w_p_scr > curwin->w_height | |
4537 && curwin->w_height > 0)) | |
4538 && full_screen) | |
4539 { | |
4540 if (pp == &(curwin->w_p_scr)) | |
4541 { | |
4542 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
|
4543 errmsg = e_invalid_scroll_size; |
7 | 4544 win_comp_scroll(curwin); |
4545 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4546 // 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
|
4547 // it. |
7 | 4548 else if (curwin->w_p_scr <= 0) |
4549 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
|
4550 else // curwin->w_p_scr > curwin->w_height |
7 | 4551 curwin->w_p_scr = curwin->w_height; |
4552 } | |
1726 | 4553 if (p_hi < 0) |
4554 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4555 errmsg = e_argument_must_be_positive; |
1726 | 4556 p_hi = 0; |
4557 } | |
5991 | 4558 else if (p_hi > 10000) |
4559 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
4560 errmsg = e_invalid_argument; |
5991 | 4561 p_hi = 10000; |
4562 } | |
4444 | 4563 if (p_re < 0 || p_re > 2) |
4564 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26802
diff
changeset
|
4565 errmsg = e_invalid_argument; |
4444 | 4566 p_re = 0; |
4567 } | |
7 | 4568 if (p_report < 0) |
4569 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4570 errmsg = e_argument_must_be_positive; |
7 | 4571 p_report = 1; |
4572 } | |
532 | 4573 if ((p_sj < -100 || p_sj >= Rows) && full_screen) |
7 | 4574 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4575 if (Rows != old_Rows) // Rows changed, just adjust p_sj |
7 | 4576 p_sj = Rows / 2; |
4577 else | |
4578 { | |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25176
diff
changeset
|
4579 errmsg = e_invalid_scroll_size; |
7 | 4580 p_sj = 1; |
4581 } | |
4582 } | |
4583 if (p_so < 0 && full_screen) | |
4584 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4585 errmsg = e_argument_must_be_positive; |
7 | 4586 p_so = 0; |
4587 } | |
4588 if (p_siso < 0 && full_screen) | |
4589 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4590 errmsg = e_argument_must_be_positive; |
7 | 4591 p_siso = 0; |
4592 } | |
4593 if (p_cwh < 1) | |
4594 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4595 errmsg = e_argument_must_be_positive; |
7 | 4596 p_cwh = 1; |
4597 } | |
4598 if (p_ut < 0) | |
4599 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4600 errmsg = e_argument_must_be_positive; |
7 | 4601 p_ut = 2000; |
4602 } | |
4603 if (p_ss < 0) | |
4604 { | |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
4605 errmsg = e_argument_must_be_positive; |
7 | 4606 p_ss = 0; |
4607 } | |
4608 | |
31922
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4609 return errmsg; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4610 } |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4611 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4612 /* |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4613 * 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
|
4614 * 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
|
4615 */ |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4616 static char * |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4617 set_num_option( |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4618 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
|
4619 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
|
4620 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
|
4621 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
|
4622 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
|
4623 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
|
4624 // OPT_MODELINE, etc. |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4625 { |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4626 char *errmsg = NULL; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4627 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
|
4628 #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
|
4629 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
|
4630 // global option |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4631 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4632 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
|
4633 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
|
4634 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
|
4635 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4636 // 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
|
4637 if ((secure |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4638 #ifdef HAVE_SANDBOX |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4639 || sandbox != 0 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4640 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4641 ) && (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
|
4642 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
|
4643 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4644 #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
|
4645 // 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
|
4646 // 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
|
4647 // 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
|
4648 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
|
4649 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
|
4650 OPT_GLOBAL); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4651 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4652 |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4653 *pp = value; |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4654 #ifdef FEAT_EVAL |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4655 // 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
|
4656 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
|
4657 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4658 #ifdef FEAT_GUI |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4659 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
|
4660 #endif |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4661 |
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
|
4662 // 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
|
4663 // 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
|
4664 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
|
4665 { |
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
|
4666 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
|
4667 |
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
|
4668 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
|
4669 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
|
4670 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
|
4671 args.os_newval.number = 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
|
4672 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
|
4673 } |
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
|
4674 |
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
|
4675 // 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
|
4676 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
|
4677 errbuf, errbuflen, errmsg); |
440256d03990
patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents:
31908
diff
changeset
|
4678 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4679 // May set global value for local option. |
7 | 4680 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
4681 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; | |
4682 | |
4683 options[opt_idx].flags |= P_WAS_SET; | |
4684 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
4685 #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
|
4686 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
|
4687 value, errmsg); |
6935 | 4688 #endif |
4689 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4690 comp_col(); // in case 'columns' or 'ls' changed |
3443 | 4691 if (curwin->w_curswant != MAXCOL |
6669 | 4692 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3443 | 4693 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
|
4694 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
|
4695 check_redraw(options[opt_idx].flags); |
7 | 4696 |
4697 return errmsg; | |
4698 } | |
4699 | |
4700 /* | |
4701 * Called after an option changed: check if something needs to be redrawn. | |
4702 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4703 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4704 check_redraw(long_u flags) |
7 | 4705 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4706 // Careful: P_RCLR and P_RALL are a combination of other P_ flags |
3263 | 4707 int doclear = (flags & P_RCLR) == P_RCLR; |
4708 int all = ((flags & P_RALL) == P_RALL || doclear); | |
7 | 4709 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4710 if ((flags & P_RSTAT) || all) // mark all status lines dirty |
7 | 4711 status_redraw_all(); |
4712 | |
4713 if ((flags & P_RBUF) || (flags & P_RWIN) || all) | |
4714 changed_window_setting(); | |
4715 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
|
4716 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
|
4717 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
|
4718 redraw_later(UPD_NOT_VALID); |
3263 | 4719 if (doclear) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
4720 redraw_all_later(UPD_CLEAR); |
7 | 4721 else if (all) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
4722 redraw_all_later(UPD_NOT_VALID); |
7 | 4723 } |
4724 | |
4725 /* | |
4726 * Find index for option 'arg'. | |
4727 * Return -1 if not found. | |
4728 */ | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
4729 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4730 findoption(char_u *arg) |
7 | 4731 { |
4732 int opt_idx; | |
4733 char *s, *p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4734 static short quick_tab[27] = {0, 0}; // quick access table |
7 | 4735 int is_term_opt; |
4736 | |
4737 /* | |
4738 * For first call: Initialize the quick-access table. | |
4739 * It contains the index for the first option that starts with a certain | |
4740 * letter. There are 26 letters, plus the first "t_" option. | |
4741 */ | |
4742 if (quick_tab[1] == 0) | |
4743 { | |
4744 p = options[0].fullname; | |
4745 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
4746 { | |
4747 if (s[0] != p[0]) | |
4748 { | |
4749 if (s[0] == 't' && s[1] == '_') | |
4750 quick_tab[26] = opt_idx; | |
4751 else | |
4752 quick_tab[CharOrdLow(s[0])] = opt_idx; | |
4753 } | |
4754 p = s; | |
4755 } | |
4756 } | |
4757 | |
4758 /* | |
4759 * Check for name starting with an illegal character. | |
4760 */ | |
4761 if (arg[0] < 'a' || arg[0] > 'z') | |
4762 return -1; | |
4763 | |
4764 is_term_opt = (arg[0] == 't' && arg[1] == '_'); | |
4765 if (is_term_opt) | |
4766 opt_idx = quick_tab[26]; | |
4767 else | |
4768 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
4769 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) | |
4770 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4771 if (STRCMP(arg, s) == 0) // match full name |
7 | 4772 break; |
4773 } | |
4774 if (s == NULL && !is_term_opt) | |
4775 { | |
4776 opt_idx = quick_tab[CharOrdLow(arg[0])]; | |
4777 for ( ; options[opt_idx].fullname != NULL; opt_idx++) | |
4778 { | |
4779 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
|
4780 if (s != NULL && STRCMP(arg, s) == 0) // match short name |
7 | 4781 break; |
4782 s = NULL; | |
4783 } | |
4784 } | |
4785 if (s == NULL) | |
4786 opt_idx = -1; | |
4787 return opt_idx; | |
4788 } | |
4789 | |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
4790 #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
|
4791 || defined(FEAT_SPELL) || defined(PROTO) |
7 | 4792 /* |
4793 * Get the value for an option. | |
4794 * | |
4795 * Returns: | |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4796 * 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
|
4797 * 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
|
4798 * 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
|
4799 * 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
|
4800 * 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
|
4801 * 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
|
4802 * 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
|
4803 * |
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
|
4804 * "flagsp" (if not NULL) is set to the option flags (P_xxxx). |
7 | 4805 */ |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4806 getoption_T |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4807 get_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4808 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4809 long *numval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4810 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
|
4811 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
|
4812 int scope) |
7 | 4813 { |
4814 int opt_idx; | |
4815 char_u *varp; | |
4816 | |
4817 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
|
4818 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
|
4819 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4820 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4821 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4822 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
|
4823 && (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
|
4824 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4825 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
|
4826 char_u *p; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4827 |
26802
f6b10a501a0e
patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
4828 if (flagsp != NULL) |
f6b10a501a0e
patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
4829 *flagsp = 0; // terminal option has no flags |
f6b10a501a0e
patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
4830 |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4831 // 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
|
4832 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4833 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4834 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
|
4835 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
|
4836 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4837 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4838 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4839 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
|
4840 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
|
4841 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4842 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
|
4843 if (p != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4844 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4845 if (stringval != NULL) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4846 *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
|
4847 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
|
4848 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
4849 } |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4850 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
|
4851 } |
7 | 4852 |
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
|
4853 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
|
4854 |
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
|
4855 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
|
4856 // 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
|
4857 *flagsp = options[opt_idx].flags; |
7 | 4858 |
4859 if (options[opt_idx].flags & P_STRING) | |
4860 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4861 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
|
4862 return gov_hidden_string; |
7 | 4863 if (stringval != NULL) |
4864 { | |
28804
12bbd8a31cac
patch 8.2.4926: #ifdef for crypt feature around too many lines
Bram Moolenaar <Bram@vim.org>
parents:
28800
diff
changeset
|
4865 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
|
4866 *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
|
4867 FALSE); |
7 | 4868 #ifdef FEAT_CRYPT |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4869 // 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
|
4870 else if ((char_u **)varp == &curbuf->b_p_key |
1622 | 4871 && **(char_u **)(varp) != NUL) |
7 | 4872 *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
|
4873 #endif |
7 | 4874 else |
4875 *stringval = vim_strsave(*(char_u **)(varp)); | |
4876 } | |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4877 return gov_string; |
7 | 4878 } |
4879 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4880 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
|
4881 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
|
4882 ? gov_hidden_number : gov_hidden_bool; |
7 | 4883 if (options[opt_idx].flags & P_NUM) |
4884 *numval = *(long *)varp; | |
4885 else | |
4886 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4887 // 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
|
4888 // it set when 'ff' or 'fenc' changed. |
7 | 4889 if ((int *)varp == &curbuf->b_changed) |
4890 *numval = curbufIsChanged(); | |
4891 else | |
9395
beab399e3883
commit https://github.com/vim/vim/commit/2acfbed9dbea990f129535de7ff3df360365130b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4892 *numval = (long) *(int *)varp; |
7 | 4893 } |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
4894 return (options[opt_idx].flags & P_NUM) ? gov_number : gov_bool; |
7 | 4895 } |
4896 #endif | |
4897 | |
5610 | 4898 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
4350 | 4899 /* |
4900 * Returns the option attributes and its value. Unlike the above function it | |
4901 * will return either global value or local value of the option depending on | |
4902 * what was requested, but it will never return global value if it was | |
4903 * requested to return local one and vice versa. Neither it will return | |
4904 * buffer-local value if it was requested to return window-local one. | |
4905 * | |
4906 * Pretends that option is absent if it is not present in the requested scope | |
4907 * (i.e. has no global, window-local or buffer-local value depending on | |
4908 * opt_type). Uses | |
4909 * | |
4910 * Returned flags: | |
5867 | 4911 * 0 hidden or unknown option, also option that does not have requested |
4912 * type (see SREQ_* in vim.h) | |
4350 | 4913 * see SOPT_* in vim.h for other flags |
4914 * | |
4915 * Possible opt_type values: see SREQ_* in vim.h | |
4916 */ | |
4917 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4918 get_option_value_strict( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4919 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4920 long *numval, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4921 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
|
4922 int opt_type, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4923 void *from) |
4350 | 4924 { |
4925 int opt_idx; | |
4367 | 4926 char_u *varp = NULL; |
4350 | 4927 struct vimoption *p; |
4928 int r = 0; | |
4929 | |
4930 opt_idx = findoption(name); | |
4931 if (opt_idx < 0) | |
4932 return 0; | |
4933 | |
4934 p = &(options[opt_idx]); | |
4935 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4936 // Hidden option |
4350 | 4937 if (p->var == NULL) |
4938 return 0; | |
4939 | |
4940 if (p->flags & P_BOOL) | |
4941 r |= SOPT_BOOL; | |
4942 else if (p->flags & P_NUM) | |
4943 r |= SOPT_NUM; | |
4944 else if (p->flags & P_STRING) | |
4945 r |= SOPT_STRING; | |
4946 | |
4947 if (p->indir == PV_NONE) | |
4948 { | |
4949 if (opt_type == SREQ_GLOBAL) | |
4950 r |= SOPT_GLOBAL; | |
4951 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4952 return 0; // Did not request global-only option |
4350 | 4953 } |
4954 else | |
4955 { | |
4956 if (p->indir & PV_BOTH) | |
4957 r |= SOPT_GLOBAL; | |
4958 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
|
4959 return 0; // Requested global option |
4350 | 4960 |
4961 if (p->indir & PV_WIN) | |
4962 { | |
4963 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
|
4964 return 0; // Did not request window-local option |
4350 | 4965 else |
4966 r |= SOPT_WIN; | |
4967 } | |
4968 else if (p->indir & PV_BUF) | |
4969 { | |
4970 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
|
4971 return 0; // Did not request buffer-local option |
4350 | 4972 else |
4973 r |= SOPT_BUF; | |
4974 } | |
4975 } | |
4976 | |
4977 if (stringval == NULL) | |
4978 return r; | |
4979 | |
4980 if (opt_type == SREQ_GLOBAL) | |
4981 varp = p->var; | |
4982 else | |
4983 { | |
4984 if (opt_type == SREQ_BUF) | |
4985 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4986 // 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
|
4987 // consider it set when 'ff' or 'fenc' changed. |
4350 | 4988 if (p->indir == PV_MOD) |
4989 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
4990 *numval = bufIsChanged((buf_T *)from); |
4350 | 4991 varp = NULL; |
4992 } | |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
4993 # ifdef FEAT_CRYPT |
4350 | 4994 else if (p->indir == PV_KEY) |
4995 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4996 // never return the value of the crypt key |
4350 | 4997 *stringval = NULL; |
4998 varp = NULL; | |
4999 } | |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
5000 # endif |
4350 | 5001 else |
5002 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
5003 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
|
5004 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
5005 // 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
|
5006 curbuf = (buf_T *)from; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
5007 curwin->w_buffer = curbuf; |
4350 | 5008 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
|
5009 curbuf = save_curbuf; |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
5010 curwin->w_buffer = curbuf; |
4350 | 5011 } |
5012 } | |
5013 else if (opt_type == SREQ_WIN) | |
5014 { | |
14179
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
5015 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
|
5016 |
ab64a4fb5edd
patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
5017 curwin = (win_T *)from; |
4350 | 5018 curbuf = curwin->w_buffer; |
5019 varp = get_varp(p); | |
5020 curwin = save_curwin; | |
5021 curbuf = curwin->w_buffer; | |
5022 } | |
5023 if (varp == p->var) | |
5024 return (r | SOPT_UNSET); | |
5025 } | |
5026 | |
5027 if (varp != NULL) | |
5028 { | |
5029 if (p->flags & P_STRING) | |
5030 *stringval = vim_strsave(*(char_u **)(varp)); | |
5031 else if (p->flags & P_NUM) | |
5032 *numval = *(long *) varp; | |
5033 else | |
5034 *numval = *(int *)varp; | |
5035 } | |
5036 | |
5037 return r; | |
5038 } | |
5610 | 5039 |
5040 /* | |
6243 | 5041 * Iterate over options. First argument is a pointer to a pointer to a |
5042 * structure inside options[] array, second is option type like in the above | |
5043 * function. | |
5610 | 5044 * |
6243 | 5045 * If first argument points to NULL it is assumed that iteration just started |
5610 | 5046 * and caller needs the very first value. |
6243 | 5047 * If first argument points to the end marker function returns NULL and sets |
5610 | 5048 * first argument to NULL. |
5049 * | |
5050 * Returns full option name for current option on each call. | |
5051 */ | |
5052 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5053 option_iter_next(void **option, int opt_type) |
5610 | 5054 { |
5055 struct vimoption *ret = NULL; | |
5056 do | |
5057 { | |
5058 if (*option == NULL) | |
5059 *option = (void *) options; | |
5060 else if (((struct vimoption *) (*option))->fullname == NULL) | |
5061 { | |
5062 *option = NULL; | |
5063 return NULL; | |
5064 } | |
5065 else | |
5066 *option = (void *) (((struct vimoption *) (*option)) + 1); | |
5067 | |
5068 ret = ((struct vimoption *) (*option)); | |
5069 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5070 // Hidden option |
5610 | 5071 if (ret->var == NULL) |
5072 { | |
5073 ret = NULL; | |
5074 continue; | |
5075 } | |
5076 | |
5077 switch (opt_type) | |
5078 { | |
5079 case SREQ_GLOBAL: | |
5080 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH)) | |
5081 ret = NULL; | |
5082 break; | |
5083 case SREQ_BUF: | |
5084 if (!(ret->indir & PV_BUF)) | |
5085 ret = NULL; | |
5086 break; | |
5087 case SREQ_WIN: | |
5088 if (!(ret->indir & PV_WIN)) | |
5089 ret = NULL; | |
5090 break; | |
5091 default: | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
5092 internal_error("option_iter_next()"); |
5610 | 5093 return NULL; |
5094 } | |
5095 } | |
5096 while (ret == NULL); | |
5097 | |
5098 return (char_u *)ret->fullname; | |
5099 } | |
4350 | 5100 #endif |
5101 | |
7 | 5102 /* |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5103 * 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
|
5104 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5105 long_u |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5106 get_option_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
|
5107 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5108 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
|
5109 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5110 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5111 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5112 * 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
|
5113 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5114 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5115 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
|
5116 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5117 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
|
5118 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5119 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5120 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5121 * Clear a flag for the option at 'opt_idx'. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5122 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5123 void |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5124 clear_option_flag(int opt_idx, long_u flag) |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5125 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5126 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
|
5127 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5128 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5129 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5130 * 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
|
5131 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5132 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5133 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
|
5134 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5135 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
|
5136 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5137 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5138 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5139 * 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
|
5140 * local value. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5141 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5142 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5143 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
|
5144 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5145 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
|
5146 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5147 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5148 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5149 * 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
|
5150 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5151 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5152 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
|
5153 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5154 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
|
5155 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5156 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5157 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5158 * 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
|
5159 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5160 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5161 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
|
5162 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5163 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
|
5164 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5165 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5166 #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
|
5167 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5168 * 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
|
5169 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5170 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5171 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
|
5172 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5173 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
|
5174 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5175 #endif |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5176 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5177 /* |
7 | 5178 * Set the value of option "name". |
5179 * 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
|
5180 * |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5181 * 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
|
5182 */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15207
diff
changeset
|
5183 char * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5184 set_option_value( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5185 char_u *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5186 long number, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5187 char_u *string, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5188 int opt_flags) // OPT_LOCAL or 0 (both) |
7 | 5189 { |
5190 int opt_idx; | |
5191 char_u *varp; | |
835 | 5192 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
|
5193 static char errbuf[80]; |
7 | 5194 |
5195 opt_idx = findoption(name); | |
838 | 5196 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
|
5197 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5198 int key; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5199 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5200 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
|
5201 && (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
|
5202 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5203 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
|
5204 |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5205 if (key < 0) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5206 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5207 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
|
5208 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
|
5209 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5210 else |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5211 { |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5212 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
|
5213 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
|
5214 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5215 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
|
5216 if (full_screen) |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5217 ttest(FALSE); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
5218 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
|
5219 return NULL; |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5220 } |
4dea7c96fc82
patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents:
10722
diff
changeset
|
5221 |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
5222 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
|
5223 } |
7 | 5224 else |
5225 { | |
5226 flags = options[opt_idx].flags; | |
5227 #ifdef HAVE_SANDBOX | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5228 // Disallow changing some options in the sandbox |
7 | 5229 if (sandbox > 0 && (flags & P_SECURE)) |
634 | 5230 { |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25176
diff
changeset
|
5231 emsg(_(e_not_allowed_in_sandbox)); |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
5232 return NULL; |
634 | 5233 } |
5234 #endif | |
5235 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
|
5236 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
|
5237 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5238 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
|
5239 if (varp != NULL) // hidden option is not changed |
7 | 5240 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5241 if (number == 0 && string != NULL) |
7 | 5242 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5243 int idx; |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5244 |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5245 // 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
|
5246 // to zero. |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5247 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
|
5248 ; |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5249 if (string[idx] != NUL || idx == 0) |
1298 | 5250 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5251 // 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
|
5252 // 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
|
5253 // 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
|
5254 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
|
5255 name, string); |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5256 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
|
5257 |
1298 | 5258 } |
7 | 5259 } |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5260 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
|
5261 { |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5262 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
|
5263 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
|
5264 } |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5265 else |
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5266 return set_bool_option(opt_idx, varp, (int)number, opt_flags); |
7 | 5267 } |
28357
86b6432aa1d8
patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents:
28353
diff
changeset
|
5268 |
7 | 5269 } |
4513
cadb57fbb781
updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents:
4444
diff
changeset
|
5270 return NULL; |
7 | 5271 } |
5272 | |
5273 /* | |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5274 * 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
|
5275 */ |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5276 void |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5277 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
|
5278 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
|
5279 long number, |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5280 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
|
5281 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
|
5282 { |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5283 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
|
5284 |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5285 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
|
5286 emsg(_(errmsg)); |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5287 } |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5288 |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28405
diff
changeset
|
5289 /* |
7 | 5290 * Get the terminal code for a terminal option. |
5291 * Returns NULL when not found. | |
5292 */ | |
5293 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5294 get_term_code(char_u *tname) |
7 | 5295 { |
5296 int opt_idx; | |
5297 char_u *varp; | |
5298 | |
5299 if (tname[0] != 't' || tname[1] != '_' || | |
5300 tname[2] == NUL || tname[3] == NUL) | |
5301 return NULL; | |
5302 if ((opt_idx = findoption(tname)) >= 0) | |
5303 { | |
5304 varp = get_varp(&(options[opt_idx])); | |
5305 if (varp != NULL) | |
5306 varp = *(char_u **)(varp); | |
5307 return varp; | |
5308 } | |
5309 return find_termcode(tname + 2); | |
5310 } | |
5311 | |
5312 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5313 get_highlight_default(void) |
7 | 5314 { |
5315 int i; | |
5316 | |
5317 i = findoption((char_u *)"hl"); | |
5318 if (i >= 0) | |
5319 return options[i].def_val[VI_DEFAULT]; | |
5320 return (char_u *)NULL; | |
5321 } | |
5322 | |
39 | 5323 char_u * |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5324 get_encoding_default(void) |
39 | 5325 { |
5326 int i; | |
5327 | |
5328 i = findoption((char_u *)"enc"); | |
5329 if (i >= 0) | |
5330 return options[i].def_val[VI_DEFAULT]; | |
5331 return (char_u *)NULL; | |
5332 } | |
5333 | |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
5334 #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
|
5335 int |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
5336 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
|
5337 { |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
5338 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
|
5339 |
44a552776007
patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
5340 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
|
5341 } |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
5342 #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
|
5343 |
29497
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5344 #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
|
5345 /* |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5346 * 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
|
5347 * 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
|
5348 */ |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5349 int |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5350 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
|
5351 { |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5352 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
|
5353 |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5354 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
|
5355 } |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5356 #endif |
9908c07ccb56
patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents:
29395
diff
changeset
|
5357 |
7 | 5358 /* |
5359 * 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
|
5360 * 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
|
5361 * Returns 0 when the key is not recognized. |
7 | 5362 */ |
5363 static int | |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
5364 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
|
5365 { |
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
5366 int key = 0; |
7 | 5367 int modifiers; |
14381
d9e6eec551e1
patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
14313
diff
changeset
|
5368 char_u *arg = arg_arg; |
7 | 5369 |
5370 /* | |
5371 * Don't use get_special_key_code() for t_xx, we don't want it to call | |
5372 * add_termcap_entry(). | |
5373 */ | |
5374 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | |
5375 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
|
5376 else if (has_lt) |
7 | 5377 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5378 --arg; // put arg at the '<' |
7 | 5379 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
|
5380 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
|
5381 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
|
5382 if (modifiers) // can't handle modifiers here |
7 | 5383 key = 0; |
5384 } | |
5385 return key; | |
5386 } | |
5387 | |
5388 /* | |
5389 * if 'all' == 0: show changed options | |
5390 * if 'all' == 1: show all normal options | |
5391 * if 'all' == 2: show all terminal options | |
5392 */ | |
5393 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5394 showoptions( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5395 int all, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5396 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
7 | 5397 { |
5398 struct vimoption *p; | |
5399 int col; | |
5400 int isterm; | |
5401 char_u *varp; | |
5402 struct vimoption **items; | |
5403 int item_count; | |
5404 int run; | |
5405 int row, rows; | |
5406 int cols; | |
5407 int i; | |
5408 int len; | |
5409 | |
5410 #define INC 20 | |
5411 #define GAP 3 | |
5412 | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5413 items = ALLOC_MULT(struct vimoption *, OPTION_COUNT); |
7 | 5414 if (items == NULL) |
5415 return; | |
5416 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5417 // Highlight title |
7 | 5418 if (all == 2) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
5419 msg_puts_title(_("\n--- Terminal codes ---")); |
7 | 5420 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
|
5421 msg_puts_title(_("\n--- Global option values ---")); |
7 | 5422 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
|
5423 msg_puts_title(_("\n--- Local option values ---")); |
7 | 5424 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
5425 msg_puts_title(_("\n--- Options ---")); |
7 | 5426 |
5427 /* | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5428 * Do the loop two times: |
7 | 5429 * 1. display the short items |
5430 * 2. display the long items (only strings and numbers) | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5431 * When "opt_flags" has OPT_ONECOLUMN do everything in run 2. |
7 | 5432 */ |
5433 for (run = 1; run <= 2 && !got_int; ++run) | |
5434 { | |
5435 /* | |
5436 * collect the items in items[] | |
5437 */ | |
5438 item_count = 0; | |
5439 for (p = &options[0]; p->fullname != NULL; p++) | |
5440 { | |
14968
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
5441 // apply :filter /pat/ |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5442 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
|
5443 continue; |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14935
diff
changeset
|
5444 |
7 | 5445 varp = NULL; |
5446 isterm = istermoption(p); | |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5447 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) != 0) |
7 | 5448 { |
5449 if (p->indir != PV_NONE && !isterm) | |
5450 varp = get_varp_scope(p, opt_flags); | |
5451 } | |
5452 else | |
5453 varp = get_varp(p); | |
5454 if (varp != NULL | |
5455 && ((all == 2 && isterm) | |
5456 || (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
|
5457 || (all == 0 && !optval_default(p, varp, p_cp)))) |
7 | 5458 { |
19137
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5459 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
|
5460 len = Columns; |
69f0e9b5c107
patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5461 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
|
5462 len = 1; // a toggle option fits always |
7 | 5463 else |
5464 { | |
5465 option_value2string(p, opt_flags); | |
5466 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; | |
5467 } | |
5468 if ((len <= INC - GAP && run == 1) || | |
5469 (len > INC - GAP && run == 2)) | |
5470 items[item_count++] = p; | |
5471 } | |
5472 } | |
5473 | |
5474 /* | |
5475 * display the items | |
5476 */ | |
5477 if (run == 1) | |
5478 { | |
5479 cols = (Columns + GAP - 3) / INC; | |
5480 if (cols == 0) | |
5481 cols = 1; | |
5482 rows = (item_count + cols - 1) / cols; | |
5483 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5484 else // run == 2 |
7 | 5485 rows = item_count; |
5486 for (row = 0; row < rows && !got_int; ++row) | |
5487 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5488 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
|
5489 if (got_int) // 'q' typed in more |
7 | 5490 break; |
5491 col = 0; | |
5492 for (i = row; i < item_count; i += rows) | |
5493 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5494 msg_col = col; // make columns |
7 | 5495 showoneopt(items[i], opt_flags); |
5496 col += INC; | |
5497 } | |
5498 out_flush(); | |
5499 ui_breakcheck(); | |
5500 } | |
5501 } | |
5502 vim_free(items); | |
5503 } | |
5504 | |
5505 /* | |
5506 * Return TRUE if option "p" has its default value. | |
5507 */ | |
5508 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
|
5509 optval_default(struct vimoption *p, char_u *varp, int compatible) |
7 | 5510 { |
5511 int dvi; | |
5512 | |
5513 if (varp == NULL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5514 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
|
5515 dvi = ((p->flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; |
7 | 5516 if (p->flags & P_NUM) |
840 | 5517 return (*(long *)varp == (long)(long_i)p->def_val[dvi]); |
7 | 5518 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
|
5519 // 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
|
5520 // needed for MSVC |
840 | 5521 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
|
5522 // P_STRING |
7 | 5523 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); |
5524 } | |
5525 | |
5526 /* | |
5527 * showoneopt: show the value of one option | |
5528 * must not be called with a hidden option! | |
5529 */ | |
5530 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5531 showoneopt( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5532 struct vimoption *p, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5533 int opt_flags) // OPT_LOCAL or OPT_GLOBAL |
7 | 5534 { |
168 | 5535 char_u *varp; |
5536 int save_silent = silent_mode; | |
5537 | |
5538 silent_mode = FALSE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5539 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
7 | 5540 |
5541 varp = get_varp_scope(p, opt_flags); | |
5542 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5543 // for 'modified' we also need to check if 'ff' or 'fenc' changed. |
7 | 5544 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed |
5545 ? !curbufIsChanged() : !*(int *)varp)) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
5546 msg_puts("no"); |
7 | 5547 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
|
5548 msg_puts("--"); |
7 | 5549 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
5550 msg_puts(" "); |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15502
diff
changeset
|
5551 msg_puts(p->fullname); |
7 | 5552 if (!(p->flags & P_BOOL)) |
5553 { | |
5554 msg_putchar('='); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5555 // put value string in NameBuff |
7 | 5556 option_value2string(p, opt_flags); |
5557 msg_outtrans(NameBuff); | |
5558 } | |
168 | 5559 |
5560 silent_mode = save_silent; | |
5561 info_message = FALSE; | |
7 | 5562 } |
5563 | |
5564 /* | |
5565 * Write modified options as ":set" commands to a file. | |
5566 * | |
5567 * There are three values for "opt_flags": | |
5568 * OPT_GLOBAL: Write global option values and fresh values of | |
5569 * buffer-local options (used for start of a session | |
5570 * file). | |
5571 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for | |
5572 * curwin (used for a vimrc file). | |
5573 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh | |
5574 * and local values for window-local options of | |
5575 * curwin. Local values are also written when at the | |
5576 * default value, because a modeline or autocommand | |
5577 * may have set them when doing ":edit file" and the | |
5578 * user has set them back at the default or fresh | |
5579 * value. | |
5580 * When "local_only" is TRUE, don't write fresh | |
5581 * values, only local values (for ":mkview"). | |
5582 * (fresh value = value used for a new buffer or window for a local option). | |
5583 * | |
5584 * Return FAIL on error, OK otherwise. | |
5585 */ | |
5586 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5587 makeset(FILE *fd, int opt_flags, int local_only) |
7 | 5588 { |
5589 struct vimoption *p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5590 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
|
5591 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
|
5592 char_u *varp_local = NULL; // fresh value |
7 | 5593 char *cmd; |
5594 int round; | |
1384 | 5595 int pri; |
7 | 5596 |
5597 /* | |
5598 * The options that don't have a default (terminal name, columns, lines) | |
5599 * are never written. Terminal options are also not written. | |
1384 | 5600 * Do the loop over "options[]" twice: once for options with the |
5601 * P_PRI_MKRC flag and once without. | |
7 | 5602 */ |
1384 | 5603 for (pri = 1; pri >= 0; --pri) |
5604 { | |
5605 for (p = &options[0]; !istermoption(p); p++) | |
5606 if (!(p->flags & P_NO_MKRC) | |
5607 && !istermoption(p) | |
5608 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) | |
7 | 5609 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5610 // skip global option when only doing locals |
7 | 5611 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) |
5612 continue; | |
5613 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5614 // 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
|
5615 // file, they are always buffer-specific. |
7 | 5616 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) |
5617 continue; | |
5618 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5619 // Global values are only written when not at the default value. |
7 | 5620 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
|
5621 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp, p_cp)) |
7 | 5622 continue; |
5623 | |
24476
e79d1475fc89
patch 8.2.2778: problem restoring 'packpath' in session
Bram Moolenaar <Bram@vim.org>
parents:
24464
diff
changeset
|
5624 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
|
5625 || 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
|
5626 continue; |
a56f9c2ba51c
patch 8.2.2772: problems when restoring 'runtimepath' from a session file
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
5627 |
7 | 5628 round = 2; |
5629 if (p->indir != PV_NONE) | |
5630 { | |
5631 if (p->var == VAR_WIN) | |
5632 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5633 // skip window-local option when only doing globals |
7 | 5634 if (!(opt_flags & OPT_LOCAL)) |
5635 continue; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5636 // 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
|
5637 // default, need to write it too. |
7 | 5638 if (!(opt_flags & OPT_GLOBAL) && !local_only) |
5639 { | |
5640 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
|
5641 if (!optval_default(p, varp_fresh, p_cp)) |
7 | 5642 { |
5643 round = 1; | |
5644 varp_local = varp; | |
5645 varp = varp_fresh; | |
5646 } | |
5647 } | |
5648 } | |
5649 } | |
5650 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5651 // 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
|
5652 // Round 2: other values |
7 | 5653 for ( ; round <= 2; varp = varp_local, ++round) |
5654 { | |
5655 if (round == 1 || (opt_flags & OPT_GLOBAL)) | |
5656 cmd = "set"; | |
5657 else | |
5658 cmd = "setlocal"; | |
5659 | |
5660 if (p->flags & P_BOOL) | |
5661 { | |
5662 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) | |
5663 return FAIL; | |
5664 } | |
5665 else if (p->flags & P_NUM) | |
5666 { | |
5667 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) | |
5668 return FAIL; | |
5669 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5670 else // P_STRING |
7 | 5671 { |
694 | 5672 int do_endif = FALSE; |
5673 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5674 // 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
|
5675 // already right, avoids reloading the syntax file. |
694 | 5676 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
5677 #if defined(FEAT_SYN_HL) |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
5678 p->indir == PV_SYN || |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
5679 #endif |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
5680 p->indir == PV_FT) |
7 | 5681 { |
5682 if (fprintf(fd, "if &%s != '%s'", p->fullname, | |
5683 *(char_u **)(varp)) < 0 | |
5684 || put_eol(fd) < 0) | |
5685 return FAIL; | |
694 | 5686 do_endif = TRUE; |
7 | 5687 } |
5688 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
|
5689 p->flags) == FAIL) |
7 | 5690 return FAIL; |
694 | 5691 if (do_endif) |
7 | 5692 { |
5693 if (put_line(fd, "endif") == FAIL) | |
5694 return FAIL; | |
5695 } | |
5696 } | |
5697 } | |
5698 } | |
1384 | 5699 } |
7 | 5700 return OK; |
5701 } | |
5702 | |
5703 #if defined(FEAT_FOLDING) || defined(PROTO) | |
5704 /* | |
5705 * Generate set commands for the local fold options only. Used when | |
5706 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options". | |
5707 */ | |
5708 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5709 makefoldset(FILE *fd) |
7 | 5710 { |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5711 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, 0) == FAIL |
7 | 5712 # 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
|
5713 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, 0) |
7 | 5714 == FAIL |
5715 # endif | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5716 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, 0) |
7 | 5717 == FAIL |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5718 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, 0) |
7 | 5719 == FAIL |
5720 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL | |
5721 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL | |
5722 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL | |
5723 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL | |
5724 ) | |
5725 return FAIL; | |
5726 | |
5727 return OK; | |
5728 } | |
5729 #endif | |
5730 | |
5731 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5732 put_setstring( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5733 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5734 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5735 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5736 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
|
5737 long_u flags) |
7 | 5738 { |
5739 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
|
5740 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
|
5741 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
|
5742 char_u *p; |
7 | 5743 |
5744 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
5745 return FAIL; | |
5746 if (*valuep != NULL) | |
5747 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5748 // 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
|
5749 // 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
|
5750 // CTRL-V or backslash |
7 | 5751 if (valuep == &p_pt) |
5752 { | |
5753 s = *valuep; | |
5754 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
|
5755 if (put_escstr(fd, str2special(&s, FALSE, FALSE), 2) == FAIL) |
7 | 5756 return FAIL; |
5757 } | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5758 // 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
|
5759 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
|
5760 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5761 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
|
5762 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5763 // 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
|
5764 buf = alloc(size); |
2780 | 5765 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
|
5766 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5767 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
|
5768 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5769 // 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
|
5770 // 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
|
5771 // 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
|
5772 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
|
5773 && 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
|
5774 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5775 part = alloc(size); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5776 if (part == NULL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5777 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5778 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5779 // 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
|
5780 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
|
5781 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5782 |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5783 p = buf; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5784 while (*p != NUL) |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5785 { |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5786 // 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
|
5787 // 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
|
5788 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
|
5789 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5790 (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
|
5791 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
|
5792 goto fail; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5793 } |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5794 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5795 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5796 return OK; |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5797 } |
7 | 5798 if (put_escstr(fd, buf, 2) == FAIL) |
2780 | 5799 { |
5800 vim_free(buf); | |
7 | 5801 return FAIL; |
2780 | 5802 } |
5803 vim_free(buf); | |
7 | 5804 } |
5805 else if (put_escstr(fd, *valuep, 2) == FAIL) | |
5806 return FAIL; | |
5807 } | |
5808 if (put_eol(fd) < 0) | |
5809 return FAIL; | |
5810 return OK; | |
15613
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5811 fail: |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5812 vim_free(buf); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5813 vim_free(part); |
90f01701ecad
patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5814 return FAIL; |
7 | 5815 } |
5816 | |
5817 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5818 put_setnum( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5819 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5820 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5821 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5822 long *valuep) |
7 | 5823 { |
5824 long wc; | |
5825 | |
5826 if (fprintf(fd, "%s %s=", cmd, name) < 0) | |
5827 return FAIL; | |
5828 if (wc_use_keyname((char_u *)valuep, &wc)) | |
5829 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5830 // print 'wildchar' and 'wildcharm' as a key name |
7 | 5831 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) |
5832 return FAIL; | |
5833 } | |
5834 else if (fprintf(fd, "%ld", *valuep) < 0) | |
5835 return FAIL; | |
5836 if (put_eol(fd) < 0) | |
5837 return FAIL; | |
5838 return OK; | |
5839 } | |
5840 | |
5841 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5842 put_setbool( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5843 FILE *fd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5844 char *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5845 char *name, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5846 int value) |
7 | 5847 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5848 if (value < 0) // global/local option using global value |
1416 | 5849 return OK; |
7 | 5850 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 |
5851 || put_eol(fd) < 0) | |
5852 return FAIL; | |
5853 return OK; | |
5854 } | |
5855 | |
5856 /* | |
5857 * Clear all the terminal options. | |
5858 * If the option has been allocated, free the memory. | |
5859 * Terminal options are never hidden or indirect. | |
5860 */ | |
5861 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5862 clear_termoptions(void) |
7 | 5863 { |
5864 /* | |
5865 * Reset a few things before clearing the old options. This may cause | |
5866 * outputting a few things that the terminal doesn't understand, but the | |
5867 * screen will be cleared later, so this is OK. | |
5868 */ | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
5869 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
|
5870 mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles |
7 | 5871 #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
|
5872 // 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
|
5873 // After restoring the title, because that will need the display. |
7 | 5874 if (gui.starting) |
5875 clear_xterm_clip(); | |
5876 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5877 stoptermcap(); // stop termcap mode |
7 | 5878 |
359 | 5879 free_termoptions(); |
5880 } | |
5881 | |
5882 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5883 free_termoptions(void) |
359 | 5884 { |
5885 struct vimoption *p; | |
5886 | |
14867
cf4d6489c9eb
patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
5887 for (p = options; p->fullname != NULL; p++) |
7 | 5888 if (istermoption(p)) |
5889 { | |
5890 if (p->flags & P_ALLOCED) | |
5891 free_string_option(*(char_u **)(p->var)); | |
5892 if (p->flags & P_DEF_ALLOCED) | |
5893 free_string_option(p->def_val[VI_DEFAULT]); | |
5894 *(char_u **)(p->var) = empty_option; | |
5895 p->def_val[VI_DEFAULT] = empty_option; | |
5896 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
|
5897 #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
|
5898 // 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
|
5899 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
|
5900 #endif |
7 | 5901 } |
5902 clear_termcodes(); | |
5903 } | |
5904 | |
5905 /* | |
1941 | 5906 * Free the string for one term option, if it was allocated. |
5907 * Set the string to empty_option and clear allocated flag. | |
5908 * "var" points to the option value. | |
5909 */ | |
5910 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5911 free_one_termoption(char_u *var) |
1941 | 5912 { |
5913 struct vimoption *p; | |
5914 | |
5915 for (p = &options[0]; p->fullname != NULL; p++) | |
5916 if (p->var == var) | |
5917 { | |
5918 if (p->flags & P_ALLOCED) | |
5919 free_string_option(*(char_u **)(p->var)); | |
5920 *(char_u **)(p->var) = empty_option; | |
5921 p->flags &= ~P_ALLOCED; | |
5922 break; | |
5923 } | |
5924 } | |
5925 | |
5926 /* | |
7 | 5927 * Set the terminal option defaults to the current value. |
5928 * Used after setting the terminal name. | |
5929 */ | |
5930 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5931 set_term_defaults(void) |
7 | 5932 { |
5933 struct vimoption *p; | |
5934 | |
5935 for (p = &options[0]; p->fullname != NULL; p++) | |
5936 { | |
5937 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) | |
5938 { | |
5939 if (p->flags & P_DEF_ALLOCED) | |
5940 { | |
5941 free_string_option(p->def_val[VI_DEFAULT]); | |
5942 p->flags &= ~P_DEF_ALLOCED; | |
5943 } | |
5944 p->def_val[VI_DEFAULT] = *(char_u **)(p->var); | |
5945 if (p->flags & P_ALLOCED) | |
5946 { | |
5947 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
|
5948 p->flags &= ~P_ALLOCED; // don't free the value now |
7 | 5949 } |
5950 } | |
5951 } | |
5952 } | |
5953 | |
5954 /* | |
5955 * return TRUE if 'p' starts with 't_' | |
5956 */ | |
5957 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5958 istermoption(struct vimoption *p) |
7 | 5959 { |
5960 return (p->fullname[0] == 't' && p->fullname[1] == '_'); | |
5961 } | |
5962 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5963 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5964 * 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
|
5965 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5966 int |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5967 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
|
5968 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5969 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
|
5970 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
5971 |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
5972 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
7 | 5973 /* |
4350 | 5974 * Unset local option value, similar to ":set opt<". |
5975 */ | |
5976 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5977 unset_global_local_option(char_u *name, void *from) |
4350 | 5978 { |
5979 struct vimoption *p; | |
5980 int opt_idx; | |
4361 | 5981 buf_T *buf = (buf_T *)from; |
4350 | 5982 |
5983 opt_idx = findoption(name); | |
7007 | 5984 if (opt_idx < 0) |
5985 return; | |
4350 | 5986 p = &(options[opt_idx]); |
5987 | |
5988 switch ((int)p->indir) | |
5989 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
5990 // global option with local value: use local value if it's been set |
4350 | 5991 case PV_EP: |
4361 | 5992 clear_string_option(&buf->b_p_ep); |
4350 | 5993 break; |
5994 case PV_KP: | |
4361 | 5995 clear_string_option(&buf->b_p_kp); |
4350 | 5996 break; |
5997 case PV_PATH: | |
4361 | 5998 clear_string_option(&buf->b_p_path); |
4350 | 5999 break; |
6000 case PV_AR: | |
6001 buf->b_p_ar = -1; | |
6002 break; | |
6243 | 6003 case PV_BKC: |
6004 clear_string_option(&buf->b_p_bkc); | |
6005 buf->b_bkc_flags = 0; | |
6006 break; | |
4350 | 6007 case PV_TAGS: |
4361 | 6008 clear_string_option(&buf->b_p_tags); |
4350 | 6009 break; |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
6010 case PV_TC: |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
6011 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
|
6012 buf->b_tc_flags = 0; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
6013 break; |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
6014 case PV_SISO: |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
6015 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
|
6016 break; |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
6017 case PV_SO: |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
6018 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
|
6019 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6020 # ifdef FEAT_FIND_ID |
4350 | 6021 case PV_DEF: |
4361 | 6022 clear_string_option(&buf->b_p_def); |
4350 | 6023 break; |
6024 case PV_INC: | |
4361 | 6025 clear_string_option(&buf->b_p_inc); |
4350 | 6026 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6027 # endif |
4350 | 6028 case PV_DICT: |
4361 | 6029 clear_string_option(&buf->b_p_dict); |
4350 | 6030 break; |
6031 case PV_TSR: | |
4361 | 6032 clear_string_option(&buf->b_p_tsr); |
4350 | 6033 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6034 # 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
|
6035 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
|
6036 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
|
6037 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6038 # endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
6039 case PV_FP: |
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
6040 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
|
6041 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6042 # ifdef FEAT_QUICKFIX |
4350 | 6043 case PV_EFM: |
4361 | 6044 clear_string_option(&buf->b_p_efm); |
4350 | 6045 break; |
6046 case PV_GP: | |
4361 | 6047 clear_string_option(&buf->b_p_gp); |
4350 | 6048 break; |
6049 case PV_MP: | |
4361 | 6050 clear_string_option(&buf->b_p_mp); |
4350 | 6051 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6052 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6053 # if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
4350 | 6054 case PV_BEXPR: |
4361 | 6055 clear_string_option(&buf->b_p_bexpr); |
4350 | 6056 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6057 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6058 # if defined(FEAT_CRYPT) |
4350 | 6059 case PV_CM: |
4361 | 6060 clear_string_option(&buf->b_p_cm); |
4350 | 6061 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6062 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6063 # 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
|
6064 case PV_SBR: |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6065 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
|
6066 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6067 # endif |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6068 # ifdef FEAT_STL_OPT |
4350 | 6069 case PV_STL: |
4361 | 6070 clear_string_option(&((win_T *)from)->w_p_stl); |
4350 | 6071 break; |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
6072 # endif |
5446 | 6073 case PV_UL: |
6074 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; | |
6075 break; | |
5712 | 6076 case PV_LW: |
6077 clear_string_option(&buf->b_p_lw); | |
6078 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
|
6079 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
|
6080 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
|
6081 break; |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
6082 case PV_LCS: |
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
6083 clear_string_option(&((win_T *)from)->w_p_lcs); |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
6084 set_chars_option((win_T *)from, &((win_T *)from)->w_p_lcs, TRUE); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
6085 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
|
6086 break; |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6087 case PV_FCS: |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6088 clear_string_option(&((win_T *)from)->w_p_fcs); |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
6089 set_chars_option((win_T *)from, &((win_T *)from)->w_p_fcs, TRUE); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
6090 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
|
6091 break; |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
6092 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
|
6093 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
|
6094 ((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
|
6095 break; |
4350 | 6096 } |
6097 } | |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
6098 #endif |
4350 | 6099 |
6100 /* | |
7 | 6101 * 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
|
6102 * "scope" can be OPT_LOCAL, OPT_GLOBAL or a combination. |
7 | 6103 */ |
6104 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
|
6105 get_varp_scope(struct vimoption *p, int scope) |
7 | 6106 { |
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
|
6107 if ((scope & OPT_GLOBAL) && p->indir != PV_NONE) |
7 | 6108 { |
6109 if (p->var == VAR_WIN) | |
6110 return (char_u *)GLOBAL_WO(get_varp(p)); | |
6111 return p->var; | |
6112 } | |
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
|
6113 if ((scope & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) |
7 | 6114 { |
6115 switch ((int)p->indir) | |
6116 { | |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
6117 case PV_FP: return (char_u *)&(curbuf->b_p_fp); |
7 | 6118 #ifdef FEAT_QUICKFIX |
694 | 6119 case PV_EFM: return (char_u *)&(curbuf->b_p_efm); |
6120 case PV_GP: return (char_u *)&(curbuf->b_p_gp); | |
6121 case PV_MP: return (char_u *)&(curbuf->b_p_mp); | |
6122 #endif | |
6123 case PV_EP: return (char_u *)&(curbuf->b_p_ep); | |
6124 case PV_KP: return (char_u *)&(curbuf->b_p_kp); | |
6125 case PV_PATH: return (char_u *)&(curbuf->b_p_path); | |
692 | 6126 case PV_AR: return (char_u *)&(curbuf->b_p_ar); |
694 | 6127 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
|
6128 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
|
6129 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
|
6130 case PV_SO: return (char_u *)&(curwin->w_p_so); |
7 | 6131 #ifdef FEAT_FIND_ID |
694 | 6132 case PV_DEF: return (char_u *)&(curbuf->b_p_def); |
6133 case PV_INC: return (char_u *)&(curbuf->b_p_inc); | |
7 | 6134 #endif |
694 | 6135 case PV_DICT: return (char_u *)&(curbuf->b_p_dict); |
6136 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
|
6137 #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
|
6138 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
|
6139 #endif |
790 | 6140 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
6141 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr); | |
6142 #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
|
6143 #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
|
6144 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
|
6145 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6146 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6147 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
|
6148 #endif |
40 | 6149 #ifdef FEAT_STL_OPT |
694 | 6150 case PV_STL: return (char_u *)&(curwin->w_p_stl); |
40 | 6151 #endif |
5446 | 6152 case PV_UL: return (char_u *)&(curbuf->b_p_ul); |
5712 | 6153 case PV_LW: return (char_u *)&(curbuf->b_p_lw); |
6243 | 6154 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
|
6155 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
|
6156 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
|
6157 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
|
6158 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
|
6159 |
7 | 6160 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6161 return NULL; // "cannot happen" |
7 | 6162 } |
6163 return get_varp(p); | |
6164 } | |
6165 | |
6166 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6167 * 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
|
6168 * scope. |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6169 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6170 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
|
6171 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
|
6172 { |
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
|
6173 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
|
6174 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6175 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6176 /* |
7 | 6177 * Get pointer to option variable. |
6178 */ | |
6179 static char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6180 get_varp(struct vimoption *p) |
7 | 6181 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6182 // hidden option, always return NULL |
7 | 6183 if (p->var == NULL) |
6184 return NULL; | |
6185 | |
6186 switch ((int)p->indir) | |
6187 { | |
6188 case PV_NONE: return p->var; | |
6189 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6190 // global option with local value: use local value if it's been set |
694 | 6191 case PV_EP: return *curbuf->b_p_ep != NUL |
7 | 6192 ? (char_u *)&curbuf->b_p_ep : p->var; |
694 | 6193 case PV_KP: return *curbuf->b_p_kp != NUL |
7 | 6194 ? (char_u *)&curbuf->b_p_kp : p->var; |
694 | 6195 case PV_PATH: return *curbuf->b_p_path != NUL |
7 | 6196 ? (char_u *)&(curbuf->b_p_path) : p->var; |
692 | 6197 case PV_AR: return curbuf->b_p_ar >= 0 |
7 | 6198 ? (char_u *)&(curbuf->b_p_ar) : p->var; |
694 | 6199 case PV_TAGS: return *curbuf->b_p_tags != NUL |
7 | 6200 ? (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
|
6201 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
|
6202 ? (char_u *)&(curbuf->b_p_tc) : p->var; |
6243 | 6203 case PV_BKC: return *curbuf->b_p_bkc != NUL |
6204 ? (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
|
6205 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
|
6206 ? (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
|
6207 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
|
6208 ? (char_u *)&(curwin->w_p_so) : p->var; |
7 | 6209 #ifdef FEAT_FIND_ID |
694 | 6210 case PV_DEF: return *curbuf->b_p_def != NUL |
7 | 6211 ? (char_u *)&(curbuf->b_p_def) : p->var; |
694 | 6212 case PV_INC: return *curbuf->b_p_inc != NUL |
7 | 6213 ? (char_u *)&(curbuf->b_p_inc) : p->var; |
6214 #endif | |
694 | 6215 case PV_DICT: return *curbuf->b_p_dict != NUL |
7 | 6216 ? (char_u *)&(curbuf->b_p_dict) : p->var; |
694 | 6217 case PV_TSR: return *curbuf->b_p_tsr != NUL |
7 | 6218 ? (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
|
6219 #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
|
6220 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
|
6221 ? (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
|
6222 #endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
6223 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
|
6224 ? (char_u *)&(curbuf->b_p_fp) : p->var; |
7 | 6225 #ifdef FEAT_QUICKFIX |
694 | 6226 case PV_EFM: return *curbuf->b_p_efm != NUL |
6227 ? (char_u *)&(curbuf->b_p_efm) : p->var; | |
6228 case PV_GP: return *curbuf->b_p_gp != NUL | |
7 | 6229 ? (char_u *)&(curbuf->b_p_gp) : p->var; |
694 | 6230 case PV_MP: return *curbuf->b_p_mp != NUL |
7 | 6231 ? (char_u *)&(curbuf->b_p_mp) : p->var; |
6232 #endif | |
790 | 6233 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
6234 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL | |
6235 ? (char_u *)&(curbuf->b_p_bexpr) : p->var; | |
6236 #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
|
6237 #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
|
6238 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
|
6239 ? (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
|
6240 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6241 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6242 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
|
6243 ? (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
|
6244 #endif |
40 | 6245 #ifdef FEAT_STL_OPT |
694 | 6246 case PV_STL: return *curwin->w_p_stl != NUL |
40 | 6247 ? (char_u *)&(curwin->w_p_stl) : p->var; |
6248 #endif | |
5446 | 6249 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL |
6250 ? (char_u *)&(curbuf->b_p_ul) : p->var; | |
5712 | 6251 case PV_LW: return *curbuf->b_p_lw != NUL |
6252 ? (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
|
6253 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
|
6254 ? (char_u *)&(curbuf->b_p_menc) : p->var; |
7 | 6255 #ifdef FEAT_ARABIC |
6256 case PV_ARAB: return (char_u *)&(curwin->w_p_arab); | |
6257 #endif | |
6258 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
|
6259 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
|
6260 ? (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
|
6261 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
|
6262 ? (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
|
6263 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
|
6264 ? (char_u *)&(curwin->w_p_ve) : p->var; |
744 | 6265 #ifdef FEAT_SPELL |
6266 case PV_SPELL: return (char_u *)&(curwin->w_p_spell); | |
6267 #endif | |
221 | 6268 #ifdef FEAT_SYN_HL |
744 | 6269 case PV_CUC: return (char_u *)&(curwin->w_p_cuc); |
6270 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
|
6271 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
|
6272 case PV_CC: return (char_u *)&(curwin->w_p_cc); |
221 | 6273 #endif |
7 | 6274 #ifdef FEAT_DIFF |
6275 case PV_DIFF: return (char_u *)&(curwin->w_p_diff); | |
6276 #endif | |
6277 #ifdef FEAT_FOLDING | |
6278 case PV_FDC: return (char_u *)&(curwin->w_p_fdc); | |
6279 case PV_FEN: return (char_u *)&(curwin->w_p_fen); | |
6280 case PV_FDI: return (char_u *)&(curwin->w_p_fdi); | |
6281 case PV_FDL: return (char_u *)&(curwin->w_p_fdl); | |
6282 case PV_FDM: return (char_u *)&(curwin->w_p_fdm); | |
6283 case PV_FML: return (char_u *)&(curwin->w_p_fml); | |
6284 case PV_FDN: return (char_u *)&(curwin->w_p_fdn); | |
6285 # ifdef FEAT_EVAL | |
6286 case PV_FDE: return (char_u *)&(curwin->w_p_fde); | |
6287 case PV_FDT: return (char_u *)&(curwin->w_p_fdt); | |
6288 # endif | |
6289 case PV_FMR: return (char_u *)&(curwin->w_p_fmr); | |
6290 #endif | |
6291 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
|
6292 case PV_RNU: return (char_u *)&(curwin->w_p_rnu); |
13 | 6293 #ifdef FEAT_LINEBREAK |
6294 case PV_NUW: return (char_u *)&(curwin->w_p_nuw); | |
6295 #endif | |
7 | 6296 case PV_WFH: return (char_u *)&(curwin->w_p_wfh); |
782 | 6297 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
|
6298 #if defined(FEAT_QUICKFIX) |
7 | 6299 case PV_PVW: return (char_u *)&(curwin->w_p_pvw); |
6300 #endif | |
6301 #ifdef FEAT_RIGHTLEFT | |
6302 case PV_RL: return (char_u *)&(curwin->w_p_rl); | |
6303 case PV_RLC: return (char_u *)&(curwin->w_p_rlc); | |
6304 #endif | |
6305 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
|
6306 case PV_SMS: return (char_u *)&(curwin->w_p_sms); |
7 | 6307 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); |
6308 #ifdef FEAT_LINEBREAK | |
6309 case PV_LBR: return (char_u *)&(curwin->w_p_lbr); | |
5995 | 6310 case PV_BRI: return (char_u *)&(curwin->w_p_bri); |
6311 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt); | |
7 | 6312 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
6313 case PV_WCR: return (char_u *)&(curwin->w_p_wcr); |
7 | 6314 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
|
6315 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
|
6316 #ifdef FEAT_CONCEAL |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
6317 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
|
6318 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
|
6319 #endif |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
6320 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6321 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
|
6322 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
|
6323 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
|
6324 #endif |
7 | 6325 |
6326 case PV_AI: return (char_u *)&(curbuf->b_p_ai); | |
6327 case PV_BIN: return (char_u *)&(curbuf->b_p_bin); | |
6328 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); | |
6329 case PV_BH: return (char_u *)&(curbuf->b_p_bh); | |
6330 case PV_BT: return (char_u *)&(curbuf->b_p_bt); | |
6331 case PV_BL: return (char_u *)&(curbuf->b_p_bl); | |
6332 case PV_CI: return (char_u *)&(curbuf->b_p_ci); | |
6333 case PV_CIN: return (char_u *)&(curbuf->b_p_cin); | |
6334 case PV_CINK: return (char_u *)&(curbuf->b_p_cink); | |
6335 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
|
6336 case PV_CINSD: return (char_u *)&(curbuf->b_p_cinsd); |
7 | 6337 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); |
6338 case PV_COM: return (char_u *)&(curbuf->b_p_com); | |
6339 #ifdef FEAT_FOLDING | |
6340 case PV_CMS: return (char_u *)&(curbuf->b_p_cms); | |
6341 #endif | |
6342 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
|
6343 #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
|
6344 case PV_CSL: return (char_u *)&(curbuf->b_p_csl); |
7 | 6345 #endif |
12 | 6346 #ifdef FEAT_COMPL_FUNC |
6347 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); | |
502 | 6348 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); |
12 | 6349 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
6350 #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
|
6351 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
|
6352 #endif |
30966
685ee8453163
Add missing entry for the 'endoffile' option.
Bram Moolenaar <Bram@vim.org>
parents:
30853
diff
changeset
|
6353 case PV_EOF: return (char_u *)&(curbuf->b_p_eof); |
7 | 6354 case PV_EOL: return (char_u *)&(curbuf->b_p_eol); |
6933 | 6355 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol); |
7 | 6356 case PV_ET: return (char_u *)&(curbuf->b_p_et); |
6357 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); | |
6358 case PV_FF: return (char_u *)&(curbuf->b_p_ff); | |
6359 case PV_FT: return (char_u *)&(curbuf->b_p_ft); | |
6360 case PV_FO: return (char_u *)&(curbuf->b_p_fo); | |
41 | 6361 case PV_FLP: return (char_u *)&(curbuf->b_p_flp); |
7 | 6362 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); |
6363 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); | |
6364 case PV_INF: return (char_u *)&(curbuf->b_p_inf); | |
6365 case PV_ISK: return (char_u *)&(curbuf->b_p_isk); | |
6366 #ifdef FEAT_FIND_ID | |
6367 # ifdef FEAT_EVAL | |
6368 case PV_INEX: return (char_u *)&(curbuf->b_p_inex); | |
6369 # endif | |
6370 #endif | |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
6371 #if defined(FEAT_EVAL) |
7 | 6372 case PV_INDE: return (char_u *)&(curbuf->b_p_inde); |
6373 case PV_INDK: return (char_u *)&(curbuf->b_p_indk); | |
6374 #endif | |
694 | 6375 #ifdef FEAT_EVAL |
667 | 6376 case PV_FEX: return (char_u *)&(curbuf->b_p_fex); |
6377 #endif | |
7 | 6378 #ifdef FEAT_CRYPT |
6379 case PV_KEY: return (char_u *)&(curbuf->b_p_key); | |
6380 #endif | |
6381 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
|
6382 case PV_LOP: return (char_u *)&(curbuf->b_p_lop); |
7 | 6383 case PV_ML: return (char_u *)&(curbuf->b_p_ml); |
6384 case PV_MPS: return (char_u *)&(curbuf->b_p_mps); | |
6385 case PV_MA: return (char_u *)&(curbuf->b_p_ma); | |
6386 case PV_MOD: return (char_u *)&(curbuf->b_changed); | |
6387 case PV_NF: return (char_u *)&(curbuf->b_p_nf); | |
6388 case PV_PI: return (char_u *)&(curbuf->b_p_pi); | |
12 | 6389 case PV_QE: return (char_u *)&(curbuf->b_p_qe); |
7 | 6390 case PV_RO: return (char_u *)&(curbuf->b_p_ro); |
6391 case PV_SI: return (char_u *)&(curbuf->b_p_si); | |
6392 case PV_SN: return (char_u *)&(curbuf->b_p_sn); | |
6393 case PV_STS: return (char_u *)&(curbuf->b_p_sts); | |
6394 case PV_SUA: return (char_u *)&(curbuf->b_p_sua); | |
6395 case PV_SWF: return (char_u *)&(curbuf->b_p_swf); | |
6396 #ifdef FEAT_SYN_HL | |
410 | 6397 case PV_SMC: return (char_u *)&(curbuf->b_p_smc); |
744 | 6398 case PV_SYN: return (char_u *)&(curbuf->b_p_syn); |
6399 #endif | |
6400 #ifdef FEAT_SPELL | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6401 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
|
6402 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
|
6403 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
|
6404 case PV_SPO: return (char_u *)&(curwin->w_s->b_p_spo); |
7 | 6405 #endif |
6406 case PV_SW: return (char_u *)&(curbuf->b_p_sw); | |
6407 case PV_TS: return (char_u *)&(curbuf->b_p_ts); | |
6408 case PV_TW: return (char_u *)&(curbuf->b_p_tw); | |
6409 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
|
6410 #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
|
6411 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
|
6412 #endif |
7 | 6413 case PV_WM: return (char_u *)&(curbuf->b_p_wm); |
6414 #ifdef FEAT_KEYMAP | |
6415 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); | |
6416 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6417 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6418 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
|
6419 #endif |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6420 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6421 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
|
6422 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
|
6423 #endif |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
6424 default: iemsg(_(e_get_varp_error)); |
7 | 6425 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6426 // always return a valid pointer to avoid a crash! |
7 | 6427 return (char_u *)&(curbuf->b_p_wm); |
6428 } | |
6429 | |
6430 /* | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6431 * 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
|
6432 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6433 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6434 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
|
6435 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6436 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
|
6437 } |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6438 |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
6439 #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
|
6440 /* |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6441 * 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
|
6442 */ |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6443 char_u * |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6444 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
|
6445 { |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6446 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
|
6447 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
6448 #endif |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6449 |
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
6450 /* |
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
|
6451 * 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
|
6452 */ |
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
|
6453 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
|
6454 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
|
6455 { |
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
|
6456 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
|
6457 } |
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
|
6458 |
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
|
6459 /* |
7 | 6460 * Get the value of 'equalprg', either the buffer-local one or the global one. |
6461 */ | |
6462 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6463 get_equalprg(void) |
7 | 6464 { |
6465 if (*curbuf->b_p_ep == NUL) | |
6466 return p_ep; | |
6467 return curbuf->b_p_ep; | |
6468 } | |
6469 | |
6470 /* | |
6471 * Copy options from one window to another. | |
6472 * Used when splitting a window. | |
6473 */ | |
6474 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6475 win_copy_options(win_T *wp_from, win_T *wp_to) |
7 | 6476 { |
6477 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); | |
6478 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
|
6479 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
|
6480 } |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
6481 |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
6482 /* |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
6483 * 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
|
6484 */ |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
6485 void |
27659
b5ebc885c25c
patch 8.2.4355: unnecessary call to check_colorcolumn()
Bram Moolenaar <Bram@vim.org>
parents:
27509
diff
changeset
|
6486 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
|
6487 { |
c81370b3ede4
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents:
18100
diff
changeset
|
6488 #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
|
6489 briopt_check(wp); |
6162 | 6490 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6491 #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
|
6492 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
|
6493 check_colorcolumn(wp); |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
6494 #endif |
29395
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
6495 set_chars_option(wp, &wp->w_p_lcs, TRUE); |
caaf5b270018
patch 9.0.0040: use of set_chars_option() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
29387
diff
changeset
|
6496 set_chars_option(wp, &wp->w_p_fcs, TRUE); |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6497 } |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6498 |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6499 static char_u * |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6500 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
|
6501 { |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6502 if (val == empty_option) |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6503 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
|
6504 return vim_strsave(val); |
7 | 6505 } |
6506 | |
6507 /* | |
6508 * Copy the options from one winopt_T to another. | |
6509 * Doesn't free the old option values in "to", use clear_winopt() for that. | |
6510 * The 'scroll' option is not copied, because it depends on the window height. | |
6511 * The 'previewwindow' option is reset, there can be only one preview window. | |
6512 */ | |
6513 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6514 copy_winopt(winopt_T *from, winopt_T *to) |
7 | 6515 { |
6516 #ifdef FEAT_ARABIC | |
6517 to->wo_arab = from->wo_arab; | |
6518 #endif | |
6519 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
|
6520 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
|
6521 to->wo_fcs = copy_option_val(from->wo_fcs); |
7 | 6522 to->wo_nu = from->wo_nu; |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2144
diff
changeset
|
6523 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
|
6524 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
|
6525 to->wo_ve_flags = from->wo_ve_flags; |
13 | 6526 #ifdef FEAT_LINEBREAK |
6527 to->wo_nuw = from->wo_nuw; | |
6528 #endif | |
7 | 6529 #ifdef FEAT_RIGHTLEFT |
6530 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
|
6531 to->wo_rlc = copy_option_val(from->wo_rlc); |
7 | 6532 #endif |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6533 #ifdef FEAT_LINEBREAK |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6534 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
|
6535 #endif |
40 | 6536 #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
|
6537 to->wo_stl = copy_option_val(from->wo_stl); |
40 | 6538 #endif |
7 | 6539 to->wo_wrap = from->wo_wrap; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6540 #ifdef FEAT_DIFF |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6541 to->wo_wrap_save = from->wo_wrap_save; |
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6542 #endif |
7 | 6543 #ifdef FEAT_LINEBREAK |
6544 to->wo_lbr = from->wo_lbr; | |
5995 | 6545 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
|
6546 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
|
6547 #endif |
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6548 to->wo_wcr = copy_option_val(from->wo_wcr); |
7 | 6549 to->wo_scb = from->wo_scb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6550 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
|
6551 to->wo_sms = from->wo_sms; |
2651 | 6552 to->wo_crb = from->wo_crb; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6553 to->wo_crb_save = from->wo_crb_save; |
744 | 6554 #ifdef FEAT_SPELL |
6555 to->wo_spell = from->wo_spell; | |
6556 #endif | |
221 | 6557 #ifdef FEAT_SYN_HL |
744 | 6558 to->wo_cuc = from->wo_cuc; |
6559 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
|
6560 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
|
6561 to->wo_cc = copy_option_val(from->wo_cc); |
221 | 6562 #endif |
7 | 6563 #ifdef FEAT_DIFF |
6564 to->wo_diff = from->wo_diff; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6565 to->wo_diff_saved = from->wo_diff_saved; |
7 | 6566 #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
|
6567 #ifdef FEAT_CONCEAL |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6568 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
|
6569 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
|
6570 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
6571 #ifdef FEAT_TERMINAL |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6572 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
|
6573 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
|
6574 #endif |
7 | 6575 #ifdef FEAT_FOLDING |
6576 to->wo_fdc = from->wo_fdc; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6577 to->wo_fdc_save = from->wo_fdc_save; |
7 | 6578 to->wo_fen = from->wo_fen; |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6579 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
|
6580 to->wo_fdi = copy_option_val(from->wo_fdi); |
7 | 6581 to->wo_fml = from->wo_fml; |
6582 to->wo_fdl = from->wo_fdl; | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6583 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
|
6584 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
|
6585 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
|
6586 ? vim_strsave(from->wo_fdm_save) : empty_option; |
7 | 6587 to->wo_fdn = from->wo_fdn; |
6588 # ifdef FEAT_EVAL | |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6589 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
|
6590 to->wo_fdt = copy_option_val(from->wo_fdt); |
7 | 6591 # endif |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6592 to->wo_fmr = copy_option_val(from->wo_fmr); |
7 | 6593 #endif |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6594 #ifdef FEAT_SIGNS |
29387
9dce192d1ac2
patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
6595 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
|
6596 #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
|
6597 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6598 #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
|
6599 // 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
|
6600 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
|
6601 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
|
6602 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6603 check_winopt(to); // don't want NULL pointers |
7 | 6604 } |
6605 | |
6606 /* | |
6607 * Check string options in a window for a NULL value. | |
6608 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
6609 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6610 check_win_options(win_T *win) |
7 | 6611 { |
6612 check_winopt(&win->w_onebuf_opt); | |
6613 check_winopt(&win->w_allbuf_opt); | |
6614 } | |
6615 | |
6616 /* | |
6617 * Check for NULL pointers in a winopt_T and replace them with empty_option. | |
6618 */ | |
5997 | 6619 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6620 check_winopt(winopt_T *wop UNUSED) |
7 | 6621 { |
6622 #ifdef FEAT_FOLDING | |
6623 check_string_option(&wop->wo_fdi); | |
6624 check_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6625 check_string_option(&wop->wo_fdm_save); |
7 | 6626 # ifdef FEAT_EVAL |
6627 check_string_option(&wop->wo_fde); | |
6628 check_string_option(&wop->wo_fdt); | |
6629 # endif | |
6630 check_string_option(&wop->wo_fmr); | |
6631 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6632 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6633 check_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6634 #endif |
7 | 6635 #ifdef FEAT_RIGHTLEFT |
6636 check_string_option(&wop->wo_rlc); | |
6637 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6638 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6639 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
|
6640 #endif |
40 | 6641 #ifdef FEAT_STL_OPT |
6642 check_string_option(&wop->wo_stl); | |
6643 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6644 #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
|
6645 check_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6646 check_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6647 #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
|
6648 #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
|
6649 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
|
6650 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
6651 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6652 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
|
6653 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
|
6654 #endif |
5995 | 6655 #ifdef FEAT_LINEBREAK |
6656 check_string_option(&wop->wo_briopt); | |
6657 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
6658 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
|
6659 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
|
6660 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
|
6661 check_string_option(&wop->wo_ve); |
7 | 6662 } |
6663 | |
6664 /* | |
6665 * Free the allocated memory inside a winopt_T. | |
6666 */ | |
6667 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6668 clear_winopt(winopt_T *wop UNUSED) |
7 | 6669 { |
6670 #ifdef FEAT_FOLDING | |
6671 clear_string_option(&wop->wo_fdi); | |
6672 clear_string_option(&wop->wo_fdm); | |
5102
11d0c6df1d7b
updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents:
5070
diff
changeset
|
6673 clear_string_option(&wop->wo_fdm_save); |
7 | 6674 # ifdef FEAT_EVAL |
6675 clear_string_option(&wop->wo_fde); | |
6676 clear_string_option(&wop->wo_fdt); | |
6677 # endif | |
6678 clear_string_option(&wop->wo_fmr); | |
6679 #endif | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6680 #ifdef FEAT_SIGNS |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6681 clear_string_option(&wop->wo_scl); |
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
6682 #endif |
5995 | 6683 #ifdef FEAT_LINEBREAK |
6684 clear_string_option(&wop->wo_briopt); | |
6685 #endif | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
6686 clear_string_option(&wop->wo_wcr); |
7 | 6687 #ifdef FEAT_RIGHTLEFT |
6688 clear_string_option(&wop->wo_rlc); | |
6689 #endif | |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6690 #ifdef FEAT_LINEBREAK |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6691 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
|
6692 #endif |
40 | 6693 #ifdef FEAT_STL_OPT |
6694 clear_string_option(&wop->wo_stl); | |
6695 #endif | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6696 #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
|
6697 clear_string_option(&wop->wo_culopt); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6698 clear_string_option(&wop->wo_cc); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
6699 #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
|
6700 #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
|
6701 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
|
6702 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11587
diff
changeset
|
6703 #ifdef FEAT_TERMINAL |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6704 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
|
6705 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
|
6706 #endif |
23952
44be09b25619
patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents:
23821
diff
changeset
|
6707 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
|
6708 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
|
6709 clear_string_option(&wop->wo_ve); |
7 | 6710 } |
6711 | |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6712 #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
|
6713 // 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
|
6714 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
|
6715 # 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
|
6716 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6717 /* |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6718 * 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
|
6719 */ |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6720 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
|
6721 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
|
6722 { |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6723 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
|
6724 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
|
6725 |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6726 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
|
6727 return; |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6728 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
|
6729 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
|
6730 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
|
6731 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
|
6732 } |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6733 #else |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6734 # 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
|
6735 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6736 |
7 | 6737 /* |
6738 * Copy global option values to local options for one buffer. | |
6739 * Used when creating a new buffer and sometimes when entering a buffer. | |
6740 * 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
|
6741 * BCO_ENTER We will enter the buffer "buf". |
7 | 6742 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when |
6743 * appropriate. | |
6744 * BCO_NOHELP Don't copy the values to a help buffer. | |
6745 */ | |
6746 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6747 buf_copy_options(buf_T *buf, int flags) |
7 | 6748 { |
6749 int should_copy = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6750 char_u *save_p_isk = NULL; // init for GCC |
7 | 6751 int dont_do_help; |
6752 int did_isk = FALSE; | |
6753 | |
6754 /* | |
6755 * Skip this when the option defaults have not been set yet. Happens when | |
6756 * main() allocates the first buffer. | |
6757 */ | |
6758 if (p_cpo != NULL) | |
6759 { | |
6760 /* | |
6761 * Always copy when entering and 'cpo' contains 'S'. | |
6762 * Don't copy when already initialized. | |
6763 * Don't copy when 'cpo' contains 's' and not entering. | |
6764 * 'S' BCO_ENTER initialized 's' should_copy | |
6765 * yes yes X X TRUE | |
6766 * yes no yes X FALSE | |
6767 * no X yes X FALSE | |
6768 * X no no yes FALSE | |
6769 * X no no no TRUE | |
6770 * no yes no X TRUE | |
6771 */ | |
6772 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) | |
6773 && (buf->b_p_initialized | |
6774 || (!(flags & BCO_ENTER) | |
6775 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
6776 should_copy = FALSE; | |
6777 | |
6778 if (should_copy || (flags & BCO_ALWAYS)) | |
6779 { | |
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
|
6780 #ifdef FEAT_EVAL |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
6781 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
|
6782 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
|
6783 #endif |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6784 // 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
|
6785 // 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
|
6786 // (jumping back to a help file with CTRL-T or CTRL-O) |
7 | 6787 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) |
6788 || 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
|
6789 if (dont_do_help) // don't free b_p_isk |
7 | 6790 { |
6791 save_p_isk = buf->b_p_isk; | |
6792 buf->b_p_isk = NULL; | |
6793 } | |
6794 /* | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14381
diff
changeset
|
6795 * Always free the allocated strings. If not already initialized, |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14381
diff
changeset
|
6796 * reset 'readonly' and copy 'fileformat'. |
7 | 6797 */ |
6798 if (!buf->b_p_initialized) | |
6799 { | |
6800 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
|
6801 buf->b_p_ro = FALSE; // don't copy readonly |
7 | 6802 buf->b_p_tx = p_tx; |
6803 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
|
6804 switch (*p_ffs) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6805 { |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6806 case 'm': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6807 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
|
6808 case 'd': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6809 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
|
6810 case 'u': |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6811 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
|
6812 default: |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6813 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
|
6814 } |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6815 if (buf->b_p_ff != NULL) |
c55a7232fb48
commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
6816 buf->b_start_ffc = *buf->b_p_ff; |
7 | 6817 buf->b_p_bh = empty_option; |
6818 buf->b_p_bt = empty_option; | |
6819 } | |
6820 else | |
6821 free_buf_options(buf, FALSE); | |
6822 | |
6823 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
|
6824 COPY_OPT_SCTX(buf, BV_AI); |
7 | 6825 buf->b_p_ai_nopaste = p_ai_nopaste; |
6826 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
|
6827 COPY_OPT_SCTX(buf, BV_SW); |
7 | 6828 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
|
6829 COPY_OPT_SCTX(buf, BV_TW); |
7 | 6830 buf->b_p_tw_nopaste = p_tw_nopaste; |
6831 buf->b_p_tw_nobin = p_tw_nobin; | |
6832 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
|
6833 COPY_OPT_SCTX(buf, BV_WM); |
7 | 6834 buf->b_p_wm_nopaste = p_wm_nopaste; |
6835 buf->b_p_wm_nobin = p_wm_nobin; | |
6836 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
|
6837 COPY_OPT_SCTX(buf, BV_BIN); |
402 | 6838 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
|
6839 COPY_OPT_SCTX(buf, BV_BOMB); |
6954 | 6840 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
|
6841 COPY_OPT_SCTX(buf, BV_FIXEOL); |
7 | 6842 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
|
6843 COPY_OPT_SCTX(buf, BV_ET); |
7 | 6844 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
|
6845 buf->b_p_et_nopaste = p_et_nopaste; |
7 | 6846 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
|
6847 COPY_OPT_SCTX(buf, BV_ML); |
7 | 6848 buf->b_p_ml_nobin = p_ml_nobin; |
6849 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
|
6850 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
|
6851 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
|
6852 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
|
6853 else |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6854 { |
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6855 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
|
6856 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
|
6857 } |
7 | 6858 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
|
6859 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
|
6860 #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
|
6861 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
|
6862 COPY_OPT_SCTX(buf, BV_CSL); |
7 | 6863 #endif |
12 | 6864 #ifdef FEAT_COMPL_FUNC |
6865 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
|
6866 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
|
6867 set_buflocal_cfu_callback(buf); |
502 | 6868 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
|
6869 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
|
6870 set_buflocal_ofu_callback(buf); |
12 | 6871 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
6872 #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
|
6873 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
|
6874 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
|
6875 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
|
6876 #endif |
7 | 6877 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
|
6878 COPY_OPT_SCTX(buf, BV_STS); |
7 | 6879 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
|
6880 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
6881 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
|
6882 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
|
6883 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
|
6884 (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
|
6885 else |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
6886 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
|
6887 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
|
6888 ? 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
|
6889 #endif |
7 | 6890 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
|
6891 COPY_OPT_SCTX(buf, BV_SN); |
7 | 6892 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
|
6893 COPY_OPT_SCTX(buf, BV_COM); |
7 | 6894 #ifdef FEAT_FOLDING |
6895 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
|
6896 COPY_OPT_SCTX(buf, BV_CMS); |
7 | 6897 #endif |
6898 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
|
6899 COPY_OPT_SCTX(buf, BV_FO); |
41 | 6900 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
|
6901 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
|
6902 // 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
|
6903 // when it is set to 8 bytes in defaults.vim. |
7 | 6904 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
|
6905 COPY_OPT_SCTX(buf, BV_NF); |
7 | 6906 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
|
6907 COPY_OPT_SCTX(buf, BV_MPS); |
7 | 6908 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
|
6909 COPY_OPT_SCTX(buf, BV_SI); |
7 | 6910 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
|
6911 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
|
6912 |
7 | 6913 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
|
6914 COPY_OPT_SCTX(buf, BV_CIN); |
7 | 6915 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
|
6916 COPY_OPT_SCTX(buf, BV_CINK); |
7 | 6917 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
|
6918 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
|
6919 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
|
6920 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
|
6921 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
|
6922 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
|
6923 |
18380
212284f893d5
patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6924 // Don't copy 'filetype', it must be detected |
7 | 6925 buf->b_p_ft = empty_option; |
6926 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
|
6927 COPY_OPT_SCTX(buf, BV_PI); |
7 | 6928 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
|
6929 COPY_OPT_SCTX(buf, BV_CINW); |
7 | 6930 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
|
6931 COPY_OPT_SCTX(buf, BV_LISP); |
7 | 6932 #ifdef FEAT_SYN_HL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6933 // Don't copy 'syntax', it must be set |
7 | 6934 buf->b_p_syn = empty_option; |
410 | 6935 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
|
6936 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
|
6937 buf->b_s.b_syn_isk = empty_option; |
744 | 6938 #endif |
6939 #ifdef FEAT_SPELL | |
2599 | 6940 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
|
6941 COPY_OPT_SCTX(buf, BV_SPC); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6942 (void)compile_cap_prog(&buf->b_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6943 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
|
6944 COPY_OPT_SCTX(buf, BV_SPF); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2248
diff
changeset
|
6945 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
|
6946 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
|
6947 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
|
6948 COPY_OPT_SCTX(buf, BV_SPO); |
7 | 6949 #endif |
28942
6cdf55afaae9
patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents:
28919
diff
changeset
|
6950 #if defined(FEAT_EVAL) |
7 | 6951 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
|
6952 COPY_OPT_SCTX(buf, BV_INDE); |
7 | 6953 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
|
6954 COPY_OPT_SCTX(buf, BV_INDK); |
7 | 6955 #endif |
10579
688b97124d23
patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents:
10456
diff
changeset
|
6956 buf->b_p_fp = empty_option; |
667 | 6957 #if defined(FEAT_EVAL) |
6958 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
|
6959 COPY_OPT_SCTX(buf, BV_FEX); |
667 | 6960 #endif |
7 | 6961 #ifdef FEAT_CRYPT |
6962 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
|
6963 COPY_OPT_SCTX(buf, BV_KEY); |
7 | 6964 #endif |
6965 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
|
6966 COPY_OPT_SCTX(buf, BV_SUA); |
7 | 6967 #ifdef FEAT_KEYMAP |
6968 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
|
6969 COPY_OPT_SCTX(buf, BV_KMAP); |
7 | 6970 buf->b_kmap_state |= KEYMAP_INIT; |
6971 #endif | |
13742
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6972 #ifdef FEAT_TERMINAL |
a34b1323286c
patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents:
13700
diff
changeset
|
6973 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
|
6974 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
|
6975 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6976 // 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
|
6977 // state from the current buffer is better than resetting it. |
7 | 6978 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
|
6979 COPY_OPT_SCTX(buf, BV_IMI); |
7 | 6980 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
|
6981 COPY_OPT_SCTX(buf, BV_IMS); |
7 | 6982 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
6983 // 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
|
6984 // are not copied, start using the global value |
7 | 6985 buf->b_p_ar = -1; |
5446 | 6986 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
6243 | 6987 buf->b_p_bkc = empty_option; |
6988 buf->b_bkc_flags = 0; | |
7 | 6989 #ifdef FEAT_QUICKFIX |
6990 buf->b_p_gp = empty_option; | |
6991 buf->b_p_mp = empty_option; | |
6992 buf->b_p_efm = empty_option; | |
6993 #endif | |
6994 buf->b_p_ep = empty_option; | |
6995 buf->b_p_kp = empty_option; | |
6996 buf->b_p_path = empty_option; | |
6997 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
|
6998 buf->b_p_tc = empty_option; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
7218
diff
changeset
|
6999 buf->b_tc_flags = 0; |
7 | 7000 #ifdef FEAT_FIND_ID |
7001 buf->b_p_def = empty_option; | |
7002 buf->b_p_inc = empty_option; | |
7003 # ifdef FEAT_EVAL | |
7004 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
|
7005 COPY_OPT_SCTX(buf, BV_INEX); |
7 | 7006 # endif |
7007 #endif | |
7008 buf->b_p_dict = empty_option; | |
7009 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
|
7010 #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
|
7011 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
|
7012 #endif |
12 | 7013 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
|
7014 COPY_OPT_SCTX(buf, BV_QE); |
790 | 7015 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) |
7016 buf->b_p_bexpr = empty_option; | |
7017 #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
|
7018 #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
|
7019 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
|
7020 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2184
diff
changeset
|
7021 #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
|
7022 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
|
7023 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
|
7024 #endif |
5712 | 7025 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
|
7026 buf->b_p_menc = empty_option; |
7 | 7027 |
7028 /* | |
7029 * Don't copy the options set by ex_help(), use the saved values, | |
7030 * when going from a help buffer to a non-help buffer. | |
7031 * Don't touch these at all when BCO_NOHELP is used and going from | |
7032 * or to a help buffer. | |
7033 */ | |
7034 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
|
7035 { |
7 | 7036 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
|
7037 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7038 if (p_vts && p_vts != empty_option && !buf->b_p_vts_array) |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
7039 (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
|
7040 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7041 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
|
7042 #endif |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7043 } |
7 | 7044 else |
7045 { | |
7046 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
|
7047 COPY_OPT_SCTX(buf, BV_ISK); |
7 | 7048 did_isk = TRUE; |
7049 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
|
7050 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
|
7051 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7052 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
|
7053 COPY_OPT_SCTX(buf, BV_VTS); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7054 if (p_vts && p_vts != empty_option && !buf->b_p_vts_array) |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
7055 (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
|
7056 else |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7057 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
|
7058 #endif |
7 | 7059 buf->b_help = FALSE; |
7060 if (buf->b_p_bt[0] == 'h') | |
7061 clear_string_option(&buf->b_p_bt); | |
7062 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
|
7063 COPY_OPT_SCTX(buf, BV_MA); |
7 | 7064 } |
7065 } | |
7066 | |
7067 /* | |
7068 * When the options should be copied (ignoring BCO_ALWAYS), set the | |
7069 * flag that indicates that the options have been initialized. | |
7070 */ | |
7071 if (should_copy) | |
7072 buf->b_p_initialized = TRUE; | |
7073 } | |
7074 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7075 check_buf_options(buf); // make sure we don't have NULLs |
7 | 7076 if (did_isk) |
7077 (void)buf_init_chartab(buf, FALSE); | |
7078 } | |
7079 | |
7080 /* | |
7081 * Reset the 'modifiable' option and its default value. | |
7082 */ | |
7083 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7084 reset_modifiable(void) |
7 | 7085 { |
7086 int opt_idx; | |
7087 | |
7088 curbuf->b_p_ma = FALSE; | |
7089 p_ma = FALSE; | |
7090 opt_idx = findoption((char_u *)"ma"); | |
838 | 7091 if (opt_idx >= 0) |
7092 options[opt_idx].def_val[VI_DEFAULT] = FALSE; | |
7 | 7093 } |
7094 | |
7095 /* | |
7096 * Set the global value for 'iminsert' to the local value. | |
7097 */ | |
7098 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7099 set_iminsert_global(void) |
7 | 7100 { |
7101 p_iminsert = curbuf->b_p_iminsert; | |
7102 } | |
7103 | |
7104 /* | |
7105 * Set the global value for 'imsearch' to the local value. | |
7106 */ | |
7107 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7108 set_imsearch_global(void) |
7 | 7109 { |
7110 p_imsearch = curbuf->b_p_imsearch; | |
7111 } | |
7112 | |
7113 static int expand_option_idx = -1; | |
7114 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; | |
7115 static int expand_option_flags = 0; | |
7116 | |
7117 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7118 set_context_in_set_cmd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7119 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7120 char_u *arg, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7121 int opt_flags) // OPT_GLOBAL and/or OPT_LOCAL |
7 | 7122 { |
7123 int nextchar; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7124 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
|
7125 int opt_idx = 0; // init for GCC |
7 | 7126 char_u *p; |
7127 char_u *s; | |
7128 int is_term_option = FALSE; | |
7129 int key; | |
7130 | |
7131 expand_option_flags = opt_flags; | |
7132 | |
7133 xp->xp_context = EXPAND_SETTINGS; | |
7134 if (*arg == NUL) | |
7135 { | |
7136 xp->xp_pattern = arg; | |
7137 return; | |
7138 } | |
7139 p = arg + STRLEN(arg) - 1; | |
7140 if (*p == ' ' && *(p - 1) != '\\') | |
7141 { | |
7142 xp->xp_pattern = p + 1; | |
7143 return; | |
7144 } | |
7145 while (p > arg) | |
7146 { | |
7147 s = p; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7148 // count number of backslashes before ' ' or ',' |
7 | 7149 if (*p == ' ' || *p == ',') |
7150 { | |
7151 while (s > arg && *(s - 1) == '\\') | |
7152 --s; | |
7153 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7154 // break at a space with an even number of backslashes |
7 | 7155 if (*p == ' ' && ((p - s) & 1) == 0) |
7156 { | |
7157 ++p; | |
7158 break; | |
7159 } | |
7160 --p; | |
7161 } | |
1911 | 7162 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0) |
7 | 7163 { |
7164 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
7165 p += 2; | |
7166 } | |
7167 if (STRNCMP(p, "inv", 3) == 0) | |
7168 { | |
7169 xp->xp_context = EXPAND_BOOL_SETTINGS; | |
7170 p += 3; | |
7171 } | |
7172 xp->xp_pattern = arg = p; | |
7173 if (*arg == '<') | |
7174 { | |
7175 while (*p != '>') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7176 if (*p++ == NUL) // expand terminal option name |
7 | 7177 return; |
7178 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
|
7179 if (key == 0) // unknown name |
7 | 7180 { |
7181 xp->xp_context = EXPAND_NOTHING; | |
7182 return; | |
7183 } | |
7184 nextchar = *++p; | |
7185 is_term_option = TRUE; | |
7186 expand_option_name[2] = KEY2TERMCAP0(key); | |
7187 expand_option_name[3] = KEY2TERMCAP1(key); | |
7188 } | |
7189 else | |
7190 { | |
7191 if (p[0] == 't' && p[1] == '_') | |
7192 { | |
7193 p += 2; | |
7194 if (*p != NUL) | |
7195 ++p; | |
7196 if (*p == NUL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7197 return; // expand option name |
7 | 7198 nextchar = *++p; |
7199 is_term_option = TRUE; | |
7200 expand_option_name[2] = p[-2]; | |
7201 expand_option_name[3] = p[-1]; | |
7202 } | |
7203 else | |
7204 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7205 // Allow * wildcard |
7 | 7206 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') |
7207 p++; | |
7208 if (*p == NUL) | |
7209 return; | |
7210 nextchar = *p; | |
7211 *p = NUL; | |
7212 opt_idx = findoption(arg); | |
7213 *p = nextchar; | |
7214 if (opt_idx == -1 || options[opt_idx].var == NULL) | |
7215 { | |
7216 xp->xp_context = EXPAND_NOTHING; | |
7217 return; | |
7218 } | |
7219 flags = options[opt_idx].flags; | |
7220 if (flags & P_BOOL) | |
7221 { | |
7222 xp->xp_context = EXPAND_NOTHING; | |
7223 return; | |
7224 } | |
7225 } | |
7226 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7227 // handle "-=" and "+=" |
7 | 7228 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') |
7229 { | |
7230 ++p; | |
7231 nextchar = '='; | |
7232 } | |
7233 if ((nextchar != '=' && nextchar != ':') | |
7234 || xp->xp_context == EXPAND_BOOL_SETTINGS) | |
7235 { | |
7236 xp->xp_context = EXPAND_UNSUCCESSFUL; | |
7237 return; | |
7238 } | |
7239 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) | |
7240 { | |
7241 xp->xp_context = EXPAND_OLD_SETTING; | |
7242 if (is_term_option) | |
7243 expand_option_idx = -1; | |
7244 else | |
7245 expand_option_idx = opt_idx; | |
7246 xp->xp_pattern = p + 1; | |
7247 return; | |
7248 } | |
7249 xp->xp_context = EXPAND_NOTHING; | |
7250 if (is_term_option || (flags & P_NUM)) | |
7251 return; | |
7252 | |
7253 xp->xp_pattern = p + 1; | |
7254 | |
7255 if (flags & P_EXPAND) | |
7256 { | |
7257 p = options[opt_idx].var; | |
7258 if (p == (char_u *)&p_bdir | |
7259 || p == (char_u *)&p_dir | |
7260 || p == (char_u *)&p_path | |
8182
95d59081580f
commit https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
7261 || p == (char_u *)&p_pp |
7 | 7262 || p == (char_u *)&p_rtp |
7263 || p == (char_u *)&p_cdpath | |
7264 #ifdef FEAT_SESSION | |
7265 || p == (char_u *)&p_vdir | |
7266 #endif | |
7267 ) | |
7268 { | |
7269 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
|
7270 if (p == (char_u *)&p_path || p == (char_u *)&p_cdpath) |
7 | 7271 xp->xp_backslash = XP_BS_THREE; |
7272 else | |
7273 xp->xp_backslash = XP_BS_ONE; | |
7274 } | |
23821
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
7275 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
|
7276 { |
bfc1ae959d9d
patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
7277 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
|
7278 } |
7 | 7279 else |
7280 { | |
7281 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
|
7282 // for 'tags' need three backslashes for a space |
7 | 7283 if (p == (char_u *)&p_tags) |
7284 xp->xp_backslash = XP_BS_THREE; | |
7285 else | |
7286 xp->xp_backslash = XP_BS_ONE; | |
7287 } | |
7288 } | |
7289 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7290 // 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
|
7291 // last file name. |
7 | 7292 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) |
7293 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7294 // count number of backslashes before ' ' or ',' |
7 | 7295 if (*p == ' ' || *p == ',') |
7296 { | |
7297 s = p; | |
7298 while (s > xp->xp_pattern && *(s - 1) == '\\') | |
7299 --s; | |
7300 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) | |
7301 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) | |
7302 { | |
7303 xp->xp_pattern = p + 1; | |
7304 break; | |
7305 } | |
7306 } | |
374 | 7307 |
744 | 7308 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7309 // for 'spellsuggest' start at "file:" |
374 | 7310 if (options[opt_idx].var == (char_u *)&p_sps |
7311 && STRNCMP(p, "file:", 5) == 0) | |
7312 { | |
7313 xp->xp_pattern = p + 5; | |
7314 break; | |
7315 } | |
7316 #endif | |
7 | 7317 } |
7318 } | |
7319 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7320 /* |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7321 * 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
|
7322 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7323 * 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
|
7324 * 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
|
7325 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7326 * 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
|
7327 * 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
|
7328 * returns TRUE. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7329 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7330 * 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
|
7331 * '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
|
7332 * |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7333 * 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
|
7334 * '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
|
7335 */ |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7336 static int |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7337 match_str( |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7338 char_u *str, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7339 regmatch_T *regmatch, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7340 char_u **matches, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7341 int idx, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7342 int test_only, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7343 int fuzzy, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7344 char_u *fuzzystr, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7345 fuzmatch_str_T *fuzmatch) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7346 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7347 if (!fuzzy) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7348 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7349 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
|
7350 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7351 if (!test_only) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7352 matches[idx] = vim_strsave(str); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7353 return TRUE; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7354 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7355 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7356 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7357 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7358 int score; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7359 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7360 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
|
7361 if (score != 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7362 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7363 if (!test_only) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7364 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7365 fuzmatch[idx].idx = idx; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7366 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
|
7367 fuzmatch[idx].score = score; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7368 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7369 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7370 return TRUE; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7371 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7372 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7373 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7374 return FALSE; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7375 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7376 |
7 | 7377 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7378 ExpandSettings( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7379 expand_T *xp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7380 regmatch_T *regmatch, |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7381 char_u *fuzzystr, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7382 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
|
7383 char_u ***matches, |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
7384 int can_fuzzy) |
7 | 7385 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7386 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
|
7387 int num_term = 0; // Nr of matching terminal code settings |
7 | 7388 int opt_idx; |
7389 int match; | |
7390 int count = 0; | |
7391 char_u *str; | |
7392 int loop; | |
7393 int is_term_opt; | |
7394 char_u name_buf[MAX_KEY_NAME_LEN]; | |
7395 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
|
7396 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
|
7397 int fuzzy; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7398 fuzmatch_str_T *fuzmatch = NULL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7399 |
28786
fd5942a62312
patch 8.2.4917: fuzzy expansion of option names is not right
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
7400 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
|
7401 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7402 // do this loop twice: |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7403 // 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
|
7404 // loop == 1: copy the matching options into allocated memory |
7 | 7405 for (loop = 0; loop <= 1; ++loop) |
7406 { | |
7407 regmatch->rm_ic = ic; | |
7408 if (xp->xp_context != EXPAND_BOOL_SETTINGS) | |
7409 { | |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
7410 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
|
7411 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7412 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
|
7413 count, (loop == 0), fuzzy, fuzzystr, fuzmatch)) |
7 | 7414 { |
7415 if (loop == 0) | |
7416 num_normal++; | |
7417 else | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7418 count++; |
7 | 7419 } |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7420 } |
7 | 7421 } |
7422 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; | |
7423 opt_idx++) | |
7424 { | |
7425 if (options[opt_idx].var == NULL) | |
7426 continue; | |
7427 if (xp->xp_context == EXPAND_BOOL_SETTINGS | |
7428 && !(options[opt_idx].flags & P_BOOL)) | |
7429 continue; | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7430 is_term_opt = istermoption_idx(opt_idx); |
7 | 7431 if (is_term_opt && num_normal > 0) |
7432 continue; | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7433 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7434 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
|
7435 fuzzy, fuzzystr, fuzmatch)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7436 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7437 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7438 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7439 if (is_term_opt) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7440 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7441 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7442 num_normal++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7443 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7444 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7445 count++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7446 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7447 else if (!fuzzy && options[opt_idx].shortname != NULL |
7 | 7448 && vim_regexec(regmatch, |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28804
diff
changeset
|
7449 (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
|
7450 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7451 // 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
|
7452 // 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
|
7453 // 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
|
7454 if (loop == 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 (is_term_opt) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7457 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7458 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7459 num_normal++; |
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 (*matches)[count++] = vim_strsave(str); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7463 } |
7 | 7464 else if (is_term_opt) |
7465 { | |
7466 name_buf[0] = '<'; | |
7467 name_buf[1] = 't'; | |
7468 name_buf[2] = '_'; | |
7469 name_buf[3] = str[2]; | |
7470 name_buf[4] = str[3]; | |
7471 name_buf[5] = '>'; | |
7472 name_buf[6] = NUL; | |
27875
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 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
|
7475 fuzzy, fuzzystr, fuzmatch)) |
7 | 7476 { |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7477 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7478 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7479 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7480 count++; |
7 | 7481 } |
7482 } | |
7483 } | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7484 |
7 | 7485 /* |
7486 * Check terminal key codes, these are not in the option table | |
7487 */ | |
7488 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) | |
7489 { | |
7490 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) | |
7491 { | |
7492 if (!isprint(str[0]) || !isprint(str[1])) | |
7493 continue; | |
7494 | |
7495 name_buf[0] = 't'; | |
7496 name_buf[1] = '_'; | |
7497 name_buf[2] = str[0]; | |
7498 name_buf[3] = str[1]; | |
7499 name_buf[4] = NUL; | |
7500 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7501 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
|
7502 (loop == 0), fuzzy, fuzzystr, fuzmatch)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7503 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7504 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7505 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7506 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7507 count++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7508 } |
7 | 7509 else |
7510 { | |
7511 name_buf[0] = '<'; | |
7512 name_buf[1] = 't'; | |
7513 name_buf[2] = '_'; | |
7514 name_buf[3] = str[0]; | |
7515 name_buf[4] = str[1]; | |
7516 name_buf[5] = '>'; | |
7517 name_buf[6] = NUL; | |
7518 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7519 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
|
7520 (loop == 0), fuzzy, fuzzystr, |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7521 fuzmatch)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7522 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7523 if (loop == 0) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7524 num_term++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7525 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7526 count++; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7527 } |
7 | 7528 } |
7529 } | |
7530 | |
7531 /* | |
7532 * Check special key names. | |
7533 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7534 regmatch->rm_ic = TRUE; // ignore case here |
7 | 7535 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) |
7536 { | |
7537 name_buf[0] = '<'; | |
7538 STRCPY(name_buf + 1, str); | |
7539 STRCAT(name_buf, ">"); | |
7540 | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7541 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
|
7542 fuzzy, fuzzystr, fuzmatch)) |
7 | 7543 { |
7544 if (loop == 0) | |
7545 num_term++; | |
7546 else | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7547 count++; |
7 | 7548 } |
7549 } | |
7550 } | |
7551 if (loop == 0) | |
7552 { | |
7553 if (num_normal > 0) | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7554 *numMatches = num_normal; |
7 | 7555 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
|
7556 *numMatches = num_term; |
7 | 7557 else |
7558 return OK; | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7559 if (!fuzzy) |
7 | 7560 { |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7561 *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
|
7562 if (*matches == NULL) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7563 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7564 *matches = (char_u **)""; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7565 return FAIL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7566 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7567 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7568 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7569 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7570 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
|
7571 if (fuzmatch == NULL) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7572 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7573 *matches = (char_u **)""; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7574 return FAIL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7575 } |
7 | 7576 } |
7577 } | |
7578 } | |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7579 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7580 if (fuzzy && |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7581 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
|
7582 return FAIL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27855
diff
changeset
|
7583 |
7 | 7584 return OK; |
7585 } | |
7586 | |
7587 int | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
7588 ExpandOldSetting(int *numMatches, char_u ***matches) |
7 | 7589 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7590 char_u *var = NULL; // init for GCC |
7 | 7591 char_u *buf; |
7592 | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
7593 *numMatches = 0; |
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
7594 *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
|
7595 if (*matches == NULL) |
7 | 7596 return FAIL; |
7597 | |
7598 /* | |
7599 * For a terminal key code expand_option_idx is < 0. | |
7600 */ | |
7601 if (expand_option_idx < 0) | |
7602 { | |
7603 var = find_termcode(expand_option_name + 2); | |
7604 if (var == NULL) | |
7605 expand_option_idx = findoption(expand_option_name); | |
7606 } | |
7607 | |
7608 if (expand_option_idx >= 0) | |
7609 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7610 // put string of option value in NameBuff |
7 | 7611 option_value2string(&options[expand_option_idx], expand_option_flags); |
7612 var = NameBuff; | |
7613 } | |
7614 else if (var == NULL) | |
7615 var = (char_u *)""; | |
7616 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7617 // 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
|
7618 // what happens in do_set(). |
7 | 7619 buf = vim_strsave_escaped(var, escape_chars); |
7620 | |
7621 if (buf == NULL) | |
7622 { | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
7623 VIM_CLEAR(*matches); |
7 | 7624 return FAIL; |
7625 } | |
7626 | |
7627 #ifdef BACKSLASH_IN_FILENAME | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7628 // 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
|
7629 // 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
|
7630 for (var = buf; *var != NUL; MB_PTR_ADV(var)) |
7 | 7631 if (var[0] == '\\' && var[1] == '\\' |
7632 && expand_option_idx >= 0 | |
7633 && (options[expand_option_idx].flags & P_EXPAND) | |
7634 && vim_isfilec(var[2]) | |
7635 && (var[2] != '\\' || (var == buf && var[4] != '\\'))) | |
1622 | 7636 STRMOVE(var, var + 1); |
7 | 7637 #endif |
7638 | |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
7639 *matches[0] = buf; |
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31766
diff
changeset
|
7640 *numMatches = 1; |
7 | 7641 return OK; |
7642 } | |
7643 | |
7644 /* | |
7645 * Get the value for the numeric or string option *opp in a nice format into | |
7646 * NameBuff[]. Must not be called with a hidden option! | |
7647 */ | |
7648 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7649 option_value2string( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7650 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
|
7651 int scope) // OPT_GLOBAL and/or OPT_LOCAL |
7 | 7652 { |
7653 char_u *varp; | |
7654 | |
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
|
7655 varp = get_varp_scope(opp, scope); |
7 | 7656 |
7657 if (opp->flags & P_NUM) | |
7658 { | |
7659 long wc = 0; | |
7660 | |
7661 if (wc_use_keyname(varp, &wc)) | |
7662 STRCPY(NameBuff, get_special_key_name((int)wc, 0)); | |
7663 else if (wc != 0) | |
7664 STRCPY(NameBuff, transchar((int)wc)); | |
7665 else | |
7666 sprintf((char *)NameBuff, "%ld", *(long *)varp); | |
7667 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7668 else // P_STRING |
7 | 7669 { |
7670 varp = *(char_u **)(varp); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7671 if (varp == NULL) // just in case |
7 | 7672 NameBuff[0] = NUL; |
7673 #ifdef FEAT_CRYPT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7674 // don't show the actual value of 'key', only that it's set |
840 | 7675 else if (opp->var == (char_u *)&p_key && *varp) |
7 | 7676 STRCPY(NameBuff, "*****"); |
7677 #endif | |
7678 else if (opp->flags & P_EXPAND) | |
7679 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
|
7680 // Translate 'pastetoggle' into special key names |
7 | 7681 else if ((char_u **)opp->var == &p_pt) |
7682 str2specialbuf(p_pt, NameBuff, MAXPATHL); | |
7683 else | |
419 | 7684 vim_strncpy(NameBuff, varp, MAXPATHL - 1); |
7 | 7685 } |
7686 } | |
7687 | |
7688 /* | |
7689 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be | |
7690 * printed as a keyname. | |
7691 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. | |
7692 */ | |
7693 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7694 wc_use_keyname(char_u *varp, long *wcp) |
7 | 7695 { |
7696 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) | |
7697 { | |
7698 *wcp = *(long *)varp; | |
7699 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0) | |
7700 return TRUE; | |
7701 } | |
7702 return FALSE; | |
7703 } | |
7704 | |
7705 /* | |
7706 * Return TRUE if "x" is present in 'shortmess' option, or | |
7707 * 'shortmess' contains 'a' and "x" is present in SHM_A. | |
7708 */ | |
7709 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7710 shortmess(int x) |
7 | 7711 { |
3384 | 7712 return p_shm != NULL && |
7713 ( vim_strchr(p_shm, x) != NULL | |
7 | 7714 || (vim_strchr(p_shm, 'a') != NULL |
7715 && vim_strchr((char_u *)SHM_A, x) != NULL)); | |
7716 } | |
7717 | |
7718 /* | |
7719 * paste_option_changed() - Called after p_paste was set or reset. | |
7720 */ | |
7721 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7722 paste_option_changed(void) |
7 | 7723 { |
7724 static int old_p_paste = FALSE; | |
7725 static int save_sm = 0; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7726 static int save_sta = 0; |
7 | 7727 static int save_ru = 0; |
7728 #ifdef FEAT_RIGHTLEFT | |
7729 static int save_ri = 0; | |
7730 static int save_hkmap = 0; | |
7731 #endif | |
7732 buf_T *buf; | |
7733 | |
7734 if (p_paste) | |
7735 { | |
7736 /* | |
7737 * Paste switched from off to on. | |
7738 * Save the current values, so they can be restored later. | |
7739 */ | |
7740 if (!old_p_paste) | |
7741 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7742 // save options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7743 FOR_ALL_BUFFERS(buf) |
7 | 7744 { |
7745 buf->b_p_tw_nopaste = buf->b_p_tw; | |
7746 buf->b_p_wm_nopaste = buf->b_p_wm; | |
7747 buf->b_p_sts_nopaste = buf->b_p_sts; | |
7748 buf->b_p_ai_nopaste = buf->b_p_ai; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7749 buf->b_p_et_nopaste = buf->b_p_et; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7750 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7751 if (buf->b_p_vsts_nopaste) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7752 vim_free(buf->b_p_vsts_nopaste); |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
7753 buf->b_p_vsts_nopaste = |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
7754 buf->b_p_vsts && buf->b_p_vsts != empty_option |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
7755 ? vim_strsave(buf->b_p_vsts) : NULL; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7756 #endif |
7 | 7757 } |
7758 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7759 // save global options |
7 | 7760 save_sm = p_sm; |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7761 save_sta = p_sta; |
7 | 7762 save_ru = p_ru; |
7763 #ifdef FEAT_RIGHTLEFT | |
7764 save_ri = p_ri; | |
7765 save_hkmap = p_hkmap; | |
7766 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7767 // save global values for local buffer options |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7768 p_ai_nopaste = p_ai; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7769 p_et_nopaste = p_et; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7770 p_sts_nopaste = p_sts; |
7 | 7771 p_tw_nopaste = p_tw; |
7772 p_wm_nopaste = p_wm; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7773 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7774 if (p_vsts_nopaste) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7775 vim_free(p_vsts_nopaste); |
31174
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
7776 p_vsts_nopaste = p_vsts && p_vsts != empty_option |
1d00fa720007
patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents:
31000
diff
changeset
|
7777 ? vim_strsave(p_vsts) : NULL; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7778 #endif |
7 | 7779 } |
7780 | |
7781 /* | |
7782 * Always set the option values, also when 'paste' is set when it is | |
7783 * already on. | |
7784 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7785 // set options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7786 FOR_ALL_BUFFERS(buf) |
7 | 7787 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7788 buf->b_p_tw = 0; // textwidth is 0 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7789 buf->b_p_wm = 0; // wrapmargin is 0 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7790 buf->b_p_sts = 0; // softtabstop is 0 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7791 buf->b_p_ai = 0; // no auto-indent |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7792 buf->b_p_et = 0; // no expandtab |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7793 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7794 if (buf->b_p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7795 free_string_option(buf->b_p_vsts); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7796 buf->b_p_vsts = empty_option; |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7797 VIM_CLEAR(buf->b_p_vsts_array); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7798 #endif |
7 | 7799 } |
7800 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7801 // set global options |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7802 p_sm = 0; // no showmatch |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7803 p_sta = 0; // no smarttab |
7 | 7804 if (p_ru) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7805 status_redraw_all(); // redraw to remove the ruler |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7806 p_ru = 0; // no ruler |
7 | 7807 #ifdef FEAT_RIGHTLEFT |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7808 p_ri = 0; // no reverse insert |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7809 p_hkmap = 0; // no Hebrew keyboard |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7810 #endif |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7811 // set global values for local buffer options |
7 | 7812 p_tw = 0; |
7813 p_wm = 0; | |
7814 p_sts = 0; | |
7815 p_ai = 0; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7816 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7817 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7818 free_string_option(p_vsts); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7819 p_vsts = empty_option; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7820 #endif |
7 | 7821 } |
7822 | |
7823 /* | |
7824 * Paste switched from on to off: Restore saved values. | |
7825 */ | |
7826 else if (old_p_paste) | |
7827 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7828 // restore options for each buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
7829 FOR_ALL_BUFFERS(buf) |
7 | 7830 { |
7831 buf->b_p_tw = buf->b_p_tw_nopaste; | |
7832 buf->b_p_wm = buf->b_p_wm_nopaste; | |
7833 buf->b_p_sts = buf->b_p_sts_nopaste; | |
7834 buf->b_p_ai = buf->b_p_ai_nopaste; | |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7835 buf->b_p_et = buf->b_p_et_nopaste; |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7836 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7837 if (buf->b_p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7838 free_string_option(buf->b_p_vsts); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7839 buf->b_p_vsts = buf->b_p_vsts_nopaste |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7840 ? vim_strsave(buf->b_p_vsts_nopaste) : empty_option; |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7841 vim_free(buf->b_p_vsts_array); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7842 if (buf->b_p_vsts && buf->b_p_vsts != empty_option) |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
25487
diff
changeset
|
7843 (void)tabstop_set(buf->b_p_vsts, &buf->b_p_vsts_array); |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7844 else |
27434
c1702fd7e716
patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7845 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
|
7846 #endif |
7 | 7847 } |
7848 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7849 // restore global options |
7 | 7850 p_sm = save_sm; |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7851 p_sta = save_sta; |
7 | 7852 if (p_ru != save_ru) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7853 status_redraw_all(); // redraw to draw the ruler |
7 | 7854 p_ru = save_ru; |
7855 #ifdef FEAT_RIGHTLEFT | |
7856 p_ri = save_ri; | |
7857 p_hkmap = save_hkmap; | |
7858 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7859 // set global values for local buffer options |
7113
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7860 p_ai = p_ai_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7861 p_et = p_et_nopaste; |
83b3261352b3
commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents:
7058
diff
changeset
|
7862 p_sts = p_sts_nopaste; |
7 | 7863 p_tw = p_tw_nopaste; |
7864 p_wm = p_wm_nopaste; | |
14175
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7865 #ifdef FEAT_VARTABS |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7866 if (p_vsts) |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7867 free_string_option(p_vsts); |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7868 p_vsts = p_vsts_nopaste ? vim_strsave(p_vsts_nopaste) : empty_option; |
2ad722003b36
patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents:
14099
diff
changeset
|
7869 #endif |
7 | 7870 } |
7871 | |
7872 old_p_paste = p_paste; | |
7873 } | |
7874 | |
7875 /* | |
7876 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found. | |
7877 * | |
7878 * Reset 'compatible' and set the values for options that didn't get set yet | |
7879 * to the Vim defaults. | |
7880 * Don't do this if the 'compatible' option has been set or reset before. | |
819 | 7881 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet. |
7 | 7882 */ |
7883 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7884 vimrc_found(char_u *fname, char_u *envname) |
819 | 7885 { |
7886 int opt_idx; | |
826 | 7887 int dofree = FALSE; |
819 | 7888 char_u *p; |
7 | 7889 |
7890 if (!option_was_set((char_u *)"cp")) | |
7891 { | |
7892 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
|
7893 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 7894 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF))) |
7895 set_option_default(opt_idx, OPT_FREE, FALSE); | |
7896 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
7897 didset_options2(); |
7 | 7898 } |
819 | 7899 |
7900 if (fname != NULL) | |
7901 { | |
7902 p = vim_getenv(envname, &dofree); | |
7903 if (p == NULL) | |
7904 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7905 // Set $MYVIMRC to the first vimrc file found. |
819 | 7906 p = FullName_save(fname, FALSE); |
7907 if (p != NULL) | |
7908 { | |
7909 vim_setenv(envname, p); | |
7910 vim_free(p); | |
7911 } | |
7912 } | |
7913 else if (dofree) | |
7914 vim_free(p); | |
7915 } | |
7 | 7916 } |
7917 | |
7918 /* | |
7919 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg. | |
7920 */ | |
7921 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7922 change_compatible(int on) |
7 | 7923 { |
838 | 7924 int opt_idx; |
7925 | |
7 | 7926 if (p_cp != on) |
7927 { | |
7928 p_cp = on; | |
7929 compatible_set(); | |
7930 } | |
838 | 7931 opt_idx = findoption((char_u *)"cp"); |
7932 if (opt_idx >= 0) | |
7933 options[opt_idx].flags |= P_WAS_SET; | |
7 | 7934 } |
7935 | |
7936 /* | |
7937 * 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
|
7938 * Only works correctly for global options. |
7 | 7939 */ |
7940 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7941 option_was_set(char_u *name) |
7 | 7942 { |
7943 int idx; | |
7944 | |
7945 idx = findoption(name); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
7946 if (idx < 0) // unknown option |
7 | 7947 return FALSE; |
7948 if (options[idx].flags & P_WAS_SET) | |
7949 return TRUE; | |
7950 return FALSE; | |
7951 } | |
7952 | |
7953 /* | |
3980 | 7954 * Reset the flag indicating option "name" was set. |
7955 */ | |
14748
00da090af0ab
patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents:
14702
diff
changeset
|
7956 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7957 reset_option_was_set(char_u *name) |
3980 | 7958 { |
7959 int idx = findoption(name); | |
7960 | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7961 if (idx < 0) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7962 return FAIL; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7963 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31313
diff
changeset
|
7964 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
|
7965 return OK; |
3980 | 7966 } |
7967 | |
7968 /* | |
7 | 7969 * compatible_set() - Called when 'compatible' has been set or unset. |
7970 * | |
7971 * When 'compatible' set: Set all relevant options (those that have the P_VIM) | |
7972 * flag) to a Vi compatible value. | |
7973 * When 'compatible' is unset: Set all options that have a different default | |
7974 * for Vim (without the P_VI_DEF flag) to that default. | |
7975 */ | |
7976 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7977 compatible_set(void) |
7 | 7978 { |
7979 int opt_idx; | |
7980 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7981 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++) |
7 | 7982 if ( ((options[opt_idx].flags & P_VIM) && p_cp) |
7983 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp)) | |
7984 set_option_default(opt_idx, OPT_FREE, p_cp); | |
7985 didset_options(); | |
7040
17a3fa77e941
commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents:
7034
diff
changeset
|
7986 didset_options2(); |
7 | 7987 } |
7988 | |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
7989 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
7 | 7990 |
7991 /* | |
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
|
7992 * Called when the 'breakat' option changes 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
|
7993 */ |
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
|
7994 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
|
7995 did_set_breakat(optset_T *args UNUSED) |
7 | 7996 { |
500 | 7997 char_u *p; |
7 | 7998 int i; |
7999 | |
8000 for (i = 0; i < 256; i++) | |
8001 breakat_flags[i] = FALSE; | |
8002 | |
8003 if (p_breakat != NULL) | |
500 | 8004 for (p = p_breakat; *p; p++) |
8005 breakat_flags[*p] = TRUE; | |
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
|
8006 |
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
|
8007 return NULL; |
7 | 8008 } |
8009 #endif | |
8010 | |
8011 /* | |
8012 * Check if backspacing over something is allowed. | |
8013 */ | |
8014 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8015 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
|
8016 int what) // BS_INDENT, BS_EOL, BS_START or BS_NOSTOP |
7 | 8017 { |
14029
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
8018 #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
|
8019 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
|
8020 return FALSE; |
d9fc15c833d5
patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
8021 #endif |
7 | 8022 switch (*p_bs) |
8023 { | |
20069
9a67d41708d2
patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
8024 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
|
8025 case '2': return (what != BS_NOSTOP); |
7 | 8026 case '1': return (what != BS_START); |
8027 case '0': return FALSE; | |
8028 } | |
8029 return vim_strchr(p_bs, what) != NULL; | |
8030 } | |
8031 | |
8032 /* | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
8033 * 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
|
8034 * 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
|
8035 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
8036 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
8037 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
|
8038 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
8039 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
|
8040 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
8041 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
8042 /* |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
8043 * 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
|
8044 * 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
|
8045 */ |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
8046 long |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
8047 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
|
8048 { |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
8049 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
|
8050 } |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
8051 |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15701
diff
changeset
|
8052 /* |
6243 | 8053 * Get the local or global value of 'backupcopy'. |
8054 */ | |
8055 unsigned int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
8056 get_bkc_value(buf_T *buf) |
6243 | 8057 { |
8058 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags; | |
8059 } | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9798
diff
changeset
|
8060 |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
8061 #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
|
8062 /* |
27128
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
8063 * 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
|
8064 */ |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
8065 char_u * |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
8066 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
|
8067 { |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
8068 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
|
8069 return p_flp; |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
8070 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
|
8071 } |
28405
473cfd79bcd8
patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents:
28357
diff
changeset
|
8072 #endif |
27128
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
8073 |
164d59ddd48a
patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
8074 /* |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
8075 * 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
|
8076 */ |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
8077 unsigned int |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
8078 get_ve_flags(void) |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
8079 { |
25487
c26ff3203b43
patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents:
25419
diff
changeset
|
8080 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
|
8081 & ~(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
|
8082 } |
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
8083 |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8084 #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
|
8085 /* |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8086 * 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
|
8087 */ |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8088 char_u * |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8089 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
|
8090 { |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8091 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
|
8092 return p_sbr; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8093 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
|
8094 return empty_option; |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8095 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
|
8096 } |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8097 #endif |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
8098 |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8099 #if defined(FEAT_EVAL) || defined(PROTO) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8100 /* |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8101 * Get window or buffer local options. |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8102 */ |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8103 dict_T * |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8104 get_winbuf_options(int bufopt) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8105 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8106 dict_T *d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8107 int opt_idx; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8108 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8109 d = dict_alloc(); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8110 if (d == NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8111 return NULL; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8112 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
8113 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
|
8114 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8115 struct vimoption *opt = &options[opt_idx]; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8116 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8117 if ((bufopt && (opt->indir & PV_BUF)) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8118 || (!bufopt && (opt->indir & PV_WIN))) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8119 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8120 char_u *varp = get_varp(opt); |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8121 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8122 if (varp != NULL) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8123 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8124 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
|
8125 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
|
8126 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
|
8127 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
|
8128 else |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14243
diff
changeset
|
8129 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
|
8130 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8131 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8132 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8133 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8134 return d; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8135 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9854
diff
changeset
|
8136 #endif |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8137 |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
8138 #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
|
8139 /* |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8140 * 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
|
8141 */ |
18100
df5778d73320
patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
8142 int |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8143 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
|
8144 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8145 char_u *p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8146 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
|
8147 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8148 if (val == NULL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8149 p = wp->w_p_culopt; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8150 else |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8151 p = val; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8152 while (*p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8153 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8154 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
|
8155 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8156 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8157 culopt_flags_new |= CULOPT_LINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8158 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8159 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
|
8160 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8161 p += 4; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8162 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
|
8163 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8164 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
|
8165 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8166 p += 6; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8167 culopt_flags_new |= CULOPT_NBR; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8168 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8169 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
|
8170 { |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8171 p += 10; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8172 culopt_flags_new |= CULOPT_SCRLINE; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8173 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8174 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8175 if (*p != ',' && *p != NUL) |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8176 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8177 if (*p == ',') |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8178 ++p; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8179 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8180 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8181 // 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
|
8182 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
|
8183 return FAIL; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8184 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
|
8185 |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8186 return OK; |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8187 } |
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18054
diff
changeset
|
8188 #endif |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8189 |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8190 /* |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8191 * 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
|
8192 */ |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8193 int |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8194 magic_isset(void) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8195 { |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8196 switch (magic_overruled) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8197 { |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23467
diff
changeset
|
8198 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
|
8199 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
|
8200 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
|
8201 } |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8202 #ifdef FEAT_EVAL |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8203 if (in_vim9script()) |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8204 return TRUE; |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8205 #endif |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8206 return p_magic; |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
8207 } |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8208 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8209 /* |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8210 * 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
|
8211 * 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
|
8212 * 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
|
8213 * returns FAIL. |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8214 */ |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8215 int |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8216 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
|
8217 { |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8218 #ifdef FEAT_EVAL |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8219 typval_T *tv; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8220 callback_T cb; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8221 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8222 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
|
8223 { |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8224 free_callback(optcb); |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8225 return OK; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8226 } |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8227 |
26362
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
8228 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
|
8229 || (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
|
8230 || (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
|
8231 // 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
|
8232 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
|
8233 else |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8234 // 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
|
8235 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
|
8236 if (tv == NULL) |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8237 return FAIL; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8238 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8239 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
|
8240 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
|
8241 { |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8242 free_tv(tv); |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8243 return FAIL; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8244 } |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8245 |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8246 free_callback(optcb); |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8247 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
|
8248 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
|
8249 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
|
8250 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
|
8251 |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27142
diff
changeset
|
8252 // 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
|
8253 // "import#funcname". |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27142
diff
changeset
|
8254 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
|
8255 |
26175
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8256 return OK; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8257 #else |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8258 return FAIL; |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8259 #endif |
6b4f017d7005
patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25990
diff
changeset
|
8260 } |