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