Mercurial > vim
annotate src/main.c @ 23417:4dfa0cd43a51
Added tag v8.2.2251 for changeset 108039938e3cb56a9625ee876814dff17a80fdcd
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 30 Dec 2020 21:30:04 +0100 |
parents | 9a5f12b36273 |
children | dfdd973cf0c9 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9832
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
6 | 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 #define EXTERN | |
11 #include "vim.h" | |
12 | |
13 #ifdef __CYGWIN__ | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
14 # ifndef MSWIN |
1657 | 15 # include <cygwin/version.h> |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
16 # include <sys/cygwin.h> // for cygwin_conv_to_posix_path() and/or |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
17 // cygwin_conv_path() |
6 | 18 # endif |
19 # include <limits.h> | |
20 #endif | |
21 | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
22 #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
9252
diff
changeset
|
23 # include "iscygpty.h" |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
9252
diff
changeset
|
24 #endif |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
9252
diff
changeset
|
25 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
26 // Values for edit_type. |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
27 #define EDIT_NONE 0 // no edit type yet |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
28 #define EDIT_FILE 1 // file name argument[s] given, use argument list |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
29 #define EDIT_STDIN 2 // read file from stdin |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
30 #define EDIT_TAG 3 // tag name argument given, use tagname |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
31 #define EDIT_QF 4 // start in quickfix mode |
443 | 32 |
2730 | 33 #if (defined(UNIX) || defined(VMS)) && !defined(NO_VIM_MAIN) |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
34 static int file_owned(char *fname); |
6 | 35 #endif |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
36 static void mainerr(int, char_u *); |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
37 static void early_arg_scan(mparm_T *parmp); |
2730 | 38 #ifndef NO_VIM_MAIN |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
39 static void usage(void); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
40 static void parse_command_name(mparm_T *parmp); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
41 static void command_line_scan(mparm_T *parmp); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
42 static void check_tty(mparm_T *parmp); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
43 static void read_stdin(void); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
44 static void create_windows(mparm_T *parmp); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
45 static void edit_buffers(mparm_T *parmp, char_u *cwd); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
46 static void exe_pre_commands(mparm_T *parmp); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
47 static void exe_commands(mparm_T *parmp); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
48 static void source_startup_scripts(mparm_T *parmp); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
49 static void main_start_gui(void); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
50 static void check_swap_exists_action(void); |
11032
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
51 # ifdef FEAT_EVAL |
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
52 static void set_progpath(char_u *argv0); |
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
53 # endif |
6 | 54 #endif |
55 | |
56 | |
57 /* | |
58 * Different types of error messages. | |
59 */ | |
60 static char *(main_errors[]) = | |
61 { | |
443 | 62 N_("Unknown option argument"), |
6 | 63 #define ME_UNKNOWN_OPTION 0 |
64 N_("Too many edit arguments"), | |
65 #define ME_TOO_MANY_ARGS 1 | |
66 N_("Argument missing after"), | |
67 #define ME_ARG_MISSING 2 | |
443 | 68 N_("Garbage after option argument"), |
6 | 69 #define ME_GARBAGE 3 |
70 N_("Too many \"+command\", \"-c command\" or \"--cmd command\" arguments"), | |
71 #define ME_EXTRA_CMD 4 | |
72 N_("Invalid argument for"), | |
73 #define ME_INVALID_ARG 5 | |
74 }; | |
75 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
76 #ifndef PROTO // don't want a prototype for main() |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
77 |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
78 // Various parameters passed between main() and other functions. |
11309
b254fd46ef62
patch 8.0.0540: building unit tests fails
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
79 static mparm_T params; |
b254fd46ef62
patch 8.0.0540: building unit tests fails
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
80 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
81 #ifndef NO_VIM_MAIN // skip this for unittests |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
82 |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
83 static char_u *start_dir = NULL; // current working dir on startup |
6763 | 84 |
9678
8c9e13109df8
commit https://github.com/vim/vim/commit/b9a46fec3e79d1fc8c406084a41733c647a5e535
Christian Brabandt <cb@256bit.org>
parents:
9669
diff
changeset
|
85 static int has_dash_c_arg = FALSE; |
8c9e13109df8
commit https://github.com/vim/vim/commit/b9a46fec3e79d1fc8c406084a41733c647a5e535
Christian Brabandt <cb@256bit.org>
parents:
9669
diff
changeset
|
86 |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
87 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
88 __declspec(dllexport) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
89 # endif |
6 | 90 int |
16198
b0e19f135e50
patch 8.1.1104: MS-Windows: not all environment variables can be used
Bram Moolenaar <Bram@vim.org>
parents:
16123
diff
changeset
|
91 # ifdef MSWIN |
6 | 92 VimMain |
93 # else | |
94 main | |
95 # endif | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
96 (int argc, char **argv) |
6 | 97 { |
13363
2103b009e32d
patch 8.0.1555: build error for some combination of features
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
98 #if defined(STARTUPTIME) || defined(CLEAN_RUNTIMEPATH) |
1972 | 99 int i; |
100 #endif | |
6 | 101 |
102 /* | |
103 * Do any system-specific initialisations. These can NOT use IObuff or | |
104 * NameBuff. Thus emsg2() cannot be called! | |
105 */ | |
106 mch_early_init(); | |
107 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
108 #ifdef MSWIN |
6193 | 109 /* |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
110 * MinGW expands command line arguments, which confuses our code to |
6193 | 111 * convert when 'encoding' changes. Get the unexpanded arguments. |
112 */ | |
113 argc = get_cmd_argsW(&argv); | |
114 #endif | |
115 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
116 // Many variables are in "params" so that we can pass them to invoked |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
117 // functions without a lot of arguments. "argc" and "argv" are also |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
118 // copied, so that they can be changed. |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19920
diff
changeset
|
119 CLEAR_FIELD(params); |
443 | 120 params.argc = argc; |
121 params.argv = argv; | |
122 params.want_full_screen = TRUE; | |
123 #ifdef FEAT_EVAL | |
124 params.use_debug_break_level = -1; | |
125 #endif | |
126 params.window_count = -1; | |
440 | 127 |
4369 | 128 #ifdef FEAT_RUBY |
129 { | |
130 int ruby_stack_start; | |
131 vim_ruby_init((void *)&ruby_stack_start); | |
132 } | |
133 #endif | |
134 | |
6 | 135 #ifdef FEAT_TCL |
443 | 136 vim_tcl_init(params.argv[0]); |
6 | 137 #endif |
138 | |
139 #ifdef MEM_PROFILE | |
140 atexit(vim_mem_profile_dump); | |
141 #endif | |
142 | |
143 #ifdef STARTUPTIME | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
144 // Need to find "--startuptime" before actually parsing arguments. |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
145 for (i = 1; i < argc - 1; ++i) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
146 if (STRICMP(argv[i], "--startuptime") == 0) |
1972 | 147 { |
1989 | 148 time_fd = mch_fopen(argv[i + 1], "a"); |
1972 | 149 TIME_MSG("--- VIM STARTING ---"); |
150 break; | |
151 } | |
6 | 152 #endif |
777 | 153 starttime = time(NULL); |
6 | 154 |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
155 #ifdef CLEAN_RUNTIMEPATH |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
156 // Need to find "--clean" before actually parsing arguments. |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
157 for (i = 1; i < argc; ++i) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
158 if (STRICMP(argv[i], "--clean") == 0) |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
159 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
160 params.clean = TRUE; |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
161 break; |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
162 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
163 #endif |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
164 common_init(¶ms); |
6 | 165 |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
166 #ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
167 // Check if the current executable file is for the GUI subsystem. |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
168 gui.starting = mch_is_gui_executable(); |
16596
2f86ca0c1e6b
patch 8.1.1301: when compiled with VIMDLL some messages are not shown
Bram Moolenaar <Bram@vim.org>
parents:
16509
diff
changeset
|
169 #elif defined(FEAT_GUI_MSWIN) |
2f86ca0c1e6b
patch 8.1.1301: when compiled with VIMDLL some messages are not shown
Bram Moolenaar <Bram@vim.org>
parents:
16509
diff
changeset
|
170 gui.starting = TRUE; |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
171 #endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
172 |
6 | 173 #ifdef FEAT_CLIENTSERVER |
174 /* | |
175 * Do the client-server stuff, unless "--servername ''" was used. | |
443 | 176 * This may exit Vim if the command was sent to the server. |
6 | 177 */ |
443 | 178 exec_on_server(¶ms); |
6 | 179 #endif |
180 | |
181 /* | |
443 | 182 * Figure out the way to work from the command name argv[0]. |
183 * "vimdiff" starts diff mode, "rvim" sets "restricted", etc. | |
6 | 184 */ |
443 | 185 parse_command_name(¶ms); |
6 | 186 |
187 /* | |
443 | 188 * Process the command line arguments. File names are put in the global |
189 * argument list "global_alist". | |
6 | 190 */ |
443 | 191 command_line_scan(¶ms); |
6 | 192 TIME_MSG("parsing arguments"); |
193 | |
194 /* | |
195 * On some systems, when we compile with the GUI, we always use it. On Mac | |
443 | 196 * there is no terminal version, and on Windows we can't fork one off with |
197 * :gui. | |
6 | 198 */ |
199 #ifdef ALWAYS_USE_GUI | |
200 gui.starting = TRUE; | |
201 #else | |
575 | 202 # if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) |
6 | 203 /* |
204 * Check if the GUI can be started. Reset gui.starting if not. | |
205 * Don't know about other systems, stay on the safe side and don't check. | |
206 */ | |
2021 | 207 if (gui.starting) |
6 | 208 { |
2021 | 209 if (gui_init_check() == FAIL) |
210 { | |
211 gui.starting = FALSE; | |
212 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
213 // When running "evim" or "gvim -y" we need the menus, exit if we |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
214 // don't have them. |
2021 | 215 if (params.evim_mode) |
216 mch_exit(1); | |
217 } | |
6 | 218 } |
219 # endif | |
220 #endif | |
221 | |
222 if (GARGCOUNT > 0) | |
223 { | |
7410
08e62c4fc17d
commit https://github.com/vim/vim/commit/53076830fea6df737455523f7e235bfe4f79864d
Christian Brabandt <cb@256bit.org>
parents:
6923
diff
changeset
|
224 #ifdef EXPAND_FILENAMES |
6 | 225 /* |
226 * Expand wildcards in file names. | |
227 */ | |
443 | 228 if (!params.literal) |
6 | 229 { |
6735
f6021786b775
patch 7.4.691 for Problem: Can't build with MzScheme.
Bram Moolenaar <bram@vim.org>
parents:
6731
diff
changeset
|
230 start_dir = alloc(MAXPATHL); |
f6021786b775
patch 7.4.691 for Problem: Can't build with MzScheme.
Bram Moolenaar <bram@vim.org>
parents:
6731
diff
changeset
|
231 if (start_dir != NULL) |
f6021786b775
patch 7.4.691 for Problem: Can't build with MzScheme.
Bram Moolenaar <bram@vim.org>
parents:
6731
diff
changeset
|
232 mch_dirname(start_dir, MAXPATHL); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
233 // Temporarily add '(' and ')' to 'isfname'. These are valid |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
234 // filename characters but are excluded from 'isfname' to make |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
235 // "gf" work on a file name in parenthesis (e.g.: see vim.h). |
6 | 236 do_cmdline_cmd((char_u *)":set isf+=(,)"); |
41 | 237 alist_expand(NULL, 0); |
6 | 238 do_cmdline_cmd((char_u *)":set isf&"); |
6735
f6021786b775
patch 7.4.691 for Problem: Can't build with MzScheme.
Bram Moolenaar <bram@vim.org>
parents:
6731
diff
changeset
|
239 if (start_dir != NULL) |
f6021786b775
patch 7.4.691 for Problem: Can't build with MzScheme.
Bram Moolenaar <bram@vim.org>
parents:
6731
diff
changeset
|
240 mch_chdir((char *)start_dir); |
6 | 241 } |
242 #endif | |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
243 params.fname = alist_name(&GARGLIST[0]); |
6 | 244 } |
23 | 245 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
246 #ifdef MSWIN |
23 | 247 { |
248 extern void set_alist_count(void); | |
249 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
250 // Remember the number of entries in the argument list. If it changes |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
251 // we don't react on setting 'encoding'. |
23 | 252 set_alist_count(); |
253 } | |
254 #endif | |
255 | |
6 | 256 #ifdef MSWIN |
443 | 257 if (GARGCOUNT == 1 && params.full_path) |
6 | 258 { |
259 /* | |
260 * If there is one filename, fully qualified, we have very probably | |
261 * been invoked from explorer, so change to the file's directory. | |
262 * Hint: to avoid this when typing a command use a forward slash. | |
263 * If the cd fails, it doesn't matter. | |
264 */ | |
13170
6559e98f3e74
patch 8.0.1459: cannot handle change of directory
Christian Brabandt <cb@256bit.org>
parents:
13160
diff
changeset
|
265 (void)vim_chdirfile(params.fname, "drop"); |
6735
f6021786b775
patch 7.4.691 for Problem: Can't build with MzScheme.
Bram Moolenaar <bram@vim.org>
parents:
6731
diff
changeset
|
266 if (start_dir != NULL) |
f6021786b775
patch 7.4.691 for Problem: Can't build with MzScheme.
Bram Moolenaar <bram@vim.org>
parents:
6731
diff
changeset
|
267 mch_dirname(start_dir, MAXPATHL); |
6 | 268 } |
269 #endif | |
270 TIME_MSG("expanding arguments"); | |
271 | |
272 #ifdef FEAT_DIFF | |
769 | 273 if (params.diff_mode && params.window_count == -1) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
274 params.window_count = 0; // open up to 3 windows |
6 | 275 #endif |
276 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
277 // Don't redraw until much later. |
6 | 278 ++RedrawingDisabled; |
279 | |
280 /* | |
281 * When listing swap file names, don't do cursor positioning et. al. | |
282 */ | |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
283 if (recoverymode && params.fname == NULL) |
443 | 284 params.want_full_screen = FALSE; |
6 | 285 |
286 /* | |
287 * When certain to start the GUI, don't check capabilities of terminal. | |
288 * For GTK we can't be sure, but when started from the desktop it doesn't | |
289 * make sense to try using a terminal. | |
290 */ | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
291 #if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) \ |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
292 || defined(VIMDLL) |
6 | 293 if (gui.starting |
294 # ifdef FEAT_GUI_GTK | |
295 && !isatty(2) | |
296 # endif | |
297 ) | |
443 | 298 params.want_full_screen = FALSE; |
6 | 299 #endif |
300 | |
301 /* | |
302 * mch_init() sets up the terminal (window) for use. This must be | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8182
diff
changeset
|
303 * done after resetting full_screen, otherwise it may move the cursor. |
6 | 304 * Note that we may use mch_exit() before mch_init()! |
305 */ | |
306 mch_init(); | |
307 TIME_MSG("shell init"); | |
308 | |
309 #ifdef USE_XSMP | |
310 /* | |
311 * For want of anywhere else to do it, try to connect to xsmp here. | |
312 * Fitting it in after gui_mch_init, but before gui_init (via termcapinit). | |
313 * Hijacking -X 'no X connection' to also disable XSMP connection as that | |
314 * has a similar delay upon failure. | |
315 * Only try if SESSION_MANAGER is set to something non-null. | |
316 */ | |
317 if (!x_no_connect) | |
318 { | |
443 | 319 char *p = getenv("SESSION_MANAGER"); |
320 | |
6 | 321 if (p != NULL && *p != NUL) |
322 { | |
323 xsmp_init(); | |
324 TIME_MSG("xsmp init"); | |
325 } | |
326 } | |
327 #endif | |
328 | |
329 /* | |
330 * Print a warning if stdout is not a terminal. | |
331 */ | |
443 | 332 check_tty(¶ms); |
6 | 333 |
13160
cb99d9198c39
patch 8.0.1454: when in silent mode too much output is buffered
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
334 #ifdef _IOLBF |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
335 // Ensure output works usefully without a tty: buffer lines instead of |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
336 // fully buffered. |
13160
cb99d9198c39
patch 8.0.1454: when in silent mode too much output is buffered
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
337 if (silent_mode) |
cb99d9198c39
patch 8.0.1454: when in silent mode too much output is buffered
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
338 setvbuf(stdout, NULL, _IOLBF, 0); |
cb99d9198c39
patch 8.0.1454: when in silent mode too much output is buffered
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
339 #endif |
cb99d9198c39
patch 8.0.1454: when in silent mode too much output is buffered
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
340 |
16509
5256c1e27ea6
patch 8.1.1258: the "N files to edit" message can not be surpressed
Bram Moolenaar <Bram@vim.org>
parents:
16453
diff
changeset
|
341 // This message comes before term inits, but after setting "silent_mode" |
5256c1e27ea6
patch 8.1.1258: the "N files to edit" message can not be surpressed
Bram Moolenaar <Bram@vim.org>
parents:
16453
diff
changeset
|
342 // when the input is not a tty. Omit the message with --not-a-term. |
5256c1e27ea6
patch 8.1.1258: the "N files to edit" message can not be surpressed
Bram Moolenaar <Bram@vim.org>
parents:
16453
diff
changeset
|
343 if (GARGCOUNT > 1 && !silent_mode && !is_not_a_term()) |
169 | 344 printf(_("%d files to edit\n"), GARGCOUNT); |
345 | |
443 | 346 if (params.want_full_screen && !silent_mode) |
6 | 347 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
348 termcapinit(params.term); // set terminal name and get terminal |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
349 // capabilities (will set full_screen) |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
350 screen_start(); // don't know where cursor is now |
6 | 351 TIME_MSG("Termcap init"); |
352 } | |
353 | |
354 /* | |
355 * Set the default values for the options that use Rows and Columns. | |
356 */ | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
357 ui_get_shellsize(); // inits Rows and Columns |
667 | 358 win_init_size(); |
6 | 359 #ifdef FEAT_DIFF |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
360 // Set the 'diff' option now, so that it can be checked for in a .vimrc |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
361 // file. There is no buffer yet though. |
443 | 362 if (params.diff_mode) |
6 | 363 diff_win_options(firstwin, FALSE); |
364 #endif | |
365 | |
366 cmdline_row = Rows - p_ch; | |
367 msg_row = cmdline_row; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
368 screenalloc(FALSE); // allocate screen buffers |
6 | 369 set_init_2(); |
370 TIME_MSG("inits 2"); | |
371 | |
372 msg_scroll = TRUE; | |
373 no_wait_return = TRUE; | |
374 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
375 init_mappings(); // set up initial mappings |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
376 |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
377 init_highlight(TRUE, FALSE); // set the default highlight groups |
6 | 378 TIME_MSG("init highlight"); |
379 | |
20836
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
380 #if defined(FEAT_TERMRESPONSE) |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
381 init_term_props(TRUE); |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
382 #endif |
2616c5a337e0
patch 8.2.0970: terminal properties are not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20768
diff
changeset
|
383 |
6 | 384 #ifdef FEAT_EVAL |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
385 // Set the break level after the terminal is initialized. |
443 | 386 debug_break_level = params.use_debug_break_level; |
6 | 387 #endif |
388 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
389 // Reset 'loadplugins' for "-u NONE" before "--cmd" arguments. |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
390 // Allows for setting 'loadplugins' there. |
12670
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
391 if (params.use_vimrc != NULL |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
392 && (STRCMP(params.use_vimrc, "NONE") == 0 |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
393 || STRCMP(params.use_vimrc, "DEFAULTS") == 0)) |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
394 p_lpl = FALSE; |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
395 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
396 // Execute --cmd arguments. |
12670
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
397 exe_pre_commands(¶ms); |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
398 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
399 // Source startup scripts. |
12670
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
400 source_startup_scripts(¶ms); |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
401 |
3348 | 402 #ifdef FEAT_MZSCHEME |
403 /* | |
404 * Newer version of MzScheme (Racket) require earlier (trampolined) | |
405 * initialisation via scheme_main_setup. | |
406 * Implement this by initialising it as early as possible | |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
407 * and splitting off remaining Vim main into vim_main2(). |
12670
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
408 * Do source startup scripts, so that 'mzschemedll' can be set. |
3348 | 409 */ |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
410 return mzscheme_main(); |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
411 #else |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
412 return vim_main2(); |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
413 #endif |
3348 | 414 } |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
415 #endif // NO_VIM_MAIN |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
416 #endif // PROTO |
3955 | 417 |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
418 /* |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
419 * vim_main2() is needed for FEAT_MZSCHEME, but we define it always to keep |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
420 * things simple. |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
421 * It is also defined when NO_VIM_MAIN is defined, but then it's empty. |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
422 */ |
3955 | 423 int |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
424 vim_main2(void) |
3348 | 425 { |
3955 | 426 #ifndef NO_VIM_MAIN |
6 | 427 #ifdef FEAT_EVAL |
428 /* | |
429 * Read all the plugin files. | |
430 * Only when compiled with +eval, since most plugins need it. | |
431 */ | |
432 if (p_lpl) | |
433 { | |
11595
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
434 char_u *rtp_copy = NULL; |
23025
3204c5e23474
patch 8.2.2059: Amiga: can't find plugins
Bram Moolenaar <Bram@vim.org>
parents:
22570
diff
changeset
|
435 char_u *plugin_pattern = (char_u *) |
3204c5e23474
patch 8.2.2059: Amiga: can't find plugins
Bram Moolenaar <Bram@vim.org>
parents:
22570
diff
changeset
|
436 # if defined(VMS) || defined(AMIGA) // VMS and Amiga don't handle the "**". |
3204c5e23474
patch 8.2.2059: Amiga: can't find plugins
Bram Moolenaar <Bram@vim.org>
parents:
22570
diff
changeset
|
437 "plugin/*.vim" |
3204c5e23474
patch 8.2.2059: Amiga: can't find plugins
Bram Moolenaar <Bram@vim.org>
parents:
22570
diff
changeset
|
438 # else |
3204c5e23474
patch 8.2.2059: Amiga: can't find plugins
Bram Moolenaar <Bram@vim.org>
parents:
22570
diff
changeset
|
439 "plugin/**/*.vim" |
3204c5e23474
patch 8.2.2059: Amiga: can't find plugins
Bram Moolenaar <Bram@vim.org>
parents:
22570
diff
changeset
|
440 # endif |
3204c5e23474
patch 8.2.2059: Amiga: can't find plugins
Bram Moolenaar <Bram@vim.org>
parents:
22570
diff
changeset
|
441 ; |
11595
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
442 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
443 // First add all package directories to 'runtimepath', so that their |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
444 // autoload directories can be found. Only if not done already with a |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
445 // :packloadall command. |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
446 // Make a copy of 'runtimepath', so that source_runtime does not use |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
447 // the pack directories. |
11457
5a1656d79707
patch 8.0.0612: pack dirs are added to 'runtimepath' too late
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
448 if (!did_source_packages) |
11595
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
449 { |
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
450 rtp_copy = vim_strsave(p_rtp); |
11457
5a1656d79707
patch 8.0.0612: pack dirs are added to 'runtimepath' too late
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
451 add_pack_start_dirs(); |
11595
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
452 } |
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
453 |
23025
3204c5e23474
patch 8.2.2059: Amiga: can't find plugins
Bram Moolenaar <Bram@vim.org>
parents:
22570
diff
changeset
|
454 source_in_path(rtp_copy == NULL ? p_rtp : rtp_copy, plugin_pattern, |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
455 DIP_ALL | DIP_NOAFTER, NULL); |
6 | 456 TIME_MSG("loading plugins"); |
11595
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
457 vim_free(rtp_copy); |
8182
95d59081580f
commit https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
458 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
459 // Only source "start" packages if not done already with a :packloadall |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
460 // command. |
11457
5a1656d79707
patch 8.0.0612: pack dirs are added to 'runtimepath' too late
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
461 if (!did_source_packages) |
5a1656d79707
patch 8.0.0612: pack dirs are added to 'runtimepath' too late
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
462 load_start_packages(); |
8182
95d59081580f
commit https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
463 TIME_MSG("loading packages"); |
9778
4360b2b46125
commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents:
9678
diff
changeset
|
464 |
23025
3204c5e23474
patch 8.2.2059: Amiga: can't find plugins
Bram Moolenaar <Bram@vim.org>
parents:
22570
diff
changeset
|
465 source_runtime(plugin_pattern, DIP_ALL | DIP_AFTER); |
9778
4360b2b46125
commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents:
9678
diff
changeset
|
466 TIME_MSG("loading after plugins"); |
6 | 467 } |
468 #endif | |
469 | |
769 | 470 #ifdef FEAT_DIFF |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
471 // Decide about window layout for diff mode after reading vimrc. |
769 | 472 if (params.diff_mode && params.window_layout == 0) |
473 { | |
474 if (diffopt_horizontal()) | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
475 params.window_layout = WIN_HOR; // use horizontal split |
769 | 476 else |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
477 params.window_layout = WIN_VER; // use vertical split |
769 | 478 } |
479 #endif | |
480 | |
6 | 481 /* |
482 * Recovery mode without a file name: List swap files. | |
483 * This uses the 'dir' option, therefore it must be after the | |
484 * initializations. | |
485 */ | |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
486 if (recoverymode && params.fname == NULL) |
6 | 487 { |
2267 | 488 recover_names(NULL, TRUE, 0, NULL); |
6 | 489 mch_exit(0); |
490 } | |
491 | |
492 /* | |
493 * Set a few option defaults after reading .vimrc files: | |
494 * 'title' and 'icon', Unix: 'shellpipe' and 'shellredir'. | |
495 */ | |
496 set_init_3(); | |
497 TIME_MSG("inits 3"); | |
498 | |
499 /* | |
500 * "-n" argument: Disable swap file by setting 'updatecount' to 0. | |
501 * Note that this overrides anything from a vimrc file. | |
502 */ | |
443 | 503 if (params.no_swap_file) |
6 | 504 p_uc = 0; |
505 | |
506 #ifdef FEAT_GUI | |
507 if (gui.starting) | |
508 { | |
17750
b27d06bd0fde
patch 8.1.1872: when Vim exits because of a signal, VimLeave is not triggered
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
509 # if defined(UNIX) || defined(VMS) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
510 // When something caused a message from a vimrc script, need to output |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
511 // an extra newline before the shell prompt. |
6 | 512 if (did_emsg || msg_didout) |
513 putchar('\n'); | |
17750
b27d06bd0fde
patch 8.1.1872: when Vim exits because of a signal, VimLeave is not triggered
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
514 # endif |
6 | 515 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
516 gui_start(NULL); // will set full_screen to TRUE |
6 | 517 TIME_MSG("starting GUI"); |
518 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
519 // When running "evim" or "gvim -y" we need the menus, exit if we |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
520 // don't have them. |
440 | 521 if (!gui.in_use && params.evim_mode) |
6 | 522 mch_exit(1); |
523 } | |
524 #endif | |
525 | |
526 #ifdef FEAT_VIMINFO | |
527 /* | |
1733 | 528 * Read in registers, history etc, but not marks, from the viminfo file. |
529 * This is where v:oldfiles gets filled. | |
6 | 530 */ |
531 if (*p_viminfo != NUL) | |
532 { | |
1733 | 533 read_viminfo(NULL, VIF_WANT_INFO | VIF_GET_OLDFILES); |
6 | 534 TIME_MSG("reading viminfo"); |
535 } | |
536 #endif | |
5598 | 537 #ifdef FEAT_EVAL |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
538 // It's better to make v:oldfiles an empty list than NULL. |
5598 | 539 if (get_vim_var_list(VV_OLDFILES) == NULL) |
540 set_vim_var_list(VV_OLDFILES, list_alloc()); | |
541 #endif | |
6 | 542 |
543 #ifdef FEAT_QUICKFIX | |
544 /* | |
545 * "-q errorfile": Load the error file now. | |
546 * If the error file can't be read, exit before doing anything else. | |
547 */ | |
443 | 548 if (params.edit_type == EDIT_QF) |
6 | 549 { |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
11060
diff
changeset
|
550 char_u *enc = NULL; |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
11060
diff
changeset
|
551 |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
11060
diff
changeset
|
552 enc = p_menc; |
443 | 553 if (params.use_ef != NULL) |
554 set_string_option_direct((char_u *)"ef", -1, | |
694 | 555 params.use_ef, OPT_FREE, SID_CARG); |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2394
diff
changeset
|
556 vim_snprintf((char *)IObuff, IOSIZE, "cfile %s", p_ef); |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
11060
diff
changeset
|
557 if (qf_init(NULL, p_ef, p_efm, TRUE, IObuff, enc) < 0) |
6 | 558 { |
559 out_char('\n'); | |
560 mch_exit(3); | |
561 } | |
562 TIME_MSG("reading errorfile"); | |
563 } | |
564 #endif | |
565 | |
566 /* | |
567 * Start putting things on the screen. | |
568 * Scroll screen down before drawing over it | |
569 * Clear screen now, so file message will not be cleared. | |
570 */ | |
571 starting = NO_BUFFERS; | |
572 no_wait_return = FALSE; | |
573 if (!exmode_active) | |
574 msg_scroll = FALSE; | |
575 | |
576 #ifdef FEAT_GUI | |
577 /* | |
578 * This seems to be required to make callbacks to be called now, instead | |
579 * of after things have been put on the screen, which then may be deleted | |
580 * when getting a resize callback. | |
581 * For the Mac this handles putting files dropped on the Vim icon to | |
582 * global_alist. | |
583 */ | |
584 if (gui.in_use) | |
585 { | |
15510
41fbbcea0f1b
patch 8.1.0763: nobody is using the Sun Workshop support
Bram Moolenaar <Bram@vim.org>
parents:
15476
diff
changeset
|
586 gui_wait_for_chars(50L, typebuf.tb_change_cnt); |
6 | 587 TIME_MSG("GUI delay"); |
588 } | |
589 #endif | |
590 | |
591 #if defined(FEAT_GUI_PHOTON) && defined(FEAT_CLIPBOARD) | |
592 qnx_clip_init(); | |
593 #endif | |
594 | |
2312
bbd6f5539378
Missing piece for Mac console clipboard support. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
595 #if defined(MACOS_X) && defined(FEAT_CLIPBOARD) |
bbd6f5539378
Missing piece for Mac console clipboard support. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
596 clip_init(TRUE); |
bbd6f5539378
Missing piece for Mac console clipboard support. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
597 #endif |
bbd6f5539378
Missing piece for Mac console clipboard support. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
598 |
6 | 599 #ifdef FEAT_XCLIPBOARD |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
600 // Start using the X clipboard, unless the GUI was started. |
6 | 601 # ifdef FEAT_GUI |
602 if (!gui.in_use) | |
603 # endif | |
604 { | |
605 setup_term_clip(); | |
606 TIME_MSG("setup clipboard"); | |
607 } | |
608 #endif | |
609 | |
610 #ifdef FEAT_CLIENTSERVER | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
611 // Prepare for being a Vim server. |
443 | 612 prepare_server(¶ms); |
6 | 613 #endif |
614 | |
615 /* | |
616 * If "-" argument given: Read file from stdin. | |
617 * Do this before starting Raw mode, because it may change things that the | |
618 * writing end of the pipe doesn't like, e.g., in case stdin and stderr | |
619 * are the same terminal: "cat | vim -". | |
620 * Using autocommands here may cause trouble... | |
621 */ | |
443 | 622 if (params.edit_type == EDIT_STDIN && !recoverymode) |
623 read_stdin(); | |
6 | 624 |
625 #if defined(UNIX) || defined(VMS) | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
626 // When switching screens and something caused a message from a vimrc |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
627 // script, need to output an extra newline on exit. |
6 | 628 if ((did_emsg || msg_didout) && *T_TI != NUL) |
629 newline_on_exit = TRUE; | |
630 #endif | |
631 | |
632 /* | |
633 * When done something that is not allowed or error message call | |
634 * wait_return. This must be done before starttermcap(), because it may | |
635 * switch to another screen. It must be done after settmode(TMODE_RAW), | |
636 * because we want to react on a single key stroke. | |
637 * Call settmode and starttermcap here, so the T_KS and T_TI may be | |
1226 | 638 * defined by termcapinit and redefined in .exrc. |
6 | 639 */ |
640 settmode(TMODE_RAW); | |
641 TIME_MSG("setting raw mode"); | |
642 | |
643 if (need_wait_return || msg_didany) | |
644 { | |
645 wait_return(TRUE); | |
646 TIME_MSG("waiting for return"); | |
647 } | |
648 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
649 starttermcap(); // start termcap if not done by wait_return() |
6 | 650 TIME_MSG("start termcap"); |
651 | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18116
diff
changeset
|
652 setmouse(); // may start using the mouse |
6 | 653 if (scroll_region) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
654 scroll_region_reset(); // In case Rows changed |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
655 scroll_start(); // may scroll the screen to the right position |
6 | 656 |
14481
4f5a15867544
patch 8.1.0254: cannot build on MS-Windows; unused macro HAVE_HANDLE_DROP
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
657 #if defined(FEAT_TITLE) && (defined(UNIX) || defined(VMS) || defined(MACOS_X)) |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14428
diff
changeset
|
658 term_push_title(SAVE_RESTORE_BOTH); |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14428
diff
changeset
|
659 #endif |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14428
diff
changeset
|
660 |
6 | 661 /* |
662 * Don't clear the screen when starting in Ex mode, unless using the GUI. | |
663 */ | |
664 if (exmode_active | |
665 #ifdef FEAT_GUI | |
666 && !gui.in_use | |
667 #endif | |
668 ) | |
669 must_redraw = CLEAR; | |
670 else | |
671 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
672 screenclear(); // clear screen |
6 | 673 TIME_MSG("clearing screen"); |
674 } | |
675 | |
676 #ifdef FEAT_CRYPT | |
443 | 677 if (params.ask_for_key) |
6 | 678 { |
6353 | 679 crypt_check_current_method(); |
6122 | 680 (void)crypt_get_key(TRUE, TRUE); |
6 | 681 TIME_MSG("getting crypt key"); |
682 } | |
683 #endif | |
684 | |
685 no_wait_return = TRUE; | |
686 | |
687 /* | |
443 | 688 * Create the requested number of windows and edit buffers in them. |
689 * Also does recovery if "recoverymode" set. | |
6 | 690 */ |
443 | 691 create_windows(¶ms); |
6 | 692 TIME_MSG("opening buffers"); |
693 | |
1093 | 694 #ifdef FEAT_EVAL |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
695 // clear v:swapcommand |
1093 | 696 set_vim_var_string(VV_SWAPCOMMAND, NULL, -1); |
697 #endif | |
698 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
699 // Ex starts at last line of the file |
6 | 700 if (exmode_active) |
701 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
702 | |
703 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | |
704 TIME_MSG("BufEnter autocommands"); | |
705 setpcmark(); | |
706 | |
707 #ifdef FEAT_QUICKFIX | |
708 /* | |
709 * When started with "-q errorfile" jump to first error now. | |
710 */ | |
443 | 711 if (params.edit_type == EDIT_QF) |
6 | 712 { |
644 | 713 qf_jump(NULL, 0, 0, FALSE); |
6 | 714 TIME_MSG("jump to first error"); |
715 } | |
716 #endif | |
717 | |
718 /* | |
719 * If opened more than one window, start editing files in the other | |
443 | 720 * windows. |
6 | 721 */ |
6735
f6021786b775
patch 7.4.691 for Problem: Can't build with MzScheme.
Bram Moolenaar <bram@vim.org>
parents:
6731
diff
changeset
|
722 edit_buffers(¶ms, start_dir); |
f6021786b775
patch 7.4.691 for Problem: Can't build with MzScheme.
Bram Moolenaar <bram@vim.org>
parents:
6731
diff
changeset
|
723 vim_free(start_dir); |
6 | 724 |
725 #ifdef FEAT_DIFF | |
443 | 726 if (params.diff_mode) |
6 | 727 { |
728 win_T *wp; | |
729 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
730 // set options in each window for "vimdiff". |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9542
diff
changeset
|
731 FOR_ALL_WINDOWS(wp) |
6 | 732 diff_win_options(wp, TRUE); |
733 } | |
734 #endif | |
735 | |
736 /* | |
737 * Shorten any of the filenames, but only when absolute. | |
738 */ | |
739 shorten_fnames(FALSE); | |
740 | |
741 /* | |
742 * Need to jump to the tag before executing the '-c command'. | |
743 * Makes "vim -c '/return' -t main" work. | |
744 */ | |
443 | 745 if (params.tagname != NULL) |
6 | 746 { |
604 | 747 swap_exists_did_quit = FALSE; |
748 | |
443 | 749 vim_snprintf((char *)IObuff, IOSIZE, "ta %s", params.tagname); |
6 | 750 do_cmdline_cmd(IObuff); |
751 TIME_MSG("jumping to tag"); | |
604 | 752 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
753 // If the user doesn't want to edit the file then we quit here. |
604 | 754 if (swap_exists_did_quit) |
755 getout(1); | |
6 | 756 } |
757 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
758 // Execute any "+", "-c" and "-S" arguments. |
443 | 759 if (params.n_commands > 0) |
760 exe_commands(¶ms); | |
6 | 761 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
762 // Must come before the may_req_ calls. |
11492
5ccf1b222223
patch 8.0.0629: checking for ambigous width is not working
Christian Brabandt <cb@256bit.org>
parents:
11457
diff
changeset
|
763 starting = 0; |
5ccf1b222223
patch 8.0.0629: checking for ambigous width is not working
Christian Brabandt <cb@256bit.org>
parents:
11457
diff
changeset
|
764 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15551
diff
changeset
|
765 #if defined(FEAT_TERMRESPONSE) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
766 // Must be done before redrawing, puts a few characters on the screen. |
20768
1e2e81dbb958
patch 8.2.0936: some terminals misinterpret the code for getting cursor style
Bram Moolenaar <Bram@vim.org>
parents:
20721
diff
changeset
|
767 check_terminal_behavior(); |
11455
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11364
diff
changeset
|
768 #endif |
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11364
diff
changeset
|
769 |
6 | 770 RedrawingDisabled = 0; |
771 redraw_all_later(NOT_VALID); | |
772 no_wait_return = FALSE; | |
773 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
774 // 'autochdir' has been postponed |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13509
diff
changeset
|
775 DO_AUTOCHDIR; |
8857
df68de6b6f1c
commit https://github.com/vim/vim/commit/baec5c1768098f9dd867b465aaabfdfb294f10c2
Christian Brabandt <cb@256bit.org>
parents:
8738
diff
changeset
|
776 |
626 | 777 #ifdef FEAT_TERMRESPONSE |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
778 // Requesting the termresponse is postponed until here, so that a "-c q" |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
779 // argument doesn't make it appear in the shell Vim was started from. |
626 | 780 may_req_termresponse(); |
11364
0ef92445b4f6
patch 8.0.0567: call for requesting color and ambiwidth is too early
Christian Brabandt <cb@256bit.org>
parents:
11309
diff
changeset
|
781 |
0ef92445b4f6
patch 8.0.0567: call for requesting color and ambiwidth is too early
Christian Brabandt <cb@256bit.org>
parents:
11309
diff
changeset
|
782 may_req_bg_color(); |
626 | 783 #endif |
784 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
785 // start in insert mode |
6 | 786 if (p_im) |
787 need_start_insertmode = TRUE; | |
788 | |
8738
e770986c855a
commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
789 #ifdef FEAT_EVAL |
e770986c855a
commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
790 set_vim_var_nr(VV_VIM_DID_ENTER, 1L); |
e770986c855a
commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
791 #endif |
6 | 792 apply_autocmds(EVENT_VIMENTER, NULL, NULL, FALSE, curbuf); |
793 TIME_MSG("VimEnter autocommands"); | |
794 | |
3488 | 795 #if defined(FEAT_EVAL) && defined(FEAT_CLIPBOARD) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
796 // Adjust default register name for "unnamed" in 'clipboard'. Can only be |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
797 // done after the clipboard is available and all initial commands that may |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
798 // modify the 'clipboard' setting have run; i.e. just before entering the |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
799 // main loop. |
20721
70d561931721
patch 8.2.0913: code for resetting v:register is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
20429
diff
changeset
|
800 reset_reg_var(); |
3488 | 801 #endif |
802 | |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
803 #if defined(FEAT_DIFF) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
804 // When a startup script or session file setup for diff'ing and |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
805 // scrollbind, sync the scrollbind now. |
6 | 806 if (curwin->w_p_diff && curwin->w_p_scb) |
807 { | |
808 update_topline(); | |
809 check_scrollbind((linenr_T)0, 0L); | |
810 TIME_MSG("diff scrollbinding"); | |
811 } | |
812 #endif | |
813 | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
814 #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
815 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
816 if (!gui.in_use) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
817 # endif |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
818 mch_set_winsize_now(); // Allow winsize changes from now on |
6 | 819 #endif |
820 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
821 #if defined(FEAT_GUI) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
822 // When tab pages were created, may need to update the tab pages line and |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
823 // scrollbars. This is skipped while creating them. |
685 | 824 if (first_tabpage->tp_next != NULL) |
825 { | |
826 out_flush(); | |
827 gui_init_which_components(NULL); | |
828 gui_update_scrollbars(TRUE); | |
829 } | |
830 need_mouse_correct = TRUE; | |
831 #endif | |
832 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
833 // If ":startinsert" command used, stuff a dummy command to be able to |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
834 // call normal_cmd(), which will then start Insert mode. |
6 | 835 if (restart_edit != 0) |
620 | 836 stuffcharReadbuff(K_NOP); |
6 | 837 |
838 #ifdef FEAT_NETBEANS_INTG | |
2210 | 839 if (netbeansArg != NULL && strncmp("-nb", netbeansArg, 3) == 0) |
2209
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
840 { |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
841 # ifdef FEAT_GUI |
2592 | 842 # if !defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK) \ |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
843 && !defined(FEAT_GUI_MSWIN) |
2209
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
844 if (gui.in_use) |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
845 { |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
846 mch_errmsg(_("netbeans is not supported with this GUI\n")); |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
847 mch_exit(2); |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
848 } |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
849 # endif |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
850 # endif |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
851 // Tell the client that it can start sending commands. |
2210 | 852 netbeans_open(netbeansArg + 3, TRUE); |
2209
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
853 } |
6 | 854 #endif |
855 | |
19287
5f2cb68f7cb8
patch 8.2.0202: when 'lazyredraw' is set the window title may not be updated
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
856 // Redraw at least once, also when 'lazyredraw' is set, to make sure the |
5f2cb68f7cb8
patch 8.2.0202: when 'lazyredraw' is set the window title may not be updated
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
857 // window title gets updated. |
5f2cb68f7cb8
patch 8.2.0202: when 'lazyredraw' is set the window title may not be updated
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
858 do_redraw = TRUE; |
5f2cb68f7cb8
patch 8.2.0202: when 'lazyredraw' is set the window title may not be updated
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
859 |
6 | 860 TIME_MSG("before starting main loop"); |
861 | |
862 /* | |
863 * Call the main command loop. This never returns. | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14171
diff
changeset
|
864 */ |
169 | 865 main_loop(FALSE, FALSE); |
6 | 866 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
867 #endif // NO_VIM_MAIN |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
868 |
6 | 869 return 0; |
870 } | |
871 | |
872 /* | |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
873 * Initialisation shared by main() and some tests. |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
874 */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
875 void |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
876 common_init(mparm_T *paramp) |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
877 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
878 estack_init(); |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14764
diff
changeset
|
879 cmdline_init(); |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
880 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
881 (void)mb_init(); // init mb_bytelen_tab[] to ones |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
882 #ifdef FEAT_EVAL |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
883 eval_init(); // init global variables |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
884 #endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
885 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
886 #ifdef __QNXNTO__ |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
887 qnx_init(); // PhAttach() for clipboard, (and gui) |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
888 #endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
889 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
890 // Init the table of Normal mode commands. |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
891 init_normal_cmds(); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
892 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
893 /* |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
894 * Allocate space for the generic buffers (needed for set_init_1() and |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
895 * emsg()). |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
896 */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
897 if ((IObuff = alloc(IOSIZE)) == NULL |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
898 || (NameBuff = alloc(MAXPATHL)) == NULL) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
899 mch_exit(0); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
900 TIME_MSG("Allocated generic buffers"); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
901 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
902 #ifdef NBDEBUG |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
903 // Wait a moment for debugging NetBeans. Must be after allocating |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
904 // NameBuff. |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
905 nbdebug_log_init("SPRO_GVIM_DEBUG", "SPRO_GVIM_DLEVEL"); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
906 nbdebug_wait(WT_ENV | WT_WAIT | WT_STOP, "SPRO_GVIM_WAIT", 20); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
907 TIME_MSG("NetBeans debug wait"); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
908 #endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
909 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
910 #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
911 /* |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
912 * Setup to use the current locale (for ctype() and many other things). |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
913 * NOTE: Translated messages with encodings other than latin1 will not |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
914 * work until set_init_1() has been called! |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
915 */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
916 init_locale(); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
917 TIME_MSG("locale set"); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
918 #endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
919 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
920 #ifdef FEAT_GUI |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
921 gui.dofork = TRUE; // default is to use fork() |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
922 #endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
923 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
924 /* |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
925 * Do a first scan of the arguments in "argv[]": |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
926 * -display or --display |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
927 * --server... |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
928 * --socketid |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
929 * --windowid |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
930 */ |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
931 early_arg_scan(paramp); |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
932 |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12678
diff
changeset
|
933 #if defined(FEAT_GUI) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
934 // Prepare for possibly starting GUI sometime |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
935 gui_prepare(¶mp->argc, paramp->argv); |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
936 TIME_MSG("GUI prepared"); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
937 #endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
938 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
939 #ifdef FEAT_CLIPBOARD |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
940 clip_init(FALSE); // Initialise clipboard stuff |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
941 TIME_MSG("clipboard setup"); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
942 #endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
943 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
944 /* |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
945 * Check if we have an interactive window. |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
946 * On the Amiga: If there is no window, we open one with a newcli command |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
947 * (needed for :! to * work). mch_check_win() will also handle the -d or |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
948 * -dev argument. |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
949 */ |
10404
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
950 stdout_isatty = (mch_check_win(paramp->argc, paramp->argv) != FAIL); |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
951 TIME_MSG("window checked"); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
952 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
953 /* |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
954 * Allocate the first window and buffer. |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
955 * Can't do anything without it, exit when it fails. |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
956 */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
957 if (win_alloc_first() == FAIL) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
958 mch_exit(0); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
959 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
960 init_yank(); // init yank buffers |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
961 |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
962 alist_init(&global_alist); // Init the argument list to empty. |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
963 global_alist.id = 0; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
964 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
965 /* |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
966 * Set the default values for the options. |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
967 * NOTE: Non-latin1 translated messages are working only after this, |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
968 * because this is where "has_mbyte" will be set, which is used by |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
969 * msg_outtrans_len_attr(). |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
970 * First find out the home directory, needed to expand "~" in options. |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
971 */ |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
972 init_homedir(); // find real value of $HOME |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
973 set_init_1(paramp->clean); |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
974 TIME_MSG("inits 1"); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
975 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
976 #ifdef FEAT_EVAL |
18477
e93cab5d0f0f
patch 8.1.2233: cannot get the Vim command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
18440
diff
changeset
|
977 // set v:lang and v:ctype |
e93cab5d0f0f
patch 8.1.2233: cannot get the Vim command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
18440
diff
changeset
|
978 set_lang_var(); |
e93cab5d0f0f
patch 8.1.2233: cannot get the Vim command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
18440
diff
changeset
|
979 |
e93cab5d0f0f
patch 8.1.2233: cannot get the Vim command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
18440
diff
changeset
|
980 // set v:argv |
e93cab5d0f0f
patch 8.1.2233: cannot get the Vim command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
18440
diff
changeset
|
981 set_argv_var(paramp->argv, paramp->argc); |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
982 #endif |
15271
a6319aca721b
patch 8.1.0644: finding next sign ID is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
983 |
a6319aca721b
patch 8.1.0644: finding next sign ID is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
984 #ifdef FEAT_SIGNS |
a6319aca721b
patch 8.1.0644: finding next sign ID is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
985 init_signs(); |
a6319aca721b
patch 8.1.0644: finding next sign ID is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
986 #endif |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
987 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
988 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
989 /* |
11307
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
990 * Return TRUE when the --not-a-term argument was found. |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
991 */ |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
992 int |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
993 is_not_a_term() |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
994 { |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
995 return params.not_a_term; |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
996 } |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
997 |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
998 |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18098
diff
changeset
|
999 // When TRUE in a safe state when starting to wait for a character. |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1000 static int was_safe = FALSE; |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1001 static oparg_T *current_oap = NULL; |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1002 |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1003 /* |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1004 * Return TRUE if an operator was started but not finished yet. |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1005 * Includes typing a count or a register name. |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1006 */ |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1007 int |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1008 op_pending(void) |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1009 { |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1010 return !(current_oap != NULL |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1011 && !finish_op |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1012 && current_oap->prev_opcount == 0 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1013 && current_oap->prev_count0 == 0 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1014 && current_oap->op_type == OP_NOP |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1015 && current_oap->regname == NUL); |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1016 } |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1017 |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1018 /* |
18116
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1019 * Return whether currently it is safe, assuming it was safe before (high level |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1020 * state didn't change). |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1021 */ |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1022 static int |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1023 is_safe_now(void) |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1024 { |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1025 return stuff_empty() |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1026 && typebuf.tb_len == 0 |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1027 && scriptin[curscript] == NULL |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1028 && !global_busy; |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1029 } |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1030 |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1031 /* |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1032 * Trigger SafeState if currently in s safe state, that is "safe" is TRUE and |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1033 * there is no typeahead. |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1034 */ |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1035 void |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1036 may_trigger_safestate(int safe) |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1037 { |
18116
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1038 int is_safe = safe && is_safe_now(); |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1039 |
18108
76126690dd92
patch 8.1.2049: cannot build tiny version
Bram Moolenaar <Bram@vim.org>
parents:
18106
diff
changeset
|
1040 #ifdef FEAT_JOB_CHANNEL |
18106
b456bba1276a
patch 8.1.2048: not clear why SafeState and SafeStateAgain are not triggered
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
1041 if (was_safe != is_safe) |
b456bba1276a
patch 8.1.2048: not clear why SafeState and SafeStateAgain are not triggered
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
1042 // Only log when the state changes, otherwise it happens at nearly |
b456bba1276a
patch 8.1.2048: not clear why SafeState and SafeStateAgain are not triggered
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
1043 // every key stroke. |
18116
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1044 ch_log(NULL, is_safe ? "SafeState: Start triggering" |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1045 : "SafeState: Stop triggering"); |
18108
76126690dd92
patch 8.1.2049: cannot build tiny version
Bram Moolenaar <Bram@vim.org>
parents:
18106
diff
changeset
|
1046 #endif |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1047 if (is_safe) |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1048 apply_autocmds(EVENT_SAFESTATE, NULL, NULL, FALSE, curbuf); |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1049 was_safe = is_safe; |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1050 } |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1051 |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1052 /* |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18098
diff
changeset
|
1053 * Something changed which causes the state possibly to be unsafe, e.g. a |
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18098
diff
changeset
|
1054 * character was typed. It will remain unsafe until the next call to |
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18098
diff
changeset
|
1055 * may_trigger_safestate(). |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1056 */ |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1057 void |
18116
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1058 state_no_longer_safe(char *reason UNUSED) |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1059 { |
18108
76126690dd92
patch 8.1.2049: cannot build tiny version
Bram Moolenaar <Bram@vim.org>
parents:
18106
diff
changeset
|
1060 #ifdef FEAT_JOB_CHANNEL |
18106
b456bba1276a
patch 8.1.2048: not clear why SafeState and SafeStateAgain are not triggered
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
1061 if (was_safe) |
18116
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1062 ch_log(NULL, "SafeState: reset: %s", reason); |
18108
76126690dd92
patch 8.1.2049: cannot build tiny version
Bram Moolenaar <Bram@vim.org>
parents:
18106
diff
changeset
|
1063 #endif |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18098
diff
changeset
|
1064 was_safe = FALSE; |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1065 } |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1066 |
18116
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1067 int |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1068 get_was_safe_state(void) |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1069 { |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1070 return was_safe; |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1071 } |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1072 |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1073 /* |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18098
diff
changeset
|
1074 * Invoked when leaving code that invokes callbacks. Then trigger |
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18098
diff
changeset
|
1075 * SafeStateAgain, if it was safe when starting to wait for a character. |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1076 */ |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1077 void |
18106
b456bba1276a
patch 8.1.2048: not clear why SafeState and SafeStateAgain are not triggered
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
1078 may_trigger_safestateagain(void) |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1079 { |
18116
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1080 if (!was_safe) |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1081 { |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1082 // If the safe state was reset in state_no_longer_safe(), e.g. because |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1083 // of calling feedkeys(), we check if it's now safe again (all keys |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1084 // were consumed). |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1085 was_safe = is_safe_now(); |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1086 #ifdef FEAT_JOB_CHANNEL |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1087 if (was_safe) |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1088 ch_log(NULL, "SafeState: undo reset"); |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1089 #endif |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1090 } |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18098
diff
changeset
|
1091 if (was_safe) |
18106
b456bba1276a
patch 8.1.2048: not clear why SafeState and SafeStateAgain are not triggered
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
1092 { |
18108
76126690dd92
patch 8.1.2049: cannot build tiny version
Bram Moolenaar <Bram@vim.org>
parents:
18106
diff
changeset
|
1093 #ifdef FEAT_JOB_CHANNEL |
18160
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1094 // Only do this message when another message was given, otherwise we |
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1095 // get lots of them. |
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1096 if ((did_repeated_msg & REPEATED_MSG_SAFESTATE) == 0) |
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1097 { |
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1098 int did = did_repeated_msg; |
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1099 |
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1100 ch_log(NULL, |
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1101 "SafeState: back to waiting, triggering SafeStateAgain"); |
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1102 did_repeated_msg = did | REPEATED_MSG_SAFESTATE; |
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1103 } |
18108
76126690dd92
patch 8.1.2049: cannot build tiny version
Bram Moolenaar <Bram@vim.org>
parents:
18106
diff
changeset
|
1104 #endif |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18098
diff
changeset
|
1105 apply_autocmds(EVENT_SAFESTATEAGAIN, NULL, NULL, FALSE, curbuf); |
18106
b456bba1276a
patch 8.1.2048: not clear why SafeState and SafeStateAgain are not triggered
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
1106 } |
18108
76126690dd92
patch 8.1.2049: cannot build tiny version
Bram Moolenaar <Bram@vim.org>
parents:
18106
diff
changeset
|
1107 #ifdef FEAT_JOB_CHANNEL |
18106
b456bba1276a
patch 8.1.2048: not clear why SafeState and SafeStateAgain are not triggered
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
1108 else |
18116
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1109 ch_log(NULL, |
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18108
diff
changeset
|
1110 "SafeState: back to waiting, not triggering SafeStateAgain"); |
18108
76126690dd92
patch 8.1.2049: cannot build tiny version
Bram Moolenaar <Bram@vim.org>
parents:
18106
diff
changeset
|
1111 #endif |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1112 } |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1113 |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1114 |
11307
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
1115 /* |
6 | 1116 * Main loop: Execute Normal mode commands until exiting Vim. |
1117 * Also used to handle commands in the command-line window, until the window | |
1118 * is closed. | |
169 | 1119 * Also used to handle ":visual" command after ":global": execute Normal mode |
1120 * commands, return when entering Ex mode. "noexmode" is TRUE then. | |
6 | 1121 */ |
1122 void | |
7598
1a528724f9d6
commit https://github.com/vim/vim/commit/b7604cc19fa1db6a8182546bf662aa13d4574d7a
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1123 main_loop( |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1124 int cmdwin, // TRUE when working in the command-line window |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1125 int noexmode) // TRUE when return on entering Ex mode |
6 | 1126 { |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1127 oparg_T oa; // operator arguments |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1128 oparg_T *prev_oap; // operator arguments |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1129 volatile int previous_got_int = FALSE; // "got_int" was TRUE |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1130 #ifdef FEAT_CONCEAL |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1131 // these are static to avoid a compiler warning |
6923 | 1132 static linenr_T conceal_old_cursor_line = 0; |
1133 static linenr_T conceal_new_cursor_line = 0; | |
1134 static int conceal_update_lines = FALSE; | |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1135 #endif |
6 | 1136 |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1137 prev_oap = current_oap; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1138 current_oap = &oa; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1139 |
6 | 1140 #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1141 // Setup to catch a terminating error from the X server. Just ignore |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1142 // it, restore the state and continue. This might not always work |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1143 // properly, but at least we don't exit unexpectedly when the X server |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1144 // exits while Vim is running in a console. |
169 | 1145 if (!cmdwin && !noexmode && SETJMP(x_jump_env)) |
6 | 1146 { |
1147 State = NORMAL; | |
1148 VIsual_active = FALSE; | |
1149 got_int = TRUE; | |
1150 need_wait_return = FALSE; | |
1151 global_busy = FALSE; | |
1152 exmode_active = 0; | |
1153 skip_redraw = FALSE; | |
1154 RedrawingDisabled = 0; | |
1155 no_wait_return = 0; | |
3119 | 1156 vgetc_busy = 0; |
6 | 1157 # ifdef FEAT_EVAL |
1158 emsg_skip = 0; | |
1159 # endif | |
1160 emsg_off = 0; | |
1161 setmouse(); | |
1162 settmode(TMODE_RAW); | |
1163 starttermcap(); | |
1164 scroll_start(); | |
1165 redraw_later_clear(); | |
1166 } | |
1167 #endif | |
1168 | |
1169 clear_oparg(&oa); | |
1170 while (!cmdwin | |
1171 #ifdef FEAT_CMDWIN | |
1172 || cmdwin_result == 0 | |
1173 #endif | |
1174 ) | |
1175 { | |
1176 if (stuff_empty()) | |
1177 { | |
1178 did_check_timestamps = FALSE; | |
1179 if (need_check_timestamps) | |
1180 check_timestamps(FALSE); | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1181 if (need_wait_return) // if wait_return still needed ... |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1182 wait_return(FALSE); // ... call it now |
5735 | 1183 if (need_start_insertmode && goto_im() && !VIsual_active) |
6 | 1184 { |
1185 need_start_insertmode = FALSE; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1186 stuffReadbuff((char_u *)"i"); // start insert mode next |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1187 // skip the fileinfo message now, because it would be shown |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1188 // after insert mode finishes! |
6 | 1189 need_fileinfo = FALSE; |
1190 } | |
1191 } | |
1345 | 1192 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1193 // Reset "got_int" now that we got back to the main loop. Except when |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1194 // inside a ":g/pat/cmd" command, then the "got_int" needs to abort |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1195 // the ":g" command. |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1196 // For ":g/pat/vi" we reset "got_int" when used once. When used |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1197 // a second time we go back to Ex mode and abort the ":g" command. |
1345 | 1198 if (got_int) |
6 | 1199 { |
1345 | 1200 if (noexmode && global_busy && !exmode_active && previous_got_int) |
1201 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1202 // Typed two CTRL-C in a row: go back to ex mode as if "Q" was |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1203 // used and keep "got_int" set, so that it aborts ":g". |
1345 | 1204 exmode_active = EXMODE_NORMAL; |
1205 State = NORMAL; | |
1206 } | |
1207 else if (!global_busy || !exmode_active) | |
1208 { | |
1209 if (!quit_more) | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1210 (void)vgetc(); // flush all buffers |
1345 | 1211 got_int = FALSE; |
1212 } | |
1213 previous_got_int = TRUE; | |
6 | 1214 } |
1345 | 1215 else |
1216 previous_got_int = FALSE; | |
1217 | |
6 | 1218 if (!exmode_active) |
1219 msg_scroll = FALSE; | |
1220 quit_more = FALSE; | |
1221 | |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1222 // it's not safe unless may_trigger_safestate_main() is called |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1223 was_safe = FALSE; |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1224 |
6 | 1225 /* |
1226 * If skip redraw is set (for ":" in wait_return()), don't redraw now. | |
1227 * If there is nothing in the stuff_buffer or do_redraw is TRUE, | |
1228 * update cursor and redraw. | |
1229 */ | |
1230 if (skip_redraw || exmode_active) | |
1231 skip_redraw = FALSE; | |
1232 else if (do_redraw || stuff_empty()) | |
1233 { | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1234 #ifdef FEAT_GUI |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14171
diff
changeset
|
1235 // If ui_breakcheck() was used a resize may have been postponed. |
10819
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10404
diff
changeset
|
1236 gui_may_resize_shell(); |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1237 #endif |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14171
diff
changeset
|
1238 #ifdef HAVE_DROP_FILE |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14171
diff
changeset
|
1239 // If files were dropped while text was locked or the curbuf was |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14171
diff
changeset
|
1240 // locked, this would be a good time to handle the drop. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14171
diff
changeset
|
1241 handle_any_postponed_drop(); |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14171
diff
changeset
|
1242 #endif |
15476
5b0f37d844b3
patch 8.1.0746: highlighting not updated with conceal and 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1243 #ifdef FEAT_CONCEAL |
5b0f37d844b3
patch 8.1.0746: highlighting not updated with conceal and 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1244 if (curwin->w_p_cole == 0) |
5b0f37d844b3
patch 8.1.0746: highlighting not updated with conceal and 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1245 conceal_update_lines = FALSE; |
5b0f37d844b3
patch 8.1.0746: highlighting not updated with conceal and 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1246 #endif |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14171
diff
changeset
|
1247 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1248 // Trigger CursorMoved if the cursor moved. |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1249 if (!finish_op && ( |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1250 has_cursormoved() |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
1251 #ifdef FEAT_PROP_POPUP |
16904
9138e2c60bf1
patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1252 || popup_visible |
9138e2c60bf1
patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1253 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1254 #ifdef FEAT_CONCEAL |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1255 || curwin->w_p_cole > 0 |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1256 #endif |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1257 ) |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1258 && !EQUAL_POS(last_cursormoved, curwin->w_cursor)) |
662 | 1259 { |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1260 if (has_cursormoved()) |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1261 apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1262 FALSE, curbuf); |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
1263 #ifdef FEAT_PROP_POPUP |
16904
9138e2c60bf1
patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1264 if (popup_visible) |
9138e2c60bf1
patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1265 popup_check_cursor_pos(); |
9138e2c60bf1
patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1266 #endif |
9138e2c60bf1
patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1267 #ifdef FEAT_CONCEAL |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
1268 if (curwin->w_p_cole > 0) |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1269 { |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1270 conceal_old_cursor_line = last_cursormoved.lnum; |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1271 conceal_new_cursor_line = curwin->w_cursor.lnum; |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1272 conceal_update_lines = TRUE; |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1273 } |
16904
9138e2c60bf1
patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1274 #endif |
662 | 1275 last_cursormoved = curwin->w_cursor; |
1276 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1277 |
15436
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1278 #if defined(FEAT_CONCEAL) |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1279 if (conceal_update_lines |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1280 && (conceal_old_cursor_line != conceal_new_cursor_line |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1281 || conceal_cursor_line(curwin) |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1282 || need_cursor_line_redraw)) |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1283 { |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1284 if (conceal_old_cursor_line != conceal_new_cursor_line |
15476
5b0f37d844b3
patch 8.1.0746: highlighting not updated with conceal and 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1285 && conceal_old_cursor_line != 0 |
15436
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1286 && conceal_old_cursor_line |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1287 <= curbuf->b_ml.ml_line_count) |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1288 redrawWinline(curwin, conceal_old_cursor_line); |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1289 redrawWinline(curwin, conceal_new_cursor_line); |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1290 curwin->w_valid &= ~VALID_CROW; |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1291 need_cursor_line_redraw = FALSE; |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1292 } |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1293 #endif |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1294 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1295 // Trigger TextChanged if b:changedtick differs. |
4232 | 1296 if (!finish_op && has_textchanged() |
13240
5ed6e4a25925
patch 8.0.1494: no autocmd triggered in Insert mode with visible popup menu
Christian Brabandt <cb@256bit.org>
parents:
13170
diff
changeset
|
1297 && curbuf->b_last_changedtick != CHANGEDTICK(curbuf)) |
4232 | 1298 { |
13240
5ed6e4a25925
patch 8.0.1494: no autocmd triggered in Insert mode with visible popup menu
Christian Brabandt <cb@256bit.org>
parents:
13170
diff
changeset
|
1299 apply_autocmds(EVENT_TEXTCHANGED, NULL, NULL, FALSE, curbuf); |
5ed6e4a25925
patch 8.0.1494: no autocmd triggered in Insert mode with visible popup menu
Christian Brabandt <cb@256bit.org>
parents:
13170
diff
changeset
|
1300 curbuf->b_last_changedtick = CHANGEDTICK(curbuf); |
4232 | 1301 } |
1302 | |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1303 // If nothing is pending and we are going to wait for the user to |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1304 // type a character, trigger SafeState. |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1305 may_trigger_safestate(!op_pending() && restart_edit == 0); |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18068
diff
changeset
|
1306 |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
1307 #if defined(FEAT_DIFF) |
14764
f562b9fbd0d3
patch 8.1.0394: diffs are not always updated correctly
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1308 // Updating diffs from changed() does not always work properly, |
f562b9fbd0d3
patch 8.1.0394: diffs are not always updated correctly
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1309 // esp. updating folds. Do an update just before redrawing if |
f562b9fbd0d3
patch 8.1.0394: diffs are not always updated correctly
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1310 // needed. |
f562b9fbd0d3
patch 8.1.0394: diffs are not always updated correctly
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1311 if (curtab->tp_diff_update || curtab->tp_diff_invalid) |
f562b9fbd0d3
patch 8.1.0394: diffs are not always updated correctly
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1312 { |
f562b9fbd0d3
patch 8.1.0394: diffs are not always updated correctly
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1313 ex_diffupdate(NULL); |
f562b9fbd0d3
patch 8.1.0394: diffs are not always updated correctly
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1314 curtab->tp_diff_update = FALSE; |
f562b9fbd0d3
patch 8.1.0394: diffs are not always updated correctly
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1315 } |
f562b9fbd0d3
patch 8.1.0394: diffs are not always updated correctly
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1316 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1317 // Scroll-binding for diff mode may have been postponed until |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1318 // here. Avoids doing it for every change. |
640 | 1319 if (diff_need_scrollbind) |
1320 { | |
1321 check_scrollbind((linenr_T)0, 0L); | |
1322 diff_need_scrollbind = FALSE; | |
1323 } | |
1324 #endif | |
5735 | 1325 #if defined(FEAT_FOLDING) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1326 // Include a closed fold completely in the Visual area. |
6 | 1327 foldAdjustVisual(); |
1328 #endif | |
1329 #ifdef FEAT_FOLDING | |
1330 /* | |
1331 * When 'foldclose' is set, apply 'foldlevel' to folds that don't | |
1332 * contain the cursor. | |
1333 * When 'foldopen' is "all", open the fold(s) under the cursor. | |
1334 * This may mark the window for redrawing. | |
1335 */ | |
1336 if (hasAnyFolding(curwin) && !char_avail()) | |
1337 { | |
1338 foldCheckClose(); | |
1339 if (fdo_flags & FDO_ALL) | |
1340 foldOpenCursor(); | |
1341 } | |
1342 #endif | |
1343 | |
1344 /* | |
1345 * Before redrawing, make sure w_topline is correct, and w_leftcol | |
1346 * if lines don't wrap, and w_skipcol if lines wrap. | |
1347 */ | |
1348 update_topline(); | |
1349 validate_cursor(); | |
1350 | |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18045
diff
changeset
|
1351 #ifdef FEAT_SYN_HL |
18440
d6cb1e706fb7
patch 8.1.2214: too much is redrawn when 'cursorline' is set
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
1352 // Might need to update for 'cursorline'. |
d6cb1e706fb7
patch 8.1.2214: too much is redrawn when 'cursorline' is set
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
1353 // When 'cursorlineopt' is "screenline" need to redraw always. |
d6cb1e706fb7
patch 8.1.2214: too much is redrawn when 'cursorline' is set
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
1354 if (curwin->w_p_cul |
d6cb1e706fb7
patch 8.1.2214: too much is redrawn when 'cursorline' is set
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
1355 && (curwin->w_last_cursorline != curwin->w_cursor.lnum |
d6cb1e706fb7
patch 8.1.2214: too much is redrawn when 'cursorline' is set
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
1356 || (curwin->w_p_culopt_flags & CULOPT_SCRLINE)) |
d6cb1e706fb7
patch 8.1.2214: too much is redrawn when 'cursorline' is set
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
1357 && !char_avail()) |
d6cb1e706fb7
patch 8.1.2214: too much is redrawn when 'cursorline' is set
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
1358 redraw_later(VALID); |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18045
diff
changeset
|
1359 #endif |
6 | 1360 if (VIsual_active) |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18045
diff
changeset
|
1361 update_curbuf(INVERTED); // update inverted part |
5735 | 1362 else if (must_redraw) |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
1363 { |
18068
1101eacc1444
patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents:
18045
diff
changeset
|
1364 mch_disable_flush(); // Stop issuing gui_mch_flush(). |
18440
d6cb1e706fb7
patch 8.1.2214: too much is redrawn when 'cursorline' is set
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
1365 update_screen(0); |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
1366 mch_enable_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
1367 } |
6 | 1368 else if (redraw_cmdline || clear_cmdline) |
1369 showmode(); | |
1370 redraw_statuslines(); | |
1371 #ifdef FEAT_TITLE | |
1372 if (need_maketitle) | |
1373 maketitle(); | |
1374 #endif | |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9403
diff
changeset
|
1375 #ifdef FEAT_VIMINFO |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9403
diff
changeset
|
1376 curbuf->b_last_used = vim_time(); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9403
diff
changeset
|
1377 #endif |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1378 // display message after redraw |
6 | 1379 if (keep_msg != NULL) |
1380 { | |
18045
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17750
diff
changeset
|
1381 char_u *p = vim_strsave(keep_msg); |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17750
diff
changeset
|
1382 |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17750
diff
changeset
|
1383 if (p != NULL) |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17750
diff
changeset
|
1384 { |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17750
diff
changeset
|
1385 // msg_start() will set keep_msg to NULL, make a copy |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17750
diff
changeset
|
1386 // first. Don't reset keep_msg, msg_attr_keep() uses it to |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17750
diff
changeset
|
1387 // check for duplicates. Never put this message in |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17750
diff
changeset
|
1388 // history. |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17750
diff
changeset
|
1389 msg_hist_off = TRUE; |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17750
diff
changeset
|
1390 msg_attr((char *)p, keep_msg_attr); |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17750
diff
changeset
|
1391 msg_hist_off = FALSE; |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17750
diff
changeset
|
1392 vim_free(p); |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17750
diff
changeset
|
1393 } |
6 | 1394 } |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1395 if (need_fileinfo) // show file info after redraw |
6 | 1396 { |
1397 fileinfo(FALSE, TRUE, FALSE); | |
1398 need_fileinfo = FALSE; | |
1399 } | |
1400 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1401 emsg_on_display = FALSE; // can delete error message now |
6 | 1402 did_emsg = FALSE; |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1403 msg_didany = FALSE; // reset lines_left in msg_start() |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1404 may_clear_sb_text(); // clear scroll-back text on next msg |
6 | 1405 showruler(FALSE); |
1406 | |
1407 setcursor(); | |
1408 cursor_on(); | |
1409 | |
1410 do_redraw = FALSE; | |
1972 | 1411 |
1412 #ifdef STARTUPTIME | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1413 // Now that we have drawn the first screen all the startup stuff |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1414 // has been done, close any file for startup messages. |
1972 | 1415 if (time_fd != NULL) |
1416 { | |
1417 TIME_MSG("first screen update"); | |
1418 TIME_MSG("--- VIM STARTED ---"); | |
1419 fclose(time_fd); | |
1420 time_fd = NULL; | |
1421 } | |
1422 #endif | |
6 | 1423 } |
1424 #ifdef FEAT_GUI | |
1425 if (need_mouse_correct) | |
1426 gui_mouse_correct(); | |
1427 #endif | |
1428 | |
1429 /* | |
1430 * Update w_curswant if w_set_curswant has been set. | |
1431 * Postponed until here to avoid computing w_virtcol too often. | |
1432 */ | |
1433 update_curswant(); | |
1434 | |
958 | 1435 #ifdef FEAT_EVAL |
1436 /* | |
1437 * May perform garbage collection when waiting for a character, but | |
1438 * only at the very toplevel. Otherwise we may be using a List or | |
1439 * Dict internally somewhere. | |
1440 * "may_garbage_collect" is reset in vgetc() which is invoked through | |
1441 * do_exmode() and normal_cmd(). | |
1442 */ | |
1443 may_garbage_collect = (!cmdwin && !noexmode); | |
1444 #endif | |
6 | 1445 /* |
1446 * If we're invoked as ex, do a round of ex commands. | |
1447 * Otherwise, get and execute a normal mode command. | |
1448 */ | |
1449 if (exmode_active) | |
169 | 1450 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1451 if (noexmode) // End of ":global/path/visual" commands |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1452 goto theend; |
6 | 1453 do_exmode(exmode_active == EXMODE_VIM); |
169 | 1454 } |
6 | 1455 else |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1456 { |
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1457 #ifdef FEAT_TERMINAL |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1458 if (term_use_loop() |
11985
d036c1c8537d
patch 8.0.0873: in terminal cannot use CTRL- CTRL-N to start Visual mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
1459 && oa.op_type == OP_NOP && oa.regname == NUL |
14129
cb731d098241
patch 8.1.0082: in terminal window, typing : at more prompt, inserts ':'
Christian Brabandt <cb@256bit.org>
parents:
13841
diff
changeset
|
1460 && !VIsual_active |
cb731d098241
patch 8.1.0082: in terminal window, typing : at more prompt, inserts ':'
Christian Brabandt <cb@256bit.org>
parents:
13841
diff
changeset
|
1461 && !skip_term_loop) |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
1462 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1463 // If terminal_loop() returns OK we got a key that is handled |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1464 // in Normal model. With FAIL we first need to position the |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1465 // cursor and the screen needs to be redrawn. |
12457
dfb8254aa735
patch 8.0.1108: cannot specify mappings for the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12148
diff
changeset
|
1466 if (terminal_loop(TRUE) == OK) |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
1467 normal_cmd(&oa, TRUE); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
1468 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
1469 else |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1470 #endif |
14129
cb731d098241
patch 8.1.0082: in terminal window, typing : at more prompt, inserts ':'
Christian Brabandt <cb@256bit.org>
parents:
13841
diff
changeset
|
1471 { |
cb731d098241
patch 8.1.0082: in terminal window, typing : at more prompt, inserts ':'
Christian Brabandt <cb@256bit.org>
parents:
13841
diff
changeset
|
1472 #ifdef FEAT_TERMINAL |
cb731d098241
patch 8.1.0082: in terminal window, typing : at more prompt, inserts ':'
Christian Brabandt <cb@256bit.org>
parents:
13841
diff
changeset
|
1473 skip_term_loop = FALSE; |
cb731d098241
patch 8.1.0082: in terminal window, typing : at more prompt, inserts ':'
Christian Brabandt <cb@256bit.org>
parents:
13841
diff
changeset
|
1474 #endif |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
1475 normal_cmd(&oa, TRUE); |
14129
cb731d098241
patch 8.1.0082: in terminal window, typing : at more prompt, inserts ':'
Christian Brabandt <cb@256bit.org>
parents:
13841
diff
changeset
|
1476 } |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1477 } |
6 | 1478 } |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1479 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1480 theend: |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
1481 current_oap = prev_oap; |
6 | 1482 } |
1483 | |
1484 | |
8617
eab968bf3ce7
commit https://github.com/vim/vim/commit/6d8d849f5ac8a3a228c62fd29e8f40ae1b8381fc
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
1485 #if defined(USE_XSMP) || defined(FEAT_GUI) || defined(PROTO) |
6 | 1486 /* |
1487 * Exit, but leave behind swap files for modified buffers. | |
1488 */ | |
1489 void | |
7598
1a528724f9d6
commit https://github.com/vim/vim/commit/b7604cc19fa1db6a8182546bf662aa13d4574d7a
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1490 getout_preserve_modified(int exitval) |
6 | 1491 { |
39 | 1492 # if defined(SIGHUP) && defined(SIG_IGN) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1493 // Ignore SIGHUP, because a dropped connection causes a read error, which |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1494 // makes Vim exit and then handling SIGHUP causes various reentrance |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1495 // problems. |
36 | 1496 signal(SIGHUP, SIG_IGN); |
39 | 1497 # endif |
36 | 1498 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1499 ml_close_notmod(); // close all not-modified buffers |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1500 ml_sync_all(FALSE, FALSE); // preserve all swap files |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1501 ml_close_all(FALSE); // close all memfiles, without deleting |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1502 getout(exitval); // exit Vim properly |
6 | 1503 } |
1504 #endif | |
1505 | |
1506 | |
8617
eab968bf3ce7
commit https://github.com/vim/vim/commit/6d8d849f5ac8a3a228c62fd29e8f40ae1b8381fc
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
1507 /* |
23048
ad674a98058a
patch 8.2.2070: can't get the exit value in VimLeave(Pre) autocommands
Bram Moolenaar <Bram@vim.org>
parents:
23025
diff
changeset
|
1508 * Exit properly. This is the only way to exit Vim after startup has |
ad674a98058a
patch 8.2.2070: can't get the exit value in VimLeave(Pre) autocommands
Bram Moolenaar <Bram@vim.org>
parents:
23025
diff
changeset
|
1509 * succeeded. We are certain to exit here, no way to abort it. |
8617
eab968bf3ce7
commit https://github.com/vim/vim/commit/6d8d849f5ac8a3a228c62fd29e8f40ae1b8381fc
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
1510 */ |
6 | 1511 void |
7598
1a528724f9d6
commit https://github.com/vim/vim/commit/b7604cc19fa1db6a8182546bf662aa13d4574d7a
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1512 getout(int exitval) |
6 | 1513 { |
1514 exiting = TRUE; | |
13509
0c56cfb463f0
patch 8.0.1628: channel log doesn't mention exiting
Christian Brabandt <cb@256bit.org>
parents:
13466
diff
changeset
|
1515 #if defined(FEAT_JOB_CHANNEL) |
0c56cfb463f0
patch 8.0.1628: channel log doesn't mention exiting
Christian Brabandt <cb@256bit.org>
parents:
13466
diff
changeset
|
1516 ch_log(NULL, "Exiting..."); |
0c56cfb463f0
patch 8.0.1628: channel log doesn't mention exiting
Christian Brabandt <cb@256bit.org>
parents:
13466
diff
changeset
|
1517 #endif |
6 | 1518 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1519 // When running in Ex mode an error causes us to exit with a non-zero exit |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1520 // code. POSIX requires this, although it's not 100% clear from the |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1521 // standard. |
169 | 1522 if (exmode_active) |
1523 exitval += ex_exitval; | |
1524 | |
23048
ad674a98058a
patch 8.2.2070: can't get the exit value in VimLeave(Pre) autocommands
Bram Moolenaar <Bram@vim.org>
parents:
23025
diff
changeset
|
1525 #ifdef FEAT_EVAL |
ad674a98058a
patch 8.2.2070: can't get the exit value in VimLeave(Pre) autocommands
Bram Moolenaar <Bram@vim.org>
parents:
23025
diff
changeset
|
1526 set_vim_var_type(VV_EXITING, VAR_NUMBER); |
ad674a98058a
patch 8.2.2070: can't get the exit value in VimLeave(Pre) autocommands
Bram Moolenaar <Bram@vim.org>
parents:
23025
diff
changeset
|
1527 set_vim_var_nr(VV_EXITING, exitval); |
ad674a98058a
patch 8.2.2070: can't get the exit value in VimLeave(Pre) autocommands
Bram Moolenaar <Bram@vim.org>
parents:
23025
diff
changeset
|
1528 #endif |
ad674a98058a
patch 8.2.2070: can't get the exit value in VimLeave(Pre) autocommands
Bram Moolenaar <Bram@vim.org>
parents:
23025
diff
changeset
|
1529 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1530 // Position the cursor on the last screen line, below all the text |
6 | 1531 #ifdef FEAT_GUI |
1532 if (!gui.in_use) | |
1533 #endif | |
1534 windgoto((int)Rows - 1, 0); | |
1535 | |
242 | 1536 #if defined(FEAT_EVAL) || defined(FEAT_SYN_HL) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1537 // Optionally print hashtable efficiency. |
242 | 1538 hash_debug_results(); |
1539 #endif | |
1540 | |
6 | 1541 #ifdef FEAT_GUI |
1542 msg_didany = FALSE; | |
1543 #endif | |
1544 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1545 if (v_dying <= 1) |
6 | 1546 { |
13708
7c84c16fd376
patch 8.0.1726: older MSVC doesn't support declarations halfway a block
Christian Brabandt <cb@256bit.org>
parents:
13704
diff
changeset
|
1547 tabpage_T *tp; |
7c84c16fd376
patch 8.0.1726: older MSVC doesn't support declarations halfway a block
Christian Brabandt <cb@256bit.org>
parents:
13704
diff
changeset
|
1548 tabpage_T *next_tp; |
7c84c16fd376
patch 8.0.1726: older MSVC doesn't support declarations halfway a block
Christian Brabandt <cb@256bit.org>
parents:
13704
diff
changeset
|
1549 buf_T *buf; |
7c84c16fd376
patch 8.0.1726: older MSVC doesn't support declarations halfway a block
Christian Brabandt <cb@256bit.org>
parents:
13704
diff
changeset
|
1550 win_T *wp; |
20429
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20377
diff
changeset
|
1551 int unblock = 0; |
13708
7c84c16fd376
patch 8.0.1726: older MSVC doesn't support declarations halfway a block
Christian Brabandt <cb@256bit.org>
parents:
13704
diff
changeset
|
1552 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1553 // Trigger BufWinLeave for all windows, but only once per buffer. |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1554 for (tp = first_tabpage; tp != NULL; tp = next_tp) |
6 | 1555 { |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1556 next_tp = tp->tp_next; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9542
diff
changeset
|
1557 FOR_ALL_WINDOWS_IN_TAB(tp, wp) |
671 | 1558 { |
4021 | 1559 if (wp->w_buffer == NULL) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1560 // Autocmd must have close the buffer already, skip. |
4021 | 1561 continue; |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1562 buf = wp->w_buffer; |
10952
835604f3c37a
patch 8.0.0365: might free a dict item that wasn't allocated
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
1563 if (CHANGEDTICK(buf) != -1) |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1564 { |
13058
1293c33ff452
patch 8.0.1404: invalid memory access on exit
Christian Brabandt <cb@256bit.org>
parents:
12837
diff
changeset
|
1565 bufref_T bufref; |
1293c33ff452
patch 8.0.1404: invalid memory access on exit
Christian Brabandt <cb@256bit.org>
parents:
12837
diff
changeset
|
1566 |
1293c33ff452
patch 8.0.1404: invalid memory access on exit
Christian Brabandt <cb@256bit.org>
parents:
12837
diff
changeset
|
1567 set_bufref(&bufref, buf); |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1568 apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, |
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1569 buf->b_fname, FALSE, buf); |
13058
1293c33ff452
patch 8.0.1404: invalid memory access on exit
Christian Brabandt <cb@256bit.org>
parents:
12837
diff
changeset
|
1570 if (bufref_valid(&bufref)) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1571 CHANGEDTICK(buf) = -1; // note we did it already |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1572 |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1573 // start all over, autocommands may mess up the lists |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1574 next_tp = first_tabpage; |
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1575 break; |
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1576 } |
671 | 1577 } |
6 | 1578 } |
640 | 1579 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1580 // Trigger BufUnload for buffers that are loaded |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9542
diff
changeset
|
1581 FOR_ALL_BUFFERS(buf) |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1582 if (buf->b_ml.ml_mfp != NULL) |
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1583 { |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9414
diff
changeset
|
1584 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9414
diff
changeset
|
1585 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9414
diff
changeset
|
1586 set_bufref(&bufref, buf); |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1587 apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, |
6 | 1588 FALSE, buf); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9414
diff
changeset
|
1589 if (!bufref_valid(&bufref)) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1590 // autocmd deleted the buffer |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1591 break; |
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1592 } |
20429
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20377
diff
changeset
|
1593 |
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20377
diff
changeset
|
1594 // deathtrap() blocks autocommands, but we do want to trigger |
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20377
diff
changeset
|
1595 // VimLeavePre. |
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20377
diff
changeset
|
1596 if (is_autocmd_blocked()) |
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20377
diff
changeset
|
1597 { |
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20377
diff
changeset
|
1598 unblock_autocmds(); |
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20377
diff
changeset
|
1599 ++unblock; |
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20377
diff
changeset
|
1600 } |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1601 apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf); |
20429
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20377
diff
changeset
|
1602 if (unblock) |
c88ebfcbab03
patch 8.2.0769: VimLeavePre not triggered when Vim is terminated
Bram Moolenaar <Bram@vim.org>
parents:
20377
diff
changeset
|
1603 block_autocmds(); |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1604 } |
6 | 1605 |
1606 #ifdef FEAT_VIMINFO | |
1607 if (*p_viminfo != NUL) | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1608 // Write out the registers, history, marks etc, to the viminfo file |
6 | 1609 write_viminfo(NULL, FALSE); |
1610 #endif | |
1611 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1612 if (v_dying <= 1) |
17750
b27d06bd0fde
patch 8.1.1872: when Vim exits because of a signal, VimLeave is not triggered
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
1613 { |
b27d06bd0fde
patch 8.1.1872: when Vim exits because of a signal, VimLeave is not triggered
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
1614 int unblock = 0; |
b27d06bd0fde
patch 8.1.1872: when Vim exits because of a signal, VimLeave is not triggered
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
1615 |
b27d06bd0fde
patch 8.1.1872: when Vim exits because of a signal, VimLeave is not triggered
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
1616 // deathtrap() blocks autocommands, but we do want to trigger VimLeave. |
b27d06bd0fde
patch 8.1.1872: when Vim exits because of a signal, VimLeave is not triggered
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
1617 if (is_autocmd_blocked()) |
b27d06bd0fde
patch 8.1.1872: when Vim exits because of a signal, VimLeave is not triggered
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
1618 { |
b27d06bd0fde
patch 8.1.1872: when Vim exits because of a signal, VimLeave is not triggered
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
1619 unblock_autocmds(); |
b27d06bd0fde
patch 8.1.1872: when Vim exits because of a signal, VimLeave is not triggered
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
1620 ++unblock; |
b27d06bd0fde
patch 8.1.1872: when Vim exits because of a signal, VimLeave is not triggered
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
1621 } |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1622 apply_autocmds(EVENT_VIMLEAVE, NULL, NULL, FALSE, curbuf); |
17750
b27d06bd0fde
patch 8.1.1872: when Vim exits because of a signal, VimLeave is not triggered
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
1623 if (unblock) |
b27d06bd0fde
patch 8.1.1872: when Vim exits because of a signal, VimLeave is not triggered
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
1624 block_autocmds(); |
b27d06bd0fde
patch 8.1.1872: when Vim exits because of a signal, VimLeave is not triggered
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
1625 } |
6 | 1626 |
170 | 1627 #ifdef FEAT_PROFILE |
1628 profile_dump(); | |
1629 #endif | |
1630 | |
6 | 1631 if (did_emsg |
1632 #ifdef FEAT_GUI | |
1633 || (gui.in_use && msg_didany && p_verbose > 0) | |
1634 #endif | |
1635 ) | |
1636 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1637 // give the user a chance to read the (error) message |
6 | 1638 no_wait_return = FALSE; |
1639 wait_return(FALSE); | |
1640 } | |
1641 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1642 // Position the cursor again, the autocommands may have moved it |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1643 #ifdef FEAT_GUI |
6 | 1644 if (!gui.in_use) |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1645 #endif |
6 | 1646 windgoto((int)Rows - 1, 0); |
1647 | |
8493
caed4b2d305f
commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents:
8362
diff
changeset
|
1648 #ifdef FEAT_JOB_CHANNEL |
8170
a0ffb1f3dedc
commit https://github.com/vim/vim/commit/65edff8f51e9e54f85407bdb9156ae8e3e1b76a1
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
1649 job_stop_on_exit(); |
a0ffb1f3dedc
commit https://github.com/vim/vim/commit/65edff8f51e9e54f85407bdb9156ae8e3e1b76a1
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
1650 #endif |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2312
diff
changeset
|
1651 #ifdef FEAT_LUA |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2312
diff
changeset
|
1652 lua_end(); |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2312
diff
changeset
|
1653 #endif |
14 | 1654 #ifdef FEAT_MZSCHEME |
1655 mzscheme_end(); | |
1656 #endif | |
6 | 1657 #ifdef FEAT_TCL |
1658 tcl_end(); | |
1659 #endif | |
1660 #ifdef FEAT_RUBY | |
1661 ruby_end(); | |
1662 #endif | |
1663 #ifdef FEAT_PYTHON | |
1664 python_end(); | |
1665 #endif | |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
1666 #ifdef FEAT_PYTHON3 |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
1667 python3_end(); |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
1668 #endif |
6 | 1669 #ifdef FEAT_PERL |
1670 perl_end(); | |
1671 #endif | |
1672 #if defined(USE_ICONV) && defined(DYNAMIC_ICONV) | |
1673 iconv_end(); | |
1674 #endif | |
1675 #ifdef FEAT_NETBEANS_INTG | |
1676 netbeans_end(); | |
1677 #endif | |
1385 | 1678 #ifdef FEAT_CSCOPE |
1679 cs_end(); | |
1680 #endif | |
1405 | 1681 #ifdef FEAT_EVAL |
1682 if (garbage_collect_at_exit) | |
8881
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8857
diff
changeset
|
1683 garbage_collect(FALSE); |
1405 | 1684 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
1685 #ifdef MSWIN |
6193 | 1686 free_cmd_argsW(); |
1687 #endif | |
6 | 1688 |
1689 mch_exit(exitval); | |
1690 } | |
1691 | |
443 | 1692 /* |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1693 * Get the name of the display, before gui_prepare() removes it from |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1694 * argv[]. Used for the xterm-clipboard display. |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1695 * |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1696 * Also find the --server... arguments and --socketid and --windowid |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1697 */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1698 static void |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1699 early_arg_scan(mparm_T *parmp UNUSED) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1700 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1701 #if defined(FEAT_XCLIPBOARD) || defined(FEAT_CLIENTSERVER) \ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1702 || !defined(FEAT_NETBEANS_INTG) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1703 int argc = parmp->argc; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1704 char **argv = parmp->argv; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1705 int i; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1706 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1707 for (i = 1; i < argc; i++) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1708 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1709 if (STRCMP(argv[i], "--") == 0) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1710 break; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1711 # ifdef FEAT_XCLIPBOARD |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1712 else if (STRICMP(argv[i], "-display") == 0 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1713 # if defined(FEAT_GUI_GTK) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1714 || STRICMP(argv[i], "--display") == 0 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1715 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1716 ) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1717 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1718 if (i == argc - 1) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1719 mainerr_arg_missing((char_u *)argv[i]); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1720 xterm_display = argv[++i]; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1721 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1722 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1723 # ifdef FEAT_CLIENTSERVER |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1724 else if (STRICMP(argv[i], "--servername") == 0) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1725 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1726 if (i == argc - 1) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1727 mainerr_arg_missing((char_u *)argv[i]); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1728 parmp->serverName_arg = (char_u *)argv[++i]; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1729 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1730 else if (STRICMP(argv[i], "--serverlist") == 0) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1731 parmp->serverArg = TRUE; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1732 else if (STRNICMP(argv[i], "--remote", 8) == 0) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1733 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1734 parmp->serverArg = TRUE; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1735 # ifdef FEAT_GUI |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1736 if (strstr(argv[i], "-wait") != 0) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1737 // don't fork() when starting the GUI to edit files ourself |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1738 gui.dofork = FALSE; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1739 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1740 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1741 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1742 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
1743 # if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN) |
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
1744 # ifdef FEAT_GUI_MSWIN |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1745 else if (STRICMP(argv[i], "--windowid") == 0) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1746 # else |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1747 else if (STRICMP(argv[i], "--socketid") == 0) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1748 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1749 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1750 long_u id; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1751 int count; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1752 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1753 if (i == argc - 1) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1754 mainerr_arg_missing((char_u *)argv[i]); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1755 if (STRNICMP(argv[i+1], "0x", 2) == 0) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1756 count = sscanf(&(argv[i + 1][2]), SCANF_HEX_LONG_U, &id); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1757 else |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1758 count = sscanf(argv[i + 1], SCANF_DECIMAL_LONG_U, &id); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1759 if (count != 1) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1760 mainerr(ME_INVALID_ARG, (char_u *)argv[i]); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1761 else |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
1762 # ifdef FEAT_GUI_MSWIN |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1763 win_socket_id = id; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1764 # else |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1765 gtk_socket_id = id; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1766 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1767 i++; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1768 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1769 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1770 # ifdef FEAT_GUI_GTK |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1771 else if (STRICMP(argv[i], "--echo-wid") == 0) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1772 echo_wid_arg = TRUE; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1773 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1774 # ifndef FEAT_NETBEANS_INTG |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1775 else if (strncmp(argv[i], "-nb", (size_t)3) == 0) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1776 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1777 mch_errmsg(_("'-nb' cannot be used: not enabled at compile time\n")); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1778 mch_exit(2); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1779 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1780 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1781 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1782 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1783 #endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1784 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1785 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1786 #ifndef NO_VIM_MAIN |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1787 /* |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1788 * Get a (optional) count for a Vim argument. |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1789 */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1790 static int |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1791 get_number_arg( |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1792 char_u *p, // pointer to argument |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1793 int *idx, // index in argument, is incremented |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1794 int def) // default value |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1795 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1796 if (vim_isdigit(p[*idx])) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1797 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1798 def = atoi((char *)&(p[*idx])); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1799 while (vim_isdigit(p[*idx])) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1800 *idx = *idx + 1; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1801 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1802 return def; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1803 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1804 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1805 /* |
14927
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
1806 * Check for: [r][e][g][vi|vim|view][diff][ex[im]] (sort of) |
443 | 1807 * If the executable name starts with "r" we disable shell commands. |
1808 * If the next character is "e" we run in Easy mode. | |
1809 * If the next character is "g" we run the GUI version. | |
1810 * If the next characters are "view" we start in readonly mode. | |
1811 * If the next characters are "diff" or "vimdiff" we start in diff mode. | |
1812 * If the next characters are "ex" we start in Ex mode. If it's followed | |
1813 * by "im" use improved Ex mode. | |
1814 */ | |
1815 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1816 parse_command_name(mparm_T *parmp) |
443 | 1817 { |
1818 char_u *initstr; | |
1819 | |
1820 initstr = gettail((char_u *)parmp->argv[0]); | |
1821 | |
1822 #ifdef FEAT_EVAL | |
1823 set_vim_var_string(VV_PROGNAME, initstr, -1); | |
11032
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
1824 set_progpath((char_u *)parmp->argv[0]); |
443 | 1825 #endif |
1826 | |
1827 if (TOLOWER_ASC(initstr[0]) == 'r') | |
1828 { | |
1829 restricted = TRUE; | |
1830 ++initstr; | |
1831 } | |
1832 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1833 // Use evim mode for "evim" and "egvim", not for "editor". |
443 | 1834 if (TOLOWER_ASC(initstr[0]) == 'e' |
1835 && (TOLOWER_ASC(initstr[1]) == 'v' | |
1836 || TOLOWER_ASC(initstr[1]) == 'g')) | |
1837 { | |
1838 #ifdef FEAT_GUI | |
1839 gui.starting = TRUE; | |
1840 #endif | |
1841 parmp->evim_mode = TRUE; | |
1842 ++initstr; | |
1843 } | |
1844 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1845 // "gvim" starts the GUI. Also accept "Gvim" for MS-Windows. |
1722 | 1846 if (TOLOWER_ASC(initstr[0]) == 'g') |
443 | 1847 { |
1848 main_start_gui(); | |
1849 #ifdef FEAT_GUI | |
1850 ++initstr; | |
1851 #endif | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
1852 #ifdef GUI_MAY_SPAWN |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
1853 gui.dospawn = FALSE; // No need to spawn a new process. |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
1854 #endif |
443 | 1855 } |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
1856 #ifdef GUI_MAY_SPAWN |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
1857 else |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
1858 gui.dospawn = TRUE; // Not "gvim". Need to spawn gvim.exe. |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
1859 #endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
1860 |
443 | 1861 |
1862 if (STRNICMP(initstr, "view", 4) == 0) | |
1863 { | |
1864 readonlymode = TRUE; | |
1865 curbuf->b_p_ro = TRUE; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1866 p_uc = 10000; // don't update very often |
443 | 1867 initstr += 4; |
1868 } | |
1869 else if (STRNICMP(initstr, "vim", 3) == 0) | |
1870 initstr += 3; | |
1871 | |
14927
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
1872 // Catch "[r][g]vimdiff" and "[r][g]viewdiff". |
443 | 1873 if (STRICMP(initstr, "diff") == 0) |
1874 { | |
1875 #ifdef FEAT_DIFF | |
1876 parmp->diff_mode = TRUE; | |
1877 #else | |
1878 mch_errmsg(_("This Vim was not compiled with the diff feature.")); | |
1879 mch_errmsg("\n"); | |
1880 mch_exit(2); | |
1881 #endif | |
1882 } | |
1883 | |
19906
031184ace7c5
patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents:
19396
diff
changeset
|
1884 // Checking for "ex" here may catch some weird names, such as "vimex" or |
14927
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
1885 // "viewex", we assume the user knows that. |
443 | 1886 if (STRNICMP(initstr, "ex", 2) == 0) |
1887 { | |
1888 if (STRNICMP(initstr + 2, "im", 2) == 0) | |
1889 exmode_active = EXMODE_VIM; | |
1890 else | |
1891 exmode_active = EXMODE_NORMAL; | |
14927
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
1892 change_compatible(TRUE); // set 'compatible' |
443 | 1893 } |
1894 } | |
1895 | |
6 | 1896 /* |
443 | 1897 * Scan the command line arguments. |
1898 */ | |
1899 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1900 command_line_scan(mparm_T *parmp) |
443 | 1901 { |
1902 int argc = parmp->argc; | |
1903 char **argv = parmp->argv; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1904 int argv_idx; // index in argv[n][] |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1905 int had_minmin = FALSE; // found "--" argument |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1906 int want_argument; // option argument with argument |
443 | 1907 int c; |
445 | 1908 char_u *p = NULL; |
443 | 1909 long n; |
1910 | |
1911 --argc; | |
1912 ++argv; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1913 argv_idx = 1; // active option letter is argv[0][argv_idx] |
443 | 1914 while (argc > 0) |
1915 { | |
1916 /* | |
1917 * "+" or "+{number}" or "+/{pat}" or "+{command}" argument. | |
1918 */ | |
1919 if (argv[0][0] == '+' && !had_minmin) | |
1920 { | |
1921 if (parmp->n_commands >= MAX_ARG_CMDS) | |
1922 mainerr(ME_EXTRA_CMD, NULL); | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1923 argv_idx = -1; // skip to next argument |
443 | 1924 if (argv[0][1] == NUL) |
1925 parmp->commands[parmp->n_commands++] = (char_u *)"$"; | |
1926 else | |
1927 parmp->commands[parmp->n_commands++] = (char_u *)&(argv[0][1]); | |
1928 } | |
1929 | |
1930 /* | |
1931 * Optional argument. | |
1932 */ | |
1933 else if (argv[0][0] == '-' && !had_minmin) | |
1934 { | |
1935 want_argument = FALSE; | |
1936 c = argv[0][argv_idx++]; | |
1937 #ifdef VMS | |
1938 /* | |
1939 * VMS only uses upper case command lines. Interpret "-X" as "-x" | |
1940 * and "-/X" as "-X". | |
1941 */ | |
1942 if (c == '/') | |
1943 { | |
1944 c = argv[0][argv_idx++]; | |
1945 c = TOUPPER_ASC(c); | |
1946 } | |
1947 else | |
1948 c = TOLOWER_ASC(c); | |
1949 #endif | |
1950 switch (c) | |
1951 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1952 case NUL: // "vim -" read from stdin |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1953 // "ex -" silent mode |
443 | 1954 if (exmode_active) |
1955 silent_mode = TRUE; | |
1956 else | |
1957 { | |
1958 if (parmp->edit_type != EDIT_NONE) | |
1959 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); | |
1960 parmp->edit_type = EDIT_STDIN; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1961 read_cmd_fd = 2; // read from stderr instead of stdin |
443 | 1962 } |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1963 argv_idx = -1; // skip to next argument |
443 | 1964 break; |
1965 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1966 case '-': // "--" don't take any more option arguments |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1967 // "--help" give help message |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1968 // "--version" give version message |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1969 // "--clean" clean context |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1970 // "--literal" take files literally |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1971 // "--nofork" don't fork |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1972 // "--not-a-term" don't warn for not a term |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1973 // "--ttyfail" exit if not a term |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1974 // "--noplugin[s]" skip plugins |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1975 // "--cmd <cmd>" execute cmd before vimrc |
443 | 1976 if (STRICMP(argv[0] + argv_idx, "help") == 0) |
1977 usage(); | |
1978 else if (STRICMP(argv[0] + argv_idx, "version") == 0) | |
1979 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1980 Columns = 80; // need to init Columns |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1981 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
443 | 1982 list_version(); |
1983 msg_putchar('\n'); | |
1984 msg_didout = FALSE; | |
1985 mch_exit(0); | |
1986 } | |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
1987 else if (STRNICMP(argv[0] + argv_idx, "clean", 5) == 0) |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
1988 { |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
1989 parmp->use_vimrc = (char_u *)"DEFAULTS"; |
13466
cf7cd0272011
patch 8.0.1607: --clean loads user settings from .gvimrc
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
1990 #ifdef FEAT_GUI |
cf7cd0272011
patch 8.0.1607: --clean loads user settings from .gvimrc
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
1991 use_gvimrc = (char_u *)"NONE"; |
cf7cd0272011
patch 8.0.1607: --clean loads user settings from .gvimrc
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
1992 #endif |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1993 parmp->clean = TRUE; |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
1994 set_option_value((char_u *)"vif", 0L, (char_u *)"NONE", 0); |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
1995 } |
443 | 1996 else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0) |
1997 { | |
7410
08e62c4fc17d
commit https://github.com/vim/vim/commit/53076830fea6df737455523f7e235bfe4f79864d
Christian Brabandt <cb@256bit.org>
parents:
6923
diff
changeset
|
1998 #ifdef EXPAND_FILENAMES |
443 | 1999 parmp->literal = TRUE; |
2000 #endif | |
2001 } | |
2002 else if (STRNICMP(argv[0] + argv_idx, "nofork", 6) == 0) | |
2003 { | |
2004 #ifdef FEAT_GUI | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2005 gui.dofork = FALSE; // don't fork() when starting GUI |
443 | 2006 #endif |
2007 } | |
2008 else if (STRNICMP(argv[0] + argv_idx, "noplugin", 8) == 0) | |
2009 p_lpl = FALSE; | |
8253
1b6a589a0efc
commit https://github.com/vim/vim/commit/49c39ff678e2ba9f7dc280b25368e12084a610cf
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
2010 else if (STRNICMP(argv[0] + argv_idx, "not-a-term", 10) == 0) |
1b6a589a0efc
commit https://github.com/vim/vim/commit/49c39ff678e2ba9f7dc280b25368e12084a610cf
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
2011 parmp->not_a_term = TRUE; |
10404
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2012 else if (STRNICMP(argv[0] + argv_idx, "ttyfail", 7) == 0) |
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2013 parmp->tty_fail = TRUE; |
443 | 2014 else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0) |
2015 { | |
2016 want_argument = TRUE; | |
2017 argv_idx += 3; | |
2018 } | |
1989 | 2019 else if (STRNICMP(argv[0] + argv_idx, "startuptime", 11) == 0) |
2020 { | |
2021 want_argument = TRUE; | |
2022 argv_idx += 11; | |
2023 } | |
443 | 2024 #ifdef FEAT_CLIENTSERVER |
2025 else if (STRNICMP(argv[0] + argv_idx, "serverlist", 10) == 0) | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2026 ; // already processed -- no arg |
443 | 2027 else if (STRNICMP(argv[0] + argv_idx, "servername", 10) == 0 |
2028 || STRNICMP(argv[0] + argv_idx, "serversend", 10) == 0) | |
2029 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2030 // already processed -- snatch the following arg |
443 | 2031 if (argc > 1) |
2032 { | |
2033 --argc; | |
2034 ++argv; | |
2035 } | |
2036 } | |
2037 #endif | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2038 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN) |
1376 | 2039 # ifdef FEAT_GUI_GTK |
443 | 2040 else if (STRNICMP(argv[0] + argv_idx, "socketid", 8) == 0) |
1376 | 2041 # else |
2042 else if (STRNICMP(argv[0] + argv_idx, "windowid", 8) == 0) | |
2043 # endif | |
443 | 2044 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2045 // already processed -- snatch the following arg |
443 | 2046 if (argc > 1) |
2047 { | |
2048 --argc; | |
2049 ++argv; | |
2050 } | |
2051 } | |
1376 | 2052 #endif |
2053 #ifdef FEAT_GUI_GTK | |
443 | 2054 else if (STRNICMP(argv[0] + argv_idx, "echo-wid", 8) == 0) |
2055 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2056 // already processed, skip |
443 | 2057 } |
2058 #endif | |
2059 else | |
2060 { | |
2061 if (argv[0][argv_idx]) | |
2062 mainerr(ME_UNKNOWN_OPTION, (char_u *)argv[0]); | |
2063 had_minmin = TRUE; | |
2064 } | |
2065 if (!want_argument) | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2066 argv_idx = -1; // skip to next argument |
443 | 2067 break; |
2068 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2069 case 'A': // "-A" start in Arabic mode |
443 | 2070 #ifdef FEAT_ARABIC |
2071 set_option_value((char_u *)"arabic", 1L, NULL, 0); | |
2072 #else | |
2073 mch_errmsg(_(e_noarabic)); | |
2074 mch_exit(2); | |
2075 #endif | |
2076 break; | |
2077 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2078 case 'b': // "-b" binary mode |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2079 // Needs to be effective before expanding file names, because |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2080 // for Win32 this makes us edit a shortcut file itself, |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2081 // instead of the file it links to. |
445 | 2082 set_options_bin(curbuf->b_p_bin, 1, 0); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2083 curbuf->b_p_bin = 1; // binary file I/O |
443 | 2084 break; |
2085 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2086 case 'C': // "-C" Compatible |
443 | 2087 change_compatible(TRUE); |
9678
8c9e13109df8
commit https://github.com/vim/vim/commit/b9a46fec3e79d1fc8c406084a41733c647a5e535
Christian Brabandt <cb@256bit.org>
parents:
9669
diff
changeset
|
2088 has_dash_c_arg = TRUE; |
443 | 2089 break; |
2090 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2091 case 'e': // "-e" Ex mode |
443 | 2092 exmode_active = EXMODE_NORMAL; |
2093 break; | |
2094 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2095 case 'E': // "-E" Improved Ex mode |
443 | 2096 exmode_active = EXMODE_VIM; |
2097 break; | |
2098 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2099 case 'f': // "-f" GUI: run in foreground. Amiga: open |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2100 // window directly, not with newcli |
443 | 2101 #ifdef FEAT_GUI |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2102 gui.dofork = FALSE; // don't fork() when starting GUI |
443 | 2103 #endif |
2104 break; | |
2105 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2106 case 'g': // "-g" start GUI |
443 | 2107 main_start_gui(); |
2108 break; | |
2109 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2110 case 'F': // "-F" was for Farsi mode |
443 | 2111 mch_errmsg(_(e_nofarsi)); |
2112 mch_exit(2); | |
2113 break; | |
2114 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2115 case '?': // "-?" give help message (for MS-Windows) |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2116 case 'h': // "-h" give help message |
443 | 2117 #ifdef FEAT_GUI_GNOME |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2118 // Tell usage() to exit for "gvim". |
443 | 2119 gui.starting = FALSE; |
2120 #endif | |
2121 usage(); | |
2122 break; | |
2123 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2124 case 'H': // "-H" start in Hebrew mode: rl + hkmap set |
443 | 2125 #ifdef FEAT_RIGHTLEFT |
1509 | 2126 p_hkmap = TRUE; |
2127 set_option_value((char_u *)"rl", 1L, NULL, 0); | |
443 | 2128 #else |
2129 mch_errmsg(_(e_nohebrew)); | |
2130 mch_exit(2); | |
2131 #endif | |
2132 break; | |
2133 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2134 case 'l': // "-l" lisp mode, 'lisp' and 'showmatch' on |
443 | 2135 #ifdef FEAT_LISP |
2136 set_option_value((char_u *)"lisp", 1L, NULL, 0); | |
2137 p_sm = TRUE; | |
2138 #endif | |
2139 break; | |
2140 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2141 case 'M': // "-M" no changes or writing of files |
443 | 2142 reset_modifiable(); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2143 // FALLTHROUGH |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2144 |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2145 case 'm': // "-m" no writing of files |
443 | 2146 p_write = FALSE; |
2147 break; | |
2148 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2149 case 'y': // "-y" easy mode |
443 | 2150 #ifdef FEAT_GUI |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2151 gui.starting = TRUE; // start GUI a bit later |
443 | 2152 #endif |
2153 parmp->evim_mode = TRUE; | |
2154 break; | |
2155 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2156 case 'N': // "-N" Nocompatible |
443 | 2157 change_compatible(FALSE); |
2158 break; | |
2159 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2160 case 'n': // "-n" no swap file |
2209
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
2161 #ifdef FEAT_NETBEANS_INTG |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2162 // checking for "-nb", netbeans parameters |
2209
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
2163 if (argv[0][argv_idx] == 'b') |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
2164 { |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
2165 netbeansArg = argv[0]; |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2166 argv_idx = -1; // skip to next argument |
2209
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
2167 } |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
2168 else |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
2169 #endif |
443 | 2170 parmp->no_swap_file = TRUE; |
2171 break; | |
2172 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2173 case 'p': // "-p[N]" open N tab pages |
674 | 2174 #ifdef TARGET_API_MAC_OSX |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2175 // For some reason on MacOS X, an argument like: |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2176 // -psn_0_10223617 is passed in when invoke from Finder |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2177 // or with the 'open' command |
674 | 2178 if (argv[0][argv_idx] == 's') |
2179 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2180 argv_idx = -1; // bypass full -psn |
674 | 2181 main_start_gui(); |
2182 break; | |
2183 } | |
2184 #endif | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2185 // default is 0: open window for each file |
673 | 2186 parmp->window_count = get_number_arg((char_u *)argv[0], |
2187 &argv_idx, 0); | |
2188 parmp->window_layout = WIN_TABS; | |
2189 break; | |
2190 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2191 case 'o': // "-o[N]" open N horizontal split windows |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2192 // default is 0: open window for each file |
445 | 2193 parmp->window_count = get_number_arg((char_u *)argv[0], |
2194 &argv_idx, 0); | |
673 | 2195 parmp->window_layout = WIN_HOR; |
443 | 2196 break; |
2197 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2198 case 'O': // "-O[N]" open N vertical split windows |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2199 // default is 0: open window for each file |
445 | 2200 parmp->window_count = get_number_arg((char_u *)argv[0], |
2201 &argv_idx, 0); | |
673 | 2202 parmp->window_layout = WIN_VER; |
443 | 2203 break; |
2204 | |
2205 #ifdef FEAT_QUICKFIX | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2206 case 'q': // "-q" QuickFix mode |
443 | 2207 if (parmp->edit_type != EDIT_NONE) |
2208 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); | |
2209 parmp->edit_type = EDIT_QF; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2210 if (argv[0][argv_idx]) // "-q{errorfile}" |
443 | 2211 { |
2212 parmp->use_ef = (char_u *)argv[0] + argv_idx; | |
2213 argv_idx = -1; | |
2214 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2215 else if (argc > 1) // "-q {errorfile}" |
443 | 2216 want_argument = TRUE; |
2217 break; | |
2218 #endif | |
2219 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2220 case 'R': // "-R" readonly mode |
443 | 2221 readonlymode = TRUE; |
2222 curbuf->b_p_ro = TRUE; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2223 p_uc = 10000; // don't update very often |
443 | 2224 break; |
2225 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2226 case 'r': // "-r" recovery mode |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2227 case 'L': // "-L" recovery mode |
443 | 2228 recoverymode = 1; |
2229 break; | |
2230 | |
2231 case 's': | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2232 if (exmode_active) // "-s" silent (batch) mode |
443 | 2233 silent_mode = TRUE; |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2234 else // "-s {scriptin}" read from script file |
443 | 2235 want_argument = TRUE; |
2236 break; | |
2237 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2238 case 't': // "-t {tag}" or "-t{tag}" jump to tag |
443 | 2239 if (parmp->edit_type != EDIT_NONE) |
2240 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); | |
2241 parmp->edit_type = EDIT_TAG; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2242 if (argv[0][argv_idx]) // "-t{tag}" |
443 | 2243 { |
2244 parmp->tagname = (char_u *)argv[0] + argv_idx; | |
2245 argv_idx = -1; | |
2246 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2247 else // "-t {tag}" |
443 | 2248 want_argument = TRUE; |
2249 break; | |
2250 | |
2251 #ifdef FEAT_EVAL | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2252 case 'D': // "-D" Debugging |
443 | 2253 parmp->use_debug_break_level = 9999; |
2254 break; | |
2255 #endif | |
2256 #ifdef FEAT_DIFF | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2257 case 'd': // "-d" 'diff' |
443 | 2258 # ifdef AMIGA |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2259 // check for "-dev {device}" |
443 | 2260 if (argv[0][argv_idx] == 'e' && argv[0][argv_idx + 1] == 'v') |
2261 want_argument = TRUE; | |
2262 else | |
2263 # endif | |
2264 parmp->diff_mode = TRUE; | |
2265 break; | |
2266 #endif | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2267 case 'V': // "-V{N}" Verbose level |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2268 // default is 10: a little bit verbose |
443 | 2269 p_verbose = get_number_arg((char_u *)argv[0], &argv_idx, 10); |
2270 if (argv[0][argv_idx] != NUL) | |
2271 { | |
2272 set_option_value((char_u *)"verbosefile", 0L, | |
2273 (char_u *)argv[0] + argv_idx, 0); | |
835 | 2274 argv_idx = (int)STRLEN(argv[0]); |
443 | 2275 } |
2276 break; | |
2277 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2278 case 'v': // "-v" Vi-mode (as if called "vi") |
443 | 2279 exmode_active = 0; |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
2280 #if defined(FEAT_GUI) && !defined(VIMDLL) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2281 gui.starting = FALSE; // don't start GUI |
443 | 2282 #endif |
2283 break; | |
2284 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2285 case 'w': // "-w{number}" set window height |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2286 // "-w {scriptout}" write to script |
443 | 2287 if (vim_isdigit(((char_u *)argv[0])[argv_idx])) |
2288 { | |
2289 n = get_number_arg((char_u *)argv[0], &argv_idx, 10); | |
2290 set_option_value((char_u *)"window", n, NULL, 0); | |
2291 break; | |
2292 } | |
2293 want_argument = TRUE; | |
2294 break; | |
2295 | |
2296 #ifdef FEAT_CRYPT | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2297 case 'x': // "-x" encrypted reading/writing of files |
443 | 2298 parmp->ask_for_key = TRUE; |
2299 break; | |
2300 #endif | |
2301 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2302 case 'X': // "-X" don't connect to X server |
443 | 2303 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_X11) |
2304 x_no_connect = TRUE; | |
2305 #endif | |
2306 break; | |
2307 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2308 case 'Z': // "-Z" restricted mode |
443 | 2309 restricted = TRUE; |
2310 break; | |
2311 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2312 case 'c': // "-c{command}" or "-c {command}" execute |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2313 // command |
443 | 2314 if (argv[0][argv_idx] != NUL) |
2315 { | |
2316 if (parmp->n_commands >= MAX_ARG_CMDS) | |
2317 mainerr(ME_EXTRA_CMD, NULL); | |
445 | 2318 parmp->commands[parmp->n_commands++] = (char_u *)argv[0] |
2319 + argv_idx; | |
443 | 2320 argv_idx = -1; |
2321 break; | |
2322 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2323 // FALLTHROUGH |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2324 case 'S': // "-S {file}" execute Vim script |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2325 case 'i': // "-i {viminfo}" use for viminfo |
443 | 2326 #ifndef FEAT_DIFF |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2327 case 'd': // "-d {device}" device (for Amiga) |
443 | 2328 #endif |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2329 case 'T': // "-T {terminal}" terminal name |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2330 case 'u': // "-u {vimrc}" vim inits file |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2331 case 'U': // "-U {gvimrc}" gvim inits file |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2332 case 'W': // "-W {scriptout}" overwrite |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2333 #ifdef FEAT_GUI_MSWIN |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2334 case 'P': // "-P {parent title}" MDI parent |
443 | 2335 #endif |
2336 want_argument = TRUE; | |
2337 break; | |
2338 | |
2339 default: | |
2340 mainerr(ME_UNKNOWN_OPTION, (char_u *)argv[0]); | |
2341 } | |
2342 | |
2343 /* | |
2344 * Handle option arguments with argument. | |
2345 */ | |
2346 if (want_argument) | |
2347 { | |
2348 /* | |
2349 * Check for garbage immediately after the option letter. | |
2350 */ | |
2351 if (argv[0][argv_idx] != NUL) | |
2352 mainerr(ME_GARBAGE, (char_u *)argv[0]); | |
2353 | |
2354 --argc; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2355 if (argc < 1 && c != 'S') // -S has an optional argument |
443 | 2356 mainerr_arg_missing((char_u *)argv[0]); |
2357 ++argv; | |
2358 argv_idx = -1; | |
2359 | |
2360 switch (c) | |
2361 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2362 case 'c': // "-c {command}" execute command |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2363 case 'S': // "-S {file}" execute Vim script |
443 | 2364 if (parmp->n_commands >= MAX_ARG_CMDS) |
2365 mainerr(ME_EXTRA_CMD, NULL); | |
2366 if (c == 'S') | |
2367 { | |
2368 char *a; | |
2369 | |
2370 if (argc < 1) | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2371 // "-S" without argument: use default session file |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2372 // name. |
443 | 2373 a = SESSION_FILE; |
2374 else if (argv[0][0] == '-') | |
2375 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2376 // "-S" followed by another option: use default |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2377 // session file name. |
443 | 2378 a = SESSION_FILE; |
2379 ++argc; | |
2380 --argv; | |
2381 } | |
2382 else | |
2383 a = argv[0]; | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
2384 p = alloc(STRLEN(a) + 4); |
443 | 2385 if (p == NULL) |
2386 mch_exit(2); | |
2387 sprintf((char *)p, "so %s", a); | |
2388 parmp->cmds_tofree[parmp->n_commands] = TRUE; | |
2389 parmp->commands[parmp->n_commands++] = p; | |
2390 } | |
2391 else | |
445 | 2392 parmp->commands[parmp->n_commands++] = |
2393 (char_u *)argv[0]; | |
443 | 2394 break; |
2395 | |
1989 | 2396 case '-': |
2397 if (argv[-1][2] == 'c') | |
2398 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2399 // "--cmd {command}" execute command |
1989 | 2400 if (parmp->n_pre_commands >= MAX_ARG_CMDS) |
2401 mainerr(ME_EXTRA_CMD, NULL); | |
2402 parmp->pre_commands[parmp->n_pre_commands++] = | |
445 | 2403 (char_u *)argv[0]; |
1989 | 2404 } |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2405 // "--startuptime <file>" already handled |
443 | 2406 break; |
2407 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2408 // case 'd': -d {device} is handled in mch_check_win() for the |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2409 // Amiga |
443 | 2410 |
2411 #ifdef FEAT_QUICKFIX | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2412 case 'q': // "-q {errorfile}" QuickFix mode |
443 | 2413 parmp->use_ef = (char_u *)argv[0]; |
2414 break; | |
2415 #endif | |
2416 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2417 case 'i': // "-i {viminfo}" use for viminfo |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
2418 set_option_value((char_u *)"vif", 0L, (char_u *)argv[0], 0); |
443 | 2419 break; |
2420 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2421 case 's': // "-s {scriptin}" read from script file |
443 | 2422 if (scriptin[0] != NULL) |
2423 { | |
2424 scripterror: | |
2425 mch_errmsg(_("Attempt to open script file again: \"")); | |
2426 mch_errmsg(argv[-1]); | |
2427 mch_errmsg(" "); | |
2428 mch_errmsg(argv[0]); | |
2429 mch_errmsg("\"\n"); | |
2430 mch_exit(2); | |
2431 } | |
2432 if ((scriptin[0] = mch_fopen(argv[0], READBIN)) == NULL) | |
2433 { | |
2434 mch_errmsg(_("Cannot open for reading: \"")); | |
2435 mch_errmsg(argv[0]); | |
2436 mch_errmsg("\"\n"); | |
2437 mch_exit(2); | |
2438 } | |
2439 if (save_typebuf() == FAIL) | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2440 mch_exit(2); // out of memory |
443 | 2441 break; |
2442 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2443 case 't': // "-t {tag}" |
443 | 2444 parmp->tagname = (char_u *)argv[0]; |
2445 break; | |
2446 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2447 case 'T': // "-T {terminal}" terminal name |
443 | 2448 /* |
2449 * The -T term argument is always available and when | |
2450 * HAVE_TERMLIB is supported it overrides the environment | |
2451 * variable TERM. | |
2452 */ | |
2453 #ifdef FEAT_GUI | |
2454 if (term_is_gui((char_u *)argv[0])) | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2455 gui.starting = TRUE; // start GUI a bit later |
443 | 2456 else |
2457 #endif | |
2458 parmp->term = (char_u *)argv[0]; | |
2459 break; | |
2460 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2461 case 'u': // "-u {vimrc}" vim inits file |
443 | 2462 parmp->use_vimrc = (char_u *)argv[0]; |
2463 break; | |
2464 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2465 case 'U': // "-U {gvimrc}" gvim inits file |
443 | 2466 #ifdef FEAT_GUI |
2467 use_gvimrc = (char_u *)argv[0]; | |
2468 #endif | |
2469 break; | |
2470 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2471 case 'w': // "-w {nr}" 'window' value |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2472 // "-w {scriptout}" append to script file |
443 | 2473 if (vim_isdigit(*((char_u *)argv[0]))) |
2474 { | |
2475 argv_idx = 0; | |
2476 n = get_number_arg((char_u *)argv[0], &argv_idx, 10); | |
2477 set_option_value((char_u *)"window", n, NULL, 0); | |
2478 argv_idx = -1; | |
2479 break; | |
2480 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2481 // FALLTHROUGH |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2482 case 'W': // "-W {scriptout}" overwrite script file |
443 | 2483 if (scriptout != NULL) |
2484 goto scripterror; | |
2485 if ((scriptout = mch_fopen(argv[0], | |
2486 c == 'w' ? APPENDBIN : WRITEBIN)) == NULL) | |
2487 { | |
2488 mch_errmsg(_("Cannot open for script output: \"")); | |
2489 mch_errmsg(argv[0]); | |
2490 mch_errmsg("\"\n"); | |
2491 mch_exit(2); | |
2492 } | |
2493 break; | |
2494 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2495 #ifdef FEAT_GUI_MSWIN |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2496 case 'P': // "-P {parent title}" MDI parent |
443 | 2497 gui_mch_set_parent(argv[0]); |
2498 break; | |
2499 #endif | |
2500 } | |
2501 } | |
2502 } | |
2503 | |
2504 /* | |
2505 * File name argument. | |
2506 */ | |
2507 else | |
2508 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2509 argv_idx = -1; // skip to next argument |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2510 |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2511 // Check for only one type of editing. |
443 | 2512 if (parmp->edit_type != EDIT_NONE && parmp->edit_type != EDIT_FILE) |
2513 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); | |
2514 parmp->edit_type = EDIT_FILE; | |
2515 | |
2516 #ifdef MSWIN | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2517 // Remember if the argument was a full path before changing |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2518 // slashes to backslashes. |
443 | 2519 if (argv[0][0] != NUL && argv[0][1] == ':' && argv[0][2] == '\\') |
2520 parmp->full_path = TRUE; | |
2521 #endif | |
2522 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2523 // Add the file to the global argument list. |
443 | 2524 if (ga_grow(&global_alist.al_ga, 1) == FAIL |
2525 || (p = vim_strsave((char_u *)argv[0])) == NULL) | |
2526 mch_exit(2); | |
2527 #ifdef FEAT_DIFF | |
2528 if (parmp->diff_mode && mch_isdir(p) && GARGCOUNT > 0 | |
2529 && !mch_isdir(alist_name(&GARGLIST[0]))) | |
2530 { | |
2531 char_u *r; | |
2532 | |
2533 r = concat_fnames(p, gettail(alist_name(&GARGLIST[0])), TRUE); | |
2534 if (r != NULL) | |
2535 { | |
2536 vim_free(p); | |
2537 p = r; | |
2538 } | |
2539 } | |
2540 #endif | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2541 #if defined(__CYGWIN32__) && !defined(MSWIN) |
443 | 2542 /* |
2543 * If vim is invoked by non-Cygwin tools, convert away any | |
2544 * DOS paths, so things like .swp files are created correctly. | |
2545 * Look for evidence of non-Cygwin paths before we bother. | |
2546 * This is only for when using the Unix files. | |
2547 */ | |
5037
5e0b6a9282df
updated for version 7.3.1262
Bram Moolenaar <bram@vim.org>
parents:
4912
diff
changeset
|
2548 if (vim_strpbrk(p, "\\:") != NULL && !path_with_url(p)) |
443 | 2549 { |
12132
9e5f310b0713
patch 8.0.0946: using PATH_MAX does not work well on some systems
Christian Brabandt <cb@256bit.org>
parents:
11993
diff
changeset
|
2550 char posix_path[MAXPATHL]; |
443 | 2551 |
1657 | 2552 # if CYGWIN_VERSION_DLL_MAJOR >= 1007 |
12132
9e5f310b0713
patch 8.0.0946: using PATH_MAX does not work well on some systems
Christian Brabandt <cb@256bit.org>
parents:
11993
diff
changeset
|
2553 cygwin_conv_path(CCP_WIN_A_TO_POSIX, p, posix_path, MAXPATHL); |
1657 | 2554 # else |
443 | 2555 cygwin_conv_to_posix_path(p, posix_path); |
1657 | 2556 # endif |
443 | 2557 vim_free(p); |
5037
5e0b6a9282df
updated for version 7.3.1262
Bram Moolenaar <bram@vim.org>
parents:
4912
diff
changeset
|
2558 p = vim_strsave((char_u *)posix_path); |
443 | 2559 if (p == NULL) |
2560 mch_exit(2); | |
2561 } | |
2562 #endif | |
587 | 2563 |
2564 #ifdef USE_FNAME_CASE | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2565 // Make the case of the file name match the actual file. |
587 | 2566 fname_case(p, 0); |
2567 #endif | |
2568 | |
443 | 2569 alist_add(&global_alist, p, |
7410
08e62c4fc17d
commit https://github.com/vim/vim/commit/53076830fea6df737455523f7e235bfe4f79864d
Christian Brabandt <cb@256bit.org>
parents:
6923
diff
changeset
|
2570 #ifdef EXPAND_FILENAMES |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2571 parmp->literal ? 2 : 0 // add buffer nr after exp. |
443 | 2572 #else |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2573 2 // add buffer number now and use curbuf |
443 | 2574 #endif |
2575 ); | |
2576 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2577 #ifdef MSWIN |
443 | 2578 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2579 // Remember this argument has been added to the argument list. |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2580 // Needed when 'encoding' is changed. |
819 | 2581 used_file_arg(argv[0], parmp->literal, parmp->full_path, |
1680 | 2582 # ifdef FEAT_DIFF |
2583 parmp->diff_mode | |
2584 # else | |
2585 FALSE | |
2586 # endif | |
2587 ); | |
443 | 2588 } |
2589 #endif | |
2590 } | |
2591 | |
2592 /* | |
2593 * If there are no more letters after the current "-", go to next | |
2594 * argument. argv_idx is set to -1 when the current argument is to be | |
2595 * skipped. | |
2596 */ | |
2597 if (argv_idx <= 0 || argv[0][argv_idx] == NUL) | |
2598 { | |
2599 --argc; | |
2600 ++argv; | |
2601 argv_idx = 1; | |
2602 } | |
2603 } | |
1093 | 2604 |
2605 #ifdef FEAT_EVAL | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2606 // If there is a "+123" or "-c" command, set v:swapcommand to the first |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2607 // one. |
1093 | 2608 if (parmp->n_commands > 0) |
2609 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
2610 p = alloc(STRLEN(parmp->commands[0]) + 3); |
1093 | 2611 if (p != NULL) |
2612 { | |
2613 sprintf((char *)p, ":%s\r", parmp->commands[0]); | |
2614 set_vim_var_string(VV_SWAPCOMMAND, p, -1); | |
2615 vim_free(p); | |
2616 } | |
2617 } | |
2618 #endif | |
443 | 2619 } |
2620 | |
2621 /* | |
2622 * Print a warning if stdout is not a terminal. | |
13160
cb99d9198c39
patch 8.0.1454: when in silent mode too much output is buffered
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
2623 * When starting in Ex mode and commands come from a file, set silent_mode. |
443 | 2624 */ |
2625 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2626 check_tty(mparm_T *parmp) |
443 | 2627 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2628 int input_isatty; // is active input a terminal? |
443 | 2629 |
2630 input_isatty = mch_input_isatty(); | |
2631 if (exmode_active) | |
2632 { | |
2633 if (!input_isatty) | |
2634 silent_mode = TRUE; | |
2635 } | |
10404
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2636 else if (parmp->want_full_screen && (!stdout_isatty || !input_isatty) |
443 | 2637 #ifdef FEAT_GUI |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2638 // don't want the delay when started from the desktop |
443 | 2639 && !gui.starting |
2640 #endif | |
8253
1b6a589a0efc
commit https://github.com/vim/vim/commit/49c39ff678e2ba9f7dc280b25368e12084a610cf
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
2641 && !parmp->not_a_term) |
443 | 2642 { |
2643 #ifdef NBDEBUG | |
2644 /* | |
2645 * This shouldn't be necessary. But if I run netbeans with the log | |
2646 * output coming to the console and XOpenDisplay fails, I get vim | |
2647 * trying to start with input/output to my console tty. This fills my | |
2648 * input buffer so fast I can't even kill the process in under 2 | |
1226 | 2649 * minutes (and it beeps continuously the whole time :-) |
443 | 2650 */ |
10404
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2651 if (netbeans_active() && (!stdout_isatty || !input_isatty)) |
443 | 2652 { |
2653 mch_errmsg(_("Vim: Error: Failure to start gvim from NetBeans\n")); | |
2654 exit(1); | |
2655 } | |
2656 #endif | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
2657 #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
2658 if ( |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
2659 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
2660 !gui.starting && |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
2661 # endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
2662 is_cygpty_used()) |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
9252
diff
changeset
|
2663 { |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15551
diff
changeset
|
2664 # if defined(HAVE_BIND_TEXTDOMAIN_CODESET) \ |
12547
aa3f6d093f4b
patch 8.0.1152: encoding of error message wrong in Cygwin terminal
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2665 && defined(FEAT_GETTEXT) |
aa3f6d093f4b
patch 8.0.1152: encoding of error message wrong in Cygwin terminal
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2666 char *s, *tofree = NULL; |
aa3f6d093f4b
patch 8.0.1152: encoding of error message wrong in Cygwin terminal
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2667 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2668 // Set the encoding of the error message based on $LC_ALL or |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2669 // other environment variables instead of 'encoding'. |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2670 // Note that the message is shown on a Cygwin terminal (e.g. |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2671 // mintty) which encoding is based on $LC_ALL or etc., not the |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2672 // current codepage used by normal Win32 console programs. |
12557
a75fea44fb77
patch 8.0.1157: compiler warning on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12547
diff
changeset
|
2673 tofree = s = (char *)enc_locale_env(NULL); |
12547
aa3f6d093f4b
patch 8.0.1152: encoding of error message wrong in Cygwin terminal
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2674 if (s == NULL) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2675 s = "utf-8"; // Use "utf-8" by default. |
12547
aa3f6d093f4b
patch 8.0.1152: encoding of error message wrong in Cygwin terminal
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2676 (void)bind_textdomain_codeset(VIMPACKAGE, s); |
aa3f6d093f4b
patch 8.0.1152: encoding of error message wrong in Cygwin terminal
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2677 vim_free(tofree); |
aa3f6d093f4b
patch 8.0.1152: encoding of error message wrong in Cygwin terminal
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2678 # endif |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
9252
diff
changeset
|
2679 mch_errmsg(_("Vim: Error: This version of Vim does not run in a Cygwin terminal\n")); |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
9252
diff
changeset
|
2680 exit(1); |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
9252
diff
changeset
|
2681 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
9252
diff
changeset
|
2682 #endif |
10404
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2683 if (!stdout_isatty) |
443 | 2684 mch_errmsg(_("Vim: Warning: Output is not to a terminal\n")); |
2685 if (!input_isatty) | |
2686 mch_errmsg(_("Vim: Warning: Input is not from a terminal\n")); | |
2687 out_flush(); | |
10404
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2688 if (parmp->tty_fail && (!stdout_isatty || !input_isatty)) |
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2689 exit(1); |
443 | 2690 if (scriptin[0] == NULL) |
18642
bbea1f108187
patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents:
18477
diff
changeset
|
2691 ui_delay(2005L, TRUE); |
443 | 2692 TIME_MSG("Warning delay"); |
2693 } | |
2694 } | |
2695 | |
2696 /* | |
2697 * Read text from stdin. | |
2698 */ | |
2699 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2700 read_stdin(void) |
443 | 2701 { |
2702 int i; | |
2703 | |
16453
4e9bea9b8025
patch 8.1.1231: asking about existing swap file unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2704 // When getting the ATTENTION prompt here, use a dialog |
443 | 2705 swap_exists_action = SEA_DIALOG; |
16453
4e9bea9b8025
patch 8.1.1231: asking about existing swap file unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2706 |
443 | 2707 no_wait_return = TRUE; |
2708 i = msg_didany; | |
2709 set_buflisted(TRUE); | |
22570
8af8aa57dd8a
patch 8.2.1833: when reading from stdin dup() is called twice
Bram Moolenaar <Bram@vim.org>
parents:
21745
diff
changeset
|
2710 |
8af8aa57dd8a
patch 8.2.1833: when reading from stdin dup() is called twice
Bram Moolenaar <Bram@vim.org>
parents:
21745
diff
changeset
|
2711 // Create memfile and read from stdin. |
8af8aa57dd8a
patch 8.2.1833: when reading from stdin dup() is called twice
Bram Moolenaar <Bram@vim.org>
parents:
21745
diff
changeset
|
2712 (void)open_buffer(TRUE, NULL, 0); |
8af8aa57dd8a
patch 8.2.1833: when reading from stdin dup() is called twice
Bram Moolenaar <Bram@vim.org>
parents:
21745
diff
changeset
|
2713 |
443 | 2714 no_wait_return = FALSE; |
2715 msg_didany = i; | |
2716 TIME_MSG("reading stdin"); | |
16453
4e9bea9b8025
patch 8.1.1231: asking about existing swap file unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2717 |
443 | 2718 check_swap_exists_action(); |
23128
448da19cb3d5
patch 8.2.2110: cannot use ":shell" when reading from stdin
Bram Moolenaar <Bram@vim.org>
parents:
23048
diff
changeset
|
2719 |
448da19cb3d5
patch 8.2.2110: cannot use ":shell" when reading from stdin
Bram Moolenaar <Bram@vim.org>
parents:
23048
diff
changeset
|
2720 #if !(defined(AMIGA) || defined(MACOS_X)) |
448da19cb3d5
patch 8.2.2110: cannot use ":shell" when reading from stdin
Bram Moolenaar <Bram@vim.org>
parents:
23048
diff
changeset
|
2721 // Dup stdin from stderr to read commands from, so that shell commands |
448da19cb3d5
patch 8.2.2110: cannot use ":shell" when reading from stdin
Bram Moolenaar <Bram@vim.org>
parents:
23048
diff
changeset
|
2722 // work. |
448da19cb3d5
patch 8.2.2110: cannot use ":shell" when reading from stdin
Bram Moolenaar <Bram@vim.org>
parents:
23048
diff
changeset
|
2723 // TODO: why is this needed, even though readfile() has done this? |
448da19cb3d5
patch 8.2.2110: cannot use ":shell" when reading from stdin
Bram Moolenaar <Bram@vim.org>
parents:
23048
diff
changeset
|
2724 close(0); |
448da19cb3d5
patch 8.2.2110: cannot use ":shell" when reading from stdin
Bram Moolenaar <Bram@vim.org>
parents:
23048
diff
changeset
|
2725 vim_ignored = dup(2); |
448da19cb3d5
patch 8.2.2110: cannot use ":shell" when reading from stdin
Bram Moolenaar <Bram@vim.org>
parents:
23048
diff
changeset
|
2726 #endif |
443 | 2727 } |
2728 | |
2729 /* | |
2730 * Create the requested number of windows and edit buffers in them. | |
2731 * Also does recovery if "recoverymode" set. | |
2732 */ | |
2733 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2734 create_windows(mparm_T *parmp UNUSED) |
443 | 2735 { |
944 | 2736 int dorewind; |
673 | 2737 int done = 0; |
2738 | |
443 | 2739 /* |
2740 * Create the number of windows that was requested. | |
2741 */ | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2742 if (parmp->window_count == -1) // was not set |
443 | 2743 parmp->window_count = 1; |
2744 if (parmp->window_count == 0) | |
2745 parmp->window_count = GARGCOUNT; | |
2746 if (parmp->window_count > 1) | |
2747 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2748 // Don't change the windows if there was a command in .vimrc that |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2749 // already split some windows |
673 | 2750 if (parmp->window_layout == 0) |
2751 parmp->window_layout = WIN_HOR; | |
2752 if (parmp->window_layout == WIN_TABS) | |
2753 { | |
2754 parmp->window_count = make_tabpages(parmp->window_count); | |
2755 TIME_MSG("making tab pages"); | |
2756 } | |
2757 else if (firstwin->w_next == NULL) | |
443 | 2758 { |
2759 parmp->window_count = make_windows(parmp->window_count, | |
673 | 2760 parmp->window_layout == WIN_VER); |
443 | 2761 TIME_MSG("making windows"); |
2762 } | |
2763 else | |
2764 parmp->window_count = win_count(); | |
2765 } | |
2766 else | |
2767 parmp->window_count = 1; | |
2768 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2769 if (recoverymode) // do recover |
443 | 2770 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2771 msg_scroll = TRUE; // scroll message up |
16738
b52ea9c5f1db
patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
2772 ml_recover(TRUE); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2773 if (curbuf->b_ml.ml_mfp == NULL) // failed |
443 | 2774 getout(1); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2775 do_modelines(0); // do modelines |
443 | 2776 } |
2777 else | |
2778 { | |
2779 /* | |
2780 * Open a buffer for windows that don't have one yet. | |
2781 * Commands in the .vimrc might have loaded a file or split the window. | |
2782 * Watch out for autocommands that delete a window. | |
2783 */ | |
2784 /* | |
2785 * Don't execute Win/Buf Enter/Leave autocommands here | |
2786 */ | |
2787 ++autocmd_no_enter; | |
2788 ++autocmd_no_leave; | |
944 | 2789 dorewind = TRUE; |
673 | 2790 while (done++ < 1000) |
2791 { | |
944 | 2792 if (dorewind) |
673 | 2793 { |
2794 if (parmp->window_layout == WIN_TABS) | |
2795 goto_tabpage(1); | |
2796 else | |
2797 curwin = firstwin; | |
2798 } | |
2799 else if (parmp->window_layout == WIN_TABS) | |
2800 { | |
2801 if (curtab->tp_next == NULL) | |
2802 break; | |
2803 goto_tabpage(0); | |
2804 } | |
2805 else | |
2806 { | |
2807 if (curwin->w_next == NULL) | |
2808 break; | |
2809 curwin = curwin->w_next; | |
2810 } | |
944 | 2811 dorewind = FALSE; |
443 | 2812 curbuf = curwin->w_buffer; |
2813 if (curbuf->b_ml.ml_mfp == NULL) | |
2814 { | |
2815 #ifdef FEAT_FOLDING | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2816 // Set 'foldlevel' to 'foldlevelstart' if it's not negative. |
443 | 2817 if (p_fdls >= 0) |
2818 curwin->w_p_fdl = p_fdls; | |
2819 #endif | |
16453
4e9bea9b8025
patch 8.1.1231: asking about existing swap file unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2820 // When getting the ATTENTION prompt here, use a dialog |
443 | 2821 swap_exists_action = SEA_DIALOG; |
16453
4e9bea9b8025
patch 8.1.1231: asking about existing swap file unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2822 |
443 | 2823 set_buflisted(TRUE); |
2394
a3aca345aafa
Add the 'undoreload' option to be able to undo a file reload.
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
2824 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2825 // create memfile, read file |
2394
a3aca345aafa
Add the 'undoreload' option to be able to undo a file reload.
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
2826 (void)open_buffer(FALSE, NULL, 0); |
443 | 2827 |
1036 | 2828 if (swap_exists_action == SEA_QUIT) |
2829 { | |
2830 if (got_int || only_one_window()) | |
2831 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2832 // abort selected or quit and only one window |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2833 did_emsg = FALSE; // avoid hit-enter prompt |
1036 | 2834 getout(1); |
2835 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2836 // We can't close the window, it would disturb what |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2837 // happens next. Clear the file name and set the arg |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2838 // index to -1 to delete it later. |
1036 | 2839 setfname(curbuf, NULL, NULL, FALSE); |
2840 curwin->w_arg_idx = -1; | |
2841 swap_exists_action = SEA_NONE; | |
2842 } | |
2843 else | |
2844 handle_swap_exists(NULL); | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2845 dorewind = TRUE; // start again |
443 | 2846 } |
2847 ui_breakcheck(); | |
2848 if (got_int) | |
2849 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2850 (void)vgetc(); // only break the file loading, not the rest |
443 | 2851 break; |
2852 } | |
673 | 2853 } |
2854 if (parmp->window_layout == WIN_TABS) | |
2855 goto_tabpage(1); | |
2856 else | |
2857 curwin = firstwin; | |
2858 curbuf = curwin->w_buffer; | |
443 | 2859 --autocmd_no_enter; |
2860 --autocmd_no_leave; | |
2861 } | |
2862 } | |
2863 | |
18872
410155e75efa
patch 8.1.2422: "make depend" does not work correctly for libvterm
Bram Moolenaar <Bram@vim.org>
parents:
18800
diff
changeset
|
2864 /* |
410155e75efa
patch 8.1.2422: "make depend" does not work correctly for libvterm
Bram Moolenaar <Bram@vim.org>
parents:
18800
diff
changeset
|
2865 * If opened more than one window, start editing files in the other |
410155e75efa
patch 8.1.2422: "make depend" does not work correctly for libvterm
Bram Moolenaar <Bram@vim.org>
parents:
18800
diff
changeset
|
2866 * windows. make_windows() has already opened the windows. |
410155e75efa
patch 8.1.2422: "make depend" does not work correctly for libvterm
Bram Moolenaar <Bram@vim.org>
parents:
18800
diff
changeset
|
2867 */ |
443 | 2868 static void |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2869 edit_buffers( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2870 mparm_T *parmp, |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2871 char_u *cwd) // current working dir |
443 | 2872 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2873 int arg_idx; // index in argument list |
443 | 2874 int i; |
1036 | 2875 int advance = TRUE; |
5308 | 2876 win_T *win; |
16385
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2877 char_u *p_shm_save = NULL; |
443 | 2878 |
2879 /* | |
2880 * Don't execute Win/Buf Enter/Leave autocommands here | |
2881 */ | |
2882 ++autocmd_no_enter; | |
2883 ++autocmd_no_leave; | |
1036 | 2884 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2885 // When w_arg_idx is -1 remove the window (see create_windows()). |
1036 | 2886 if (curwin->w_arg_idx == -1) |
2887 { | |
2888 win_close(curwin, TRUE); | |
2889 advance = FALSE; | |
2890 } | |
2891 | |
443 | 2892 arg_idx = 1; |
2893 for (i = 1; i < parmp->window_count; ++i) | |
2894 { | |
6731 | 2895 if (cwd != NULL) |
2896 mch_chdir((char *)cwd); | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2897 // When w_arg_idx is -1 remove the window (see create_windows()). |
1036 | 2898 if (curwin->w_arg_idx == -1) |
673 | 2899 { |
1036 | 2900 ++arg_idx; |
2901 win_close(curwin, TRUE); | |
2902 advance = FALSE; | |
2903 continue; | |
673 | 2904 } |
1036 | 2905 |
2906 if (advance) | |
673 | 2907 { |
1036 | 2908 if (parmp->window_layout == WIN_TABS) |
2909 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2910 if (curtab->tp_next == NULL) // just checking |
1036 | 2911 break; |
2912 goto_tabpage(0); | |
16385
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2913 // Temporarily reset 'shm' option to not print fileinfo when |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2914 // loading the other buffers. This would overwrite the already |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2915 // existing fileinfo for the first tab. |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2916 if (i == 1) |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2917 { |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2918 char buf[100]; |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2919 |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2920 p_shm_save = vim_strsave(p_shm); |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2921 vim_snprintf(buf, 100, "F%s", p_shm); |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2922 set_option_value((char_u *)"shm", 0L, (char_u *)buf, 0); |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2923 } |
1036 | 2924 } |
2925 else | |
2926 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2927 if (curwin->w_next == NULL) // just checking |
1036 | 2928 break; |
2929 win_enter(curwin->w_next, FALSE); | |
2930 } | |
673 | 2931 } |
1036 | 2932 advance = TRUE; |
443 | 2933 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2934 // Only open the file if there is no file in this window yet (that can |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2935 // happen when .vimrc contains ":sall"). |
443 | 2936 if (curbuf == firstwin->w_buffer || curbuf->b_ffname == NULL) |
2937 { | |
2938 curwin->w_arg_idx = arg_idx; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2939 // Edit file from arg list, if there is one. When "Quit" selected |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2940 // at the ATTENTION prompt close the window. |
1684 | 2941 swap_exists_did_quit = FALSE; |
443 | 2942 (void)do_ecmd(0, arg_idx < GARGCOUNT |
2943 ? alist_name(&GARGLIST[arg_idx]) : NULL, | |
1743 | 2944 NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin); |
1684 | 2945 if (swap_exists_did_quit) |
1036 | 2946 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2947 // abort or quit selected |
1036 | 2948 if (got_int || only_one_window()) |
2949 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2950 // abort selected and only one window |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2951 did_emsg = FALSE; // avoid hit-enter prompt |
1036 | 2952 getout(1); |
2953 } | |
2954 win_close(curwin, TRUE); | |
2955 advance = FALSE; | |
2956 } | |
443 | 2957 if (arg_idx == GARGCOUNT - 1) |
2958 arg_had_last = TRUE; | |
2959 ++arg_idx; | |
2960 } | |
2961 ui_breakcheck(); | |
2962 if (got_int) | |
2963 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2964 (void)vgetc(); // only break the file loading, not the rest |
443 | 2965 break; |
2966 } | |
2967 } | |
673 | 2968 |
16385
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2969 if (p_shm_save != NULL) |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2970 { |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2971 set_option_value((char_u *)"shm", 0L, p_shm_save, 0); |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2972 vim_free(p_shm_save); |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2973 } |
bb0f7cb7e2d5
patch 8.1.1197: when starting with multiple tabs file messages is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16223
diff
changeset
|
2974 |
673 | 2975 if (parmp->window_layout == WIN_TABS) |
2976 goto_tabpage(1); | |
443 | 2977 --autocmd_no_enter; |
5308 | 2978 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2979 // make the first window the current window |
5308 | 2980 win = firstwin; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
2981 #if defined(FEAT_QUICKFIX) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2982 // Avoid making a preview window the current window. |
5308 | 2983 while (win->w_p_pvw) |
4912
d8f65e6238fa
updated for version 7.3.1201
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2984 { |
5308 | 2985 win = win->w_next; |
2986 if (win == NULL) | |
2987 { | |
2988 win = firstwin; | |
2989 break; | |
2990 } | |
4912
d8f65e6238fa
updated for version 7.3.1201
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2991 } |
d8f65e6238fa
updated for version 7.3.1201
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2992 #endif |
5308 | 2993 win_enter(win, FALSE); |
4912
d8f65e6238fa
updated for version 7.3.1201
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2994 |
443 | 2995 --autocmd_no_leave; |
2996 TIME_MSG("editing files in windows"); | |
673 | 2997 if (parmp->window_count > 1 && parmp->window_layout != WIN_TABS) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2998 win_equal(curwin, FALSE, 'b'); // adjust heights |
443 | 2999 } |
3000 | |
3001 /* | |
440 | 3002 * Execute the commands from --cmd arguments "cmds[cnt]". |
3003 */ | |
3004 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3005 exe_pre_commands(mparm_T *parmp) |
440 | 3006 { |
443 | 3007 char_u **cmds = parmp->pre_commands; |
3008 int cnt = parmp->n_pre_commands; | |
440 | 3009 int i; |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
3010 ESTACK_CHECK_DECLARATION |
440 | 3011 |
3012 if (cnt > 0) | |
3013 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3014 curwin->w_cursor.lnum = 0; // just in case.. |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
3015 estack_push(ETYPE_ARGS, (char_u *)_("pre-vimrc command line"), 0); |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
3016 ESTACK_CHECK_SETUP |
440 | 3017 # 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:
14481
diff
changeset
|
3018 current_sctx.sc_sid = SID_CMDARG; |
440 | 3019 # endif |
3020 for (i = 0; i < cnt; ++i) | |
3021 do_cmdline_cmd(cmds[i]); | |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
3022 ESTACK_CHECK_NOW |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
3023 estack_pop(); |
440 | 3024 # 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:
14481
diff
changeset
|
3025 current_sctx.sc_sid = 0; |
440 | 3026 # endif |
3027 TIME_MSG("--cmd commands"); | |
3028 } | |
3029 } | |
3030 | |
3031 /* | |
443 | 3032 * Execute "+", "-c" and "-S" arguments. |
3033 */ | |
3034 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3035 exe_commands(mparm_T *parmp) |
443 | 3036 { |
3037 int i; | |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
3038 ESTACK_CHECK_DECLARATION |
443 | 3039 |
3040 /* | |
3041 * We start commands on line 0, make "vim +/pat file" match a | |
3042 * pattern on line 1. But don't move the cursor when an autocommand | |
3043 * with g`" was used. | |
3044 */ | |
3045 msg_scroll = TRUE; | |
3046 if (parmp->tagname == NULL && curwin->w_cursor.lnum <= 1) | |
3047 curwin->w_cursor.lnum = 0; | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
3048 estack_push(ETYPE_ARGS, (char_u *)"command line", 0); |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
3049 ESTACK_CHECK_SETUP |
443 | 3050 #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:
14481
diff
changeset
|
3051 current_sctx.sc_sid = SID_CARG; |
15008
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
14927
diff
changeset
|
3052 current_sctx.sc_seq = 0; |
443 | 3053 #endif |
3054 for (i = 0; i < parmp->n_commands; ++i) | |
3055 { | |
3056 do_cmdline_cmd(parmp->commands[i]); | |
3057 if (parmp->cmds_tofree[i]) | |
3058 vim_free(parmp->commands[i]); | |
3059 } | |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
3060 ESTACK_CHECK_NOW |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
3061 estack_pop(); |
443 | 3062 #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:
14481
diff
changeset
|
3063 current_sctx.sc_sid = 0; |
443 | 3064 #endif |
3065 if (curwin->w_cursor.lnum == 0) | |
3066 curwin->w_cursor.lnum = 1; | |
3067 | |
3068 if (!exmode_active) | |
3069 msg_scroll = FALSE; | |
3070 | |
3071 #ifdef FEAT_QUICKFIX | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3072 // When started with "-q errorfile" jump to first error again. |
443 | 3073 if (parmp->edit_type == EDIT_QF) |
644 | 3074 qf_jump(NULL, 0, 0, FALSE); |
443 | 3075 #endif |
3076 TIME_MSG("executing command arguments"); | |
3077 } | |
3078 | |
3079 /* | |
440 | 3080 * Source startup scripts. |
3081 */ | |
3082 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3083 source_startup_scripts(mparm_T *parmp) |
440 | 3084 { |
3085 int i; | |
3086 | |
3087 /* | |
3088 * For "evim" source evim.vim first of all, so that the user can overrule | |
3089 * any things he doesn't like. | |
3090 */ | |
3091 if (parmp->evim_mode) | |
3092 { | |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3093 (void)do_source((char_u *)EVIM_FILE, FALSE, DOSO_NONE, NULL); |
440 | 3094 TIME_MSG("source evim file"); |
3095 } | |
3096 | |
3097 /* | |
443 | 3098 * If -u argument given, use only the initializations from that file and |
440 | 3099 * nothing else. |
3100 */ | |
3101 if (parmp->use_vimrc != NULL) | |
3102 { | |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
3103 if (STRCMP(parmp->use_vimrc, "DEFAULTS") == 0) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3104 do_source((char_u *)VIM_DEFAULTS_FILE, FALSE, DOSO_NONE, NULL); |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
3105 else if (STRCMP(parmp->use_vimrc, "NONE") == 0 |
445 | 3106 || STRCMP(parmp->use_vimrc, "NORC") == 0) |
440 | 3107 { |
3108 #ifdef FEAT_GUI | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3109 if (use_gvimrc == NULL) // don't load gvimrc either |
440 | 3110 use_gvimrc = parmp->use_vimrc; |
3111 #endif | |
3112 } | |
3113 else | |
3114 { | |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3115 if (do_source(parmp->use_vimrc, FALSE, DOSO_NONE, NULL) != OK) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
3116 semsg(_("E282: Cannot read from \"%s\""), parmp->use_vimrc); |
440 | 3117 } |
3118 } | |
3119 else if (!silent_mode) | |
3120 { | |
3121 #ifdef AMIGA | |
3122 struct Process *proc = (struct Process *)FindTask(0L); | |
3123 APTR save_winptr = proc->pr_WindowPtr; | |
3124 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3125 // Avoid a requester here for a volume that doesn't exist. |
440 | 3126 proc->pr_WindowPtr = (APTR)-1L; |
3127 #endif | |
3128 | |
3129 /* | |
3130 * Get system wide defaults, if the file name is defined. | |
3131 */ | |
3132 #ifdef SYS_VIMRC_FILE | |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3133 (void)do_source((char_u *)SYS_VIMRC_FILE, FALSE, DOSO_NONE, NULL); |
440 | 3134 #endif |
720 | 3135 #ifdef MACOS_X |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3136 (void)do_source((char_u *)"$VIMRUNTIME/macmap.vim", FALSE, |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3137 DOSO_NONE, NULL); |
720 | 3138 #endif |
440 | 3139 |
3140 /* | |
3141 * Try to read initialization commands from the following places: | |
3142 * - environment variable VIMINIT | |
3143 * - user vimrc file (s:.vimrc for Amiga, ~/.vimrc otherwise) | |
3144 * - second user vimrc file ($VIM/.vimrc for Dos) | |
3145 * - environment variable EXINIT | |
3146 * - user exrc file (s:.exrc for Amiga, ~/.exrc otherwise) | |
3147 * - second user exrc file ($VIM/.exrc for Dos) | |
3148 * The first that exists is used, the rest is ignored. | |
3149 */ | |
3150 if (process_env((char_u *)"VIMINIT", TRUE) != OK) | |
3151 { | |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3152 if (do_source((char_u *)USR_VIMRC_FILE, TRUE, |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3153 DOSO_VIMRC, NULL) == FAIL |
440 | 3154 #ifdef USR_VIMRC_FILE2 |
819 | 3155 && do_source((char_u *)USR_VIMRC_FILE2, TRUE, |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3156 DOSO_VIMRC, NULL) == FAIL |
440 | 3157 #endif |
3158 #ifdef USR_VIMRC_FILE3 | |
819 | 3159 && do_source((char_u *)USR_VIMRC_FILE3, TRUE, |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3160 DOSO_VIMRC, NULL) == FAIL |
440 | 3161 #endif |
4863
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4369
diff
changeset
|
3162 #ifdef USR_VIMRC_FILE4 |
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4369
diff
changeset
|
3163 && do_source((char_u *)USR_VIMRC_FILE4, TRUE, |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3164 DOSO_VIMRC, NULL) == FAIL |
4863
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4369
diff
changeset
|
3165 #endif |
440 | 3166 && process_env((char_u *)"EXINIT", FALSE) == FAIL |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3167 && do_source((char_u *)USR_EXRC_FILE, FALSE, |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3168 DOSO_NONE, NULL) == FAIL |
440 | 3169 #ifdef USR_EXRC_FILE2 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3170 && do_source((char_u *)USR_EXRC_FILE2, FALSE, |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3171 DOSO_NONE, NULL) == FAIL |
440 | 3172 #endif |
9678
8c9e13109df8
commit https://github.com/vim/vim/commit/b9a46fec3e79d1fc8c406084a41733c647a5e535
Christian Brabandt <cb@256bit.org>
parents:
9669
diff
changeset
|
3173 && !has_dash_c_arg) |
9669
284b4eb307fc
commit https://github.com/vim/vim/commit/8c08b5b569e2a9e9f63dea514591ecfa2d3bb392
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
3174 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3175 // When no .vimrc file was found: source defaults.vim. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3176 do_source((char_u *)VIM_DEFAULTS_FILE, FALSE, DOSO_NONE, NULL); |
440 | 3177 } |
3178 } | |
3179 | |
3180 /* | |
3181 * Read initialization commands from ".vimrc" or ".exrc" in current | |
3182 * directory. This is only done if the 'exrc' option is set. | |
3183 * Because of security reasons we disallow shell and write commands | |
9669
284b4eb307fc
commit https://github.com/vim/vim/commit/8c08b5b569e2a9e9f63dea514591ecfa2d3bb392
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
3184 * now, except for Unix if the file is owned by the user or 'secure' |
440 | 3185 * option has been reset in environment of global ".exrc" or ".vimrc". |
3186 * Only do this if VIMRC_FILE is not the same as USR_VIMRC_FILE or | |
3187 * SYS_VIMRC_FILE. | |
3188 */ | |
3189 if (p_exrc) | |
3190 { | |
3191 #if defined(UNIX) || defined(VMS) | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3192 // If ".vimrc" file is not owned by user, set 'secure' mode. |
440 | 3193 if (!file_owned(VIMRC_FILE)) |
3194 #endif | |
3195 secure = p_secure; | |
3196 | |
3197 i = FAIL; | |
3198 if (fullpathcmp((char_u *)USR_VIMRC_FILE, | |
16738
b52ea9c5f1db
patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
3199 (char_u *)VIMRC_FILE, FALSE, TRUE) != FPC_SAME |
440 | 3200 #ifdef USR_VIMRC_FILE2 |
3201 && fullpathcmp((char_u *)USR_VIMRC_FILE2, | |
16738
b52ea9c5f1db
patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
3202 (char_u *)VIMRC_FILE, FALSE, TRUE) != FPC_SAME |
440 | 3203 #endif |
3204 #ifdef USR_VIMRC_FILE3 | |
3205 && fullpathcmp((char_u *)USR_VIMRC_FILE3, | |
16738
b52ea9c5f1db
patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
3206 (char_u *)VIMRC_FILE, FALSE, TRUE) != FPC_SAME |
440 | 3207 #endif |
3208 #ifdef SYS_VIMRC_FILE | |
3209 && fullpathcmp((char_u *)SYS_VIMRC_FILE, | |
16738
b52ea9c5f1db
patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
3210 (char_u *)VIMRC_FILE, FALSE, TRUE) != FPC_SAME |
440 | 3211 #endif |
3212 ) | |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3213 i = do_source((char_u *)VIMRC_FILE, TRUE, DOSO_VIMRC, NULL); |
440 | 3214 |
3215 if (i == FAIL) | |
3216 { | |
3217 #if defined(UNIX) || defined(VMS) | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3218 // if ".exrc" is not owned by user set 'secure' mode |
440 | 3219 if (!file_owned(EXRC_FILE)) |
3220 secure = p_secure; | |
3221 else | |
3222 secure = 0; | |
3223 #endif | |
3224 if ( fullpathcmp((char_u *)USR_EXRC_FILE, | |
16738
b52ea9c5f1db
patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
3225 (char_u *)EXRC_FILE, FALSE, TRUE) != FPC_SAME |
440 | 3226 #ifdef USR_EXRC_FILE2 |
3227 && fullpathcmp((char_u *)USR_EXRC_FILE2, | |
16738
b52ea9c5f1db
patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
3228 (char_u *)EXRC_FILE, FALSE, TRUE) != FPC_SAME |
440 | 3229 #endif |
3230 ) | |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3231 (void)do_source((char_u *)EXRC_FILE, FALSE, |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3232 DOSO_NONE, NULL); |
440 | 3233 } |
3234 } | |
3235 if (secure == 2) | |
3236 need_wait_return = TRUE; | |
3237 secure = 0; | |
3238 #ifdef AMIGA | |
3239 proc->pr_WindowPtr = save_winptr; | |
3240 #endif | |
3241 } | |
3242 TIME_MSG("sourcing vimrc file(s)"); | |
3243 } | |
3244 | |
3245 /* | |
6 | 3246 * Setup to start using the GUI. Exit with an error when not available. |
3247 */ | |
3248 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3249 main_start_gui(void) |
6 | 3250 { |
3251 #ifdef FEAT_GUI | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3252 gui.starting = TRUE; // start GUI a bit later |
6 | 3253 #else |
3254 mch_errmsg(_(e_nogvim)); | |
3255 mch_errmsg("\n"); | |
3256 mch_exit(2); | |
3257 #endif | |
3258 } | |
3259 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3260 #endif // NO_VIM_MAIN |
2730 | 3261 |
6 | 3262 /* |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
3263 * Get an environment variable and execute it as Ex commands. |
6 | 3264 * Returns FAIL if the environment variable was not executed, OK otherwise. |
3265 */ | |
3266 int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3267 process_env( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3268 char_u *env, |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3269 int is_viminit) // when TRUE, called for VIMINIT |
6 | 3270 { |
3271 char_u *initstr; | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14481
diff
changeset
|
3272 sctx_T save_current_sctx; |
23390
9a5f12b36273
patch 8.2.2238: Vim9: cannot load a Vim9 script without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
23128
diff
changeset
|
3273 |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
3274 ESTACK_CHECK_DECLARATION |
6 | 3275 |
3276 if ((initstr = mch_getenv(env)) != NULL && *initstr != NUL) | |
3277 { | |
3278 if (is_viminit) | |
819 | 3279 vimrc_found(NULL, NULL); |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
3280 estack_push(ETYPE_ENV, env, 0); |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
3281 ESTACK_CHECK_SETUP |
23390
9a5f12b36273
patch 8.2.2238: Vim9: cannot load a Vim9 script without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
23128
diff
changeset
|
3282 save_current_sctx = current_sctx; |
9a5f12b36273
patch 8.2.2238: Vim9: cannot load a Vim9 script without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
23128
diff
changeset
|
3283 current_sctx.sc_version = 1; |
6 | 3284 #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:
14481
diff
changeset
|
3285 current_sctx.sc_sid = SID_ENV; |
15008
67e3103d6e18
patch 8.1.0515: reloading a script gives errors for existing functions
Bram Moolenaar <Bram@vim.org>
parents:
14927
diff
changeset
|
3286 current_sctx.sc_seq = 0; |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14481
diff
changeset
|
3287 current_sctx.sc_lnum = 0; |
6 | 3288 #endif |
23390
9a5f12b36273
patch 8.2.2238: Vim9: cannot load a Vim9 script without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
23128
diff
changeset
|
3289 |
6 | 3290 do_cmdline_cmd(initstr); |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
3291 |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
3292 ESTACK_CHECK_NOW |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
3293 estack_pop(); |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14481
diff
changeset
|
3294 current_sctx = save_current_sctx; |
6 | 3295 return OK; |
3296 } | |
3297 return FAIL; | |
3298 } | |
3299 | |
2730 | 3300 #if (defined(UNIX) || defined(VMS)) && !defined(NO_VIM_MAIN) |
6 | 3301 /* |
3302 * Return TRUE if we are certain the user owns the file "fname". | |
3303 * Used for ".vimrc" and ".exrc". | |
3304 * Use both stat() and lstat() for extra security. | |
3305 */ | |
3306 static int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3307 file_owned(char *fname) |
6 | 3308 { |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9363
diff
changeset
|
3309 stat_T s; |
6 | 3310 # ifdef UNIX |
3311 uid_t uid = getuid(); | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3312 # else // VMS |
6 | 3313 uid_t uid = ((getgid() << 16) | getuid()); |
3314 # endif | |
3315 | |
3316 return !(mch_stat(fname, &s) != 0 || s.st_uid != uid | |
3317 # ifdef HAVE_LSTAT | |
3318 || mch_lstat(fname, &s) != 0 || s.st_uid != uid | |
3319 # endif | |
3320 ); | |
3321 } | |
3322 #endif | |
3323 | |
3324 /* | |
3325 * Give an error message main_errors["n"] and exit. | |
3326 */ | |
3327 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3328 mainerr( |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3329 int n, // one of the ME_ defines |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3330 char_u *str) // extra argument or NULL |
6 | 3331 { |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
3332 #if defined(UNIX) || defined(VMS) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3333 reset_signals(); // kill us with CTRL-C here, if you like |
6 | 3334 #endif |
3335 | |
16596
2f86ca0c1e6b
patch 8.1.1301: when compiled with VIMDLL some messages are not shown
Bram Moolenaar <Bram@vim.org>
parents:
16509
diff
changeset
|
3336 // If this is a Windows GUI executable, show an error dialog box. |
2f86ca0c1e6b
patch 8.1.1301: when compiled with VIMDLL some messages are not shown
Bram Moolenaar <Bram@vim.org>
parents:
16509
diff
changeset
|
3337 #ifdef VIMDLL |
2f86ca0c1e6b
patch 8.1.1301: when compiled with VIMDLL some messages are not shown
Bram Moolenaar <Bram@vim.org>
parents:
16509
diff
changeset
|
3338 gui.in_use = mch_is_gui_executable(); |
2f86ca0c1e6b
patch 8.1.1301: when compiled with VIMDLL some messages are not shown
Bram Moolenaar <Bram@vim.org>
parents:
16509
diff
changeset
|
3339 #endif |
2f86ca0c1e6b
patch 8.1.1301: when compiled with VIMDLL some messages are not shown
Bram Moolenaar <Bram@vim.org>
parents:
16509
diff
changeset
|
3340 #ifdef FEAT_GUI_MSWIN |
2f86ca0c1e6b
patch 8.1.1301: when compiled with VIMDLL some messages are not shown
Bram Moolenaar <Bram@vim.org>
parents:
16509
diff
changeset
|
3341 gui.starting = FALSE; // Needed to show as error. |
2f86ca0c1e6b
patch 8.1.1301: when compiled with VIMDLL some messages are not shown
Bram Moolenaar <Bram@vim.org>
parents:
16509
diff
changeset
|
3342 #endif |
2f86ca0c1e6b
patch 8.1.1301: when compiled with VIMDLL some messages are not shown
Bram Moolenaar <Bram@vim.org>
parents:
16509
diff
changeset
|
3343 |
14171
ddf160d82971
patch 8.1.0103: long version string cannot be translated
Christian Brabandt <cb@256bit.org>
parents:
14153
diff
changeset
|
3344 init_longVersion(); |
6 | 3345 mch_errmsg(longVersion); |
159 | 3346 mch_errmsg("\n"); |
6 | 3347 mch_errmsg(_(main_errors[n])); |
3348 if (str != NULL) | |
3349 { | |
3350 mch_errmsg(": \""); | |
3351 mch_errmsg((char *)str); | |
3352 mch_errmsg("\""); | |
3353 } | |
159 | 3354 mch_errmsg(_("\nMore info with: \"vim -h\"\n")); |
6 | 3355 |
3356 mch_exit(1); | |
3357 } | |
3358 | |
3359 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3360 mainerr_arg_missing(char_u *str) |
6 | 3361 { |
3362 mainerr(ME_ARG_MISSING, str); | |
3363 } | |
3364 | |
2730 | 3365 #ifndef NO_VIM_MAIN |
6 | 3366 /* |
3367 * print a message with three spaces prepended and '\n' appended. | |
3368 */ | |
3369 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3370 main_msg(char *s) |
6 | 3371 { |
3372 mch_msg(" "); | |
3373 mch_msg(s); | |
3374 mch_msg("\n"); | |
3375 } | |
3376 | |
3377 /* | |
3378 * Print messages for "vim -h" or "vim --help" and exit. | |
3379 */ | |
3380 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3381 usage(void) |
6 | 3382 { |
3383 int i; | |
3384 static char *(use[]) = | |
3385 { | |
3386 N_("[file ..] edit specified file(s)"), | |
3387 N_("- read text from stdin"), | |
3388 N_("-t tag edit file where tag is defined"), | |
3389 #ifdef FEAT_QUICKFIX | |
3390 N_("-q [errorfile] edit file with first error") | |
3391 #endif | |
3392 }; | |
3393 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
3394 #if defined(UNIX) || defined(VMS) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3395 reset_signals(); // kill us with CTRL-C here, if you like |
6 | 3396 #endif |
3397 | |
14171
ddf160d82971
patch 8.1.0103: long version string cannot be translated
Christian Brabandt <cb@256bit.org>
parents:
14153
diff
changeset
|
3398 init_longVersion(); |
6 | 3399 mch_msg(longVersion); |
14153
01b7a627d403
patch 8.1.0094: help text "usage:" is not capatalized
Christian Brabandt <cb@256bit.org>
parents:
14129
diff
changeset
|
3400 mch_msg(_("\n\nUsage:")); |
6 | 3401 for (i = 0; ; ++i) |
3402 { | |
3403 mch_msg(_(" vim [arguments] ")); | |
3404 mch_msg(_(use[i])); | |
3405 if (i == (sizeof(use) / sizeof(char_u *)) - 1) | |
3406 break; | |
3407 mch_msg(_("\n or:")); | |
3408 } | |
22 | 3409 #ifdef VMS |
1164 | 3410 mch_msg(_("\nWhere case is ignored prepend / to make flag upper case")); |
22 | 3411 #endif |
6 | 3412 |
3413 mch_msg(_("\n\nArguments:\n")); | |
3414 main_msg(_("--\t\t\tOnly file names after this")); | |
7410
08e62c4fc17d
commit https://github.com/vim/vim/commit/53076830fea6df737455523f7e235bfe4f79864d
Christian Brabandt <cb@256bit.org>
parents:
6923
diff
changeset
|
3415 #ifdef EXPAND_FILENAMES |
6 | 3416 main_msg(_("--literal\t\tDon't expand wildcards")); |
3417 #endif | |
3418 #ifdef FEAT_OLE | |
3419 main_msg(_("-register\t\tRegister this gvim for OLE")); | |
3420 main_msg(_("-unregister\t\tUnregister gvim for OLE")); | |
3421 #endif | |
3422 #ifdef FEAT_GUI | |
3423 main_msg(_("-g\t\t\tRun using GUI (like \"gvim\")")); | |
3424 main_msg(_("-f or --nofork\tForeground: Don't fork when starting GUI")); | |
3425 #endif | |
3426 main_msg(_("-v\t\t\tVi mode (like \"vi\")")); | |
3427 main_msg(_("-e\t\t\tEx mode (like \"ex\")")); | |
3437 | 3428 main_msg(_("-E\t\t\tImproved Ex mode")); |
6 | 3429 main_msg(_("-s\t\t\tSilent (batch) mode (only for \"ex\")")); |
3430 #ifdef FEAT_DIFF | |
3431 main_msg(_("-d\t\t\tDiff mode (like \"vimdiff\")")); | |
3432 #endif | |
3433 main_msg(_("-y\t\t\tEasy mode (like \"evim\", modeless)")); | |
3434 main_msg(_("-R\t\t\tReadonly mode (like \"view\")")); | |
3435 main_msg(_("-Z\t\t\tRestricted mode (like \"rvim\")")); | |
3436 main_msg(_("-m\t\t\tModifications (writing files) not allowed")); | |
3437 main_msg(_("-M\t\t\tModifications in text not allowed")); | |
3438 main_msg(_("-b\t\t\tBinary mode")); | |
3439 #ifdef FEAT_LISP | |
3440 main_msg(_("-l\t\t\tLisp mode")); | |
3441 #endif | |
3442 main_msg(_("-C\t\t\tCompatible with Vi: 'compatible'")); | |
3443 main_msg(_("-N\t\t\tNot fully Vi compatible: 'nocompatible'")); | |
1164 | 3444 main_msg(_("-V[N][fname]\t\tBe verbose [level N] [log messages to fname]")); |
3445 #ifdef FEAT_EVAL | |
6 | 3446 main_msg(_("-D\t\t\tDebugging mode")); |
1164 | 3447 #endif |
6 | 3448 main_msg(_("-n\t\t\tNo swap file, use memory only")); |
3449 main_msg(_("-r\t\t\tList swap files and exit")); | |
3450 main_msg(_("-r (with file name)\tRecover crashed session")); | |
3451 main_msg(_("-L\t\t\tSame as -r")); | |
3452 #ifdef AMIGA | |
3453 main_msg(_("-f\t\t\tDon't use newcli to open window")); | |
3454 main_msg(_("-dev <device>\t\tUse <device> for I/O")); | |
3455 #endif | |
3456 #ifdef FEAT_ARABIC | |
14129
cb731d098241
patch 8.1.0082: in terminal window, typing : at more prompt, inserts ':'
Christian Brabandt <cb@256bit.org>
parents:
13841
diff
changeset
|
3457 main_msg(_("-A\t\t\tStart in Arabic mode")); |
6 | 3458 #endif |
3459 #ifdef FEAT_RIGHTLEFT | |
3460 main_msg(_("-H\t\t\tStart in Hebrew mode")); | |
3461 #endif | |
3462 main_msg(_("-T <terminal>\tSet terminal type to <terminal>")); | |
8253
1b6a589a0efc
commit https://github.com/vim/vim/commit/49c39ff678e2ba9f7dc280b25368e12084a610cf
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
3463 main_msg(_("--not-a-term\t\tSkip warning for input/output not being a terminal")); |
10404
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
3464 main_msg(_("--ttyfail\t\tExit if input or output is not a terminal")); |
6 | 3465 main_msg(_("-u <vimrc>\t\tUse <vimrc> instead of any .vimrc")); |
3466 #ifdef FEAT_GUI | |
3467 main_msg(_("-U <gvimrc>\t\tUse <gvimrc> instead of any .gvimrc")); | |
3468 #endif | |
3469 main_msg(_("--noplugin\t\tDon't load plugin scripts")); | |
673 | 3470 main_msg(_("-p[N]\t\tOpen N tab pages (default: one for each file)")); |
6 | 3471 main_msg(_("-o[N]\t\tOpen N windows (default: one for each file)")); |
3472 main_msg(_("-O[N]\t\tLike -o but split vertically")); | |
3473 main_msg(_("+\t\t\tStart at end of file")); | |
3474 main_msg(_("+<lnum>\t\tStart at line <lnum>")); | |
3475 main_msg(_("--cmd <command>\tExecute <command> before loading any vimrc file")); | |
3476 main_msg(_("-c <command>\t\tExecute <command> after loading the first file")); | |
3477 main_msg(_("-S <session>\t\tSource file <session> after loading the first file")); | |
3478 main_msg(_("-s <scriptin>\tRead Normal mode commands from file <scriptin>")); | |
3479 main_msg(_("-w <scriptout>\tAppend all typed commands to file <scriptout>")); | |
3480 main_msg(_("-W <scriptout>\tWrite all typed commands to file <scriptout>")); | |
3481 #ifdef FEAT_CRYPT | |
3482 main_msg(_("-x\t\t\tEdit encrypted files")); | |
3483 #endif | |
3484 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_X11) | |
3485 # if defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK) | |
20369
6e1e4d7a7b39
patch 8.2.0740: minor message mistakes
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
3486 main_msg(_("-display <display>\tConnect Vim to this particular X-server")); |
6 | 3487 # endif |
3488 main_msg(_("-X\t\t\tDo not connect to X server")); | |
3489 #endif | |
3490 #ifdef FEAT_CLIENTSERVER | |
3491 main_msg(_("--remote <files>\tEdit <files> in a Vim server if possible")); | |
3492 main_msg(_("--remote-silent <files> Same, don't complain if there is no server")); | |
3493 main_msg(_("--remote-wait <files> As --remote but wait for files to have been edited")); | |
3494 main_msg(_("--remote-wait-silent <files> Same, don't complain if there is no server")); | |
1501 | 3495 main_msg(_("--remote-tab[-wait][-silent] <files> As --remote but use tab page per file")); |
6 | 3496 main_msg(_("--remote-send <keys>\tSend <keys> to a Vim server and exit")); |
3497 main_msg(_("--remote-expr <expr>\tEvaluate <expr> in a Vim server and print result")); | |
3498 main_msg(_("--serverlist\t\tList available Vim server names and exit")); | |
3499 main_msg(_("--servername <name>\tSend to/become the Vim server <name>")); | |
3500 #endif | |
1989 | 3501 #ifdef STARTUPTIME |
1999 | 3502 main_msg(_("--startuptime <file>\tWrite startup timing messages to <file>")); |
1989 | 3503 #endif |
6 | 3504 #ifdef FEAT_VIMINFO |
3505 main_msg(_("-i <viminfo>\t\tUse <viminfo> instead of .viminfo")); | |
3506 #endif | |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
3507 main_msg(_("--clean\t\t'nocompatible', Vim defaults, no plugins, no viminfo")); |
6 | 3508 main_msg(_("-h or --help\tPrint Help (this message) and exit")); |
3509 main_msg(_("--version\t\tPrint version information and exit")); | |
3510 | |
3511 #ifdef FEAT_GUI_X11 | |
3512 # ifdef FEAT_GUI_MOTIF | |
3513 mch_msg(_("\nArguments recognised by gvim (Motif version):\n")); | |
3514 # else | |
3515 # ifdef FEAT_GUI_ATHENA | |
3516 # ifdef FEAT_GUI_NEXTAW | |
3517 mch_msg(_("\nArguments recognised by gvim (neXtaw version):\n")); | |
3518 # else | |
3519 mch_msg(_("\nArguments recognised by gvim (Athena version):\n")); | |
3520 # endif | |
3521 # endif | |
3522 # endif | |
20369
6e1e4d7a7b39
patch 8.2.0740: minor message mistakes
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
3523 main_msg(_("-display <display>\tRun Vim on <display>")); |
20377
f1956699a8e4
patch 8.2.0744: the name vim is not capatilized in a message
Bram Moolenaar <Bram@vim.org>
parents:
20369
diff
changeset
|
3524 main_msg(_("-iconic\t\tStart Vim iconified")); |
6 | 3525 main_msg(_("-background <color>\tUse <color> for the background (also: -bg)")); |
3526 main_msg(_("-foreground <color>\tUse <color> for normal text (also: -fg)")); | |
3527 main_msg(_("-font <font>\t\tUse <font> for normal text (also: -fn)")); | |
3528 main_msg(_("-boldfont <font>\tUse <font> for bold text")); | |
3529 main_msg(_("-italicfont <font>\tUse <font> for italic text")); | |
3530 main_msg(_("-geometry <geom>\tUse <geom> for initial geometry (also: -geom)")); | |
3531 main_msg(_("-borderwidth <width>\tUse a border width of <width> (also: -bw)")); | |
3532 main_msg(_("-scrollbarwidth <width> Use a scrollbar width of <width> (also: -sw)")); | |
3533 # ifdef FEAT_GUI_ATHENA | |
3534 main_msg(_("-menuheight <height>\tUse a menu bar height of <height> (also: -mh)")); | |
3535 # endif | |
3536 main_msg(_("-reverse\t\tUse reverse video (also: -rv)")); | |
3537 main_msg(_("+reverse\t\tDon't use reverse video (also: +rv)")); | |
3538 main_msg(_("-xrm <resource>\tSet the specified resource")); | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3539 #endif // FEAT_GUI_X11 |
6 | 3540 #ifdef FEAT_GUI_GTK |
3541 mch_msg(_("\nArguments recognised by gvim (GTK+ version):\n")); | |
3542 main_msg(_("-font <font>\t\tUse <font> for normal text (also: -fn)")); | |
3543 main_msg(_("-geometry <geom>\tUse <geom> for initial geometry (also: -geom)")); | |
3544 main_msg(_("-reverse\t\tUse reverse video (also: -rv)")); | |
20369
6e1e4d7a7b39
patch 8.2.0740: minor message mistakes
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
3545 main_msg(_("-display <display>\tRun Vim on <display> (also: --display)")); |
6 | 3546 main_msg(_("--role <role>\tSet a unique role to identify the main window")); |
3547 main_msg(_("--socketid <xid>\tOpen Vim inside another GTK widget")); | |
3437 | 3548 main_msg(_("--echo-wid\t\tMake gvim echo the Window ID on stdout")); |
6 | 3549 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3550 #ifdef FEAT_GUI_MSWIN |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
3551 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
3552 if (gui.starting) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
3553 # endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
3554 { |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
3555 main_msg(_("-P <parent title>\tOpen Vim inside parent application")); |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
3556 main_msg(_("--windowid <HWND>\tOpen Vim inside another win32 widget")); |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16385
diff
changeset
|
3557 } |
6 | 3558 #endif |
3559 | |
3560 #ifdef FEAT_GUI_GNOME | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3561 // Gnome gives extra messages for --help if we continue, but not for -h. |
6 | 3562 if (gui.starting) |
3198 | 3563 { |
6 | 3564 mch_msg("\n"); |
3198 | 3565 gui.dofork = FALSE; |
3566 } | |
6 | 3567 else |
3568 #endif | |
3569 mch_exit(0); | |
3570 } | |
3571 | |
3572 /* | |
3573 * Check the result of the ATTENTION dialog: | |
3574 * When "Quit" selected, exit Vim. | |
3575 * When "Recover" selected, recover the file. | |
3576 */ | |
3577 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3578 check_swap_exists_action(void) |
6 | 3579 { |
3580 if (swap_exists_action == SEA_QUIT) | |
3581 getout(1); | |
3582 handle_swap_exists(NULL); | |
3583 } | |
3584 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3585 #endif // NO_VIM_MAIN |
2730 | 3586 |
11040
fde2cdef6b97
patch 8.0.0409: set_progpath is defined but not always used
Christian Brabandt <cb@256bit.org>
parents:
11032
diff
changeset
|
3587 #if !defined(NO_VIM_MAIN) && defined(FEAT_EVAL) |
11032
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3588 static void |
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3589 set_progpath(char_u *argv0) |
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3590 { |
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3591 char_u *val = argv0; |
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3592 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3593 # ifdef MSWIN |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3594 // A relative path containing a "/" will become invalid when using ":cd", |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3595 // turn it into a full path. |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3596 // On MS-Windows "vim" should be expanded to "vim.exe", thus always do |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3597 // this. |
11060
354593196e20
patch 8.0.0419: test for v:progpath fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11054
diff
changeset
|
3598 char_u *path = NULL; |
354593196e20
patch 8.0.0419: test for v:progpath fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11054
diff
changeset
|
3599 |
354593196e20
patch 8.0.0419: test for v:progpath fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11054
diff
changeset
|
3600 if (mch_can_exe(argv0, &path, FALSE) && path != NULL) |
354593196e20
patch 8.0.0419: test for v:progpath fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11054
diff
changeset
|
3601 val = path; |
12148
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3602 # else |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3603 char_u buf[MAXPATHL + 1]; |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3604 # ifdef PROC_EXE_LINK |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3605 char linkbuf[MAXPATHL + 1]; |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3606 ssize_t len; |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3607 |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3608 len = readlink(PROC_EXE_LINK, linkbuf, MAXPATHL); |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3609 if (len > 0) |
11054
576238eda5a4
patch 8.0.0416: setting v:progpath is not quite right
Christian Brabandt <cb@256bit.org>
parents:
11040
diff
changeset
|
3610 { |
12148
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3611 linkbuf[len] = NUL; |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3612 val = (char_u *)linkbuf; |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3613 } |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3614 # endif |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3615 |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3616 if (!mch_isFullName(val)) |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3617 { |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3618 if (gettail(val) != val |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3619 && vim_FullName(val, buf, MAXPATHL, TRUE) != FAIL) |
11054
576238eda5a4
patch 8.0.0416: setting v:progpath is not quite right
Christian Brabandt <cb@256bit.org>
parents:
11040
diff
changeset
|
3620 val = buf; |
11060
354593196e20
patch 8.0.0419: test for v:progpath fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11054
diff
changeset
|
3621 } |
11032
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3622 # endif |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
3623 |
11032
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3624 set_vim_var_string(VV_PROGPATH, val, -1); |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
3625 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3626 # ifdef MSWIN |
11054
576238eda5a4
patch 8.0.0416: setting v:progpath is not quite right
Christian Brabandt <cb@256bit.org>
parents:
11040
diff
changeset
|
3627 vim_free(path); |
11060
354593196e20
patch 8.0.0419: test for v:progpath fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11054
diff
changeset
|
3628 # endif |
11032
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3629 } |
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3630 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3631 #endif // NO_VIM_MAIN |