Mercurial > vim
annotate src/main.c @ 15868:7fad90423bd2 v8.1.0941
patch 8.1.0941: macros for MS-Windows are inconsistent
commit https://github.com/vim/vim/commit/4f97475d326c2773a78561fb874e4f23c25cbcd9
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 17 17:44:42 2019 +0100
patch 8.1.0941: macros for MS-Windows are inconsistent
Problem: Macros for MS-Windows are inconsistent, using "32", "3264 and
others.
Solution: Use MSWIN for all MS-Windows builds. Use FEAT_GUI_MSWIN for the
GUI build. (Hirohito Higashi, closes #3932)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 17 Feb 2019 17:45:08 +0100 |
parents | a6ca8cf07a98 |
children | a246b020984c |
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> |
16 # include <sys/cygwin.h> /* for cygwin_conv_to_posix_path() and/or | |
17 * cygwin_conv_path() */ | |
6 | 18 # endif |
19 # include <limits.h> | |
20 #endif | |
21 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
22 #if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) |
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 |
443 | 26 /* Values for edit_type. */ |
27 #define EDIT_NONE 0 /* no edit type yet */ | |
28 #define EDIT_FILE 1 /* file name argument[s] given, use argument list */ | |
29 #define EDIT_STDIN 2 /* read file from stdin */ | |
30 #define EDIT_TAG 3 /* tag name argument given, use tagname */ | |
31 #define EDIT_QF 4 /* start in quickfix mode */ | |
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 # 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
|
38 static void init_locale(void); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
39 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
40 static void early_arg_scan(mparm_T *parmp); |
2730 | 41 #ifndef NO_VIM_MAIN |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
42 static void usage(void); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
43 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
|
44 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
|
45 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
|
46 static void read_stdin(void); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 static void main_start_gui(void); |
2730 | 53 # if defined(HAS_SWAP_EXISTS_ACTION) |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
54 static void check_swap_exists_action(void); |
2730 | 55 # endif |
11032
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
56 # ifdef FEAT_EVAL |
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
57 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
|
58 # endif |
2730 | 59 # if defined(FEAT_CLIENTSERVER) || defined(PROTO) |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
60 static void exec_on_server(mparm_T *parmp); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
61 static void prepare_server(mparm_T *parmp); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
62 static void cmdsrv_main(int *argc, char **argv, char_u *serverName_arg, char_u **serverStr); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
63 static char_u *serverMakeName(char_u *arg, char *cmd); |
2730 | 64 # endif |
6 | 65 #endif |
66 | |
67 | |
68 /* | |
69 * Different types of error messages. | |
70 */ | |
71 static char *(main_errors[]) = | |
72 { | |
443 | 73 N_("Unknown option argument"), |
6 | 74 #define ME_UNKNOWN_OPTION 0 |
75 N_("Too many edit arguments"), | |
76 #define ME_TOO_MANY_ARGS 1 | |
77 N_("Argument missing after"), | |
78 #define ME_ARG_MISSING 2 | |
443 | 79 N_("Garbage after option argument"), |
6 | 80 #define ME_GARBAGE 3 |
81 N_("Too many \"+command\", \"-c command\" or \"--cmd command\" arguments"), | |
82 #define ME_EXTRA_CMD 4 | |
83 N_("Invalid argument for"), | |
84 #define ME_INVALID_ARG 5 | |
85 }; | |
86 | |
3955 | 87 #ifndef PROTO /* don't want a prototype for main() */ |
11309
b254fd46ef62
patch 8.0.0540: building unit tests fails
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
88 |
b254fd46ef62
patch 8.0.0540: building unit tests fails
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
89 /* Various parameters passed between main() and other functions. */ |
b254fd46ef62
patch 8.0.0540: building unit tests fails
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
90 static mparm_T params; |
b254fd46ef62
patch 8.0.0540: building unit tests fails
Christian Brabandt <cb@256bit.org>
parents:
11307
diff
changeset
|
91 |
2730 | 92 #ifndef NO_VIM_MAIN /* skip this for unittests */ |
6763 | 93 |
94 static char_u *start_dir = NULL; /* current working dir on startup */ | |
95 | |
9678
8c9e13109df8
commit https://github.com/vim/vim/commit/b9a46fec3e79d1fc8c406084a41733c647a5e535
Christian Brabandt <cb@256bit.org>
parents:
9669
diff
changeset
|
96 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
|
97 |
6 | 98 int |
99 # ifdef VIMDLL | |
100 _export | |
101 # endif | |
102 # ifdef FEAT_GUI_MSWIN | |
103 # ifdef __BORLANDC__ | |
104 _cdecl | |
105 # endif | |
106 VimMain | |
107 # else | |
108 main | |
109 # endif | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
110 (int argc, char **argv) |
6 | 111 { |
13363
2103b009e32d
patch 8.0.1555: build error for some combination of features
Christian Brabandt <cb@256bit.org>
parents:
13361
diff
changeset
|
112 #if defined(STARTUPTIME) || defined(CLEAN_RUNTIMEPATH) |
1972 | 113 int i; |
114 #endif | |
6 | 115 |
116 /* | |
117 * Do any system-specific initialisations. These can NOT use IObuff or | |
118 * NameBuff. Thus emsg2() cannot be called! | |
119 */ | |
120 mch_early_init(); | |
121 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
122 #ifdef MSWIN |
6193 | 123 /* |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
124 * MinGW expands command line arguments, which confuses our code to |
6193 | 125 * convert when 'encoding' changes. Get the unexpanded arguments. |
126 */ | |
127 argc = get_cmd_argsW(&argv); | |
128 #endif | |
129 | |
443 | 130 /* Many variables are in "params" so that we can pass them to invoked |
131 * functions without a lot of arguments. "argc" and "argv" are also | |
132 * copied, so that they can be changed. */ | |
440 | 133 vim_memset(¶ms, 0, sizeof(params)); |
443 | 134 params.argc = argc; |
135 params.argv = argv; | |
136 params.want_full_screen = TRUE; | |
137 #ifdef FEAT_EVAL | |
138 params.use_debug_break_level = -1; | |
139 #endif | |
140 params.window_count = -1; | |
440 | 141 |
4369 | 142 #ifdef FEAT_RUBY |
143 { | |
144 int ruby_stack_start; | |
145 vim_ruby_init((void *)&ruby_stack_start); | |
146 } | |
147 #endif | |
148 | |
6 | 149 #ifdef FEAT_TCL |
443 | 150 vim_tcl_init(params.argv[0]); |
6 | 151 #endif |
152 | |
153 #ifdef MEM_PROFILE | |
154 atexit(vim_mem_profile_dump); | |
155 #endif | |
156 | |
157 #ifdef STARTUPTIME | |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
158 /* 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
|
159 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
|
160 if (STRICMP(argv[i], "--startuptime") == 0) |
1972 | 161 { |
1989 | 162 time_fd = mch_fopen(argv[i + 1], "a"); |
1972 | 163 TIME_MSG("--- VIM STARTING ---"); |
164 break; | |
165 } | |
6 | 166 #endif |
777 | 167 starttime = time(NULL); |
6 | 168 |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
169 #ifdef CLEAN_RUNTIMEPATH |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
170 /* Need to find "--clean" before actually parsing arguments. */ |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
171 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
|
172 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
|
173 { |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
174 params.clean = TRUE; |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
175 break; |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
176 } |
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
177 #endif |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
178 common_init(¶ms); |
6 | 179 |
180 #ifdef FEAT_CLIENTSERVER | |
181 /* | |
182 * Do the client-server stuff, unless "--servername ''" was used. | |
443 | 183 * This may exit Vim if the command was sent to the server. |
6 | 184 */ |
443 | 185 exec_on_server(¶ms); |
6 | 186 #endif |
187 | |
188 /* | |
443 | 189 * Figure out the way to work from the command name argv[0]. |
190 * "vimdiff" starts diff mode, "rvim" sets "restricted", etc. | |
6 | 191 */ |
443 | 192 parse_command_name(¶ms); |
6 | 193 |
194 /* | |
443 | 195 * Process the command line arguments. File names are put in the global |
196 * argument list "global_alist". | |
6 | 197 */ |
443 | 198 command_line_scan(¶ms); |
6 | 199 TIME_MSG("parsing arguments"); |
200 | |
201 /* | |
202 * On some systems, when we compile with the GUI, we always use it. On Mac | |
443 | 203 * there is no terminal version, and on Windows we can't fork one off with |
204 * :gui. | |
6 | 205 */ |
206 #ifdef ALWAYS_USE_GUI | |
207 gui.starting = TRUE; | |
208 #else | |
575 | 209 # if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) |
6 | 210 /* |
211 * Check if the GUI can be started. Reset gui.starting if not. | |
212 * Don't know about other systems, stay on the safe side and don't check. | |
213 */ | |
2021 | 214 if (gui.starting) |
6 | 215 { |
2021 | 216 if (gui_init_check() == FAIL) |
217 { | |
218 gui.starting = FALSE; | |
219 | |
220 /* When running "evim" or "gvim -y" we need the menus, exit if we | |
221 * don't have them. */ | |
222 if (params.evim_mode) | |
223 mch_exit(1); | |
224 } | |
6 | 225 } |
226 # endif | |
227 #endif | |
228 | |
229 if (GARGCOUNT > 0) | |
230 { | |
7410
08e62c4fc17d
commit https://github.com/vim/vim/commit/53076830fea6df737455523f7e235bfe4f79864d
Christian Brabandt <cb@256bit.org>
parents:
6923
diff
changeset
|
231 #ifdef EXPAND_FILENAMES |
6 | 232 /* |
233 * Expand wildcards in file names. | |
234 */ | |
443 | 235 if (!params.literal) |
6 | 236 { |
6735
f6021786b775
patch 7.4.691 for Problem: Can't build with MzScheme.
Bram Moolenaar <bram@vim.org>
parents:
6731
diff
changeset
|
237 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
|
238 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
|
239 mch_dirname(start_dir, MAXPATHL); |
6 | 240 /* Temporarily add '(' and ')' to 'isfname'. These are valid |
241 * filename characters but are excluded from 'isfname' to make | |
242 * "gf" work on a file name in parenthesis (e.g.: see vim.h). */ | |
243 do_cmdline_cmd((char_u *)":set isf+=(,)"); | |
41 | 244 alist_expand(NULL, 0); |
6 | 245 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
|
246 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
|
247 mch_chdir((char *)start_dir); |
6 | 248 } |
249 #endif | |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
250 params.fname = alist_name(&GARGLIST[0]); |
6 | 251 } |
23 | 252 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
253 #ifdef MSWIN |
23 | 254 { |
255 extern void set_alist_count(void); | |
256 | |
257 /* Remember the number of entries in the argument list. If it changes | |
258 * we don't react on setting 'encoding'. */ | |
259 set_alist_count(); | |
260 } | |
261 #endif | |
262 | |
6 | 263 #ifdef MSWIN |
443 | 264 if (GARGCOUNT == 1 && params.full_path) |
6 | 265 { |
266 /* | |
267 * If there is one filename, fully qualified, we have very probably | |
268 * been invoked from explorer, so change to the file's directory. | |
269 * Hint: to avoid this when typing a command use a forward slash. | |
270 * If the cd fails, it doesn't matter. | |
271 */ | |
13170
6559e98f3e74
patch 8.0.1459: cannot handle change of directory
Christian Brabandt <cb@256bit.org>
parents:
13160
diff
changeset
|
272 (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
|
273 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
|
274 mch_dirname(start_dir, MAXPATHL); |
6 | 275 } |
276 #endif | |
277 TIME_MSG("expanding arguments"); | |
278 | |
279 #ifdef FEAT_DIFF | |
769 | 280 if (params.diff_mode && params.window_count == -1) |
281 params.window_count = 0; /* open up to 3 windows */ | |
6 | 282 #endif |
283 | |
443 | 284 /* Don't redraw until much later. */ |
6 | 285 ++RedrawingDisabled; |
286 | |
287 /* | |
288 * When listing swap file names, don't do cursor positioning et. al. | |
289 */ | |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
290 if (recoverymode && params.fname == NULL) |
443 | 291 params.want_full_screen = FALSE; |
6 | 292 |
293 /* | |
294 * When certain to start the GUI, don't check capabilities of terminal. | |
295 * For GTK we can't be sure, but when started from the desktop it doesn't | |
296 * make sense to try using a terminal. | |
297 */ | |
575 | 298 #if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) |
6 | 299 if (gui.starting |
300 # ifdef FEAT_GUI_GTK | |
301 && !isatty(2) | |
302 # endif | |
303 ) | |
443 | 304 params.want_full_screen = FALSE; |
6 | 305 #endif |
306 | |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12678
diff
changeset
|
307 #if defined(FEAT_GUI_MAC) && defined(MACOS_X_DARWIN) |
6 | 308 /* When the GUI is started from Finder, need to display messages in a |
309 * message box. isatty(2) returns TRUE anyway, thus we need to check the | |
310 * name to know we're not started from a terminal. */ | |
311 if (gui.starting && (!isatty(2) || strcmp("/dev/console", ttyname(2)) == 0)) | |
816 | 312 { |
443 | 313 params.want_full_screen = FALSE; |
816 | 314 |
315 /* Avoid always using "/" as the current directory. Note that when | |
316 * started from Finder the arglist will be filled later in | |
317 * HandleODocAE() and "fname" will be NULL. */ | |
318 if (getcwd((char *)NameBuff, MAXPATHL) != NULL | |
319 && STRCMP(NameBuff, "/") == 0) | |
320 { | |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
321 if (params.fname != NULL) |
13170
6559e98f3e74
patch 8.0.1459: cannot handle change of directory
Christian Brabandt <cb@256bit.org>
parents:
13160
diff
changeset
|
322 (void)vim_chdirfile(params.fname, "drop"); |
816 | 323 else |
324 { | |
325 expand_env((char_u *)"$HOME", NameBuff, MAXPATHL); | |
326 vim_chdir(NameBuff); | |
327 } | |
6735
f6021786b775
patch 7.4.691 for Problem: Can't build with MzScheme.
Bram Moolenaar <bram@vim.org>
parents:
6731
diff
changeset
|
328 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
|
329 mch_dirname(start_dir, MAXPATHL); |
816 | 330 } |
331 } | |
6 | 332 #endif |
333 | |
334 /* | |
335 * 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
|
336 * done after resetting full_screen, otherwise it may move the cursor. |
6 | 337 * Note that we may use mch_exit() before mch_init()! |
338 */ | |
339 mch_init(); | |
340 TIME_MSG("shell init"); | |
341 | |
342 #ifdef USE_XSMP | |
343 /* | |
344 * For want of anywhere else to do it, try to connect to xsmp here. | |
345 * Fitting it in after gui_mch_init, but before gui_init (via termcapinit). | |
346 * Hijacking -X 'no X connection' to also disable XSMP connection as that | |
347 * has a similar delay upon failure. | |
348 * Only try if SESSION_MANAGER is set to something non-null. | |
349 */ | |
350 if (!x_no_connect) | |
351 { | |
443 | 352 char *p = getenv("SESSION_MANAGER"); |
353 | |
6 | 354 if (p != NULL && *p != NUL) |
355 { | |
356 xsmp_init(); | |
357 TIME_MSG("xsmp init"); | |
358 } | |
359 } | |
360 #endif | |
361 | |
362 /* | |
363 * Print a warning if stdout is not a terminal. | |
364 */ | |
443 | 365 check_tty(¶ms); |
6 | 366 |
13160
cb99d9198c39
patch 8.0.1454: when in silent mode too much output is buffered
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
367 #ifdef _IOLBF |
cb99d9198c39
patch 8.0.1454: when in silent mode too much output is buffered
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
368 /* Ensure output works usefully without a tty: buffer lines instead of |
cb99d9198c39
patch 8.0.1454: when in silent mode too much output is buffered
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
369 * fully buffered. */ |
cb99d9198c39
patch 8.0.1454: when in silent mode too much output is buffered
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
370 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
|
371 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
|
372 #endif |
cb99d9198c39
patch 8.0.1454: when in silent mode too much output is buffered
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
373 |
169 | 374 /* This message comes before term inits, but after setting "silent_mode" |
375 * when the input is not a tty. */ | |
376 if (GARGCOUNT > 1 && !silent_mode) | |
377 printf(_("%d files to edit\n"), GARGCOUNT); | |
378 | |
443 | 379 if (params.want_full_screen && !silent_mode) |
6 | 380 { |
443 | 381 termcapinit(params.term); /* set terminal name and get terminal |
6 | 382 capabilities (will set full_screen) */ |
383 screen_start(); /* don't know where cursor is now */ | |
384 TIME_MSG("Termcap init"); | |
385 } | |
386 | |
387 /* | |
388 * Set the default values for the options that use Rows and Columns. | |
389 */ | |
390 ui_get_shellsize(); /* inits Rows and Columns */ | |
667 | 391 win_init_size(); |
6 | 392 #ifdef FEAT_DIFF |
393 /* Set the 'diff' option now, so that it can be checked for in a .vimrc | |
394 * file. There is no buffer yet though. */ | |
443 | 395 if (params.diff_mode) |
6 | 396 diff_win_options(firstwin, FALSE); |
397 #endif | |
398 | |
399 cmdline_row = Rows - p_ch; | |
400 msg_row = cmdline_row; | |
401 screenalloc(FALSE); /* allocate screen buffers */ | |
402 set_init_2(); | |
403 TIME_MSG("inits 2"); | |
404 | |
405 msg_scroll = TRUE; | |
406 no_wait_return = TRUE; | |
407 | |
408 init_mappings(); /* set up initial mappings */ | |
409 | |
410 init_highlight(TRUE, FALSE); /* set the default highlight groups */ | |
411 TIME_MSG("init highlight"); | |
412 | |
413 #ifdef FEAT_EVAL | |
414 /* Set the break level after the terminal is initialized. */ | |
443 | 415 debug_break_level = params.use_debug_break_level; |
6 | 416 #endif |
417 | |
12670
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
418 /* Reset 'loadplugins' for "-u NONE" before "--cmd" arguments. |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
419 * Allows for setting 'loadplugins' there. */ |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
420 if (params.use_vimrc != NULL |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
421 && (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
|
422 || 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
|
423 p_lpl = FALSE; |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
424 |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
425 /* Execute --cmd arguments. */ |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
426 exe_pre_commands(¶ms); |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
427 |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
428 /* Source startup scripts. */ |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
429 source_startup_scripts(¶ms); |
d348256f04d1
patch 8.0.1213: setting 'mzschemedll' has no effect
Christian Brabandt <cb@256bit.org>
parents:
12557
diff
changeset
|
430 |
3348 | 431 #ifdef FEAT_MZSCHEME |
432 /* | |
433 * Newer version of MzScheme (Racket) require earlier (trampolined) | |
434 * initialisation via scheme_main_setup. | |
435 * 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
|
436 * 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
|
437 * Do source startup scripts, so that 'mzschemedll' can be set. |
3348 | 438 */ |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
439 return mzscheme_main(); |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
440 #else |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
441 return vim_main2(); |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
442 #endif |
3348 | 443 } |
3955 | 444 #endif /* NO_VIM_MAIN */ |
9832
568ea507b0cd
commit https://github.com/vim/vim/commit/a357e44ccdf5cfe9f6d35cc348ca33ccd973e1a9
Christian Brabandt <cb@256bit.org>
parents:
9802
diff
changeset
|
445 #endif /* PROTO */ |
3955 | 446 |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
447 /* |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
448 * 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
|
449 * things simple. |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
450 * 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
|
451 */ |
3955 | 452 int |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
453 vim_main2(void) |
3348 | 454 { |
3955 | 455 #ifndef NO_VIM_MAIN |
6 | 456 #ifdef FEAT_EVAL |
457 /* | |
458 * Read all the plugin files. | |
459 * Only when compiled with +eval, since most plugins need it. | |
460 */ | |
461 if (p_lpl) | |
462 { | |
11595
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
463 char_u *rtp_copy = NULL; |
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
464 |
11457
5a1656d79707
patch 8.0.0612: pack dirs are added to 'runtimepath' too late
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
465 /* First add all package directories to 'runtimepath', so that their |
5a1656d79707
patch 8.0.0612: pack dirs are added to 'runtimepath' too late
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
466 * autoload directories can be found. Only if not done already with a |
11595
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
467 * :packloadall command. |
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
468 * Make a copy of 'runtimepath', so that source_runtime does not use |
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
469 * 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
|
470 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
|
471 { |
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
472 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
|
473 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
|
474 } |
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
475 |
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
476 source_in_path(rtp_copy == NULL ? p_rtp : rtp_copy, |
892 | 477 # ifdef VMS /* Somehow VMS doesn't handle the "**". */ |
11595
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
478 (char_u *)"plugin/*.vim", |
892 | 479 # else |
11595
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
480 (char_u *)"plugin/**/*.vim", |
892 | 481 # endif |
11595
42cd59477698
patch 8.0.0680: plugins in start packages are sourced twice
Christian Brabandt <cb@256bit.org>
parents:
11492
diff
changeset
|
482 DIP_ALL | DIP_NOAFTER); |
6 | 483 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
|
484 vim_free(rtp_copy); |
8182
95d59081580f
commit https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
485 |
11457
5a1656d79707
patch 8.0.0612: pack dirs are added to 'runtimepath' too late
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
486 /* Only source "start" packages if not done already with a :packloadall |
5a1656d79707
patch 8.0.0612: pack dirs are added to 'runtimepath' too late
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
487 * command. */ |
5a1656d79707
patch 8.0.0612: pack dirs are added to 'runtimepath' too late
Christian Brabandt <cb@256bit.org>
parents:
11455
diff
changeset
|
488 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
|
489 load_start_packages(); |
8182
95d59081580f
commit https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
490 TIME_MSG("loading packages"); |
9778
4360b2b46125
commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents:
9678
diff
changeset
|
491 |
4360b2b46125
commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents:
9678
diff
changeset
|
492 # ifdef VMS /* Somehow VMS doesn't handle the "**". */ |
4360b2b46125
commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents:
9678
diff
changeset
|
493 source_runtime((char_u *)"plugin/*.vim", DIP_ALL | DIP_AFTER); |
4360b2b46125
commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents:
9678
diff
changeset
|
494 # else |
4360b2b46125
commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents:
9678
diff
changeset
|
495 source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL | DIP_AFTER); |
4360b2b46125
commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents:
9678
diff
changeset
|
496 # endif |
4360b2b46125
commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents:
9678
diff
changeset
|
497 TIME_MSG("loading after plugins"); |
4360b2b46125
commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents:
9678
diff
changeset
|
498 |
6 | 499 } |
500 #endif | |
501 | |
769 | 502 #ifdef FEAT_DIFF |
503 /* Decide about window layout for diff mode after reading vimrc. */ | |
504 if (params.diff_mode && params.window_layout == 0) | |
505 { | |
506 if (diffopt_horizontal()) | |
507 params.window_layout = WIN_HOR; /* use horizontal split */ | |
508 else | |
509 params.window_layout = WIN_VER; /* use vertical split */ | |
510 } | |
511 #endif | |
512 | |
6 | 513 /* |
514 * Recovery mode without a file name: List swap files. | |
515 * This uses the 'dir' option, therefore it must be after the | |
516 * initializations. | |
517 */ | |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
518 if (recoverymode && params.fname == NULL) |
6 | 519 { |
2267 | 520 recover_names(NULL, TRUE, 0, NULL); |
6 | 521 mch_exit(0); |
522 } | |
523 | |
524 /* | |
525 * Set a few option defaults after reading .vimrc files: | |
526 * 'title' and 'icon', Unix: 'shellpipe' and 'shellredir'. | |
527 */ | |
528 set_init_3(); | |
529 TIME_MSG("inits 3"); | |
530 | |
531 /* | |
532 * "-n" argument: Disable swap file by setting 'updatecount' to 0. | |
533 * Note that this overrides anything from a vimrc file. | |
534 */ | |
443 | 535 if (params.no_swap_file) |
6 | 536 p_uc = 0; |
537 | |
538 #ifdef FEAT_GUI | |
539 if (gui.starting) | |
540 { | |
541 #if defined(UNIX) || defined(VMS) | |
542 /* When something caused a message from a vimrc script, need to output | |
543 * an extra newline before the shell prompt. */ | |
544 if (did_emsg || msg_didout) | |
545 putchar('\n'); | |
546 #endif | |
547 | |
548 gui_start(); /* will set full_screen to TRUE */ | |
549 TIME_MSG("starting GUI"); | |
550 | |
551 /* When running "evim" or "gvim -y" we need the menus, exit if we | |
552 * don't have them. */ | |
440 | 553 if (!gui.in_use && params.evim_mode) |
6 | 554 mch_exit(1); |
555 } | |
556 #endif | |
557 | |
558 #ifdef FEAT_VIMINFO | |
559 /* | |
1733 | 560 * Read in registers, history etc, but not marks, from the viminfo file. |
561 * This is where v:oldfiles gets filled. | |
6 | 562 */ |
563 if (*p_viminfo != NUL) | |
564 { | |
1733 | 565 read_viminfo(NULL, VIF_WANT_INFO | VIF_GET_OLDFILES); |
6 | 566 TIME_MSG("reading viminfo"); |
567 } | |
568 #endif | |
5598 | 569 #ifdef FEAT_EVAL |
570 /* It's better to make v:oldfiles an empty list than NULL. */ | |
571 if (get_vim_var_list(VV_OLDFILES) == NULL) | |
572 set_vim_var_list(VV_OLDFILES, list_alloc()); | |
573 #endif | |
6 | 574 |
575 #ifdef FEAT_QUICKFIX | |
576 /* | |
577 * "-q errorfile": Load the error file now. | |
578 * If the error file can't be read, exit before doing anything else. | |
579 */ | |
443 | 580 if (params.edit_type == EDIT_QF) |
6 | 581 { |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
11060
diff
changeset
|
582 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
|
583 |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
11060
diff
changeset
|
584 enc = p_menc; |
443 | 585 if (params.use_ef != NULL) |
586 set_string_option_direct((char_u *)"ef", -1, | |
694 | 587 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
|
588 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
|
589 if (qf_init(NULL, p_ef, p_efm, TRUE, IObuff, enc) < 0) |
6 | 590 { |
591 out_char('\n'); | |
592 mch_exit(3); | |
593 } | |
594 TIME_MSG("reading errorfile"); | |
595 } | |
596 #endif | |
597 | |
598 /* | |
599 * Start putting things on the screen. | |
600 * Scroll screen down before drawing over it | |
601 * Clear screen now, so file message will not be cleared. | |
602 */ | |
603 starting = NO_BUFFERS; | |
604 no_wait_return = FALSE; | |
605 if (!exmode_active) | |
606 msg_scroll = FALSE; | |
607 | |
608 #ifdef FEAT_GUI | |
609 /* | |
610 * This seems to be required to make callbacks to be called now, instead | |
611 * of after things have been put on the screen, which then may be deleted | |
612 * when getting a resize callback. | |
613 * For the Mac this handles putting files dropped on the Vim icon to | |
614 * global_alist. | |
615 */ | |
616 if (gui.in_use) | |
617 { | |
15510
41fbbcea0f1b
patch 8.1.0763: nobody is using the Sun Workshop support
Bram Moolenaar <Bram@vim.org>
parents:
15476
diff
changeset
|
618 gui_wait_for_chars(50L, typebuf.tb_change_cnt); |
6 | 619 TIME_MSG("GUI delay"); |
620 } | |
621 #endif | |
622 | |
623 #if defined(FEAT_GUI_PHOTON) && defined(FEAT_CLIPBOARD) | |
624 qnx_clip_init(); | |
625 #endif | |
626 | |
2312
bbd6f5539378
Missing piece for Mac console clipboard support. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
627 #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
|
628 clip_init(TRUE); |
bbd6f5539378
Missing piece for Mac console clipboard support. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
629 #endif |
bbd6f5539378
Missing piece for Mac console clipboard support. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
630 |
6 | 631 #ifdef FEAT_XCLIPBOARD |
632 /* Start using the X clipboard, unless the GUI was started. */ | |
633 # ifdef FEAT_GUI | |
634 if (!gui.in_use) | |
635 # endif | |
636 { | |
637 setup_term_clip(); | |
638 TIME_MSG("setup clipboard"); | |
639 } | |
640 #endif | |
641 | |
642 #ifdef FEAT_CLIENTSERVER | |
443 | 643 /* Prepare for being a Vim server. */ |
644 prepare_server(¶ms); | |
6 | 645 #endif |
646 | |
647 /* | |
648 * If "-" argument given: Read file from stdin. | |
649 * Do this before starting Raw mode, because it may change things that the | |
650 * writing end of the pipe doesn't like, e.g., in case stdin and stderr | |
651 * are the same terminal: "cat | vim -". | |
652 * Using autocommands here may cause trouble... | |
653 */ | |
443 | 654 if (params.edit_type == EDIT_STDIN && !recoverymode) |
655 read_stdin(); | |
6 | 656 |
657 #if defined(UNIX) || defined(VMS) | |
658 /* When switching screens and something caused a message from a vimrc | |
659 * script, need to output an extra newline on exit. */ | |
660 if ((did_emsg || msg_didout) && *T_TI != NUL) | |
661 newline_on_exit = TRUE; | |
662 #endif | |
663 | |
664 /* | |
665 * When done something that is not allowed or error message call | |
666 * wait_return. This must be done before starttermcap(), because it may | |
667 * switch to another screen. It must be done after settmode(TMODE_RAW), | |
668 * because we want to react on a single key stroke. | |
669 * Call settmode and starttermcap here, so the T_KS and T_TI may be | |
1226 | 670 * defined by termcapinit and redefined in .exrc. |
6 | 671 */ |
672 settmode(TMODE_RAW); | |
673 TIME_MSG("setting raw mode"); | |
674 | |
675 if (need_wait_return || msg_didany) | |
676 { | |
677 wait_return(TRUE); | |
678 TIME_MSG("waiting for return"); | |
679 } | |
680 | |
681 starttermcap(); /* start termcap if not done by wait_return() */ | |
682 TIME_MSG("start termcap"); | |
683 | |
684 #ifdef FEAT_MOUSE | |
685 setmouse(); /* may start using the mouse */ | |
686 #endif | |
687 if (scroll_region) | |
688 scroll_region_reset(); /* In case Rows changed */ | |
440 | 689 scroll_start(); /* may scroll the screen to the right position */ |
6 | 690 |
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
|
691 #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
|
692 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
|
693 #endif |
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14428
diff
changeset
|
694 |
6 | 695 /* |
696 * Don't clear the screen when starting in Ex mode, unless using the GUI. | |
697 */ | |
698 if (exmode_active | |
699 #ifdef FEAT_GUI | |
700 && !gui.in_use | |
701 #endif | |
702 ) | |
703 must_redraw = CLEAR; | |
704 else | |
705 { | |
706 screenclear(); /* clear screen */ | |
707 TIME_MSG("clearing screen"); | |
708 } | |
709 | |
710 #ifdef FEAT_CRYPT | |
443 | 711 if (params.ask_for_key) |
6 | 712 { |
6353 | 713 crypt_check_current_method(); |
6122 | 714 (void)crypt_get_key(TRUE, TRUE); |
6 | 715 TIME_MSG("getting crypt key"); |
716 } | |
717 #endif | |
718 | |
719 no_wait_return = TRUE; | |
720 | |
721 /* | |
443 | 722 * Create the requested number of windows and edit buffers in them. |
723 * Also does recovery if "recoverymode" set. | |
6 | 724 */ |
443 | 725 create_windows(¶ms); |
6 | 726 TIME_MSG("opening buffers"); |
727 | |
1093 | 728 #ifdef FEAT_EVAL |
729 /* clear v:swapcommand */ | |
730 set_vim_var_string(VV_SWAPCOMMAND, NULL, -1); | |
731 #endif | |
732 | |
6 | 733 /* Ex starts at last line of the file */ |
734 if (exmode_active) | |
735 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
736 | |
737 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | |
738 TIME_MSG("BufEnter autocommands"); | |
739 setpcmark(); | |
740 | |
741 #ifdef FEAT_QUICKFIX | |
742 /* | |
743 * When started with "-q errorfile" jump to first error now. | |
744 */ | |
443 | 745 if (params.edit_type == EDIT_QF) |
6 | 746 { |
644 | 747 qf_jump(NULL, 0, 0, FALSE); |
6 | 748 TIME_MSG("jump to first error"); |
749 } | |
750 #endif | |
751 | |
752 /* | |
753 * If opened more than one window, start editing files in the other | |
443 | 754 * windows. |
6 | 755 */ |
6735
f6021786b775
patch 7.4.691 for Problem: Can't build with MzScheme.
Bram Moolenaar <bram@vim.org>
parents:
6731
diff
changeset
|
756 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
|
757 vim_free(start_dir); |
6 | 758 |
759 #ifdef FEAT_DIFF | |
443 | 760 if (params.diff_mode) |
6 | 761 { |
762 win_T *wp; | |
763 | |
764 /* 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
|
765 FOR_ALL_WINDOWS(wp) |
6 | 766 diff_win_options(wp, TRUE); |
767 } | |
768 #endif | |
769 | |
770 /* | |
771 * Shorten any of the filenames, but only when absolute. | |
772 */ | |
773 shorten_fnames(FALSE); | |
774 | |
775 /* | |
776 * Need to jump to the tag before executing the '-c command'. | |
777 * Makes "vim -c '/return' -t main" work. | |
778 */ | |
443 | 779 if (params.tagname != NULL) |
6 | 780 { |
604 | 781 #if defined(HAS_SWAP_EXISTS_ACTION) |
782 swap_exists_did_quit = FALSE; | |
783 #endif | |
784 | |
443 | 785 vim_snprintf((char *)IObuff, IOSIZE, "ta %s", params.tagname); |
6 | 786 do_cmdline_cmd(IObuff); |
787 TIME_MSG("jumping to tag"); | |
604 | 788 |
789 #if defined(HAS_SWAP_EXISTS_ACTION) | |
790 /* If the user doesn't want to edit the file then we quit here. */ | |
791 if (swap_exists_did_quit) | |
792 getout(1); | |
793 #endif | |
6 | 794 } |
795 | |
443 | 796 /* Execute any "+", "-c" and "-S" arguments. */ |
797 if (params.n_commands > 0) | |
798 exe_commands(¶ms); | |
6 | 799 |
11492
5ccf1b222223
patch 8.0.0629: checking for ambigous width is not working
Christian Brabandt <cb@256bit.org>
parents:
11457
diff
changeset
|
800 /* Must come before the may_req_ calls. */ |
5ccf1b222223
patch 8.0.0629: checking for ambigous width is not working
Christian Brabandt <cb@256bit.org>
parents:
11457
diff
changeset
|
801 starting = 0; |
5ccf1b222223
patch 8.0.0629: checking for ambigous width is not working
Christian Brabandt <cb@256bit.org>
parents:
11457
diff
changeset
|
802 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15551
diff
changeset
|
803 #if defined(FEAT_TERMRESPONSE) |
11455
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11364
diff
changeset
|
804 /* Must be done before redrawing, puts a few characters on the screen. */ |
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11364
diff
changeset
|
805 may_req_ambiguous_char_width(); |
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11364
diff
changeset
|
806 #endif |
08e60ce4cbf3
patch 8.0.0611: the screen is not redrawn after sending t_u7
Christian Brabandt <cb@256bit.org>
parents:
11364
diff
changeset
|
807 |
6 | 808 RedrawingDisabled = 0; |
809 redraw_all_later(NOT_VALID); | |
810 no_wait_return = FALSE; | |
811 | |
8857
df68de6b6f1c
commit https://github.com/vim/vim/commit/baec5c1768098f9dd867b465aaabfdfb294f10c2
Christian Brabandt <cb@256bit.org>
parents:
8738
diff
changeset
|
812 /* '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
|
813 DO_AUTOCHDIR; |
8857
df68de6b6f1c
commit https://github.com/vim/vim/commit/baec5c1768098f9dd867b465aaabfdfb294f10c2
Christian Brabandt <cb@256bit.org>
parents:
8738
diff
changeset
|
814 |
626 | 815 #ifdef FEAT_TERMRESPONSE |
816 /* Requesting the termresponse is postponed until here, so that a "-c q" | |
817 * argument doesn't make it appear in the shell Vim was started from. */ | |
818 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
|
819 |
0ef92445b4f6
patch 8.0.0567: call for requesting color and ambiwidth is too early
Christian Brabandt <cb@256bit.org>
parents:
11309
diff
changeset
|
820 may_req_bg_color(); |
626 | 821 #endif |
822 | |
6 | 823 /* start in insert mode */ |
824 if (p_im) | |
825 need_start_insertmode = TRUE; | |
826 | |
8738
e770986c855a
commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
827 #ifdef FEAT_EVAL |
e770986c855a
commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
828 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
|
829 #endif |
6 | 830 apply_autocmds(EVENT_VIMENTER, NULL, NULL, FALSE, curbuf); |
831 TIME_MSG("VimEnter autocommands"); | |
832 | |
3488 | 833 #if defined(FEAT_EVAL) && defined(FEAT_CLIPBOARD) |
834 /* Adjust default register name for "unnamed" in 'clipboard'. Can only be | |
835 * done after the clipboard is available and all initial commands that may | |
836 * modify the 'clipboard' setting have run; i.e. just before entering the | |
837 * main loop. */ | |
838 { | |
839 int default_regname = 0; | |
7410
08e62c4fc17d
commit https://github.com/vim/vim/commit/53076830fea6df737455523f7e235bfe4f79864d
Christian Brabandt <cb@256bit.org>
parents:
6923
diff
changeset
|
840 |
3488 | 841 adjust_clip_reg(&default_regname); |
842 set_reg_var(default_regname); | |
843 } | |
844 #endif | |
845 | |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
846 #if defined(FEAT_DIFF) |
6 | 847 /* When a startup script or session file setup for diff'ing and |
848 * scrollbind, sync the scrollbind now. */ | |
849 if (curwin->w_p_diff && curwin->w_p_scb) | |
850 { | |
851 update_topline(); | |
852 check_scrollbind((linenr_T)0, 0L); | |
853 TIME_MSG("diff scrollbinding"); | |
854 } | |
855 #endif | |
856 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
857 #if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) |
6 | 858 mch_set_winsize_now(); /* Allow winsize changes from now on */ |
859 #endif | |
860 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
861 #if defined(FEAT_GUI) |
685 | 862 /* When tab pages were created, may need to update the tab pages line and |
863 * scrollbars. This is skipped while creating them. */ | |
864 if (first_tabpage->tp_next != NULL) | |
865 { | |
866 out_flush(); | |
867 gui_init_which_components(NULL); | |
868 gui_update_scrollbars(TRUE); | |
869 } | |
870 need_mouse_correct = TRUE; | |
871 #endif | |
872 | |
6 | 873 /* If ":startinsert" command used, stuff a dummy command to be able to |
874 * call normal_cmd(), which will then start Insert mode. */ | |
875 if (restart_edit != 0) | |
620 | 876 stuffcharReadbuff(K_NOP); |
6 | 877 |
878 #ifdef FEAT_NETBEANS_INTG | |
2210 | 879 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
|
880 { |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
881 # ifdef FEAT_GUI |
2592 | 882 # 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
|
883 && !defined(FEAT_GUI_MSWIN) |
2209
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
884 if (gui.in_use) |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
885 { |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
886 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
|
887 mch_exit(2); |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
888 } |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
889 # endif |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
890 # endif |
6 | 891 /* Tell the client that it can start sending commands. */ |
2210 | 892 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
|
893 } |
6 | 894 #endif |
895 | |
896 TIME_MSG("before starting main loop"); | |
897 | |
898 /* | |
899 * 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
|
900 */ |
169 | 901 main_loop(FALSE, FALSE); |
6 | 902 |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
903 #endif /* NO_VIM_MAIN */ |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
904 |
6 | 905 return 0; |
906 } | |
907 | |
908 /* | |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
909 * 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
|
910 */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
911 void |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
912 common_init(mparm_T *paramp) |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
913 { |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14764
diff
changeset
|
914 cmdline_init(); |
9542
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 (void)mb_init(); /* init mb_bytelen_tab[] to ones */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
917 #ifdef FEAT_EVAL |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
918 eval_init(); /* init global variables */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
919 #endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
920 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
921 #ifdef __QNXNTO__ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
922 qnx_init(); /* PhAttach() for clipboard, (and gui) */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
923 #endif |
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 /* Init the table of Normal mode commands. */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
926 init_normal_cmds(); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
927 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
928 /* |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
929 * 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
|
930 * emsg()). |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
931 */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
932 if ((IObuff = alloc(IOSIZE)) == NULL |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
933 || (NameBuff = alloc(MAXPATHL)) == NULL) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
934 mch_exit(0); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
935 TIME_MSG("Allocated generic buffers"); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
936 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
937 #ifdef NBDEBUG |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
938 /* Wait a moment for debugging NetBeans. Must be after allocating |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
939 * NameBuff. */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
940 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
|
941 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
|
942 TIME_MSG("NetBeans debug wait"); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
943 #endif |
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 #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
|
946 /* |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
947 * 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
|
948 * 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
|
949 * 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
|
950 */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
951 init_locale(); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
952 TIME_MSG("locale set"); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
953 #endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
954 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
955 #ifdef FEAT_GUI |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
956 gui.dofork = TRUE; /* default is to use fork() */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
957 #endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
958 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
959 /* |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
960 * 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
|
961 * -display or --display |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
962 * --server... |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
963 * --socketid |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
964 * --windowid |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
965 */ |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9778
diff
changeset
|
966 early_arg_scan(paramp); |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
967 |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12678
diff
changeset
|
968 #if defined(FEAT_GUI) |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
969 /* 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
|
970 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
|
971 TIME_MSG("GUI prepared"); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
972 #endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
973 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
974 #ifdef FEAT_CLIPBOARD |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
975 clip_init(FALSE); /* Initialise clipboard stuff */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
976 TIME_MSG("clipboard setup"); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
977 #endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
978 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
979 /* |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
980 * 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
|
981 * 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
|
982 * (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
|
983 * -dev argument. |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
984 */ |
10404
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
985 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
|
986 TIME_MSG("window checked"); |
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 * Allocate the first window and buffer. |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
990 * 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
|
991 */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
992 if (win_alloc_first() == FAIL) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
993 mch_exit(0); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
994 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
995 init_yank(); /* init yank buffers */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
996 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
997 alist_init(&global_alist); /* Init the argument list to empty. */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
998 global_alist.id = 0; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
999 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1000 /* |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1001 * 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
|
1002 * 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
|
1003 * 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
|
1004 * msg_outtrans_len_attr(). |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1005 * 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
|
1006 */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1007 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
|
1008 set_init_1(paramp->clean); |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1009 TIME_MSG("inits 1"); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1010 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1011 #ifdef FEAT_EVAL |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1012 set_lang_var(); /* set v:lang and v:ctype */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1013 #endif |
15271
a6319aca721b
patch 8.1.0644: finding next sign ID is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
1014 |
a6319aca721b
patch 8.1.0644: finding next sign ID is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
1015 #ifdef FEAT_SIGNS |
a6319aca721b
patch 8.1.0644: finding next sign ID is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
1016 init_signs(); |
a6319aca721b
patch 8.1.0644: finding next sign ID is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
15008
diff
changeset
|
1017 #endif |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1018 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1019 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1020 /* |
11307
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
1021 * 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
|
1022 */ |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
1023 int |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
1024 is_not_a_term() |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
1025 { |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
1026 return params.not_a_term; |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
1027 } |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
1028 |
6e1c19d3de03
patch 8.0.0539: startup test fails on Mac
Christian Brabandt <cb@256bit.org>
parents:
11215
diff
changeset
|
1029 /* |
6 | 1030 * Main loop: Execute Normal mode commands until exiting Vim. |
1031 * Also used to handle commands in the command-line window, until the window | |
1032 * is closed. | |
169 | 1033 * Also used to handle ":visual" command after ":global": execute Normal mode |
1034 * commands, return when entering Ex mode. "noexmode" is TRUE then. | |
6 | 1035 */ |
1036 void | |
7598
1a528724f9d6
commit https://github.com/vim/vim/commit/b7604cc19fa1db6a8182546bf662aa13d4574d7a
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1037 main_loop( |
1a528724f9d6
commit https://github.com/vim/vim/commit/b7604cc19fa1db6a8182546bf662aa13d4574d7a
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1038 int cmdwin, /* TRUE when working in the command-line window */ |
1a528724f9d6
commit https://github.com/vim/vim/commit/b7604cc19fa1db6a8182546bf662aa13d4574d7a
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1039 int noexmode) /* TRUE when return on entering Ex mode */ |
6 | 1040 { |
13708
7c84c16fd376
patch 8.0.1726: older MSVC doesn't support declarations halfway a block
Christian Brabandt <cb@256bit.org>
parents:
13704
diff
changeset
|
1041 oparg_T oa; /* operator arguments */ |
6604 | 1042 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
|
1043 #ifdef FEAT_CONCEAL |
6923 | 1044 /* these are static to avoid a compiler warning */ |
1045 static linenr_T conceal_old_cursor_line = 0; | |
1046 static linenr_T conceal_new_cursor_line = 0; | |
1047 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
|
1048 #endif |
6 | 1049 |
1050 #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) | |
1051 /* Setup to catch a terminating error from the X server. Just ignore | |
1052 * it, restore the state and continue. This might not always work | |
1053 * properly, but at least we don't exit unexpectedly when the X server | |
5598 | 1054 * exits while Vim is running in a console. */ |
169 | 1055 if (!cmdwin && !noexmode && SETJMP(x_jump_env)) |
6 | 1056 { |
1057 State = NORMAL; | |
1058 VIsual_active = FALSE; | |
1059 got_int = TRUE; | |
1060 need_wait_return = FALSE; | |
1061 global_busy = FALSE; | |
1062 exmode_active = 0; | |
1063 skip_redraw = FALSE; | |
1064 RedrawingDisabled = 0; | |
1065 no_wait_return = 0; | |
3119 | 1066 vgetc_busy = 0; |
6 | 1067 # ifdef FEAT_EVAL |
1068 emsg_skip = 0; | |
1069 # endif | |
1070 emsg_off = 0; | |
1071 # ifdef FEAT_MOUSE | |
1072 setmouse(); | |
1073 # endif | |
1074 settmode(TMODE_RAW); | |
1075 starttermcap(); | |
1076 scroll_start(); | |
1077 redraw_later_clear(); | |
1078 } | |
1079 #endif | |
1080 | |
1081 clear_oparg(&oa); | |
1082 while (!cmdwin | |
1083 #ifdef FEAT_CMDWIN | |
1084 || cmdwin_result == 0 | |
1085 #endif | |
1086 ) | |
1087 { | |
1088 if (stuff_empty()) | |
1089 { | |
1090 did_check_timestamps = FALSE; | |
1091 if (need_check_timestamps) | |
1092 check_timestamps(FALSE); | |
1093 if (need_wait_return) /* if wait_return still needed ... */ | |
1094 wait_return(FALSE); /* ... call it now */ | |
5735 | 1095 if (need_start_insertmode && goto_im() && !VIsual_active) |
6 | 1096 { |
1097 need_start_insertmode = FALSE; | |
1098 stuffReadbuff((char_u *)"i"); /* start insert mode next */ | |
1099 /* skip the fileinfo message now, because it would be shown | |
1100 * after insert mode finishes! */ | |
1101 need_fileinfo = FALSE; | |
1102 } | |
1103 } | |
1345 | 1104 |
1105 /* Reset "got_int" now that we got back to the main loop. Except when | |
1106 * inside a ":g/pat/cmd" command, then the "got_int" needs to abort | |
1107 * the ":g" command. | |
1108 * For ":g/pat/vi" we reset "got_int" when used once. When used | |
1109 * a second time we go back to Ex mode and abort the ":g" command. */ | |
1110 if (got_int) | |
6 | 1111 { |
1345 | 1112 if (noexmode && global_busy && !exmode_active && previous_got_int) |
1113 { | |
1114 /* Typed two CTRL-C in a row: go back to ex mode as if "Q" was | |
1115 * used and keep "got_int" set, so that it aborts ":g". */ | |
1116 exmode_active = EXMODE_NORMAL; | |
1117 State = NORMAL; | |
1118 } | |
1119 else if (!global_busy || !exmode_active) | |
1120 { | |
1121 if (!quit_more) | |
1122 (void)vgetc(); /* flush all buffers */ | |
1123 got_int = FALSE; | |
1124 } | |
1125 previous_got_int = TRUE; | |
6 | 1126 } |
1345 | 1127 else |
1128 previous_got_int = FALSE; | |
1129 | |
6 | 1130 if (!exmode_active) |
1131 msg_scroll = FALSE; | |
1132 quit_more = FALSE; | |
1133 | |
1134 /* | |
1135 * If skip redraw is set (for ":" in wait_return()), don't redraw now. | |
1136 * If there is nothing in the stuff_buffer or do_redraw is TRUE, | |
1137 * update cursor and redraw. | |
1138 */ | |
1139 if (skip_redraw || exmode_active) | |
1140 skip_redraw = FALSE; | |
1141 else if (do_redraw || stuff_empty()) | |
1142 { | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1143 #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
|
1144 // 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
|
1145 gui_may_resize_shell(); |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1146 #endif |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14171
diff
changeset
|
1147 #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
|
1148 // 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
|
1149 // 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
|
1150 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
|
1151 #endif |
15476
5b0f37d844b3
patch 8.1.0746: highlighting not updated with conceal and 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1152 #ifdef FEAT_CONCEAL |
5b0f37d844b3
patch 8.1.0746: highlighting not updated with conceal and 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1153 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
|
1154 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
|
1155 #endif |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14171
diff
changeset
|
1156 |
662 | 1157 /* 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
|
1158 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
|
1159 has_cursormoved() |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1160 #ifdef FEAT_CONCEAL |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1161 || curwin->w_p_cole > 0 |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1162 #endif |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1163 ) |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1164 && !EQUAL_POS(last_cursormoved, curwin->w_cursor)) |
662 | 1165 { |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1166 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
|
1167 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
|
1168 FALSE, curbuf); |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1169 # 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
|
1170 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
|
1171 { |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1172 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
|
1173 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
|
1174 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
|
1175 } |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1176 # endif |
662 | 1177 last_cursormoved = curwin->w_cursor; |
1178 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1179 |
15436
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1180 #if defined(FEAT_CONCEAL) |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1181 if (conceal_update_lines |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1182 && (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
|
1183 || conceal_cursor_line(curwin) |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1184 || need_cursor_line_redraw)) |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1185 { |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1186 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
|
1187 && 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
|
1188 && conceal_old_cursor_line |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1189 <= 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
|
1190 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
|
1191 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
|
1192 curwin->w_valid &= ~VALID_CROW; |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1193 need_cursor_line_redraw = FALSE; |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1194 } |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1195 #endif |
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15271
diff
changeset
|
1196 |
10952
835604f3c37a
patch 8.0.0365: might free a dict item that wasn't allocated
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
1197 /* Trigger TextChanged if b:changedtick differs. */ |
4232 | 1198 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
|
1199 && curbuf->b_last_changedtick != CHANGEDTICK(curbuf)) |
4232 | 1200 { |
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
|
1201 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
|
1202 curbuf->b_last_changedtick = CHANGEDTICK(curbuf); |
4232 | 1203 } |
1204 | |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
1205 #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
|
1206 // 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
|
1207 // 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
|
1208 // needed. |
f562b9fbd0d3
patch 8.1.0394: diffs are not always updated correctly
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1209 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
|
1210 { |
f562b9fbd0d3
patch 8.1.0394: diffs are not always updated correctly
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1211 ex_diffupdate(NULL); |
f562b9fbd0d3
patch 8.1.0394: diffs are not always updated correctly
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1212 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
|
1213 } |
f562b9fbd0d3
patch 8.1.0394: diffs are not always updated correctly
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1214 |
640 | 1215 /* Scroll-binding for diff mode may have been postponed until |
1216 * here. Avoids doing it for every change. */ | |
1217 if (diff_need_scrollbind) | |
1218 { | |
1219 check_scrollbind((linenr_T)0, 0L); | |
1220 diff_need_scrollbind = FALSE; | |
1221 } | |
1222 #endif | |
5735 | 1223 #if defined(FEAT_FOLDING) |
6 | 1224 /* Include a closed fold completely in the Visual area. */ |
1225 foldAdjustVisual(); | |
1226 #endif | |
1227 #ifdef FEAT_FOLDING | |
1228 /* | |
1229 * When 'foldclose' is set, apply 'foldlevel' to folds that don't | |
1230 * contain the cursor. | |
1231 * When 'foldopen' is "all", open the fold(s) under the cursor. | |
1232 * This may mark the window for redrawing. | |
1233 */ | |
1234 if (hasAnyFolding(curwin) && !char_avail()) | |
1235 { | |
1236 foldCheckClose(); | |
1237 if (fdo_flags & FDO_ALL) | |
1238 foldOpenCursor(); | |
1239 } | |
1240 #endif | |
1241 | |
1242 /* | |
1243 * Before redrawing, make sure w_topline is correct, and w_leftcol | |
1244 * if lines don't wrap, and w_skipcol if lines wrap. | |
1245 */ | |
1246 update_topline(); | |
1247 validate_cursor(); | |
1248 | |
1249 if (VIsual_active) | |
1250 update_curbuf(INVERTED);/* update inverted part */ | |
5735 | 1251 else if (must_redraw) |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
1252 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
1253 mch_disable_flush(); /* Stop issuing gui_mch_flush(). */ |
6 | 1254 update_screen(0); |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
1255 mch_enable_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
1256 } |
6 | 1257 else if (redraw_cmdline || clear_cmdline) |
1258 showmode(); | |
1259 redraw_statuslines(); | |
1260 #ifdef FEAT_TITLE | |
1261 if (need_maketitle) | |
1262 maketitle(); | |
1263 #endif | |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9403
diff
changeset
|
1264 #ifdef FEAT_VIMINFO |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9403
diff
changeset
|
1265 curbuf->b_last_used = vim_time(); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9403
diff
changeset
|
1266 #endif |
6 | 1267 /* display message after redraw */ |
1268 if (keep_msg != NULL) | |
1269 { | |
1270 char_u *p; | |
1271 | |
1272 /* msg_attr_keep() will set keep_msg to NULL, must free the | |
6207 | 1273 * string here. Don't reset keep_msg, msg_attr_keep() uses it |
1274 * to check for duplicates. */ | |
6 | 1275 p = keep_msg; |
15551
b069a878bbeb
patch 8.1.0783: compiler warning for signed/unsigned
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
1276 msg_attr((char *)p, keep_msg_attr); |
6 | 1277 vim_free(p); |
1278 } | |
1279 if (need_fileinfo) /* show file info after redraw */ | |
1280 { | |
1281 fileinfo(FALSE, TRUE, FALSE); | |
1282 need_fileinfo = FALSE; | |
1283 } | |
1284 | |
1285 emsg_on_display = FALSE; /* can delete error message now */ | |
1286 did_emsg = FALSE; | |
1287 msg_didany = FALSE; /* reset lines_left in msg_start() */ | |
448 | 1288 may_clear_sb_text(); /* clear scroll-back text on next msg */ |
6 | 1289 showruler(FALSE); |
1290 | |
1291 setcursor(); | |
1292 cursor_on(); | |
1293 | |
1294 do_redraw = FALSE; | |
1972 | 1295 |
1296 #ifdef STARTUPTIME | |
1297 /* Now that we have drawn the first screen all the startup stuff | |
1298 * has been done, close any file for startup messages. */ | |
1299 if (time_fd != NULL) | |
1300 { | |
1301 TIME_MSG("first screen update"); | |
1302 TIME_MSG("--- VIM STARTED ---"); | |
1303 fclose(time_fd); | |
1304 time_fd = NULL; | |
1305 } | |
1306 #endif | |
6 | 1307 } |
1308 #ifdef FEAT_GUI | |
1309 if (need_mouse_correct) | |
1310 gui_mouse_correct(); | |
1311 #endif | |
1312 | |
1313 /* | |
1314 * Update w_curswant if w_set_curswant has been set. | |
1315 * Postponed until here to avoid computing w_virtcol too often. | |
1316 */ | |
1317 update_curswant(); | |
1318 | |
958 | 1319 #ifdef FEAT_EVAL |
1320 /* | |
1321 * May perform garbage collection when waiting for a character, but | |
1322 * only at the very toplevel. Otherwise we may be using a List or | |
1323 * Dict internally somewhere. | |
1324 * "may_garbage_collect" is reset in vgetc() which is invoked through | |
1325 * do_exmode() and normal_cmd(). | |
1326 */ | |
1327 may_garbage_collect = (!cmdwin && !noexmode); | |
1328 #endif | |
6 | 1329 /* |
1330 * If we're invoked as ex, do a round of ex commands. | |
1331 * Otherwise, get and execute a normal mode command. | |
1332 */ | |
1333 if (exmode_active) | |
169 | 1334 { |
1335 if (noexmode) /* End of ":global/path/visual" commands */ | |
1336 return; | |
6 | 1337 do_exmode(exmode_active == EXMODE_VIM); |
169 | 1338 } |
6 | 1339 else |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1340 { |
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1341 #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
|
1342 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
|
1343 && 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
|
1344 && !VIsual_active |
cb731d098241
patch 8.1.0082: in terminal window, typing : at more prompt, inserts ':'
Christian Brabandt <cb@256bit.org>
parents:
13841
diff
changeset
|
1345 && !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
|
1346 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
1347 /* If terminal_loop() returns OK we got a key that is handled |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1348 * in Normal model. With FAIL we first need to position the |
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1349 * 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
|
1350 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
|
1351 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
|
1352 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
1353 else |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1354 #endif |
14129
cb731d098241
patch 8.1.0082: in terminal window, typing : at more prompt, inserts ':'
Christian Brabandt <cb@256bit.org>
parents:
13841
diff
changeset
|
1355 { |
cb731d098241
patch 8.1.0082: in terminal window, typing : at more prompt, inserts ':'
Christian Brabandt <cb@256bit.org>
parents:
13841
diff
changeset
|
1356 #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
|
1357 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
|
1358 #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
|
1359 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
|
1360 } |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1361 } |
6 | 1362 } |
1363 } | |
1364 | |
1365 | |
8617
eab968bf3ce7
commit https://github.com/vim/vim/commit/6d8d849f5ac8a3a228c62fd29e8f40ae1b8381fc
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
1366 #if defined(USE_XSMP) || defined(FEAT_GUI) || defined(PROTO) |
6 | 1367 /* |
1368 * Exit, but leave behind swap files for modified buffers. | |
1369 */ | |
1370 void | |
7598
1a528724f9d6
commit https://github.com/vim/vim/commit/b7604cc19fa1db6a8182546bf662aa13d4574d7a
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1371 getout_preserve_modified(int exitval) |
6 | 1372 { |
39 | 1373 # if defined(SIGHUP) && defined(SIG_IGN) |
1374 /* Ignore SIGHUP, because a dropped connection causes a read error, which | |
1375 * makes Vim exit and then handling SIGHUP causes various reentrance | |
1376 * problems. */ | |
36 | 1377 signal(SIGHUP, SIG_IGN); |
39 | 1378 # endif |
36 | 1379 |
6 | 1380 ml_close_notmod(); /* close all not-modified buffers */ |
1381 ml_sync_all(FALSE, FALSE); /* preserve all swap files */ | |
1382 ml_close_all(FALSE); /* close all memfiles, without deleting */ | |
1383 getout(exitval); /* exit Vim properly */ | |
1384 } | |
1385 #endif | |
1386 | |
1387 | |
8617
eab968bf3ce7
commit https://github.com/vim/vim/commit/6d8d849f5ac8a3a228c62fd29e8f40ae1b8381fc
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
1388 /* |
eab968bf3ce7
commit https://github.com/vim/vim/commit/6d8d849f5ac8a3a228c62fd29e8f40ae1b8381fc
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
1389 * Exit properly. |
eab968bf3ce7
commit https://github.com/vim/vim/commit/6d8d849f5ac8a3a228c62fd29e8f40ae1b8381fc
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
1390 */ |
6 | 1391 void |
7598
1a528724f9d6
commit https://github.com/vim/vim/commit/b7604cc19fa1db6a8182546bf662aa13d4574d7a
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
1392 getout(int exitval) |
6 | 1393 { |
1394 exiting = TRUE; | |
13509
0c56cfb463f0
patch 8.0.1628: channel log doesn't mention exiting
Christian Brabandt <cb@256bit.org>
parents:
13466
diff
changeset
|
1395 #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
|
1396 ch_log(NULL, "Exiting..."); |
0c56cfb463f0
patch 8.0.1628: channel log doesn't mention exiting
Christian Brabandt <cb@256bit.org>
parents:
13466
diff
changeset
|
1397 #endif |
6 | 1398 |
169 | 1399 /* When running in Ex mode an error causes us to exit with a non-zero exit |
1400 * code. POSIX requires this, although it's not 100% clear from the | |
1401 * standard. */ | |
1402 if (exmode_active) | |
1403 exitval += ex_exitval; | |
1404 | |
6 | 1405 /* Position the cursor on the last screen line, below all the text */ |
1406 #ifdef FEAT_GUI | |
1407 if (!gui.in_use) | |
1408 #endif | |
1409 windgoto((int)Rows - 1, 0); | |
1410 | |
242 | 1411 #if defined(FEAT_EVAL) || defined(FEAT_SYN_HL) |
1412 /* Optionally print hashtable efficiency. */ | |
1413 hash_debug_results(); | |
1414 #endif | |
1415 | |
6 | 1416 #ifdef FEAT_GUI |
1417 msg_didany = FALSE; | |
1418 #endif | |
1419 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1420 if (v_dying <= 1) |
6 | 1421 { |
13708
7c84c16fd376
patch 8.0.1726: older MSVC doesn't support declarations halfway a block
Christian Brabandt <cb@256bit.org>
parents:
13704
diff
changeset
|
1422 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
|
1423 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
|
1424 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
|
1425 win_T *wp; |
7c84c16fd376
patch 8.0.1726: older MSVC doesn't support declarations halfway a block
Christian Brabandt <cb@256bit.org>
parents:
13704
diff
changeset
|
1426 |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1427 /* Trigger BufWinLeave for all windows, but only once per buffer. */ |
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1428 for (tp = first_tabpage; tp != NULL; tp = next_tp) |
6 | 1429 { |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1430 next_tp = tp->tp_next; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9542
diff
changeset
|
1431 FOR_ALL_WINDOWS_IN_TAB(tp, wp) |
671 | 1432 { |
4021 | 1433 if (wp->w_buffer == NULL) |
1434 /* Autocmd must have close the buffer already, skip. */ | |
1435 continue; | |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1436 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
|
1437 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
|
1438 { |
13058
1293c33ff452
patch 8.0.1404: invalid memory access on exit
Christian Brabandt <cb@256bit.org>
parents:
12837
diff
changeset
|
1439 bufref_T bufref; |
1293c33ff452
patch 8.0.1404: invalid memory access on exit
Christian Brabandt <cb@256bit.org>
parents:
12837
diff
changeset
|
1440 |
1293c33ff452
patch 8.0.1404: invalid memory access on exit
Christian Brabandt <cb@256bit.org>
parents:
12837
diff
changeset
|
1441 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
|
1442 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
|
1443 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
|
1444 if (bufref_valid(&bufref)) |
1293c33ff452
patch 8.0.1404: invalid memory access on exit
Christian Brabandt <cb@256bit.org>
parents:
12837
diff
changeset
|
1445 CHANGEDTICK(buf) = -1; /* note we did it already */ |
1293c33ff452
patch 8.0.1404: invalid memory access on exit
Christian Brabandt <cb@256bit.org>
parents:
12837
diff
changeset
|
1446 |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1447 /* start all over, autocommands may mess up the lists */ |
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1448 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
|
1449 break; |
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1450 } |
671 | 1451 } |
6 | 1452 } |
640 | 1453 |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1454 /* 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
|
1455 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
|
1456 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
|
1457 { |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9414
diff
changeset
|
1458 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9414
diff
changeset
|
1459 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9414
diff
changeset
|
1460 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
|
1461 apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, |
6 | 1462 FALSE, buf); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9414
diff
changeset
|
1463 if (!bufref_valid(&bufref)) |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9414
diff
changeset
|
1464 /* 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
|
1465 break; |
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1466 } |
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1467 apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf); |
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1468 } |
6 | 1469 |
1470 #ifdef FEAT_VIMINFO | |
1471 if (*p_viminfo != NUL) | |
1472 /* Write out the registers, history, marks etc, to the viminfo file */ | |
1473 write_viminfo(NULL, FALSE); | |
1474 #endif | |
1475 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1476 if (v_dying <= 1) |
2226
36a9ac99e1ca
Don't execute some autocommands when v:dying is 2 or more.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
1477 apply_autocmds(EVENT_VIMLEAVE, NULL, NULL, FALSE, curbuf); |
6 | 1478 |
170 | 1479 #ifdef FEAT_PROFILE |
1480 profile_dump(); | |
1481 #endif | |
1482 | |
6 | 1483 if (did_emsg |
1484 #ifdef FEAT_GUI | |
1485 || (gui.in_use && msg_didany && p_verbose > 0) | |
1486 #endif | |
1487 ) | |
1488 { | |
1489 /* give the user a chance to read the (error) message */ | |
1490 no_wait_return = FALSE; | |
1491 wait_return(FALSE); | |
1492 } | |
1493 | |
1494 /* 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
|
1495 #ifdef FEAT_GUI |
6 | 1496 if (!gui.in_use) |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13363
diff
changeset
|
1497 #endif |
6 | 1498 windgoto((int)Rows - 1, 0); |
1499 | |
8493
caed4b2d305f
commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents:
8362
diff
changeset
|
1500 #ifdef FEAT_JOB_CHANNEL |
8170
a0ffb1f3dedc
commit https://github.com/vim/vim/commit/65edff8f51e9e54f85407bdb9156ae8e3e1b76a1
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
1501 job_stop_on_exit(); |
a0ffb1f3dedc
commit https://github.com/vim/vim/commit/65edff8f51e9e54f85407bdb9156ae8e3e1b76a1
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
1502 #endif |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2312
diff
changeset
|
1503 #ifdef FEAT_LUA |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2312
diff
changeset
|
1504 lua_end(); |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2312
diff
changeset
|
1505 #endif |
14 | 1506 #ifdef FEAT_MZSCHEME |
1507 mzscheme_end(); | |
1508 #endif | |
6 | 1509 #ifdef FEAT_TCL |
1510 tcl_end(); | |
1511 #endif | |
1512 #ifdef FEAT_RUBY | |
1513 ruby_end(); | |
1514 #endif | |
1515 #ifdef FEAT_PYTHON | |
1516 python_end(); | |
1517 #endif | |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
1518 #ifdef FEAT_PYTHON3 |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
1519 python3_end(); |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
1520 #endif |
6 | 1521 #ifdef FEAT_PERL |
1522 perl_end(); | |
1523 #endif | |
1524 #if defined(USE_ICONV) && defined(DYNAMIC_ICONV) | |
1525 iconv_end(); | |
1526 #endif | |
1527 #ifdef FEAT_NETBEANS_INTG | |
1528 netbeans_end(); | |
1529 #endif | |
1385 | 1530 #ifdef FEAT_CSCOPE |
1531 cs_end(); | |
1532 #endif | |
1405 | 1533 #ifdef FEAT_EVAL |
1534 if (garbage_collect_at_exit) | |
8881
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8857
diff
changeset
|
1535 garbage_collect(FALSE); |
1405 | 1536 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
1537 #ifdef MSWIN |
6193 | 1538 free_cmd_argsW(); |
1539 #endif | |
6 | 1540 |
1541 mch_exit(exitval); | |
1542 } | |
1543 | |
443 | 1544 #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) |
1545 /* | |
1546 * Setup to use the current locale (for ctype() and many other things). | |
1547 */ | |
1548 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1549 init_locale(void) |
443 | 1550 { |
1551 setlocale(LC_ALL, ""); | |
1624 | 1552 |
2201
4c6b4298852f
Other solution for GTK not changing the locale.
Bram Moolenaar <bram@vim.org>
parents:
2180
diff
changeset
|
1553 # ifdef FEAT_GUI_GTK |
4c6b4298852f
Other solution for GTK not changing the locale.
Bram Moolenaar <bram@vim.org>
parents:
2180
diff
changeset
|
1554 /* Tell Gtk not to change our locale settings. */ |
4c6b4298852f
Other solution for GTK not changing the locale.
Bram Moolenaar <bram@vim.org>
parents:
2180
diff
changeset
|
1555 gtk_disable_setlocale(); |
4c6b4298852f
Other solution for GTK not changing the locale.
Bram Moolenaar <bram@vim.org>
parents:
2180
diff
changeset
|
1556 # endif |
1624 | 1557 # if defined(FEAT_FLOAT) && defined(LC_NUMERIC) |
1558 /* Make sure strtod() uses a decimal point, not a comma. */ | |
1559 setlocale(LC_NUMERIC, "C"); | |
1560 # endif | |
1561 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
1562 # ifdef MSWIN |
534 | 1563 /* Apparently MS-Windows printf() may cause a crash when we give it 8-bit |
1564 * text while it's expecting text in the current locale. This call avoids | |
1565 * that. */ | |
1566 setlocale(LC_CTYPE, "C"); | |
1567 # endif | |
443 | 1568 |
1569 # ifdef FEAT_GETTEXT | |
1570 { | |
1571 int mustfree = FALSE; | |
1572 char_u *p; | |
1573 | |
1574 # ifdef DYNAMIC_GETTEXT | |
1575 /* Initialize the gettext library */ | |
7613
4456fa2d22e8
commit https://github.com/vim/vim/commit/286eacd3f6631e985089176fb1dff1bcf1a1d6b5
Christian Brabandt <cb@256bit.org>
parents:
7598
diff
changeset
|
1576 dyn_libintl_init(); |
443 | 1577 # endif |
7697
f04e2b6feea2
commit https://github.com/vim/vim/commit/88e8f9f14434a7cd538d0c159dc432bea869a5bd
Christian Brabandt <cb@256bit.org>
parents:
7613
diff
changeset
|
1578 /* expand_env() doesn't work yet, because g_chartab[] is not |
f04e2b6feea2
commit https://github.com/vim/vim/commit/88e8f9f14434a7cd538d0c159dc432bea869a5bd
Christian Brabandt <cb@256bit.org>
parents:
7613
diff
changeset
|
1579 * initialized yet, call vim_getenv() directly */ |
443 | 1580 p = vim_getenv((char_u *)"VIMRUNTIME", &mustfree); |
1581 if (p != NULL && *p != NUL) | |
1582 { | |
1297 | 1583 vim_snprintf((char *)NameBuff, MAXPATHL, "%s/lang", p); |
443 | 1584 bindtextdomain(VIMPACKAGE, (char *)NameBuff); |
1585 } | |
1586 if (mustfree) | |
1587 vim_free(p); | |
1588 textdomain(VIMPACKAGE); | |
1589 } | |
1590 # endif | |
1591 } | |
1592 #endif | |
1593 | |
1594 /* | |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1595 * 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
|
1596 * 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
|
1597 * |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1598 * 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
|
1599 */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1600 static void |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1601 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
|
1602 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1603 #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
|
1604 || !defined(FEAT_NETBEANS_INTG) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1605 int argc = parmp->argc; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1606 char **argv = parmp->argv; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1607 int i; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1608 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1609 for (i = 1; i < argc; i++) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1610 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1611 if (STRCMP(argv[i], "--") == 0) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1612 break; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1613 # ifdef FEAT_XCLIPBOARD |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1614 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
|
1615 # if defined(FEAT_GUI_GTK) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1616 || STRICMP(argv[i], "--display") == 0 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1617 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1618 ) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1619 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1620 if (i == argc - 1) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1621 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
|
1622 xterm_display = argv[++i]; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1623 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1624 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1625 # ifdef FEAT_CLIENTSERVER |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1626 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
|
1627 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1628 if (i == argc - 1) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1629 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
|
1630 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
|
1631 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1632 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
|
1633 parmp->serverArg = TRUE; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1634 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
|
1635 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1636 parmp->serverArg = TRUE; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1637 # ifdef FEAT_GUI |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1638 if (strstr(argv[i], "-wait") != 0) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1639 /* don't fork() when starting the GUI to edit files ourself */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1640 gui.dofork = FALSE; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1641 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1642 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1643 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1644 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
1645 # 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
|
1646 # ifdef FEAT_GUI_MSWIN |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1647 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
|
1648 # else |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1649 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
|
1650 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1651 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1652 long_u id; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1653 int count; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1654 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1655 if (i == argc - 1) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1656 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
|
1657 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
|
1658 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
|
1659 else |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1660 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
|
1661 if (count != 1) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1662 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
|
1663 else |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
1664 # ifdef FEAT_GUI_MSWIN |
9542
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1665 win_socket_id = id; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1666 # else |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1667 gtk_socket_id = id; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1668 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1669 i++; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1670 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1671 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1672 # ifdef FEAT_GUI_GTK |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1673 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
|
1674 echo_wid_arg = TRUE; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1675 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1676 # ifndef FEAT_NETBEANS_INTG |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1677 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
|
1678 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1679 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
|
1680 mch_exit(2); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1681 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1682 # endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1683 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1684 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1685 #endif |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1686 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1687 |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1688 #ifndef NO_VIM_MAIN |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1689 /* |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1690 * 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
|
1691 */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1692 static int |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1693 get_number_arg( |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1694 char_u *p, /* pointer to argument */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1695 int *idx, /* index in argument, is incremented */ |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1696 int def) /* default value */ |
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 if (vim_isdigit(p[*idx])) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1699 { |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1700 def = atoi((char *)&(p[*idx])); |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1701 while (vim_isdigit(p[*idx])) |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1702 *idx = *idx + 1; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1703 } |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1704 return def; |
00ee8d8c2e0c
commit https://github.com/vim/vim/commit/502ae4ba63561c98ac69af26cd9883bfd18d225f
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
1705 } |
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 /* |
14927
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
1708 * Check for: [r][e][g][vi|vim|view][diff][ex[im]] (sort of) |
443 | 1709 * If the executable name starts with "r" we disable shell commands. |
1710 * If the next character is "e" we run in Easy mode. | |
1711 * If the next character is "g" we run the GUI version. | |
1712 * If the next characters are "view" we start in readonly mode. | |
1713 * If the next characters are "diff" or "vimdiff" we start in diff mode. | |
1714 * If the next characters are "ex" we start in Ex mode. If it's followed | |
1715 * by "im" use improved Ex mode. | |
1716 */ | |
1717 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1718 parse_command_name(mparm_T *parmp) |
443 | 1719 { |
1720 char_u *initstr; | |
1721 | |
1722 initstr = gettail((char_u *)parmp->argv[0]); | |
1723 | |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12678
diff
changeset
|
1724 #ifdef FEAT_GUI_MAC |
443 | 1725 /* An issue has been seen when launching Vim in such a way that |
1726 * $PWD/$ARGV[0] or $ARGV[0] is not the absolute path to the | |
1727 * executable or a symbolic link of it. Until this issue is resolved | |
1728 * we prohibit the GUI from being used. | |
1729 */ | |
1730 if (STRCMP(initstr, parmp->argv[0]) == 0) | |
1731 disallow_gui = TRUE; | |
1732 | |
1733 /* TODO: On MacOS X default to gui if argv[0] ends in: | |
769 | 1734 * /Vim.app/Contents/MacOS/Vim */ |
443 | 1735 #endif |
1736 | |
1737 #ifdef FEAT_EVAL | |
1738 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
|
1739 set_progpath((char_u *)parmp->argv[0]); |
443 | 1740 #endif |
1741 | |
1742 if (TOLOWER_ASC(initstr[0]) == 'r') | |
1743 { | |
1744 restricted = TRUE; | |
1745 ++initstr; | |
1746 } | |
1747 | |
2133
2b273c71a14b
updated for version 7.2.415
Bram Moolenaar <bram@zimbu.org>
parents:
2021
diff
changeset
|
1748 /* Use evim mode for "evim" and "egvim", not for "editor". */ |
443 | 1749 if (TOLOWER_ASC(initstr[0]) == 'e' |
1750 && (TOLOWER_ASC(initstr[1]) == 'v' | |
1751 || TOLOWER_ASC(initstr[1]) == 'g')) | |
1752 { | |
1753 #ifdef FEAT_GUI | |
1754 gui.starting = TRUE; | |
1755 #endif | |
1756 parmp->evim_mode = TRUE; | |
1757 ++initstr; | |
1758 } | |
1759 | |
1722 | 1760 /* "gvim" starts the GUI. Also accept "Gvim" for MS-Windows. */ |
1761 if (TOLOWER_ASC(initstr[0]) == 'g') | |
443 | 1762 { |
1763 main_start_gui(); | |
1764 #ifdef FEAT_GUI | |
1765 ++initstr; | |
1766 #endif | |
1767 } | |
1768 | |
1769 if (STRNICMP(initstr, "view", 4) == 0) | |
1770 { | |
1771 readonlymode = TRUE; | |
1772 curbuf->b_p_ro = TRUE; | |
1773 p_uc = 10000; /* don't update very often */ | |
1774 initstr += 4; | |
1775 } | |
1776 else if (STRNICMP(initstr, "vim", 3) == 0) | |
1777 initstr += 3; | |
1778 | |
14927
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
1779 // Catch "[r][g]vimdiff" and "[r][g]viewdiff". |
443 | 1780 if (STRICMP(initstr, "diff") == 0) |
1781 { | |
1782 #ifdef FEAT_DIFF | |
1783 parmp->diff_mode = TRUE; | |
1784 #else | |
1785 mch_errmsg(_("This Vim was not compiled with the diff feature.")); | |
1786 mch_errmsg("\n"); | |
1787 mch_exit(2); | |
1788 #endif | |
1789 } | |
1790 | |
14927
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
1791 // Checking for "ex" here may catch some weir names, such as "vimex" or |
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
1792 // "viewex", we assume the user knows that. |
443 | 1793 if (STRNICMP(initstr, "ex", 2) == 0) |
1794 { | |
1795 if (STRNICMP(initstr + 2, "im", 2) == 0) | |
1796 exmode_active = EXMODE_VIM; | |
1797 else | |
1798 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
|
1799 change_compatible(TRUE); // set 'compatible' |
443 | 1800 } |
1801 } | |
1802 | |
6 | 1803 /* |
443 | 1804 * Scan the command line arguments. |
1805 */ | |
1806 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1807 command_line_scan(mparm_T *parmp) |
443 | 1808 { |
1809 int argc = parmp->argc; | |
1810 char **argv = parmp->argv; | |
1811 int argv_idx; /* index in argv[n][] */ | |
1812 int had_minmin = FALSE; /* found "--" argument */ | |
1813 int want_argument; /* option argument with argument */ | |
1814 int c; | |
445 | 1815 char_u *p = NULL; |
443 | 1816 long n; |
1817 | |
1818 --argc; | |
1819 ++argv; | |
1820 argv_idx = 1; /* active option letter is argv[0][argv_idx] */ | |
1821 while (argc > 0) | |
1822 { | |
1823 /* | |
1824 * "+" or "+{number}" or "+/{pat}" or "+{command}" argument. | |
1825 */ | |
1826 if (argv[0][0] == '+' && !had_minmin) | |
1827 { | |
1828 if (parmp->n_commands >= MAX_ARG_CMDS) | |
1829 mainerr(ME_EXTRA_CMD, NULL); | |
1830 argv_idx = -1; /* skip to next argument */ | |
1831 if (argv[0][1] == NUL) | |
1832 parmp->commands[parmp->n_commands++] = (char_u *)"$"; | |
1833 else | |
1834 parmp->commands[parmp->n_commands++] = (char_u *)&(argv[0][1]); | |
1835 } | |
1836 | |
1837 /* | |
1838 * Optional argument. | |
1839 */ | |
1840 else if (argv[0][0] == '-' && !had_minmin) | |
1841 { | |
1842 want_argument = FALSE; | |
1843 c = argv[0][argv_idx++]; | |
1844 #ifdef VMS | |
1845 /* | |
1846 * VMS only uses upper case command lines. Interpret "-X" as "-x" | |
1847 * and "-/X" as "-X". | |
1848 */ | |
1849 if (c == '/') | |
1850 { | |
1851 c = argv[0][argv_idx++]; | |
1852 c = TOUPPER_ASC(c); | |
1853 } | |
1854 else | |
1855 c = TOLOWER_ASC(c); | |
1856 #endif | |
1857 switch (c) | |
1858 { | |
1859 case NUL: /* "vim -" read from stdin */ | |
1860 /* "ex -" silent mode */ | |
1861 if (exmode_active) | |
1862 silent_mode = TRUE; | |
1863 else | |
1864 { | |
1865 if (parmp->edit_type != EDIT_NONE) | |
1866 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); | |
1867 parmp->edit_type = EDIT_STDIN; | |
1868 read_cmd_fd = 2; /* read from stderr instead of stdin */ | |
1869 } | |
1870 argv_idx = -1; /* skip to next argument */ | |
1871 break; | |
1872 | |
1873 case '-': /* "--" don't take any more option arguments */ | |
1874 /* "--help" give help message */ | |
1875 /* "--version" give version message */ | |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
1876 /* "--clean" clean context */ |
443 | 1877 /* "--literal" take files literally */ |
1878 /* "--nofork" don't fork */ | |
8253
1b6a589a0efc
commit https://github.com/vim/vim/commit/49c39ff678e2ba9f7dc280b25368e12084a610cf
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
1879 /* "--not-a-term" don't warn for not a term */ |
10404
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1880 /* "--ttyfail" exit if not a term */ |
443 | 1881 /* "--noplugin[s]" skip plugins */ |
1882 /* "--cmd <cmd>" execute cmd before vimrc */ | |
1883 if (STRICMP(argv[0] + argv_idx, "help") == 0) | |
1884 usage(); | |
1885 else if (STRICMP(argv[0] + argv_idx, "version") == 0) | |
1886 { | |
1887 Columns = 80; /* need to init Columns */ | |
1888 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ | |
1889 list_version(); | |
1890 msg_putchar('\n'); | |
1891 msg_didout = FALSE; | |
1892 mch_exit(0); | |
1893 } | |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
1894 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
|
1895 { |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
1896 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
|
1897 #ifdef FEAT_GUI |
cf7cd0272011
patch 8.0.1607: --clean loads user settings from .gvimrc
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
1898 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
|
1899 #endif |
13361
65c29bd4548b
patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1900 parmp->clean = TRUE; |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
1901 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
|
1902 } |
443 | 1903 else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0) |
1904 { | |
7410
08e62c4fc17d
commit https://github.com/vim/vim/commit/53076830fea6df737455523f7e235bfe4f79864d
Christian Brabandt <cb@256bit.org>
parents:
6923
diff
changeset
|
1905 #ifdef EXPAND_FILENAMES |
443 | 1906 parmp->literal = TRUE; |
1907 #endif | |
1908 } | |
1909 else if (STRNICMP(argv[0] + argv_idx, "nofork", 6) == 0) | |
1910 { | |
1911 #ifdef FEAT_GUI | |
1912 gui.dofork = FALSE; /* don't fork() when starting GUI */ | |
1913 #endif | |
1914 } | |
1915 else if (STRNICMP(argv[0] + argv_idx, "noplugin", 8) == 0) | |
1916 p_lpl = FALSE; | |
8253
1b6a589a0efc
commit https://github.com/vim/vim/commit/49c39ff678e2ba9f7dc280b25368e12084a610cf
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
1917 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
|
1918 parmp->not_a_term = TRUE; |
10404
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1919 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
|
1920 parmp->tty_fail = TRUE; |
443 | 1921 else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0) |
1922 { | |
1923 want_argument = TRUE; | |
1924 argv_idx += 3; | |
1925 } | |
1989 | 1926 else if (STRNICMP(argv[0] + argv_idx, "startuptime", 11) == 0) |
1927 { | |
1928 want_argument = TRUE; | |
1929 argv_idx += 11; | |
1930 } | |
443 | 1931 #ifdef FEAT_CLIENTSERVER |
1932 else if (STRNICMP(argv[0] + argv_idx, "serverlist", 10) == 0) | |
1933 ; /* already processed -- no arg */ | |
1934 else if (STRNICMP(argv[0] + argv_idx, "servername", 10) == 0 | |
1935 || STRNICMP(argv[0] + argv_idx, "serversend", 10) == 0) | |
1936 { | |
1937 /* already processed -- snatch the following arg */ | |
1938 if (argc > 1) | |
1939 { | |
1940 --argc; | |
1941 ++argv; | |
1942 } | |
1943 } | |
1944 #endif | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
1945 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN) |
1376 | 1946 # ifdef FEAT_GUI_GTK |
443 | 1947 else if (STRNICMP(argv[0] + argv_idx, "socketid", 8) == 0) |
1376 | 1948 # else |
1949 else if (STRNICMP(argv[0] + argv_idx, "windowid", 8) == 0) | |
1950 # endif | |
443 | 1951 { |
1952 /* already processed -- snatch the following arg */ | |
1953 if (argc > 1) | |
1954 { | |
1955 --argc; | |
1956 ++argv; | |
1957 } | |
1958 } | |
1376 | 1959 #endif |
1960 #ifdef FEAT_GUI_GTK | |
443 | 1961 else if (STRNICMP(argv[0] + argv_idx, "echo-wid", 8) == 0) |
1962 { | |
1963 /* already processed, skip */ | |
1964 } | |
1965 #endif | |
1966 else | |
1967 { | |
1968 if (argv[0][argv_idx]) | |
1969 mainerr(ME_UNKNOWN_OPTION, (char_u *)argv[0]); | |
1970 had_minmin = TRUE; | |
1971 } | |
1972 if (!want_argument) | |
1973 argv_idx = -1; /* skip to next argument */ | |
1974 break; | |
1975 | |
1976 case 'A': /* "-A" start in Arabic mode */ | |
1977 #ifdef FEAT_ARABIC | |
1978 set_option_value((char_u *)"arabic", 1L, NULL, 0); | |
1979 #else | |
1980 mch_errmsg(_(e_noarabic)); | |
1981 mch_exit(2); | |
1982 #endif | |
1983 break; | |
1984 | |
1985 case 'b': /* "-b" binary mode */ | |
445 | 1986 /* Needs to be effective before expanding file names, because |
1987 * for Win32 this makes us edit a shortcut file itself, | |
1988 * instead of the file it links to. */ | |
1989 set_options_bin(curbuf->b_p_bin, 1, 0); | |
1990 curbuf->b_p_bin = 1; /* binary file I/O */ | |
443 | 1991 break; |
1992 | |
1993 case 'C': /* "-C" Compatible */ | |
1994 change_compatible(TRUE); | |
9678
8c9e13109df8
commit https://github.com/vim/vim/commit/b9a46fec3e79d1fc8c406084a41733c647a5e535
Christian Brabandt <cb@256bit.org>
parents:
9669
diff
changeset
|
1995 has_dash_c_arg = TRUE; |
443 | 1996 break; |
1997 | |
1998 case 'e': /* "-e" Ex mode */ | |
1999 exmode_active = EXMODE_NORMAL; | |
2000 break; | |
2001 | |
2002 case 'E': /* "-E" Improved Ex mode */ | |
2003 exmode_active = EXMODE_VIM; | |
2004 break; | |
2005 | |
2006 case 'f': /* "-f" GUI: run in foreground. Amiga: open | |
2007 window directly, not with newcli */ | |
2008 #ifdef FEAT_GUI | |
2009 gui.dofork = FALSE; /* don't fork() when starting GUI */ | |
2010 #endif | |
2011 break; | |
2012 | |
2013 case 'g': /* "-g" start GUI */ | |
2014 main_start_gui(); | |
2015 break; | |
2016 | |
15850
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
2017 case 'F': /* "-F" was for Farsi mode */ |
443 | 2018 mch_errmsg(_(e_nofarsi)); |
2019 mch_exit(2); | |
2020 break; | |
2021 | |
13841
032bc07c32da
patch 8.0.1792: MS-Windows users expect -? to work like --help
Christian Brabandt <cb@256bit.org>
parents:
13708
diff
changeset
|
2022 case '?': /* "-?" give help message (for MS-Windows) */ |
443 | 2023 case 'h': /* "-h" give help message */ |
2024 #ifdef FEAT_GUI_GNOME | |
2025 /* Tell usage() to exit for "gvim". */ | |
2026 gui.starting = FALSE; | |
2027 #endif | |
2028 usage(); | |
2029 break; | |
2030 | |
2031 case 'H': /* "-H" start in Hebrew mode: rl + hkmap set */ | |
2032 #ifdef FEAT_RIGHTLEFT | |
1509 | 2033 p_hkmap = TRUE; |
2034 set_option_value((char_u *)"rl", 1L, NULL, 0); | |
443 | 2035 #else |
2036 mch_errmsg(_(e_nohebrew)); | |
2037 mch_exit(2); | |
2038 #endif | |
2039 break; | |
2040 | |
2041 case 'l': /* "-l" lisp mode, 'lisp' and 'showmatch' on */ | |
2042 #ifdef FEAT_LISP | |
2043 set_option_value((char_u *)"lisp", 1L, NULL, 0); | |
2044 p_sm = TRUE; | |
2045 #endif | |
2046 break; | |
2047 | |
2048 case 'M': /* "-M" no changes or writing of files */ | |
2049 reset_modifiable(); | |
2050 /* FALLTHROUGH */ | |
2051 | |
2052 case 'm': /* "-m" no writing of files */ | |
2053 p_write = FALSE; | |
2054 break; | |
2055 | |
2056 case 'y': /* "-y" easy mode */ | |
2057 #ifdef FEAT_GUI | |
2058 gui.starting = TRUE; /* start GUI a bit later */ | |
2059 #endif | |
2060 parmp->evim_mode = TRUE; | |
2061 break; | |
2062 | |
2063 case 'N': /* "-N" Nocompatible */ | |
2064 change_compatible(FALSE); | |
2065 break; | |
2066 | |
2067 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
|
2068 #ifdef FEAT_NETBEANS_INTG |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
2069 /* checking for "-nb", netbeans parameters */ |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
2070 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
|
2071 { |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
2072 netbeansArg = argv[0]; |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
2073 argv_idx = -1; /* skip to next argument */ |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
2074 } |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
2075 else |
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
2076 #endif |
443 | 2077 parmp->no_swap_file = TRUE; |
2078 break; | |
2079 | |
673 | 2080 case 'p': /* "-p[N]" open N tab pages */ |
674 | 2081 #ifdef TARGET_API_MAC_OSX |
2082 /* For some reason on MacOS X, an argument like: | |
2083 -psn_0_10223617 is passed in when invoke from Finder | |
2084 or with the 'open' command */ | |
2085 if (argv[0][argv_idx] == 's') | |
2086 { | |
2087 argv_idx = -1; /* bypass full -psn */ | |
2088 main_start_gui(); | |
2089 break; | |
2090 } | |
2091 #endif | |
673 | 2092 /* default is 0: open window for each file */ |
2093 parmp->window_count = get_number_arg((char_u *)argv[0], | |
2094 &argv_idx, 0); | |
2095 parmp->window_layout = WIN_TABS; | |
2096 break; | |
2097 | |
443 | 2098 case 'o': /* "-o[N]" open N horizontal split windows */ |
2099 /* default is 0: open window for each file */ | |
445 | 2100 parmp->window_count = get_number_arg((char_u *)argv[0], |
2101 &argv_idx, 0); | |
673 | 2102 parmp->window_layout = WIN_HOR; |
443 | 2103 break; |
2104 | |
2105 case 'O': /* "-O[N]" open N vertical split windows */ | |
2106 /* default is 0: open window for each file */ | |
445 | 2107 parmp->window_count = get_number_arg((char_u *)argv[0], |
2108 &argv_idx, 0); | |
673 | 2109 parmp->window_layout = WIN_VER; |
443 | 2110 break; |
2111 | |
2112 #ifdef FEAT_QUICKFIX | |
2113 case 'q': /* "-q" QuickFix mode */ | |
2114 if (parmp->edit_type != EDIT_NONE) | |
2115 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); | |
2116 parmp->edit_type = EDIT_QF; | |
2117 if (argv[0][argv_idx]) /* "-q{errorfile}" */ | |
2118 { | |
2119 parmp->use_ef = (char_u *)argv[0] + argv_idx; | |
2120 argv_idx = -1; | |
2121 } | |
2122 else if (argc > 1) /* "-q {errorfile}" */ | |
2123 want_argument = TRUE; | |
2124 break; | |
2125 #endif | |
2126 | |
2127 case 'R': /* "-R" readonly mode */ | |
2128 readonlymode = TRUE; | |
2129 curbuf->b_p_ro = TRUE; | |
2130 p_uc = 10000; /* don't update very often */ | |
2131 break; | |
2132 | |
2133 case 'r': /* "-r" recovery mode */ | |
2134 case 'L': /* "-L" recovery mode */ | |
2135 recoverymode = 1; | |
2136 break; | |
2137 | |
2138 case 's': | |
2139 if (exmode_active) /* "-s" silent (batch) mode */ | |
2140 silent_mode = TRUE; | |
2141 else /* "-s {scriptin}" read from script file */ | |
2142 want_argument = TRUE; | |
2143 break; | |
2144 | |
2145 case 't': /* "-t {tag}" or "-t{tag}" jump to tag */ | |
2146 if (parmp->edit_type != EDIT_NONE) | |
2147 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); | |
2148 parmp->edit_type = EDIT_TAG; | |
2149 if (argv[0][argv_idx]) /* "-t{tag}" */ | |
2150 { | |
2151 parmp->tagname = (char_u *)argv[0] + argv_idx; | |
2152 argv_idx = -1; | |
2153 } | |
2154 else /* "-t {tag}" */ | |
2155 want_argument = TRUE; | |
2156 break; | |
2157 | |
2158 #ifdef FEAT_EVAL | |
2159 case 'D': /* "-D" Debugging */ | |
2160 parmp->use_debug_break_level = 9999; | |
2161 break; | |
2162 #endif | |
2163 #ifdef FEAT_DIFF | |
2164 case 'd': /* "-d" 'diff' */ | |
2165 # ifdef AMIGA | |
2166 /* check for "-dev {device}" */ | |
2167 if (argv[0][argv_idx] == 'e' && argv[0][argv_idx + 1] == 'v') | |
2168 want_argument = TRUE; | |
2169 else | |
2170 # endif | |
2171 parmp->diff_mode = TRUE; | |
2172 break; | |
2173 #endif | |
2174 case 'V': /* "-V{N}" Verbose level */ | |
2175 /* default is 10: a little bit verbose */ | |
2176 p_verbose = get_number_arg((char_u *)argv[0], &argv_idx, 10); | |
2177 if (argv[0][argv_idx] != NUL) | |
2178 { | |
2179 set_option_value((char_u *)"verbosefile", 0L, | |
2180 (char_u *)argv[0] + argv_idx, 0); | |
835 | 2181 argv_idx = (int)STRLEN(argv[0]); |
443 | 2182 } |
2183 break; | |
2184 | |
2185 case 'v': /* "-v" Vi-mode (as if called "vi") */ | |
2186 exmode_active = 0; | |
2187 #ifdef FEAT_GUI | |
2188 gui.starting = FALSE; /* don't start GUI */ | |
2189 #endif | |
2190 break; | |
2191 | |
2192 case 'w': /* "-w{number}" set window height */ | |
2193 /* "-w {scriptout}" write to script */ | |
2194 if (vim_isdigit(((char_u *)argv[0])[argv_idx])) | |
2195 { | |
2196 n = get_number_arg((char_u *)argv[0], &argv_idx, 10); | |
2197 set_option_value((char_u *)"window", n, NULL, 0); | |
2198 break; | |
2199 } | |
2200 want_argument = TRUE; | |
2201 break; | |
2202 | |
2203 #ifdef FEAT_CRYPT | |
2204 case 'x': /* "-x" encrypted reading/writing of files */ | |
2205 parmp->ask_for_key = TRUE; | |
2206 break; | |
2207 #endif | |
2208 | |
2209 case 'X': /* "-X" don't connect to X server */ | |
2210 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_X11) | |
2211 x_no_connect = TRUE; | |
2212 #endif | |
2213 break; | |
2214 | |
2215 case 'Z': /* "-Z" restricted mode */ | |
2216 restricted = TRUE; | |
2217 break; | |
2218 | |
2219 case 'c': /* "-c{command}" or "-c {command}" execute | |
2220 command */ | |
2221 if (argv[0][argv_idx] != NUL) | |
2222 { | |
2223 if (parmp->n_commands >= MAX_ARG_CMDS) | |
2224 mainerr(ME_EXTRA_CMD, NULL); | |
445 | 2225 parmp->commands[parmp->n_commands++] = (char_u *)argv[0] |
2226 + argv_idx; | |
443 | 2227 argv_idx = -1; |
2228 break; | |
2229 } | |
12674
e769c912fcd9
patch 8.0.1215: newer gcc warns for implicit fallthrough
Christian Brabandt <cb@256bit.org>
parents:
12670
diff
changeset
|
2230 /* FALLTHROUGH */ |
443 | 2231 case 'S': /* "-S {file}" execute Vim script */ |
2232 case 'i': /* "-i {viminfo}" use for viminfo */ | |
2233 #ifndef FEAT_DIFF | |
2234 case 'd': /* "-d {device}" device (for Amiga) */ | |
2235 #endif | |
2236 case 'T': /* "-T {terminal}" terminal name */ | |
2237 case 'u': /* "-u {vimrc}" vim inits file */ | |
2238 case 'U': /* "-U {gvimrc}" gvim inits file */ | |
2239 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
|
2240 #ifdef FEAT_GUI_MSWIN |
443 | 2241 case 'P': /* "-P {parent title}" MDI parent */ |
2242 #endif | |
2243 want_argument = TRUE; | |
2244 break; | |
2245 | |
2246 default: | |
2247 mainerr(ME_UNKNOWN_OPTION, (char_u *)argv[0]); | |
2248 } | |
2249 | |
2250 /* | |
2251 * Handle option arguments with argument. | |
2252 */ | |
2253 if (want_argument) | |
2254 { | |
2255 /* | |
2256 * Check for garbage immediately after the option letter. | |
2257 */ | |
2258 if (argv[0][argv_idx] != NUL) | |
2259 mainerr(ME_GARBAGE, (char_u *)argv[0]); | |
2260 | |
2261 --argc; | |
1989 | 2262 if (argc < 1 && c != 'S') /* -S has an optional argument */ |
443 | 2263 mainerr_arg_missing((char_u *)argv[0]); |
2264 ++argv; | |
2265 argv_idx = -1; | |
2266 | |
2267 switch (c) | |
2268 { | |
2269 case 'c': /* "-c {command}" execute command */ | |
2270 case 'S': /* "-S {file}" execute Vim script */ | |
2271 if (parmp->n_commands >= MAX_ARG_CMDS) | |
2272 mainerr(ME_EXTRA_CMD, NULL); | |
2273 if (c == 'S') | |
2274 { | |
2275 char *a; | |
2276 | |
2277 if (argc < 1) | |
2278 /* "-S" without argument: use default session file | |
2279 * name. */ | |
2280 a = SESSION_FILE; | |
2281 else if (argv[0][0] == '-') | |
2282 { | |
2283 /* "-S" followed by another option: use default | |
2284 * session file name. */ | |
2285 a = SESSION_FILE; | |
2286 ++argc; | |
2287 --argv; | |
2288 } | |
2289 else | |
2290 a = argv[0]; | |
2291 p = alloc((unsigned)(STRLEN(a) + 4)); | |
2292 if (p == NULL) | |
2293 mch_exit(2); | |
2294 sprintf((char *)p, "so %s", a); | |
2295 parmp->cmds_tofree[parmp->n_commands] = TRUE; | |
2296 parmp->commands[parmp->n_commands++] = p; | |
2297 } | |
2298 else | |
445 | 2299 parmp->commands[parmp->n_commands++] = |
2300 (char_u *)argv[0]; | |
443 | 2301 break; |
2302 | |
1989 | 2303 case '-': |
2304 if (argv[-1][2] == 'c') | |
2305 { | |
2306 /* "--cmd {command}" execute command */ | |
2307 if (parmp->n_pre_commands >= MAX_ARG_CMDS) | |
2308 mainerr(ME_EXTRA_CMD, NULL); | |
2309 parmp->pre_commands[parmp->n_pre_commands++] = | |
445 | 2310 (char_u *)argv[0]; |
1989 | 2311 } |
2312 /* "--startuptime <file>" already handled */ | |
443 | 2313 break; |
2314 | |
2315 /* case 'd': -d {device} is handled in mch_check_win() for the | |
2316 * Amiga */ | |
2317 | |
2318 #ifdef FEAT_QUICKFIX | |
2319 case 'q': /* "-q {errorfile}" QuickFix mode */ | |
2320 parmp->use_ef = (char_u *)argv[0]; | |
2321 break; | |
2322 #endif | |
2323 | |
2324 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
|
2325 set_option_value((char_u *)"vif", 0L, (char_u *)argv[0], 0); |
443 | 2326 break; |
2327 | |
2328 case 's': /* "-s {scriptin}" read from script file */ | |
2329 if (scriptin[0] != NULL) | |
2330 { | |
2331 scripterror: | |
2332 mch_errmsg(_("Attempt to open script file again: \"")); | |
2333 mch_errmsg(argv[-1]); | |
2334 mch_errmsg(" "); | |
2335 mch_errmsg(argv[0]); | |
2336 mch_errmsg("\"\n"); | |
2337 mch_exit(2); | |
2338 } | |
2339 if ((scriptin[0] = mch_fopen(argv[0], READBIN)) == NULL) | |
2340 { | |
2341 mch_errmsg(_("Cannot open for reading: \"")); | |
2342 mch_errmsg(argv[0]); | |
2343 mch_errmsg("\"\n"); | |
2344 mch_exit(2); | |
2345 } | |
2346 if (save_typebuf() == FAIL) | |
2347 mch_exit(2); /* out of memory */ | |
2348 break; | |
2349 | |
2350 case 't': /* "-t {tag}" */ | |
2351 parmp->tagname = (char_u *)argv[0]; | |
2352 break; | |
2353 | |
2354 case 'T': /* "-T {terminal}" terminal name */ | |
2355 /* | |
2356 * The -T term argument is always available and when | |
2357 * HAVE_TERMLIB is supported it overrides the environment | |
2358 * variable TERM. | |
2359 */ | |
2360 #ifdef FEAT_GUI | |
2361 if (term_is_gui((char_u *)argv[0])) | |
2362 gui.starting = TRUE; /* start GUI a bit later */ | |
2363 else | |
2364 #endif | |
2365 parmp->term = (char_u *)argv[0]; | |
2366 break; | |
2367 | |
2368 case 'u': /* "-u {vimrc}" vim inits file */ | |
2369 parmp->use_vimrc = (char_u *)argv[0]; | |
2370 break; | |
2371 | |
2372 case 'U': /* "-U {gvimrc}" gvim inits file */ | |
2373 #ifdef FEAT_GUI | |
2374 use_gvimrc = (char_u *)argv[0]; | |
2375 #endif | |
2376 break; | |
2377 | |
2378 case 'w': /* "-w {nr}" 'window' value */ | |
2379 /* "-w {scriptout}" append to script file */ | |
2380 if (vim_isdigit(*((char_u *)argv[0]))) | |
2381 { | |
2382 argv_idx = 0; | |
2383 n = get_number_arg((char_u *)argv[0], &argv_idx, 10); | |
2384 set_option_value((char_u *)"window", n, NULL, 0); | |
2385 argv_idx = -1; | |
2386 break; | |
2387 } | |
12674
e769c912fcd9
patch 8.0.1215: newer gcc warns for implicit fallthrough
Christian Brabandt <cb@256bit.org>
parents:
12670
diff
changeset
|
2388 /* FALLTHROUGH */ |
443 | 2389 case 'W': /* "-W {scriptout}" overwrite script file */ |
2390 if (scriptout != NULL) | |
2391 goto scripterror; | |
2392 if ((scriptout = mch_fopen(argv[0], | |
2393 c == 'w' ? APPENDBIN : WRITEBIN)) == NULL) | |
2394 { | |
2395 mch_errmsg(_("Cannot open for script output: \"")); | |
2396 mch_errmsg(argv[0]); | |
2397 mch_errmsg("\"\n"); | |
2398 mch_exit(2); | |
2399 } | |
2400 break; | |
2401 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2402 #ifdef FEAT_GUI_MSWIN |
443 | 2403 case 'P': /* "-P {parent title}" MDI parent */ |
2404 gui_mch_set_parent(argv[0]); | |
2405 break; | |
2406 #endif | |
2407 } | |
2408 } | |
2409 } | |
2410 | |
2411 /* | |
2412 * File name argument. | |
2413 */ | |
2414 else | |
2415 { | |
2416 argv_idx = -1; /* skip to next argument */ | |
2417 | |
2418 /* Check for only one type of editing. */ | |
2419 if (parmp->edit_type != EDIT_NONE && parmp->edit_type != EDIT_FILE) | |
2420 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); | |
2421 parmp->edit_type = EDIT_FILE; | |
2422 | |
2423 #ifdef MSWIN | |
2424 /* Remember if the argument was a full path before changing | |
2425 * slashes to backslashes. */ | |
2426 if (argv[0][0] != NUL && argv[0][1] == ':' && argv[0][2] == '\\') | |
2427 parmp->full_path = TRUE; | |
2428 #endif | |
2429 | |
2430 /* Add the file to the global argument list. */ | |
2431 if (ga_grow(&global_alist.al_ga, 1) == FAIL | |
2432 || (p = vim_strsave((char_u *)argv[0])) == NULL) | |
2433 mch_exit(2); | |
2434 #ifdef FEAT_DIFF | |
2435 if (parmp->diff_mode && mch_isdir(p) && GARGCOUNT > 0 | |
2436 && !mch_isdir(alist_name(&GARGLIST[0]))) | |
2437 { | |
2438 char_u *r; | |
2439 | |
2440 r = concat_fnames(p, gettail(alist_name(&GARGLIST[0])), TRUE); | |
2441 if (r != NULL) | |
2442 { | |
2443 vim_free(p); | |
2444 p = r; | |
2445 } | |
2446 } | |
2447 #endif | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2448 #if defined(__CYGWIN32__) && !defined(MSWIN) |
443 | 2449 /* |
2450 * If vim is invoked by non-Cygwin tools, convert away any | |
2451 * DOS paths, so things like .swp files are created correctly. | |
2452 * Look for evidence of non-Cygwin paths before we bother. | |
2453 * This is only for when using the Unix files. | |
2454 */ | |
5037
5e0b6a9282df
updated for version 7.3.1262
Bram Moolenaar <bram@vim.org>
parents:
4912
diff
changeset
|
2455 if (vim_strpbrk(p, "\\:") != NULL && !path_with_url(p)) |
443 | 2456 { |
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
|
2457 char posix_path[MAXPATHL]; |
443 | 2458 |
1657 | 2459 # 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
|
2460 cygwin_conv_path(CCP_WIN_A_TO_POSIX, p, posix_path, MAXPATHL); |
1657 | 2461 # else |
443 | 2462 cygwin_conv_to_posix_path(p, posix_path); |
1657 | 2463 # endif |
443 | 2464 vim_free(p); |
5037
5e0b6a9282df
updated for version 7.3.1262
Bram Moolenaar <bram@vim.org>
parents:
4912
diff
changeset
|
2465 p = vim_strsave((char_u *)posix_path); |
443 | 2466 if (p == NULL) |
2467 mch_exit(2); | |
2468 } | |
2469 #endif | |
587 | 2470 |
2471 #ifdef USE_FNAME_CASE | |
2472 /* Make the case of the file name match the actual file. */ | |
2473 fname_case(p, 0); | |
2474 #endif | |
2475 | |
443 | 2476 alist_add(&global_alist, p, |
7410
08e62c4fc17d
commit https://github.com/vim/vim/commit/53076830fea6df737455523f7e235bfe4f79864d
Christian Brabandt <cb@256bit.org>
parents:
6923
diff
changeset
|
2477 #ifdef EXPAND_FILENAMES |
445 | 2478 parmp->literal ? 2 : 0 /* add buffer nr after exp. */ |
443 | 2479 #else |
2480 2 /* add buffer number now and use curbuf */ | |
2481 #endif | |
2482 ); | |
2483 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2484 #ifdef MSWIN |
443 | 2485 { |
2486 /* Remember this argument has been added to the argument list. | |
2487 * Needed when 'encoding' is changed. */ | |
819 | 2488 used_file_arg(argv[0], parmp->literal, parmp->full_path, |
1680 | 2489 # ifdef FEAT_DIFF |
2490 parmp->diff_mode | |
2491 # else | |
2492 FALSE | |
2493 # endif | |
2494 ); | |
443 | 2495 } |
2496 #endif | |
2497 } | |
2498 | |
2499 /* | |
2500 * If there are no more letters after the current "-", go to next | |
2501 * argument. argv_idx is set to -1 when the current argument is to be | |
2502 * skipped. | |
2503 */ | |
2504 if (argv_idx <= 0 || argv[0][argv_idx] == NUL) | |
2505 { | |
2506 --argc; | |
2507 ++argv; | |
2508 argv_idx = 1; | |
2509 } | |
2510 } | |
1093 | 2511 |
2512 #ifdef FEAT_EVAL | |
2513 /* If there is a "+123" or "-c" command, set v:swapcommand to the first | |
2514 * one. */ | |
2515 if (parmp->n_commands > 0) | |
2516 { | |
2517 p = alloc((unsigned)STRLEN(parmp->commands[0]) + 3); | |
2518 if (p != NULL) | |
2519 { | |
2520 sprintf((char *)p, ":%s\r", parmp->commands[0]); | |
2521 set_vim_var_string(VV_SWAPCOMMAND, p, -1); | |
2522 vim_free(p); | |
2523 } | |
2524 } | |
2525 #endif | |
443 | 2526 } |
2527 | |
2528 /* | |
2529 * 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
|
2530 * When starting in Ex mode and commands come from a file, set silent_mode. |
443 | 2531 */ |
2532 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2533 check_tty(mparm_T *parmp) |
443 | 2534 { |
2535 int input_isatty; /* is active input a terminal? */ | |
2536 | |
2537 input_isatty = mch_input_isatty(); | |
2538 if (exmode_active) | |
2539 { | |
2540 if (!input_isatty) | |
2541 silent_mode = TRUE; | |
2542 } | |
10404
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2543 else if (parmp->want_full_screen && (!stdout_isatty || !input_isatty) |
443 | 2544 #ifdef FEAT_GUI |
2545 /* don't want the delay when started from the desktop */ | |
2546 && !gui.starting | |
2547 #endif | |
8253
1b6a589a0efc
commit https://github.com/vim/vim/commit/49c39ff678e2ba9f7dc280b25368e12084a610cf
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
2548 && !parmp->not_a_term) |
443 | 2549 { |
2550 #ifdef NBDEBUG | |
2551 /* | |
2552 * This shouldn't be necessary. But if I run netbeans with the log | |
2553 * output coming to the console and XOpenDisplay fails, I get vim | |
2554 * trying to start with input/output to my console tty. This fills my | |
2555 * input buffer so fast I can't even kill the process in under 2 | |
1226 | 2556 * minutes (and it beeps continuously the whole time :-) |
443 | 2557 */ |
10404
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2558 if (netbeans_active() && (!stdout_isatty || !input_isatty)) |
443 | 2559 { |
2560 mch_errmsg(_("Vim: Error: Failure to start gvim from NetBeans\n")); | |
2561 exit(1); | |
2562 } | |
2563 #endif | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2564 #if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
9252
diff
changeset
|
2565 if (is_cygpty_used()) |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
9252
diff
changeset
|
2566 { |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15551
diff
changeset
|
2567 # 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
|
2568 && 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
|
2569 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
|
2570 |
aa3f6d093f4b
patch 8.0.1152: encoding of error message wrong in Cygwin terminal
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2571 /* Set the encoding of the error message based on $LC_ALL or |
aa3f6d093f4b
patch 8.0.1152: encoding of error message wrong in Cygwin terminal
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2572 * other environment variables instead of 'encoding'. |
aa3f6d093f4b
patch 8.0.1152: encoding of error message wrong in Cygwin terminal
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2573 * Note that the message is shown on a Cygwin terminal (e.g. |
aa3f6d093f4b
patch 8.0.1152: encoding of error message wrong in Cygwin terminal
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2574 * mintty) which encoding is based on $LC_ALL or etc., not the |
aa3f6d093f4b
patch 8.0.1152: encoding of error message wrong in Cygwin terminal
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2575 * 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
|
2576 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
|
2577 if (s == NULL) |
aa3f6d093f4b
patch 8.0.1152: encoding of error message wrong in Cygwin terminal
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2578 s = "utf-8"; /* Use "utf-8" by default. */ |
aa3f6d093f4b
patch 8.0.1152: encoding of error message wrong in Cygwin terminal
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2579 (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
|
2580 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
|
2581 # endif |
9363
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
9252
diff
changeset
|
2582 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
|
2583 exit(1); |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
9252
diff
changeset
|
2584 } |
f9dda6450c76
commit https://github.com/vim/vim/commit/97ff9b9cffd97219d888874b9b3811d55e99c78f
Christian Brabandt <cb@256bit.org>
parents:
9252
diff
changeset
|
2585 #endif |
10404
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2586 if (!stdout_isatty) |
443 | 2587 mch_errmsg(_("Vim: Warning: Output is not to a terminal\n")); |
2588 if (!input_isatty) | |
2589 mch_errmsg(_("Vim: Warning: Input is not from a terminal\n")); | |
2590 out_flush(); | |
10404
65e0537a4560
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2591 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
|
2592 exit(1); |
443 | 2593 if (scriptin[0] == NULL) |
2594 ui_delay(2000L, TRUE); | |
2595 TIME_MSG("Warning delay"); | |
2596 } | |
2597 } | |
2598 | |
2599 /* | |
2600 * Read text from stdin. | |
2601 */ | |
2602 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2603 read_stdin(void) |
443 | 2604 { |
2605 int i; | |
2606 | |
580 | 2607 #if defined(HAS_SWAP_EXISTS_ACTION) |
443 | 2608 /* When getting the ATTENTION prompt here, use a dialog */ |
2609 swap_exists_action = SEA_DIALOG; | |
2610 #endif | |
2611 no_wait_return = TRUE; | |
2612 i = msg_didany; | |
2613 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
|
2614 (void)open_buffer(TRUE, NULL, 0); /* create memfile and read file */ |
443 | 2615 no_wait_return = FALSE; |
2616 msg_didany = i; | |
2617 TIME_MSG("reading stdin"); | |
580 | 2618 #if defined(HAS_SWAP_EXISTS_ACTION) |
443 | 2619 check_swap_exists_action(); |
2620 #endif | |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12678
diff
changeset
|
2621 #if !(defined(AMIGA) || defined(MACOS_X)) |
443 | 2622 /* |
2623 * Close stdin and dup it from stderr. Required for GPM to work | |
2624 * properly, and for running external commands. | |
2625 * Is there any other system that cannot do this? | |
2626 */ | |
2627 close(0); | |
14730
193471015e1a
patch 8.1.0377: xdiff doesn't use the Vim memory allocation functions
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
2628 vim_ignored = dup(2); |
443 | 2629 #endif |
2630 } | |
2631 | |
2632 /* | |
2633 * Create the requested number of windows and edit buffers in them. | |
2634 * Also does recovery if "recoverymode" set. | |
2635 */ | |
2636 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2637 create_windows(mparm_T *parmp UNUSED) |
443 | 2638 { |
944 | 2639 int dorewind; |
673 | 2640 int done = 0; |
2641 | |
443 | 2642 /* |
2643 * Create the number of windows that was requested. | |
2644 */ | |
2645 if (parmp->window_count == -1) /* was not set */ | |
2646 parmp->window_count = 1; | |
2647 if (parmp->window_count == 0) | |
2648 parmp->window_count = GARGCOUNT; | |
2649 if (parmp->window_count > 1) | |
2650 { | |
2651 /* Don't change the windows if there was a command in .vimrc that | |
2652 * already split some windows */ | |
673 | 2653 if (parmp->window_layout == 0) |
2654 parmp->window_layout = WIN_HOR; | |
2655 if (parmp->window_layout == WIN_TABS) | |
2656 { | |
2657 parmp->window_count = make_tabpages(parmp->window_count); | |
2658 TIME_MSG("making tab pages"); | |
2659 } | |
2660 else if (firstwin->w_next == NULL) | |
443 | 2661 { |
2662 parmp->window_count = make_windows(parmp->window_count, | |
673 | 2663 parmp->window_layout == WIN_VER); |
443 | 2664 TIME_MSG("making windows"); |
2665 } | |
2666 else | |
2667 parmp->window_count = win_count(); | |
2668 } | |
2669 else | |
2670 parmp->window_count = 1; | |
2671 | |
2672 if (recoverymode) /* do recover */ | |
2673 { | |
2674 msg_scroll = TRUE; /* scroll message up */ | |
2675 ml_recover(); | |
2676 if (curbuf->b_ml.ml_mfp == NULL) /* failed */ | |
2677 getout(1); | |
717 | 2678 do_modelines(0); /* do modelines */ |
443 | 2679 } |
2680 else | |
2681 { | |
2682 /* | |
2683 * Open a buffer for windows that don't have one yet. | |
2684 * Commands in the .vimrc might have loaded a file or split the window. | |
2685 * Watch out for autocommands that delete a window. | |
2686 */ | |
2687 /* | |
2688 * Don't execute Win/Buf Enter/Leave autocommands here | |
2689 */ | |
2690 ++autocmd_no_enter; | |
2691 ++autocmd_no_leave; | |
944 | 2692 dorewind = TRUE; |
673 | 2693 while (done++ < 1000) |
2694 { | |
944 | 2695 if (dorewind) |
673 | 2696 { |
2697 if (parmp->window_layout == WIN_TABS) | |
2698 goto_tabpage(1); | |
2699 else | |
2700 curwin = firstwin; | |
2701 } | |
2702 else if (parmp->window_layout == WIN_TABS) | |
2703 { | |
2704 if (curtab->tp_next == NULL) | |
2705 break; | |
2706 goto_tabpage(0); | |
2707 } | |
2708 else | |
2709 { | |
2710 if (curwin->w_next == NULL) | |
2711 break; | |
2712 curwin = curwin->w_next; | |
2713 } | |
944 | 2714 dorewind = FALSE; |
443 | 2715 curbuf = curwin->w_buffer; |
2716 if (curbuf->b_ml.ml_mfp == NULL) | |
2717 { | |
2718 #ifdef FEAT_FOLDING | |
2719 /* Set 'foldlevel' to 'foldlevelstart' if it's not negative. */ | |
2720 if (p_fdls >= 0) | |
2721 curwin->w_p_fdl = p_fdls; | |
2722 #endif | |
580 | 2723 #if defined(HAS_SWAP_EXISTS_ACTION) |
443 | 2724 /* When getting the ATTENTION prompt here, use a dialog */ |
2725 swap_exists_action = SEA_DIALOG; | |
2726 #endif | |
2727 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
|
2728 |
a3aca345aafa
Add the 'undoreload' option to be able to undo a file reload.
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
2729 /* create memfile, read file */ |
a3aca345aafa
Add the 'undoreload' option to be able to undo a file reload.
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
2730 (void)open_buffer(FALSE, NULL, 0); |
443 | 2731 |
580 | 2732 #if defined(HAS_SWAP_EXISTS_ACTION) |
1036 | 2733 if (swap_exists_action == SEA_QUIT) |
2734 { | |
2735 if (got_int || only_one_window()) | |
2736 { | |
2737 /* abort selected or quit and only one window */ | |
2738 did_emsg = FALSE; /* avoid hit-enter prompt */ | |
2739 getout(1); | |
2740 } | |
2741 /* We can't close the window, it would disturb what | |
2742 * happens next. Clear the file name and set the arg | |
2743 * index to -1 to delete it later. */ | |
2744 setfname(curbuf, NULL, NULL, FALSE); | |
2745 curwin->w_arg_idx = -1; | |
2746 swap_exists_action = SEA_NONE; | |
2747 } | |
2748 else | |
2749 handle_swap_exists(NULL); | |
443 | 2750 #endif |
944 | 2751 dorewind = TRUE; /* start again */ |
443 | 2752 } |
2753 ui_breakcheck(); | |
2754 if (got_int) | |
2755 { | |
2756 (void)vgetc(); /* only break the file loading, not the rest */ | |
2757 break; | |
2758 } | |
673 | 2759 } |
2760 if (parmp->window_layout == WIN_TABS) | |
2761 goto_tabpage(1); | |
2762 else | |
2763 curwin = firstwin; | |
2764 curbuf = curwin->w_buffer; | |
443 | 2765 --autocmd_no_enter; |
2766 --autocmd_no_leave; | |
2767 } | |
2768 } | |
2769 | |
2770 /* | |
2771 * If opened more than one window, start editing files in the other | |
2772 * windows. make_windows() has already opened the windows. | |
2773 */ | |
2774 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2775 edit_buffers( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2776 mparm_T *parmp, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2777 char_u *cwd) /* current working dir */ |
443 | 2778 { |
2779 int arg_idx; /* index in argument list */ | |
2780 int i; | |
1036 | 2781 int advance = TRUE; |
5308 | 2782 win_T *win; |
443 | 2783 |
2784 /* | |
2785 * Don't execute Win/Buf Enter/Leave autocommands here | |
2786 */ | |
2787 ++autocmd_no_enter; | |
2788 ++autocmd_no_leave; | |
1036 | 2789 |
2790 /* When w_arg_idx is -1 remove the window (see create_windows()). */ | |
2791 if (curwin->w_arg_idx == -1) | |
2792 { | |
2793 win_close(curwin, TRUE); | |
2794 advance = FALSE; | |
2795 } | |
2796 | |
443 | 2797 arg_idx = 1; |
2798 for (i = 1; i < parmp->window_count; ++i) | |
2799 { | |
6731 | 2800 if (cwd != NULL) |
2801 mch_chdir((char *)cwd); | |
1036 | 2802 /* When w_arg_idx is -1 remove the window (see create_windows()). */ |
2803 if (curwin->w_arg_idx == -1) | |
673 | 2804 { |
1036 | 2805 ++arg_idx; |
2806 win_close(curwin, TRUE); | |
2807 advance = FALSE; | |
2808 continue; | |
673 | 2809 } |
1036 | 2810 |
2811 if (advance) | |
673 | 2812 { |
1036 | 2813 if (parmp->window_layout == WIN_TABS) |
2814 { | |
2815 if (curtab->tp_next == NULL) /* just checking */ | |
2816 break; | |
2817 goto_tabpage(0); | |
2818 } | |
2819 else | |
2820 { | |
2821 if (curwin->w_next == NULL) /* just checking */ | |
2822 break; | |
2823 win_enter(curwin->w_next, FALSE); | |
2824 } | |
673 | 2825 } |
1036 | 2826 advance = TRUE; |
443 | 2827 |
2828 /* Only open the file if there is no file in this window yet (that can | |
1036 | 2829 * happen when .vimrc contains ":sall"). */ |
443 | 2830 if (curbuf == firstwin->w_buffer || curbuf->b_ffname == NULL) |
2831 { | |
2832 curwin->w_arg_idx = arg_idx; | |
1036 | 2833 /* Edit file from arg list, if there is one. When "Quit" selected |
2834 * at the ATTENTION prompt close the window. */ | |
1684 | 2835 # ifdef HAS_SWAP_EXISTS_ACTION |
2836 swap_exists_did_quit = FALSE; | |
2837 # endif | |
443 | 2838 (void)do_ecmd(0, arg_idx < GARGCOUNT |
2839 ? alist_name(&GARGLIST[arg_idx]) : NULL, | |
1743 | 2840 NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin); |
1684 | 2841 # ifdef HAS_SWAP_EXISTS_ACTION |
2842 if (swap_exists_did_quit) | |
1036 | 2843 { |
1684 | 2844 /* abort or quit selected */ |
1036 | 2845 if (got_int || only_one_window()) |
2846 { | |
1684 | 2847 /* abort selected and only one window */ |
1036 | 2848 did_emsg = FALSE; /* avoid hit-enter prompt */ |
2849 getout(1); | |
2850 } | |
2851 win_close(curwin, TRUE); | |
2852 advance = FALSE; | |
2853 } | |
1684 | 2854 # endif |
443 | 2855 if (arg_idx == GARGCOUNT - 1) |
2856 arg_had_last = TRUE; | |
2857 ++arg_idx; | |
2858 } | |
2859 ui_breakcheck(); | |
2860 if (got_int) | |
2861 { | |
2862 (void)vgetc(); /* only break the file loading, not the rest */ | |
2863 break; | |
2864 } | |
2865 } | |
673 | 2866 |
2867 if (parmp->window_layout == WIN_TABS) | |
2868 goto_tabpage(1); | |
443 | 2869 --autocmd_no_enter; |
5308 | 2870 |
2871 /* make the first window the current window */ | |
2872 win = firstwin; | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
2873 #if defined(FEAT_QUICKFIX) |
5308 | 2874 /* Avoid making a preview window the current window. */ |
2875 while (win->w_p_pvw) | |
4912
d8f65e6238fa
updated for version 7.3.1201
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2876 { |
5308 | 2877 win = win->w_next; |
2878 if (win == NULL) | |
2879 { | |
2880 win = firstwin; | |
2881 break; | |
2882 } | |
4912
d8f65e6238fa
updated for version 7.3.1201
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2883 } |
d8f65e6238fa
updated for version 7.3.1201
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2884 #endif |
5308 | 2885 win_enter(win, FALSE); |
4912
d8f65e6238fa
updated for version 7.3.1201
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2886 |
443 | 2887 --autocmd_no_leave; |
2888 TIME_MSG("editing files in windows"); | |
673 | 2889 if (parmp->window_count > 1 && parmp->window_layout != WIN_TABS) |
443 | 2890 win_equal(curwin, FALSE, 'b'); /* adjust heights */ |
2891 } | |
2892 | |
2893 /* | |
440 | 2894 * Execute the commands from --cmd arguments "cmds[cnt]". |
2895 */ | |
2896 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2897 exe_pre_commands(mparm_T *parmp) |
440 | 2898 { |
443 | 2899 char_u **cmds = parmp->pre_commands; |
2900 int cnt = parmp->n_pre_commands; | |
440 | 2901 int i; |
2902 | |
2903 if (cnt > 0) | |
2904 { | |
2905 curwin->w_cursor.lnum = 0; /* just in case.. */ | |
2906 sourcing_name = (char_u *)_("pre-vimrc command line"); | |
2907 # 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
|
2908 current_sctx.sc_sid = SID_CMDARG; |
440 | 2909 # endif |
2910 for (i = 0; i < cnt; ++i) | |
2911 do_cmdline_cmd(cmds[i]); | |
2912 sourcing_name = NULL; | |
2913 # 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
|
2914 current_sctx.sc_sid = 0; |
440 | 2915 # endif |
2916 TIME_MSG("--cmd commands"); | |
2917 } | |
2918 } | |
2919 | |
2920 /* | |
443 | 2921 * Execute "+", "-c" and "-S" arguments. |
2922 */ | |
2923 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2924 exe_commands(mparm_T *parmp) |
443 | 2925 { |
2926 int i; | |
2927 | |
2928 /* | |
2929 * We start commands on line 0, make "vim +/pat file" match a | |
2930 * pattern on line 1. But don't move the cursor when an autocommand | |
2931 * with g`" was used. | |
2932 */ | |
2933 msg_scroll = TRUE; | |
2934 if (parmp->tagname == NULL && curwin->w_cursor.lnum <= 1) | |
2935 curwin->w_cursor.lnum = 0; | |
2936 sourcing_name = (char_u *)"command line"; | |
2937 #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
|
2938 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
|
2939 current_sctx.sc_seq = 0; |
443 | 2940 #endif |
2941 for (i = 0; i < parmp->n_commands; ++i) | |
2942 { | |
2943 do_cmdline_cmd(parmp->commands[i]); | |
2944 if (parmp->cmds_tofree[i]) | |
2945 vim_free(parmp->commands[i]); | |
2946 } | |
2947 sourcing_name = NULL; | |
2948 #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
|
2949 current_sctx.sc_sid = 0; |
443 | 2950 #endif |
2951 if (curwin->w_cursor.lnum == 0) | |
2952 curwin->w_cursor.lnum = 1; | |
2953 | |
2954 if (!exmode_active) | |
2955 msg_scroll = FALSE; | |
2956 | |
2957 #ifdef FEAT_QUICKFIX | |
2958 /* When started with "-q errorfile" jump to first error again. */ | |
2959 if (parmp->edit_type == EDIT_QF) | |
644 | 2960 qf_jump(NULL, 0, 0, FALSE); |
443 | 2961 #endif |
2962 TIME_MSG("executing command arguments"); | |
2963 } | |
2964 | |
2965 /* | |
440 | 2966 * Source startup scripts. |
2967 */ | |
2968 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2969 source_startup_scripts(mparm_T *parmp) |
440 | 2970 { |
2971 int i; | |
2972 | |
2973 /* | |
2974 * For "evim" source evim.vim first of all, so that the user can overrule | |
2975 * any things he doesn't like. | |
2976 */ | |
2977 if (parmp->evim_mode) | |
2978 { | |
819 | 2979 (void)do_source((char_u *)EVIM_FILE, FALSE, DOSO_NONE); |
440 | 2980 TIME_MSG("source evim file"); |
2981 } | |
2982 | |
2983 /* | |
443 | 2984 * If -u argument given, use only the initializations from that file and |
440 | 2985 * nothing else. |
2986 */ | |
2987 if (parmp->use_vimrc != NULL) | |
2988 { | |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
2989 if (STRCMP(parmp->use_vimrc, "DEFAULTS") == 0) |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
2990 do_source((char_u *)VIM_DEFAULTS_FILE, FALSE, DOSO_NONE); |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
2991 else if (STRCMP(parmp->use_vimrc, "NONE") == 0 |
445 | 2992 || STRCMP(parmp->use_vimrc, "NORC") == 0) |
440 | 2993 { |
2994 #ifdef FEAT_GUI | |
2995 if (use_gvimrc == NULL) /* don't load gvimrc either */ | |
2996 use_gvimrc = parmp->use_vimrc; | |
2997 #endif | |
2998 } | |
2999 else | |
3000 { | |
819 | 3001 if (do_source(parmp->use_vimrc, FALSE, DOSO_NONE) != OK) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
3002 semsg(_("E282: Cannot read from \"%s\""), parmp->use_vimrc); |
440 | 3003 } |
3004 } | |
3005 else if (!silent_mode) | |
3006 { | |
3007 #ifdef AMIGA | |
3008 struct Process *proc = (struct Process *)FindTask(0L); | |
3009 APTR save_winptr = proc->pr_WindowPtr; | |
3010 | |
3011 /* Avoid a requester here for a volume that doesn't exist. */ | |
3012 proc->pr_WindowPtr = (APTR)-1L; | |
3013 #endif | |
3014 | |
3015 /* | |
3016 * Get system wide defaults, if the file name is defined. | |
3017 */ | |
3018 #ifdef SYS_VIMRC_FILE | |
819 | 3019 (void)do_source((char_u *)SYS_VIMRC_FILE, FALSE, DOSO_NONE); |
440 | 3020 #endif |
720 | 3021 #ifdef MACOS_X |
819 | 3022 (void)do_source((char_u *)"$VIMRUNTIME/macmap.vim", FALSE, DOSO_NONE); |
720 | 3023 #endif |
440 | 3024 |
3025 /* | |
3026 * Try to read initialization commands from the following places: | |
3027 * - environment variable VIMINIT | |
3028 * - user vimrc file (s:.vimrc for Amiga, ~/.vimrc otherwise) | |
3029 * - second user vimrc file ($VIM/.vimrc for Dos) | |
3030 * - environment variable EXINIT | |
3031 * - user exrc file (s:.exrc for Amiga, ~/.exrc otherwise) | |
3032 * - second user exrc file ($VIM/.exrc for Dos) | |
3033 * The first that exists is used, the rest is ignored. | |
3034 */ | |
3035 if (process_env((char_u *)"VIMINIT", TRUE) != OK) | |
3036 { | |
819 | 3037 if (do_source((char_u *)USR_VIMRC_FILE, TRUE, DOSO_VIMRC) == FAIL |
440 | 3038 #ifdef USR_VIMRC_FILE2 |
819 | 3039 && do_source((char_u *)USR_VIMRC_FILE2, TRUE, |
3040 DOSO_VIMRC) == FAIL | |
440 | 3041 #endif |
3042 #ifdef USR_VIMRC_FILE3 | |
819 | 3043 && do_source((char_u *)USR_VIMRC_FILE3, TRUE, |
3044 DOSO_VIMRC) == FAIL | |
440 | 3045 #endif |
4863
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4369
diff
changeset
|
3046 #ifdef USR_VIMRC_FILE4 |
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4369
diff
changeset
|
3047 && do_source((char_u *)USR_VIMRC_FILE4, TRUE, |
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4369
diff
changeset
|
3048 DOSO_VIMRC) == FAIL |
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4369
diff
changeset
|
3049 #endif |
440 | 3050 && process_env((char_u *)"EXINIT", FALSE) == FAIL |
9669
284b4eb307fc
commit https://github.com/vim/vim/commit/8c08b5b569e2a9e9f63dea514591ecfa2d3bb392
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
3051 && do_source((char_u *)USR_EXRC_FILE, FALSE, DOSO_NONE) == FAIL |
440 | 3052 #ifdef USR_EXRC_FILE2 |
9669
284b4eb307fc
commit https://github.com/vim/vim/commit/8c08b5b569e2a9e9f63dea514591ecfa2d3bb392
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
3053 && do_source((char_u *)USR_EXRC_FILE2, FALSE, DOSO_NONE) == FAIL |
440 | 3054 #endif |
9678
8c9e13109df8
commit https://github.com/vim/vim/commit/b9a46fec3e79d1fc8c406084a41733c647a5e535
Christian Brabandt <cb@256bit.org>
parents:
9669
diff
changeset
|
3055 && !has_dash_c_arg) |
9669
284b4eb307fc
commit https://github.com/vim/vim/commit/8c08b5b569e2a9e9f63dea514591ecfa2d3bb392
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
3056 { |
284b4eb307fc
commit https://github.com/vim/vim/commit/8c08b5b569e2a9e9f63dea514591ecfa2d3bb392
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
3057 /* When no .vimrc file was found: source defaults.vim. */ |
284b4eb307fc
commit https://github.com/vim/vim/commit/8c08b5b569e2a9e9f63dea514591ecfa2d3bb392
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
3058 do_source((char_u *)VIM_DEFAULTS_FILE, FALSE, DOSO_NONE); |
440 | 3059 } |
3060 } | |
3061 | |
3062 /* | |
3063 * Read initialization commands from ".vimrc" or ".exrc" in current | |
3064 * directory. This is only done if the 'exrc' option is set. | |
3065 * 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
|
3066 * now, except for Unix if the file is owned by the user or 'secure' |
440 | 3067 * option has been reset in environment of global ".exrc" or ".vimrc". |
3068 * Only do this if VIMRC_FILE is not the same as USR_VIMRC_FILE or | |
3069 * SYS_VIMRC_FILE. | |
3070 */ | |
3071 if (p_exrc) | |
3072 { | |
3073 #if defined(UNIX) || defined(VMS) | |
3074 /* If ".vimrc" file is not owned by user, set 'secure' mode. */ | |
3075 if (!file_owned(VIMRC_FILE)) | |
3076 #endif | |
3077 secure = p_secure; | |
3078 | |
3079 i = FAIL; | |
3080 if (fullpathcmp((char_u *)USR_VIMRC_FILE, | |
3081 (char_u *)VIMRC_FILE, FALSE) != FPC_SAME | |
3082 #ifdef USR_VIMRC_FILE2 | |
3083 && fullpathcmp((char_u *)USR_VIMRC_FILE2, | |
3084 (char_u *)VIMRC_FILE, FALSE) != FPC_SAME | |
3085 #endif | |
3086 #ifdef USR_VIMRC_FILE3 | |
3087 && fullpathcmp((char_u *)USR_VIMRC_FILE3, | |
3088 (char_u *)VIMRC_FILE, FALSE) != FPC_SAME | |
3089 #endif | |
3090 #ifdef SYS_VIMRC_FILE | |
3091 && fullpathcmp((char_u *)SYS_VIMRC_FILE, | |
3092 (char_u *)VIMRC_FILE, FALSE) != FPC_SAME | |
3093 #endif | |
3094 ) | |
819 | 3095 i = do_source((char_u *)VIMRC_FILE, TRUE, DOSO_VIMRC); |
440 | 3096 |
3097 if (i == FAIL) | |
3098 { | |
3099 #if defined(UNIX) || defined(VMS) | |
3100 /* if ".exrc" is not owned by user set 'secure' mode */ | |
3101 if (!file_owned(EXRC_FILE)) | |
3102 secure = p_secure; | |
3103 else | |
3104 secure = 0; | |
3105 #endif | |
3106 if ( fullpathcmp((char_u *)USR_EXRC_FILE, | |
3107 (char_u *)EXRC_FILE, FALSE) != FPC_SAME | |
3108 #ifdef USR_EXRC_FILE2 | |
3109 && fullpathcmp((char_u *)USR_EXRC_FILE2, | |
3110 (char_u *)EXRC_FILE, FALSE) != FPC_SAME | |
3111 #endif | |
3112 ) | |
819 | 3113 (void)do_source((char_u *)EXRC_FILE, FALSE, DOSO_NONE); |
440 | 3114 } |
3115 } | |
3116 if (secure == 2) | |
3117 need_wait_return = TRUE; | |
3118 secure = 0; | |
3119 #ifdef AMIGA | |
3120 proc->pr_WindowPtr = save_winptr; | |
3121 #endif | |
3122 } | |
3123 TIME_MSG("sourcing vimrc file(s)"); | |
3124 } | |
3125 | |
3126 /* | |
6 | 3127 * Setup to start using the GUI. Exit with an error when not available. |
3128 */ | |
3129 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3130 main_start_gui(void) |
6 | 3131 { |
3132 #ifdef FEAT_GUI | |
3133 gui.starting = TRUE; /* start GUI a bit later */ | |
3134 #else | |
3135 mch_errmsg(_(e_nogvim)); | |
3136 mch_errmsg("\n"); | |
3137 mch_exit(2); | |
3138 #endif | |
3139 } | |
3140 | |
2730 | 3141 #endif /* NO_VIM_MAIN */ |
3142 | |
6 | 3143 /* |
1226 | 3144 * Get an environment variable, and execute it as Ex commands. |
6 | 3145 * Returns FAIL if the environment variable was not executed, OK otherwise. |
3146 */ | |
3147 int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3148 process_env( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3149 char_u *env, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3150 int is_viminit) /* when TRUE, called for VIMINIT */ |
6 | 3151 { |
3152 char_u *initstr; | |
3153 char_u *save_sourcing_name; | |
3154 linenr_T save_sourcing_lnum; | |
3155 #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
|
3156 sctx_T save_current_sctx; |
6 | 3157 #endif |
3158 | |
3159 if ((initstr = mch_getenv(env)) != NULL && *initstr != NUL) | |
3160 { | |
3161 if (is_viminit) | |
819 | 3162 vimrc_found(NULL, NULL); |
6 | 3163 save_sourcing_name = sourcing_name; |
3164 save_sourcing_lnum = sourcing_lnum; | |
3165 sourcing_name = env; | |
3166 sourcing_lnum = 0; | |
3167 #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
|
3168 save_current_sctx = current_sctx; |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14481
diff
changeset
|
3169 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
|
3170 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
|
3171 current_sctx.sc_lnum = 0; |
6 | 3172 #endif |
3173 do_cmdline_cmd(initstr); | |
3174 sourcing_name = save_sourcing_name; | |
3175 sourcing_lnum = save_sourcing_lnum; | |
3176 #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
|
3177 current_sctx = save_current_sctx; |
6 | 3178 #endif |
3179 return OK; | |
3180 } | |
3181 return FAIL; | |
3182 } | |
3183 | |
2730 | 3184 #if (defined(UNIX) || defined(VMS)) && !defined(NO_VIM_MAIN) |
6 | 3185 /* |
3186 * Return TRUE if we are certain the user owns the file "fname". | |
3187 * Used for ".vimrc" and ".exrc". | |
3188 * Use both stat() and lstat() for extra security. | |
3189 */ | |
3190 static int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3191 file_owned(char *fname) |
6 | 3192 { |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9363
diff
changeset
|
3193 stat_T s; |
6 | 3194 # ifdef UNIX |
3195 uid_t uid = getuid(); | |
3196 # else /* VMS */ | |
3197 uid_t uid = ((getgid() << 16) | getuid()); | |
3198 # endif | |
3199 | |
3200 return !(mch_stat(fname, &s) != 0 || s.st_uid != uid | |
3201 # ifdef HAVE_LSTAT | |
3202 || mch_lstat(fname, &s) != 0 || s.st_uid != uid | |
3203 # endif | |
3204 ); | |
3205 } | |
3206 #endif | |
3207 | |
3208 /* | |
3209 * Give an error message main_errors["n"] and exit. | |
3210 */ | |
3211 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3212 mainerr( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3213 int n, /* one of the ME_ defines */ |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3214 char_u *str) /* extra argument or NULL */ |
6 | 3215 { |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
3216 #if defined(UNIX) || defined(VMS) |
6 | 3217 reset_signals(); /* kill us with CTRL-C here, if you like */ |
3218 #endif | |
3219 | |
14171
ddf160d82971
patch 8.1.0103: long version string cannot be translated
Christian Brabandt <cb@256bit.org>
parents:
14153
diff
changeset
|
3220 init_longVersion(); |
6 | 3221 mch_errmsg(longVersion); |
159 | 3222 mch_errmsg("\n"); |
6 | 3223 mch_errmsg(_(main_errors[n])); |
3224 if (str != NULL) | |
3225 { | |
3226 mch_errmsg(": \""); | |
3227 mch_errmsg((char *)str); | |
3228 mch_errmsg("\""); | |
3229 } | |
159 | 3230 mch_errmsg(_("\nMore info with: \"vim -h\"\n")); |
6 | 3231 |
3232 mch_exit(1); | |
3233 } | |
3234 | |
3235 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3236 mainerr_arg_missing(char_u *str) |
6 | 3237 { |
3238 mainerr(ME_ARG_MISSING, str); | |
3239 } | |
3240 | |
2730 | 3241 #ifndef NO_VIM_MAIN |
6 | 3242 /* |
3243 * print a message with three spaces prepended and '\n' appended. | |
3244 */ | |
3245 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3246 main_msg(char *s) |
6 | 3247 { |
3248 mch_msg(" "); | |
3249 mch_msg(s); | |
3250 mch_msg("\n"); | |
3251 } | |
3252 | |
3253 /* | |
3254 * Print messages for "vim -h" or "vim --help" and exit. | |
3255 */ | |
3256 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3257 usage(void) |
6 | 3258 { |
3259 int i; | |
3260 static char *(use[]) = | |
3261 { | |
3262 N_("[file ..] edit specified file(s)"), | |
3263 N_("- read text from stdin"), | |
3264 N_("-t tag edit file where tag is defined"), | |
3265 #ifdef FEAT_QUICKFIX | |
3266 N_("-q [errorfile] edit file with first error") | |
3267 #endif | |
3268 }; | |
3269 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
3270 #if defined(UNIX) || defined(VMS) |
6 | 3271 reset_signals(); /* kill us with CTRL-C here, if you like */ |
3272 #endif | |
3273 | |
14171
ddf160d82971
patch 8.1.0103: long version string cannot be translated
Christian Brabandt <cb@256bit.org>
parents:
14153
diff
changeset
|
3274 init_longVersion(); |
6 | 3275 mch_msg(longVersion); |
14153
01b7a627d403
patch 8.1.0094: help text "usage:" is not capatalized
Christian Brabandt <cb@256bit.org>
parents:
14129
diff
changeset
|
3276 mch_msg(_("\n\nUsage:")); |
6 | 3277 for (i = 0; ; ++i) |
3278 { | |
3279 mch_msg(_(" vim [arguments] ")); | |
3280 mch_msg(_(use[i])); | |
3281 if (i == (sizeof(use) / sizeof(char_u *)) - 1) | |
3282 break; | |
3283 mch_msg(_("\n or:")); | |
3284 } | |
22 | 3285 #ifdef VMS |
1164 | 3286 mch_msg(_("\nWhere case is ignored prepend / to make flag upper case")); |
22 | 3287 #endif |
6 | 3288 |
3289 mch_msg(_("\n\nArguments:\n")); | |
3290 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
|
3291 #ifdef EXPAND_FILENAMES |
6 | 3292 main_msg(_("--literal\t\tDon't expand wildcards")); |
3293 #endif | |
3294 #ifdef FEAT_OLE | |
3295 main_msg(_("-register\t\tRegister this gvim for OLE")); | |
3296 main_msg(_("-unregister\t\tUnregister gvim for OLE")); | |
3297 #endif | |
3298 #ifdef FEAT_GUI | |
3299 main_msg(_("-g\t\t\tRun using GUI (like \"gvim\")")); | |
3300 main_msg(_("-f or --nofork\tForeground: Don't fork when starting GUI")); | |
3301 #endif | |
3302 main_msg(_("-v\t\t\tVi mode (like \"vi\")")); | |
3303 main_msg(_("-e\t\t\tEx mode (like \"ex\")")); | |
3437 | 3304 main_msg(_("-E\t\t\tImproved Ex mode")); |
6 | 3305 main_msg(_("-s\t\t\tSilent (batch) mode (only for \"ex\")")); |
3306 #ifdef FEAT_DIFF | |
3307 main_msg(_("-d\t\t\tDiff mode (like \"vimdiff\")")); | |
3308 #endif | |
3309 main_msg(_("-y\t\t\tEasy mode (like \"evim\", modeless)")); | |
3310 main_msg(_("-R\t\t\tReadonly mode (like \"view\")")); | |
3311 main_msg(_("-Z\t\t\tRestricted mode (like \"rvim\")")); | |
3312 main_msg(_("-m\t\t\tModifications (writing files) not allowed")); | |
3313 main_msg(_("-M\t\t\tModifications in text not allowed")); | |
3314 main_msg(_("-b\t\t\tBinary mode")); | |
3315 #ifdef FEAT_LISP | |
3316 main_msg(_("-l\t\t\tLisp mode")); | |
3317 #endif | |
3318 main_msg(_("-C\t\t\tCompatible with Vi: 'compatible'")); | |
3319 main_msg(_("-N\t\t\tNot fully Vi compatible: 'nocompatible'")); | |
1164 | 3320 main_msg(_("-V[N][fname]\t\tBe verbose [level N] [log messages to fname]")); |
3321 #ifdef FEAT_EVAL | |
6 | 3322 main_msg(_("-D\t\t\tDebugging mode")); |
1164 | 3323 #endif |
6 | 3324 main_msg(_("-n\t\t\tNo swap file, use memory only")); |
3325 main_msg(_("-r\t\t\tList swap files and exit")); | |
3326 main_msg(_("-r (with file name)\tRecover crashed session")); | |
3327 main_msg(_("-L\t\t\tSame as -r")); | |
3328 #ifdef AMIGA | |
3329 main_msg(_("-f\t\t\tDon't use newcli to open window")); | |
3330 main_msg(_("-dev <device>\t\tUse <device> for I/O")); | |
3331 #endif | |
3332 #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
|
3333 main_msg(_("-A\t\t\tStart in Arabic mode")); |
6 | 3334 #endif |
3335 #ifdef FEAT_RIGHTLEFT | |
3336 main_msg(_("-H\t\t\tStart in Hebrew mode")); | |
3337 #endif | |
3338 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
|
3339 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
|
3340 main_msg(_("--ttyfail\t\tExit if input or output is not a terminal")); |
6 | 3341 main_msg(_("-u <vimrc>\t\tUse <vimrc> instead of any .vimrc")); |
3342 #ifdef FEAT_GUI | |
3343 main_msg(_("-U <gvimrc>\t\tUse <gvimrc> instead of any .gvimrc")); | |
3344 #endif | |
3345 main_msg(_("--noplugin\t\tDon't load plugin scripts")); | |
673 | 3346 main_msg(_("-p[N]\t\tOpen N tab pages (default: one for each file)")); |
6 | 3347 main_msg(_("-o[N]\t\tOpen N windows (default: one for each file)")); |
3348 main_msg(_("-O[N]\t\tLike -o but split vertically")); | |
3349 main_msg(_("+\t\t\tStart at end of file")); | |
3350 main_msg(_("+<lnum>\t\tStart at line <lnum>")); | |
3351 main_msg(_("--cmd <command>\tExecute <command> before loading any vimrc file")); | |
3352 main_msg(_("-c <command>\t\tExecute <command> after loading the first file")); | |
3353 main_msg(_("-S <session>\t\tSource file <session> after loading the first file")); | |
3354 main_msg(_("-s <scriptin>\tRead Normal mode commands from file <scriptin>")); | |
3355 main_msg(_("-w <scriptout>\tAppend all typed commands to file <scriptout>")); | |
3356 main_msg(_("-W <scriptout>\tWrite all typed commands to file <scriptout>")); | |
3357 #ifdef FEAT_CRYPT | |
3358 main_msg(_("-x\t\t\tEdit encrypted files")); | |
3359 #endif | |
3360 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_X11) | |
3361 # if defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK) | |
3362 main_msg(_("-display <display>\tConnect vim to this particular X-server")); | |
3363 # endif | |
3364 main_msg(_("-X\t\t\tDo not connect to X server")); | |
3365 #endif | |
3366 #ifdef FEAT_CLIENTSERVER | |
3367 main_msg(_("--remote <files>\tEdit <files> in a Vim server if possible")); | |
3368 main_msg(_("--remote-silent <files> Same, don't complain if there is no server")); | |
3369 main_msg(_("--remote-wait <files> As --remote but wait for files to have been edited")); | |
3370 main_msg(_("--remote-wait-silent <files> Same, don't complain if there is no server")); | |
1501 | 3371 main_msg(_("--remote-tab[-wait][-silent] <files> As --remote but use tab page per file")); |
6 | 3372 main_msg(_("--remote-send <keys>\tSend <keys> to a Vim server and exit")); |
3373 main_msg(_("--remote-expr <expr>\tEvaluate <expr> in a Vim server and print result")); | |
3374 main_msg(_("--serverlist\t\tList available Vim server names and exit")); | |
3375 main_msg(_("--servername <name>\tSend to/become the Vim server <name>")); | |
3376 #endif | |
1989 | 3377 #ifdef STARTUPTIME |
1999 | 3378 main_msg(_("--startuptime <file>\tWrite startup timing messages to <file>")); |
1989 | 3379 #endif |
6 | 3380 #ifdef FEAT_VIMINFO |
3381 main_msg(_("-i <viminfo>\t\tUse <viminfo> instead of .viminfo")); | |
3382 #endif | |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11595
diff
changeset
|
3383 main_msg(_("--clean\t\t'nocompatible', Vim defaults, no plugins, no viminfo")); |
6 | 3384 main_msg(_("-h or --help\tPrint Help (this message) and exit")); |
3385 main_msg(_("--version\t\tPrint version information and exit")); | |
3386 | |
3387 #ifdef FEAT_GUI_X11 | |
3388 # ifdef FEAT_GUI_MOTIF | |
3389 mch_msg(_("\nArguments recognised by gvim (Motif version):\n")); | |
3390 # else | |
3391 # ifdef FEAT_GUI_ATHENA | |
3392 # ifdef FEAT_GUI_NEXTAW | |
3393 mch_msg(_("\nArguments recognised by gvim (neXtaw version):\n")); | |
3394 # else | |
3395 mch_msg(_("\nArguments recognised by gvim (Athena version):\n")); | |
3396 # endif | |
3397 # endif | |
3398 # endif | |
3399 main_msg(_("-display <display>\tRun vim on <display>")); | |
3400 main_msg(_("-iconic\t\tStart vim iconified")); | |
3401 main_msg(_("-background <color>\tUse <color> for the background (also: -bg)")); | |
3402 main_msg(_("-foreground <color>\tUse <color> for normal text (also: -fg)")); | |
3403 main_msg(_("-font <font>\t\tUse <font> for normal text (also: -fn)")); | |
3404 main_msg(_("-boldfont <font>\tUse <font> for bold text")); | |
3405 main_msg(_("-italicfont <font>\tUse <font> for italic text")); | |
3406 main_msg(_("-geometry <geom>\tUse <geom> for initial geometry (also: -geom)")); | |
3407 main_msg(_("-borderwidth <width>\tUse a border width of <width> (also: -bw)")); | |
3408 main_msg(_("-scrollbarwidth <width> Use a scrollbar width of <width> (also: -sw)")); | |
3409 # ifdef FEAT_GUI_ATHENA | |
3410 main_msg(_("-menuheight <height>\tUse a menu bar height of <height> (also: -mh)")); | |
3411 # endif | |
3412 main_msg(_("-reverse\t\tUse reverse video (also: -rv)")); | |
3413 main_msg(_("+reverse\t\tDon't use reverse video (also: +rv)")); | |
3414 main_msg(_("-xrm <resource>\tSet the specified resource")); | |
3415 #endif /* FEAT_GUI_X11 */ | |
3416 #ifdef FEAT_GUI_GTK | |
3417 mch_msg(_("\nArguments recognised by gvim (GTK+ version):\n")); | |
3418 main_msg(_("-font <font>\t\tUse <font> for normal text (also: -fn)")); | |
3419 main_msg(_("-geometry <geom>\tUse <geom> for initial geometry (also: -geom)")); | |
3420 main_msg(_("-reverse\t\tUse reverse video (also: -rv)")); | |
3421 main_msg(_("-display <display>\tRun vim on <display> (also: --display)")); | |
3422 main_msg(_("--role <role>\tSet a unique role to identify the main window")); | |
3423 main_msg(_("--socketid <xid>\tOpen Vim inside another GTK widget")); | |
3437 | 3424 main_msg(_("--echo-wid\t\tMake gvim echo the Window ID on stdout")); |
6 | 3425 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3426 #ifdef FEAT_GUI_MSWIN |
6 | 3427 main_msg(_("-P <parent title>\tOpen Vim inside parent application")); |
1376 | 3428 main_msg(_("--windowid <HWND>\tOpen Vim inside another win32 widget")); |
6 | 3429 #endif |
3430 | |
3431 #ifdef FEAT_GUI_GNOME | |
3432 /* Gnome gives extra messages for --help if we continue, but not for -h. */ | |
3433 if (gui.starting) | |
3198 | 3434 { |
6 | 3435 mch_msg("\n"); |
3198 | 3436 gui.dofork = FALSE; |
3437 } | |
6 | 3438 else |
3439 #endif | |
3440 mch_exit(0); | |
3441 } | |
3442 | |
580 | 3443 #if defined(HAS_SWAP_EXISTS_ACTION) |
6 | 3444 /* |
3445 * Check the result of the ATTENTION dialog: | |
3446 * When "Quit" selected, exit Vim. | |
3447 * When "Recover" selected, recover the file. | |
3448 */ | |
3449 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3450 check_swap_exists_action(void) |
6 | 3451 { |
3452 if (swap_exists_action == SEA_QUIT) | |
3453 getout(1); | |
3454 handle_swap_exists(NULL); | |
3455 } | |
3456 #endif | |
3457 | |
11032
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3458 #endif /* NO_VIM_MAIN */ |
2730 | 3459 |
6 | 3460 #if defined(STARTUPTIME) || defined(PROTO) |
3461 static struct timeval prev_timeval; | |
3462 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3463 # ifdef MSWIN |
1972 | 3464 /* |
3465 * Windows doesn't have gettimeofday(), although it does have struct timeval. | |
3466 */ | |
3467 static int | |
3468 gettimeofday(struct timeval *tv, char *dummy) | |
3469 { | |
3470 long t = clock(); | |
3471 tv->tv_sec = t / CLOCKS_PER_SEC; | |
3472 tv->tv_usec = (t - tv->tv_sec * CLOCKS_PER_SEC) * 1000000 / CLOCKS_PER_SEC; | |
3473 return 0; | |
3474 } | |
3475 # endif | |
3476 | |
6 | 3477 /* |
3478 * Save the previous time before doing something that could nest. | |
3479 * set "*tv_rel" to the time elapsed so far. | |
3480 */ | |
3481 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3482 time_push(void *tv_rel, void *tv_start) |
6 | 3483 { |
3484 *((struct timeval *)tv_rel) = prev_timeval; | |
3485 gettimeofday(&prev_timeval, NULL); | |
3486 ((struct timeval *)tv_rel)->tv_usec = prev_timeval.tv_usec | |
3487 - ((struct timeval *)tv_rel)->tv_usec; | |
3488 ((struct timeval *)tv_rel)->tv_sec = prev_timeval.tv_sec | |
3489 - ((struct timeval *)tv_rel)->tv_sec; | |
3490 if (((struct timeval *)tv_rel)->tv_usec < 0) | |
3491 { | |
3492 ((struct timeval *)tv_rel)->tv_usec += 1000000; | |
3493 --((struct timeval *)tv_rel)->tv_sec; | |
3494 } | |
3495 *(struct timeval *)tv_start = prev_timeval; | |
3496 } | |
3497 | |
3498 /* | |
3499 * Compute the previous time after doing something that could nest. | |
3500 * Subtract "*tp" from prev_timeval; | |
3501 * Note: The arguments are (void *) to avoid trouble with systems that don't | |
3502 * have struct timeval. | |
3503 */ | |
3504 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3505 time_pop( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3506 void *tp) /* actually (struct timeval *) */ |
6 | 3507 { |
3508 prev_timeval.tv_usec -= ((struct timeval *)tp)->tv_usec; | |
3509 prev_timeval.tv_sec -= ((struct timeval *)tp)->tv_sec; | |
3510 if (prev_timeval.tv_usec < 0) | |
3511 { | |
3512 prev_timeval.tv_usec += 1000000; | |
3513 --prev_timeval.tv_sec; | |
3514 } | |
3515 } | |
3516 | |
3517 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3518 time_diff(struct timeval *then, struct timeval *now) |
6 | 3519 { |
3520 long usec; | |
3521 long msec; | |
3522 | |
3523 usec = now->tv_usec - then->tv_usec; | |
3524 msec = (now->tv_sec - then->tv_sec) * 1000L + usec / 1000L, | |
3525 usec = usec % 1000L; | |
3526 fprintf(time_fd, "%03ld.%03ld", msec, usec >= 0 ? usec : usec + 1000L); | |
3527 } | |
3528 | |
3529 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3530 time_msg( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3531 char *mesg, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3532 void *tv_start) /* only for do_source: start time; actually |
6 | 3533 (struct timeval *) */ |
3534 { | |
3535 static struct timeval start; | |
3536 struct timeval now; | |
3537 | |
3538 if (time_fd != NULL) | |
3539 { | |
2271
2b33a7678e7b
Fix compiler warnings for shadowed variables. Make 'conceal' a long instead
Bram Moolenaar <bram@vim.org>
parents:
2267
diff
changeset
|
3540 if (strstr(mesg, "STARTING") != NULL) |
6 | 3541 { |
3542 gettimeofday(&start, NULL); | |
3543 prev_timeval = start; | |
3544 fprintf(time_fd, "\n\ntimes in msec\n"); | |
3545 fprintf(time_fd, " clock self+sourced self: sourced script\n"); | |
3546 fprintf(time_fd, " clock elapsed: other lines\n\n"); | |
3547 } | |
3548 gettimeofday(&now, NULL); | |
3549 time_diff(&start, &now); | |
3550 if (((struct timeval *)tv_start) != NULL) | |
3551 { | |
3552 fprintf(time_fd, " "); | |
3553 time_diff(((struct timeval *)tv_start), &now); | |
3554 } | |
3555 fprintf(time_fd, " "); | |
3556 time_diff(&prev_timeval, &now); | |
3557 prev_timeval = now; | |
2271
2b33a7678e7b
Fix compiler warnings for shadowed variables. Make 'conceal' a long instead
Bram Moolenaar <bram@vim.org>
parents:
2267
diff
changeset
|
3558 fprintf(time_fd, ": %s\n", mesg); |
6 | 3559 } |
3560 } | |
3561 | |
3562 #endif | |
3563 | |
11040
fde2cdef6b97
patch 8.0.0409: set_progpath is defined but not always used
Christian Brabandt <cb@256bit.org>
parents:
11032
diff
changeset
|
3564 #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
|
3565 static void |
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3566 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
|
3567 { |
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3568 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
|
3569 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3570 # ifdef MSWIN |
11032
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3571 /* A relative path containing a "/" will become invalid when using ":cd", |
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3572 * turn it into a full path. |
11060
354593196e20
patch 8.0.0419: test for v:progpath fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11054
diff
changeset
|
3573 * On MS-Windows "vim" should be expanded to "vim.exe", thus always do |
354593196e20
patch 8.0.0419: test for v:progpath fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11054
diff
changeset
|
3574 * this. */ |
354593196e20
patch 8.0.0419: test for v:progpath fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11054
diff
changeset
|
3575 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
|
3576 |
354593196e20
patch 8.0.0419: test for v:progpath fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11054
diff
changeset
|
3577 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
|
3578 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
|
3579 # else |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3580 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
|
3581 # 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
|
3582 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
|
3583 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
|
3584 |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3585 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
|
3586 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
|
3587 { |
12148
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3588 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
|
3589 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
|
3590 } |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3591 # endif |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3592 |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3593 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
|
3594 { |
315919a95b4d
patch 8.0.0954: /proc/self/exe might be a relative path
Christian Brabandt <cb@256bit.org>
parents:
12132
diff
changeset
|
3595 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
|
3596 && 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
|
3597 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
|
3598 } |
11032
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3599 # endif |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
3600 |
11032
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3601 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
|
3602 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3603 # ifdef MSWIN |
11054
576238eda5a4
patch 8.0.0416: setting v:progpath is not quite right
Christian Brabandt <cb@256bit.org>
parents:
11040
diff
changeset
|
3604 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
|
3605 # endif |
11032
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3606 } |
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3607 |
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3608 #endif /* NO_VIM_MAIN */ |
516391d8865f
patch 8.0.0405: v:progpath may become invalid after :cd
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
3609 |
2730 | 3610 #if (defined(FEAT_CLIENTSERVER) && !defined(NO_VIM_MAIN)) || defined(PROTO) |
6 | 3611 |
3612 /* | |
3613 * Common code for the X command server and the Win32 command server. | |
3614 */ | |
3615 | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7697
diff
changeset
|
3616 static char_u *build_drop_cmd(int filec, char **filev, int tabs, int sendReply); |
6 | 3617 |
443 | 3618 /* |
3619 * Do the client-server stuff, unless "--servername ''" was used. | |
3620 */ | |
3621 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3622 exec_on_server(mparm_T *parmp) |
443 | 3623 { |
3624 if (parmp->serverName_arg == NULL || *parmp->serverName_arg != NUL) | |
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 |
443 | 3627 /* Initialise the client/server messaging infrastructure. */ |
3628 serverInitMessaging(); | |
3629 # endif | |
3630 | |
3631 /* | |
3632 * When a command server argument was found, execute it. This may | |
3633 * exit Vim when it was successful. Otherwise it's executed further | |
3634 * on. Remember the encoding used here in "serverStrEnc". | |
3635 */ | |
3636 if (parmp->serverArg) | |
3637 { | |
3638 cmdsrv_main(&parmp->argc, parmp->argv, | |
3639 parmp->serverName_arg, &parmp->serverStr); | |
3640 parmp->serverStrEnc = vim_strsave(p_enc); | |
3641 } | |
3642 | |
3643 /* If we're still running, get the name to register ourselves. | |
3644 * On Win32 can register right now, for X11 need to setup the | |
3645 * clipboard first, it's further down. */ | |
3646 parmp->servername = serverMakeName(parmp->serverName_arg, | |
3647 parmp->argv[0]); | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3648 # ifdef MSWIN |
443 | 3649 if (parmp->servername != NULL) |
3650 { | |
3651 serverSetName(parmp->servername); | |
3652 vim_free(parmp->servername); | |
3653 } | |
3654 # endif | |
3655 } | |
3656 } | |
3657 | |
3658 /* | |
3659 * Prepare for running as a Vim server. | |
3660 */ | |
3661 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3662 prepare_server(mparm_T *parmp) |
443 | 3663 { |
3664 # if defined(FEAT_X11) | |
3665 /* | |
3666 * Register for remote command execution with :serversend and --remote | |
3667 * unless there was a -X or a --servername '' on the command line. | |
12837
963cdeb42c41
patch 8.0.1295: cannot automatically get a server name in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
3668 * Only register nongui-vim's with an explicit --servername argument, |
963cdeb42c41
patch 8.0.1295: cannot automatically get a server name in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
3669 * or when compiling with autoservername. |
926 | 3670 * When running as root --servername is also required. |
443 | 3671 */ |
3672 if (X_DISPLAY != NULL && parmp->servername != NULL && ( | |
12837
963cdeb42c41
patch 8.0.1295: cannot automatically get a server name in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
3673 # if defined(FEAT_AUTOSERVERNAME) || defined(FEAT_GUI) |
963cdeb42c41
patch 8.0.1295: cannot automatically get a server name in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
3674 ( |
963cdeb42c41
patch 8.0.1295: cannot automatically get a server name in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
3675 # if defined(FEAT_AUTOSERVERNAME) |
963cdeb42c41
patch 8.0.1295: cannot automatically get a server name in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
3676 1 |
963cdeb42c41
patch 8.0.1295: cannot automatically get a server name in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
3677 # else |
963cdeb42c41
patch 8.0.1295: cannot automatically get a server name in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
3678 gui.in_use |
963cdeb42c41
patch 8.0.1295: cannot automatically get a server name in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
3679 # endif |
926 | 3680 # ifdef UNIX |
1076 | 3681 && getuid() != ROOT_UID |
926 | 3682 # endif |
3683 ) || | |
443 | 3684 # endif |
3685 parmp->serverName_arg != NULL)) | |
3686 { | |
3687 (void)serverRegisterName(X_DISPLAY, parmp->servername); | |
3688 vim_free(parmp->servername); | |
3689 TIME_MSG("register server name"); | |
3690 } | |
3691 else | |
3692 serverDelayedStartName = parmp->servername; | |
3693 # endif | |
3694 | |
3695 /* | |
3696 * Execute command ourselves if we're here because the send failed (or | |
3697 * else we would have exited above). | |
3698 */ | |
3699 if (parmp->serverStr != NULL) | |
3700 { | |
3701 char_u *p; | |
3702 | |
3703 server_to_input_buf(serverConvert(parmp->serverStrEnc, | |
3704 parmp->serverStr, &p)); | |
3705 vim_free(p); | |
3706 } | |
3707 } | |
3708 | |
6 | 3709 static void |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3710 cmdsrv_main( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3711 int *argc, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3712 char **argv, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3713 char_u *serverName_arg, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3714 char_u **serverStr) |
6 | 3715 { |
3716 char_u *res; | |
3717 int i; | |
3718 char_u *sname; | |
3719 int ret; | |
3720 int didone = FALSE; | |
3721 int exiterr = 0; | |
3722 char **newArgV = argv + 1; | |
3723 int newArgC = 1, | |
3724 Argc = *argc; | |
3725 int argtype; | |
3726 #define ARGTYPE_OTHER 0 | |
3727 #define ARGTYPE_EDIT 1 | |
3728 #define ARGTYPE_EDIT_WAIT 2 | |
3729 #define ARGTYPE_SEND 3 | |
3730 int silent = FALSE; | |
734 | 3731 int tabs = FALSE; |
6 | 3732 # ifndef FEAT_X11 |
3733 HWND srv; | |
3734 # else | |
3735 Window srv; | |
3736 | |
3737 setup_term_clip(); | |
3738 # endif | |
3739 | |
3740 sname = serverMakeName(serverName_arg, argv[0]); | |
3741 if (sname == NULL) | |
3742 return; | |
3743 | |
3744 /* | |
3745 * Execute the command server related arguments and remove them | |
3746 * from the argc/argv array; We may have to return into main() | |
3747 */ | |
3748 for (i = 1; i < Argc; i++) | |
3749 { | |
3750 res = NULL; | |
443 | 3751 if (STRCMP(argv[i], "--") == 0) /* end of option arguments */ |
6 | 3752 { |
3753 for (; i < *argc; i++) | |
3754 { | |
3755 *newArgV++ = argv[i]; | |
3756 newArgC++; | |
3757 } | |
3758 break; | |
3759 } | |
3760 | |
734 | 3761 if (STRICMP(argv[i], "--remote-send") == 0) |
3762 argtype = ARGTYPE_SEND; | |
3763 else if (STRNICMP(argv[i], "--remote", 8) == 0) | |
3764 { | |
3765 char *p = argv[i] + 8; | |
3766 | |
6 | 3767 argtype = ARGTYPE_EDIT; |
734 | 3768 while (*p != NUL) |
3769 { | |
3770 if (STRNICMP(p, "-wait", 5) == 0) | |
3771 { | |
3772 argtype = ARGTYPE_EDIT_WAIT; | |
3773 p += 5; | |
3774 } | |
3775 else if (STRNICMP(p, "-silent", 7) == 0) | |
3776 { | |
3777 silent = TRUE; | |
3778 p += 7; | |
3779 } | |
3780 else if (STRNICMP(p, "-tab", 4) == 0) | |
3781 { | |
3782 tabs = TRUE; | |
3783 p += 4; | |
3784 } | |
3785 else | |
3786 { | |
3787 argtype = ARGTYPE_OTHER; | |
3788 break; | |
3789 } | |
3790 } | |
6 | 3791 } |
3792 else | |
3793 argtype = ARGTYPE_OTHER; | |
734 | 3794 |
6 | 3795 if (argtype != ARGTYPE_OTHER) |
3796 { | |
3797 if (i == *argc - 1) | |
3798 mainerr_arg_missing((char_u *)argv[i]); | |
3799 if (argtype == ARGTYPE_SEND) | |
3800 { | |
3801 *serverStr = (char_u *)argv[i + 1]; | |
3802 i++; | |
3803 } | |
3804 else | |
3805 { | |
3806 *serverStr = build_drop_cmd(*argc - i - 1, argv + i + 1, | |
734 | 3807 tabs, argtype == ARGTYPE_EDIT_WAIT); |
6 | 3808 if (*serverStr == NULL) |
3809 { | |
3810 /* Probably out of memory, exit. */ | |
3811 didone = TRUE; | |
3812 exiterr = 1; | |
3813 break; | |
3814 } | |
3815 Argc = i; | |
3816 } | |
3817 # ifdef FEAT_X11 | |
3818 if (xterm_dpy == NULL) | |
3819 { | |
3820 mch_errmsg(_("No display")); | |
3821 ret = -1; | |
3822 } | |
3823 else | |
3824 ret = serverSendToVim(xterm_dpy, sname, *serverStr, | |
11211
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11179
diff
changeset
|
3825 NULL, &srv, 0, 0, 0, silent); |
6 | 3826 # else |
3827 /* Win32 always works? */ | |
11211
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11179
diff
changeset
|
3828 ret = serverSendToVim(sname, *serverStr, NULL, &srv, 0, 0, silent); |
6 | 3829 # endif |
3830 if (ret < 0) | |
3831 { | |
3832 if (argtype == ARGTYPE_SEND) | |
3833 { | |
3834 /* Failed to send, abort. */ | |
3835 mch_errmsg(_(": Send failed.\n")); | |
3836 didone = TRUE; | |
3837 exiterr = 1; | |
3838 } | |
3839 else if (!silent) | |
3840 /* Let vim start normally. */ | |
3841 mch_errmsg(_(": Send failed. Trying to execute locally\n")); | |
3842 break; | |
3843 } | |
3844 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3845 # ifdef FEAT_GUI_MSWIN |
6 | 3846 /* Guess that when the server name starts with "g" it's a GUI |
3847 * server, which we can bring to the foreground here. | |
3848 * Foreground() in the server doesn't work very well. */ | |
3849 if (argtype != ARGTYPE_SEND && TOUPPER_ASC(*sname) == 'G') | |
3850 SetForegroundWindow(srv); | |
3851 # endif | |
3852 | |
3853 /* | |
3854 * For --remote-wait: Wait until the server did edit each | |
3855 * file. Also detect that the server no longer runs. | |
3856 */ | |
3857 if (ret >= 0 && argtype == ARGTYPE_EDIT_WAIT) | |
3858 { | |
3859 int numFiles = *argc - i - 1; | |
3860 int j; | |
3861 char_u *done = alloc(numFiles); | |
3862 char_u *p; | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3863 # ifdef FEAT_GUI_MSWIN |
6 | 3864 NOTIFYICONDATA ni; |
3865 int count = 0; | |
3866 extern HWND message_window; | |
3867 # endif | |
3868 | |
3869 if (numFiles > 0 && argv[i + 1][0] == '+') | |
3870 /* Skip "+cmd" argument, don't wait for it to be edited. */ | |
3871 --numFiles; | |
3872 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3873 # ifdef FEAT_GUI_MSWIN |
6 | 3874 ni.cbSize = sizeof(ni); |
3875 ni.hWnd = message_window; | |
3876 ni.uID = 0; | |
3877 ni.uFlags = NIF_ICON|NIF_TIP; | |
3878 ni.hIcon = LoadIcon((HINSTANCE)GetModuleHandle(0), "IDR_VIM"); | |
3879 sprintf(ni.szTip, _("%d of %d edited"), count, numFiles); | |
3880 Shell_NotifyIcon(NIM_ADD, &ni); | |
3881 # endif | |
3882 | |
3883 /* Wait for all files to unload in remote */ | |
2215
cccb71c2c5c1
Fix uninit memory read in undo code. Fix uint32_t in proto file.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3884 vim_memset(done, 0, numFiles); |
6 | 3885 while (memchr(done, 0, numFiles) != NULL) |
3886 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3887 # ifdef MSWIN |
11211
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11179
diff
changeset
|
3888 p = serverGetReply(srv, NULL, TRUE, TRUE, 0); |
6 | 3889 if (p == NULL) |
3890 break; | |
3891 # else | |
11211
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11179
diff
changeset
|
3892 if (serverReadReply(xterm_dpy, srv, &p, TRUE, -1) < 0) |
6 | 3893 break; |
3894 # endif | |
3895 j = atoi((char *)p); | |
3896 if (j >= 0 && j < numFiles) | |
3897 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3898 # ifdef FEAT_GUI_MSWIN |
6 | 3899 ++count; |
3900 sprintf(ni.szTip, _("%d of %d edited"), | |
3901 count, numFiles); | |
3902 Shell_NotifyIcon(NIM_MODIFY, &ni); | |
3903 # endif | |
3904 done[j] = 1; | |
3905 } | |
3906 } | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3907 # ifdef FEAT_GUI_MSWIN |
6 | 3908 Shell_NotifyIcon(NIM_DELETE, &ni); |
3909 # endif | |
3910 } | |
3911 } | |
3912 else if (STRICMP(argv[i], "--remote-expr") == 0) | |
3913 { | |
3914 if (i == *argc - 1) | |
3915 mainerr_arg_missing((char_u *)argv[i]); | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3916 # ifdef MSWIN |
6 | 3917 /* Win32 always works? */ |
3918 if (serverSendToVim(sname, (char_u *)argv[i + 1], | |
11211
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11179
diff
changeset
|
3919 &res, NULL, 1, 0, FALSE) < 0) |
6 | 3920 # else |
3921 if (xterm_dpy == NULL) | |
3922 mch_errmsg(_("No display: Send expression failed.\n")); | |
3923 else if (serverSendToVim(xterm_dpy, sname, (char_u *)argv[i + 1], | |
11211
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11179
diff
changeset
|
3924 &res, NULL, 1, 0, 1, FALSE) < 0) |
6 | 3925 # endif |
3926 { | |
3927 if (res != NULL && *res != NUL) | |
3928 { | |
3929 /* Output error from remote */ | |
3930 mch_errmsg((char *)res); | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13240
diff
changeset
|
3931 VIM_CLEAR(res); |
6 | 3932 } |
3933 mch_errmsg(_(": Send expression failed.\n")); | |
3934 } | |
3935 } | |
3936 else if (STRICMP(argv[i], "--serverlist") == 0) | |
3937 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3938 # ifdef MSWIN |
6 | 3939 /* Win32 always works? */ |
3940 res = serverGetVimNames(); | |
3941 # else | |
3942 if (xterm_dpy != NULL) | |
3943 res = serverGetVimNames(xterm_dpy); | |
3944 # endif | |
3945 if (called_emsg) | |
3946 mch_errmsg("\n"); | |
3947 } | |
3948 else if (STRICMP(argv[i], "--servername") == 0) | |
3949 { | |
2021 | 3950 /* Already processed. Take it out of the command line */ |
6 | 3951 i++; |
3952 continue; | |
3953 } | |
3954 else | |
3955 { | |
3956 *newArgV++ = argv[i]; | |
3957 newArgC++; | |
3958 continue; | |
3959 } | |
3960 didone = TRUE; | |
3961 if (res != NULL && *res != NUL) | |
3962 { | |
3963 mch_msg((char *)res); | |
3964 if (res[STRLEN(res) - 1] != '\n') | |
3965 mch_msg("\n"); | |
3966 } | |
3967 vim_free(res); | |
3968 } | |
3969 | |
3970 if (didone) | |
3971 { | |
3972 display_errors(); /* display any collected messages */ | |
3973 exit(exiterr); /* Mission accomplished - get out */ | |
3974 } | |
3975 | |
3976 /* Return back into main() */ | |
3977 *argc = newArgC; | |
3978 vim_free(sname); | |
3979 } | |
3980 | |
3981 /* | |
3982 * Build a ":drop" command to send to a Vim server. | |
3983 */ | |
3984 static char_u * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3985 build_drop_cmd( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3986 int filec, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3987 char **filev, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3988 int tabs, /* Use ":tab drop" instead of ":drop". */ |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3989 int sendReply) |
6 | 3990 { |
3991 garray_T ga; | |
3992 int i; | |
3993 char_u *inicmd = NULL; | |
3994 char_u *p; | |
6708 | 3995 char_u *cdp; |
2770 | 3996 char_u *cwd; |
6 | 3997 |
3998 if (filec > 0 && filev[0][0] == '+') | |
3999 { | |
4000 inicmd = (char_u *)filev[0] + 1; | |
4001 filev++; | |
4002 filec--; | |
4003 } | |
4004 /* Check if we have at least one argument. */ | |
4005 if (filec <= 0) | |
4006 mainerr_arg_missing((char_u *)filev[-1]); | |
2640 | 4007 |
4008 /* Temporarily cd to the current directory to handle relative file names. */ | |
2770 | 4009 cwd = alloc(MAXPATHL); |
4010 if (cwd == NULL) | |
6 | 4011 return NULL; |
2770 | 4012 if (mch_dirname(cwd, MAXPATHL) != OK) |
4013 { | |
4014 vim_free(cwd); | |
4015 return NULL; | |
4016 } | |
6708 | 4017 cdp = vim_strsave_escaped_ext(cwd, |
1385 | 4018 #ifdef BACKSLASH_IN_FILENAME |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
4019 (char_u *)"", /* rem_backslash() will tell what chars to escape */ |
1385 | 4020 #else |
4021 PATH_ESC_CHARS, | |
4022 #endif | |
2770 | 4023 '\\', TRUE); |
4024 vim_free(cwd); | |
6708 | 4025 if (cdp == NULL) |
6 | 4026 return NULL; |
4027 ga_init2(&ga, 1, 100); | |
4028 ga_concat(&ga, (char_u *)"<C-\\><C-N>:cd "); | |
6708 | 4029 ga_concat(&ga, cdp); |
734 | 4030 |
6 | 4031 /* Call inputsave() so that a prompt for an encryption key works. */ |
734 | 4032 ga_concat(&ga, (char_u *)"<CR>:if exists('*inputsave')|call inputsave()|endif|"); |
4033 if (tabs) | |
4034 ga_concat(&ga, (char_u *)"tab "); | |
4035 ga_concat(&ga, (char_u *)"drop"); | |
6 | 4036 for (i = 0; i < filec; i++) |
4037 { | |
4038 /* On Unix the shell has already expanded the wildcards, don't want to | |
40 | 4039 * do it again in the Vim server. On MS-Windows only escape |
4040 * non-wildcard characters. */ | |
6 | 4041 p = vim_strsave_escaped((char_u *)filev[i], |
4042 #ifdef UNIX | |
4043 PATH_ESC_CHARS | |
4044 #else | |
40 | 4045 (char_u *)" \t%#" |
6 | 4046 #endif |
4047 ); | |
4048 if (p == NULL) | |
4049 { | |
4050 vim_free(ga.ga_data); | |
4051 return NULL; | |
4052 } | |
4053 ga_concat(&ga, (char_u *)" "); | |
4054 ga_concat(&ga, p); | |
4055 vim_free(p); | |
4056 } | |
2640 | 4057 ga_concat(&ga, (char_u *)"|if exists('*inputrestore')|call inputrestore()|endif<CR>"); |
4058 | |
6 | 4059 /* The :drop commands goes to Insert mode when 'insertmode' is set, use |
4060 * CTRL-\ CTRL-N again. */ | |
2640 | 4061 ga_concat(&ga, (char_u *)"<C-\\><C-N>"); |
4062 | |
4063 /* Switch back to the correct current directory (prior to temporary path | |
4064 * switch) unless 'autochdir' is set, in which case it will already be | |
6708 | 4065 * correct after the :drop command. With line breaks and spaces: |
4066 * if !exists('+acd') || !&acd | |
4067 * if haslocaldir() | |
4068 * cd - | |
4069 * lcd - | |
6895 | 4070 * elseif getcwd() ==# 'current path' |
6708 | 4071 * cd - |
4072 * endif | |
4073 * endif | |
4074 */ | |
4075 ga_concat(&ga, (char_u *)":if !exists('+acd')||!&acd|if haslocaldir()|"); | |
6895 | 4076 ga_concat(&ga, (char_u *)"cd -|lcd -|elseif getcwd() ==# '"); |
6708 | 4077 ga_concat(&ga, cdp); |
6895 | 4078 ga_concat(&ga, (char_u *)"'|cd -|endif|endif<CR>"); |
6708 | 4079 vim_free(cdp); |
2640 | 4080 |
6 | 4081 if (sendReply) |
2640 | 4082 ga_concat(&ga, (char_u *)":call SetupRemoteReplies()<CR>"); |
4083 ga_concat(&ga, (char_u *)":"); | |
6 | 4084 if (inicmd != NULL) |
4085 { | |
4086 /* Can't use <CR> after "inicmd", because an "startinsert" would cause | |
4087 * the following commands to be inserted as text. Use a "|", | |
4088 * hopefully "inicmd" does allow this... */ | |
4089 ga_concat(&ga, inicmd); | |
4090 ga_concat(&ga, (char_u *)"|"); | |
4091 } | |
4092 /* Bring the window to the foreground, goto Insert mode when 'im' set and | |
4093 * clear command line. */ | |
46 | 4094 ga_concat(&ga, (char_u *)"cal foreground()|if &im|star|en|redr|f<CR>"); |
6 | 4095 ga_append(&ga, NUL); |
4096 return ga.ga_data; | |
4097 } | |
4098 | |
4099 /* | |
2730 | 4100 * Make our basic server name: use the specified "arg" if given, otherwise use |
4101 * the tail of the command "cmd" we were started with. | |
4102 * Return the name in allocated memory. This doesn't include a serial number. | |
4103 */ | |
4104 static char_u * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4105 serverMakeName(char_u *arg, char *cmd) |
2730 | 4106 { |
4107 char_u *p; | |
4108 | |
4109 if (arg != NULL && *arg != NUL) | |
4110 p = vim_strsave_up(arg); | |
4111 else | |
4112 { | |
4113 p = vim_strsave_up(gettail((char_u *)cmd)); | |
4114 /* Remove .exe or .bat from the name. */ | |
4115 if (p != NULL && vim_strchr(p, '.') != NULL) | |
4116 *vim_strchr(p, '.') = NUL; | |
4117 } | |
4118 return p; | |
4119 } | |
4120 #endif /* FEAT_CLIENTSERVER */ | |
4121 | |
4122 #if defined(FEAT_CLIENTSERVER) || defined(PROTO) | |
4123 /* | |
6 | 4124 * Replace termcodes such as <CR> and insert as key presses if there is room. |
4125 */ | |
4126 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4127 server_to_input_buf(char_u *str) |
6 | 4128 { |
4129 char_u *ptr = NULL; | |
4130 char_u *cpo_save = p_cpo; | |
4131 | |
4132 /* Set 'cpoptions' the way we want it. | |
4133 * B set - backslashes are *not* treated specially | |
4134 * k set - keycodes are *not* reverse-engineered | |
4135 * < unset - <Key> sequences *are* interpreted | |
860 | 4136 * The last but one parameter of replace_termcodes() is TRUE so that the |
4137 * <lt> sequence is recognised - needed for a real backslash. | |
6 | 4138 */ |
4139 p_cpo = (char_u *)"Bk"; | |
860 | 4140 str = replace_termcodes((char_u *)str, &ptr, FALSE, TRUE, FALSE); |
6 | 4141 p_cpo = cpo_save; |
4142 | |
4143 if (*ptr != NUL) /* trailing CTRL-V results in nothing */ | |
4144 { | |
4145 /* | |
4146 * Add the string to the input stream. | |
4147 * Can't use add_to_input_buf() here, we now have K_SPECIAL bytes. | |
4148 * | |
4149 * First clear typed characters from the typeahead buffer, there could | |
4150 * be half a mapping there. Then append to the existing string, so | |
4151 * that multiple commands from a client are concatenated. | |
4152 */ | |
4153 if (typebuf.tb_maplen < typebuf.tb_len) | |
4154 del_typebuf(typebuf.tb_len - typebuf.tb_maplen, typebuf.tb_maplen); | |
4155 (void)ins_typebuf(str, REMAP_NONE, typebuf.tb_len, TRUE, FALSE); | |
4156 | |
4157 /* Let input_available() know we inserted text in the typeahead | |
4158 * buffer. */ | |
841 | 4159 typebuf_was_filled = TRUE; |
6 | 4160 } |
4161 vim_free((char_u *)ptr); | |
4162 } | |
4163 | |
4164 /* | |
4165 * Evaluate an expression that the client sent to a string. | |
4166 */ | |
4167 char_u * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4168 eval_client_expr_to_string(char_u *expr) |
6 | 4169 { |
4170 char_u *res; | |
4171 int save_dbl = debug_break_level; | |
4172 int save_ro = redir_off; | |
14927
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4173 funccal_entry_T funccal_entry; |
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4174 int did_save_funccal = FALSE; |
11179
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4175 |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4176 /* Evaluate the expression at the toplevel, don't use variables local to |
12678
116b7394b8af
patch 8.0.1217: can't use remote eval to inspect vars in debug mode
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
4177 * the calling function. Except when in debug mode. */ |
116b7394b8af
patch 8.0.1217: can't use remote eval to inspect vars in debug mode
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
4178 if (!debug_mode) |
14927
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4179 { |
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4180 save_funccal(&funccal_entry); |
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4181 did_save_funccal = TRUE; |
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4182 } |
6 | 4183 |
4217 | 4184 /* Disable debugging, otherwise Vim hangs, waiting for "cont" to be |
4185 * typed. */ | |
6 | 4186 debug_break_level = -1; |
4187 redir_off = 0; | |
4217 | 4188 /* Do not display error message, otherwise Vim hangs, waiting for "cont" |
4189 * to be typed. Do generate errors so that try/catch works. */ | |
4190 ++emsg_silent; | |
6 | 4191 |
714 | 4192 res = eval_to_string(expr, NULL, TRUE); |
6 | 4193 |
4194 debug_break_level = save_dbl; | |
4195 redir_off = save_ro; | |
4217 | 4196 --emsg_silent; |
4197 if (emsg_silent < 0) | |
4198 emsg_silent = 0; | |
14927
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4199 if (did_save_funccal) |
162d79d273e6
patch 8.1.0475: memory not freed on exit when quit in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4200 restore_funccal(); |
6 | 4201 |
591 | 4202 /* A client can tell us to redraw, but not to display the cursor, so do |
4203 * that here. */ | |
4204 setcursor(); | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
4205 out_flush_cursor(FALSE, FALSE); |
591 | 4206 |
6 | 4207 return res; |
4208 } | |
4209 | |
39 | 4210 /* |
11179
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4211 * Evaluate a command or expression sent to ourselves. |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4212 */ |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4213 int |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4214 sendToLocalVim(char_u *cmd, int asExpr, char_u **result) |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4215 { |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4216 if (asExpr) |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4217 { |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4218 char_u *ret; |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4219 |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4220 ret = eval_client_expr_to_string(cmd); |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4221 if (result != NULL) |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4222 { |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4223 if (ret == NULL) |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4224 { |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4225 char *err = _(e_invexprmsg); |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4226 size_t len = STRLEN(cmd) + STRLEN(err) + 5; |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4227 char_u *msg; |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4228 |
11215
2e4877acfe0a
patch 8.0.0494: build failure with older compiler on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
4229 msg = alloc((unsigned)len); |
11179
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4230 if (msg != NULL) |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4231 vim_snprintf((char *)msg, len, "%s: \"%s\"", err, cmd); |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4232 *result = msg; |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4233 } |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4234 else |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4235 *result = ret; |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4236 } |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4237 else |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4238 vim_free(ret); |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4239 return ret == NULL ? -1 : 0; |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4240 } |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4241 server_to_input_buf(cmd); |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4242 return 0; |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4243 } |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4244 |
49fda934f7e8
patch 8.0.0476: missing change to main.c
Christian Brabandt <cb@256bit.org>
parents:
11154
diff
changeset
|
4245 /* |
39 | 4246 * If conversion is needed, convert "data" from "client_enc" to 'encoding' and |
4247 * return an allocated string. Otherwise return "data". | |
4248 * "*tofree" is set to the result when it needs to be freed later. | |
4249 */ | |
4250 char_u * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4251 serverConvert( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4252 char_u *client_enc UNUSED, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4253 char_u *data, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4254 char_u **tofree) |
39 | 4255 { |
4256 char_u *res = data; | |
4257 | |
4258 *tofree = NULL; | |
4259 if (client_enc != NULL && p_enc != NULL) | |
4260 { | |
4261 vimconv_T vimconv; | |
4262 | |
4263 vimconv.vc_type = CONV_NONE; | |
4264 if (convert_setup(&vimconv, client_enc, p_enc) != FAIL | |
4265 && vimconv.vc_type != CONV_NONE) | |
4266 { | |
4267 res = string_convert(&vimconv, data, NULL); | |
4268 if (res == NULL) | |
4269 res = data; | |
4270 else | |
4271 *tofree = res; | |
4272 } | |
4273 convert_setup(&vimconv, NULL, NULL); | |
4274 } | |
4275 return res; | |
4276 } | |
2730 | 4277 #endif |