annotate src/main.c @ 411:5f33b64a6694 v7.0107

updated for version 7.0107
author vimboss
date Mon, 11 Jul 2005 22:42:07 +0000
parents 6c62b9b939bd
children 1ec6b77beee0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2 *
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
4 *
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
8 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
9
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
10 #if defined(MSDOS) || defined(WIN32) || defined(_WIN64)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
11 # include <io.h> /* for close() and dup() */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
12 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
13
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
14 #define EXTERN
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
15 #include "vim.h"
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
16
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
17 #ifdef SPAWNO
242
a711f7a6852d updated for version 7.0067
vimboss
parents: 237
diff changeset
18 # include <spawno.h> /* special MS-DOS swapping library */
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
19 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
20
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
21 #ifdef HAVE_FCNTL_H
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
22 # include <fcntl.h>
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
23 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
24
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
25 #ifdef __CYGWIN__
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
26 # ifndef WIN32
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
27 # include <sys/cygwin.h> /* for cygwin_conv_to_posix_path() */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
28 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
29 # include <limits.h>
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
30 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
31
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
32 #if defined(UNIX) || defined(VMS)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
33 static int file_owned __ARGS((char *fname));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
34 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
35 static void mainerr __ARGS((int, char_u *));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
36 static void main_msg __ARGS((char *s));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
37 static void usage __ARGS((void));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
38 static int get_number_arg __ARGS((char_u *p, int *idx, int def));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
39 static void main_start_gui __ARGS((void));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
40 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
41 static void check_swap_exists_action __ARGS((void));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
42 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
43 #ifdef FEAT_CLIENTSERVER
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
44 static void cmdsrv_main __ARGS((int *argc, char **argv, char_u *serverName_arg, char_u **serverStr));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
45 static char_u *serverMakeName __ARGS((char_u *arg, char *cmd));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
46 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
47
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
48
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
49 #ifdef STARTUPTIME
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
50 static FILE *time_fd = NULL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
51 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
52
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
53 #define FEAT_PRECOMMANDS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
54
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
55 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
56 * Different types of error messages.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
57 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
58 static char *(main_errors[]) =
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
59 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
60 N_("Unknown option"),
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
61 #define ME_UNKNOWN_OPTION 0
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
62 N_("Too many edit arguments"),
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
63 #define ME_TOO_MANY_ARGS 1
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
64 N_("Argument missing after"),
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
65 #define ME_ARG_MISSING 2
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
66 N_("Garbage after option"),
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
67 #define ME_GARBAGE 3
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
68 N_("Too many \"+command\", \"-c command\" or \"--cmd command\" arguments"),
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
69 #define ME_EXTRA_CMD 4
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
70 N_("Invalid argument for"),
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
71 #define ME_INVALID_ARG 5
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
72 };
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
73
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
74 /* Maximum number of commands from + or -c options */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
75 #define MAX_ARG_CMDS 10
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
76
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
77 #ifndef PROTO /* don't want a prototype for main() */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
78 int
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
79 # ifdef VIMDLL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
80 _export
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
81 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
82 # ifdef FEAT_GUI_MSWIN
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
83 # ifdef __BORLANDC__
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
84 _cdecl
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
85 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
86 VimMain
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
87 # else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
88 main
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
89 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
90 (argc, argv)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
91 int argc;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
92 char **argv;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
93 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
94 char_u *initstr; /* init string from environment */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
95 char_u *term = NULL; /* specified terminal name */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
96 char_u *fname = NULL; /* file name from command line */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
97 char_u *tagname = NULL; /* tag from -t option */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
98 char_u *use_vimrc = NULL; /* vimrc from -u option */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
99 #ifdef FEAT_QUICKFIX
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
100 char_u *use_ef = NULL; /* 'errorfile' from -q option */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
101 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
102 #ifdef FEAT_CRYPT
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
103 int ask_for_key = FALSE; /* -x argument */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
104 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
105 int n_commands = 0; /* no. of commands from + or -c */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
106 char_u *commands[MAX_ARG_CMDS]; /* commands from + or -c option */
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 294
diff changeset
107 char_u cmds_tofree[MAX_ARG_CMDS]; /* commands that need free() */
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
108 #ifdef FEAT_PRECOMMANDS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
109 int p_commands = 0; /* no. of commands from --cmd */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
110 char_u *pre_commands[MAX_ARG_CMDS]; /* commands from --cmd option */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
111 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
112 int no_swap_file = FALSE; /* "-n" option used */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
113 int c;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
114 int i;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
115 char_u *p = NULL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
116 int bin_mode = FALSE; /* -b option used */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
117 #ifdef FEAT_EVAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
118 int use_debug_break_level = -1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
119 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
120 #ifdef FEAT_WINDOWS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
121 int window_count = -1; /* number of windows to use */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
122 int arg_idx; /* index in argument list */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
123 int vert_windows = MAYBE; /* "-O" used instead of "-o" */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
124 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
125 int had_minmin = FALSE; /* found "--" option */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
126 int argv_idx; /* index in argv[n][] */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
127 int want_full_screen = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
128 int want_argument; /* option with argument */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
129 #define EDIT_NONE 0 /* no edit type yet */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
130 #define EDIT_FILE 1 /* file name argument[s] given, use argument list */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
131 #define EDIT_STDIN 2 /* read file from stdin */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
132 #define EDIT_TAG 3 /* tag name argument given, use tagname */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
133 #define EDIT_QF 4 /* start in quickfix mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
134 int edit_type = EDIT_NONE; /* type of editing to do */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
135 #ifdef FEAT_DIFF
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
136 int diff_mode = FALSE; /* start with 'diff' set */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
137 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
138 int evim_mode = FALSE; /* started as "evim" */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
139 int stdout_isatty; /* is stdout a terminal? */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
140 int input_isatty; /* is active input a terminal? */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
141 #ifdef MSWIN
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
142 int full_path = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
143 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
144 #ifdef FEAT_CLIENTSERVER
43
f55897d6921d updated for version 7.0026
vimboss
parents: 41
diff changeset
145 char_u *serverStr = NULL; /* remote server command */
f55897d6921d updated for version 7.0026
vimboss
parents: 41
diff changeset
146 char_u *serverStrEnc = NULL; /* encoding of serverStr */
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
147 char_u *serverName_arg = NULL; /* cmdline arg for server name */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
148 int serverArg = FALSE; /* TRUE when argument for a server */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
149 char_u *servername = NULL; /* allocated name for our server */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
150 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
151 #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
152 int literal = FALSE; /* don't expand file names */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
153 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
154
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
155 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
156 * Do any system-specific initialisations. These can NOT use IObuff or
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
157 * NameBuff. Thus emsg2() cannot be called!
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
158 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
159 mch_early_init();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
160
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
161 #ifdef FEAT_TCL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
162 vim_tcl_init(argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
163 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
164
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
165 #ifdef MEM_PROFILE
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
166 atexit(vim_mem_profile_dump);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
167 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
168
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
169 #ifdef STARTUPTIME
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
170 time_fd = fopen(STARTUPTIME, "a");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
171 TIME_MSG("--- VIM STARTING ---");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
172 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
173
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
174 #ifdef __EMX__
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
175 _wildcard(&argc, &argv);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
176 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
177
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
178 #ifdef FEAT_MBYTE
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
179 (void)mb_init(); /* init mb_bytelen_tab[] to ones */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
180 #endif
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 46
diff changeset
181 #ifdef FEAT_EVAL
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 46
diff changeset
182 eval_init(); /* init global variables */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 46
diff changeset
183 #endif
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
184
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
185 #ifdef __QNXNTO__
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
186 qnx_init(); /* PhAttach() for clipboard, (and gui) */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
187 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
188
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
189 #ifdef MAC_OS_CLASSIC
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
190 /* Macintosh needs this before any memory is allocated. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
191 gui_prepare(&argc, argv); /* Prepare for possibly starting GUI sometime */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
192 TIME_MSG("GUI prepared");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
193 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
194
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 294
diff changeset
195 vim_memset(cmds_tofree, 0, sizeof(cmds_tofree));
6c62b9b939bd updated for version 7.0093
vimboss
parents: 294
diff changeset
196
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
197 /* Init the table of Normal mode commands. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
198 init_normal_cmds();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
199
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
200 #if defined(HAVE_DATE_TIME) && defined(VMS) && defined(VAXC)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
201 make_version();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
202 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
203
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
204 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
205 * Allocate space for the generic buffers (needed for set_init_1() and
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
206 * EMSG2()).
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
207 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
208 if ((IObuff = alloc(IOSIZE)) == NULL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
209 || (NameBuff = alloc(MAXPATHL)) == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
210 mch_exit(0);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
211
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
212 TIME_MSG("Allocated generic buffers");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
213
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 16
diff changeset
214 #ifdef NBDEBUG
cc049b00ee70 updated for version 7.0014
vimboss
parents: 16
diff changeset
215 /* Wait a moment for debugging NetBeans. Must be after allocating
cc049b00ee70 updated for version 7.0014
vimboss
parents: 16
diff changeset
216 * NameBuff. */
cc049b00ee70 updated for version 7.0014
vimboss
parents: 16
diff changeset
217 nbdebug_log_init("SPRO_GVIM_DEBUG", "SPRO_GVIM_DLEVEL");
cc049b00ee70 updated for version 7.0014
vimboss
parents: 16
diff changeset
218 nbdebug_wait(WT_ENV | WT_WAIT | WT_STOP, "SPRO_GVIM_WAIT", 20);
cc049b00ee70 updated for version 7.0014
vimboss
parents: 16
diff changeset
219 #endif
cc049b00ee70 updated for version 7.0014
vimboss
parents: 16
diff changeset
220
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
221 #if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
222 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
223 * Setup to use the current locale (for ctype() and many other things).
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
224 * NOTE: Translated messages with encodings other than latin1 will not
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
225 * work until set_init_1() has been called!
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
226 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
227 setlocale(LC_ALL, "");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
228
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
229 # ifdef FEAT_GETTEXT
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
230 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
231 int mustfree = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
232
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
233 # ifdef DYNAMIC_GETTEXT
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
234 /* Initialize the gettext library */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
235 dyn_libintl_init(NULL);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
236 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
237 /* expand_env() doesn't work yet, because chartab[] is not initialized
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
238 * yet, call vim_getenv() directly */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
239 p = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
240 if (p != NULL && *p != NUL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
241 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
242 STRCPY(NameBuff, p);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
243 STRCAT(NameBuff, "/lang");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
244 bindtextdomain(VIMPACKAGE, (char *)NameBuff);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
245 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
246 if (mustfree)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
247 vim_free(p);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
248 textdomain(VIMPACKAGE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
249 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
250 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
251 TIME_MSG("locale set");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
252 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
253
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
254 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
255 gui.dofork = TRUE; /* default is to use fork() */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
256 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
257
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
258 #if defined(FEAT_XCLIPBOARD) || defined(FEAT_CLIENTSERVER)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
259 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
260 * Get the name of the display, before gui_prepare() removes it from
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
261 * argv[]. Used for the xterm-clipboard display.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
262 *
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
263 * Also find the --server... arguments
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
264 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
265 for (i = 1; i < argc; i++)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
266 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
267 if (STRCMP(argv[i], "--") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
268 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
269 # ifdef FEAT_XCLIPBOARD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
270 else if (STRICMP(argv[i], "-display") == 0
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
271 # if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
272 || STRICMP(argv[i], "--display") == 0
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
273 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
274 )
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
275 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
276 if (i == argc - 1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
277 mainerr_arg_missing((char_u *)argv[i]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
278 xterm_display = argv[++i];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
279 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
280 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
281 # ifdef FEAT_CLIENTSERVER
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
282 else if (STRICMP(argv[i], "--servername") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
283 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
284 if (i == argc - 1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
285 mainerr_arg_missing((char_u *)argv[i]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
286 serverName_arg = (char_u *)argv[++i];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
287 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
288 else if (STRICMP(argv[i], "--serverlist") == 0
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
289 || STRICMP(argv[i], "--remote-send") == 0
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
290 || STRICMP(argv[i], "--remote-expr") == 0
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
291 || STRICMP(argv[i], "--remote") == 0
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
292 || STRICMP(argv[i], "--remote-silent") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
293 serverArg = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
294 else if (STRICMP(argv[i], "--remote-wait") == 0
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
295 || STRICMP(argv[i], "--remote-wait-silent") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
296 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
297 serverArg = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
298 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
299 /* don't fork() when starting the GUI to edit the files ourself */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
300 gui.dofork = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
301 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
302 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
303 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
304 # ifdef FEAT_GUI_GTK
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
305 else if (STRICMP(argv[i], "--socketid") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
306 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
307 unsigned int socket_id;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
308 int count;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
309
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
310 if (i == argc - 1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
311 mainerr_arg_missing((char_u *)argv[i]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
312 if (STRNICMP(argv[i+1], "0x", 2) == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
313 count = sscanf(&(argv[i + 1][2]), "%x", &socket_id);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
314 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
315 count = sscanf(argv[i+1], "%u", &socket_id);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
316 if (count != 1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
317 mainerr(ME_INVALID_ARG, (char_u *)argv[i]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
318 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
319 gtk_socket_id = socket_id;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
320 i++;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
321 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
322 else if (STRICMP(argv[i], "--echo-wid") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
323 echo_wid_arg = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
324 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
325 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
326 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
327
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
328 #ifdef FEAT_SUN_WORKSHOP
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
329 findYourself(argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
330 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
331 #if defined(FEAT_GUI) && !defined(MAC_OS_CLASSIC)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
332 gui_prepare(&argc, argv); /* Prepare for possibly starting GUI sometime */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
333 TIME_MSG("GUI prepared");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
334 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
335
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
336 #ifdef FEAT_CLIPBOARD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
337 clip_init(FALSE); /* Initialise clipboard stuff */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
338 TIME_MSG("clipboard setup");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
339 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
340
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
341 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
342 * Check if we have an interactive window.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
343 * On the Amiga: If there is no window, we open one with a newcli command
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
344 * (needed for :! to * work). mch_check_win() will also handle the -d or
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
345 * -dev argument.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
346 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
347 stdout_isatty = (mch_check_win(argc, argv) != FAIL);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
348 TIME_MSG("window checked");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
349
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
350 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
351 * Allocate the first window and buffer. Can't do much without it.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
352 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
353 win_alloc_first();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
354
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
355 init_yank(); /* init yank buffers */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
356
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
357 /* Init the argument list to empty. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
358 alist_init(&global_alist);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
359
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
360 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
361 * Set the default values for the options.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
362 * NOTE: Non-latin1 translated messages are working only after this,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
363 * because this is where "has_mbyte" will be set, which is used by
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
364 * msg_outtrans_len_attr().
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
365 * First find out the home directory, needed to expand "~" in options.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
366 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
367 init_homedir(); /* find real value of $HOME */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
368 set_init_1();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
369 TIME_MSG("inits 1");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
370
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
371 #ifdef FEAT_EVAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
372 set_lang_var(); /* set v:lang and v:ctype */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
373 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
374
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
375 #ifdef FEAT_CLIENTSERVER
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
376 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
377 * Do the client-server stuff, unless "--servername ''" was used.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
378 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
379 if (serverName_arg == NULL || *serverName_arg != NUL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
380 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
381 # ifdef WIN32
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
382 /* Initialise the client/server messaging infrastructure. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
383 serverInitMessaging();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
384 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
385
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
386 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
387 * When a command server argument was found, execute it. This may
43
f55897d6921d updated for version 7.0026
vimboss
parents: 41
diff changeset
388 * exit Vim when it was successful. Otherwise it's executed further
f55897d6921d updated for version 7.0026
vimboss
parents: 41
diff changeset
389 * on. Remember the encoding used here in "serverStrEnc".
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
390 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
391 if (serverArg)
43
f55897d6921d updated for version 7.0026
vimboss
parents: 41
diff changeset
392 {
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
393 cmdsrv_main(&argc, argv, serverName_arg, &serverStr);
43
f55897d6921d updated for version 7.0026
vimboss
parents: 41
diff changeset
394 # ifdef FEAT_MBYTE
f55897d6921d updated for version 7.0026
vimboss
parents: 41
diff changeset
395 serverStrEnc = vim_strsave(p_enc);
f55897d6921d updated for version 7.0026
vimboss
parents: 41
diff changeset
396 # endif
f55897d6921d updated for version 7.0026
vimboss
parents: 41
diff changeset
397 }
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
398
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
399 /* If we're still running, get the name to register ourselves.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
400 * On Win32 can register right now, for X11 need to setup the
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
401 * clipboard first, it's further down. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
402 servername = serverMakeName(serverName_arg, argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
403 # ifdef WIN32
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
404 if (servername != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
405 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
406 serverSetName(servername);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
407 vim_free(servername);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
408 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
409 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
410 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
411 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
412
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
413 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
414 * Check for: [r][e][g][vi|vim|view][diff][ex[im]]
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
415 * If the executable name starts with "r" we disable shell commands.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
416 * If the next character is "e" we run in Easy mode.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
417 * If the next character is "g" we run the GUI version.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
418 * If the next characters are "view" we start in readonly mode.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
419 * If the next characters are "diff" or "vimdiff" we start in diff mode.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
420 * If the next characters are "ex" we start in Ex mode. If it's followed
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
421 * by "im" use improved Ex mode.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
422 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
423 initstr = gettail((char_u *)argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
424
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
425 #ifdef MACOS_X_UNIX
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
426 /* An issue has been seen when launching Vim in such a way that
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
427 * $PWD/$ARGV[0] or $ARGV[0] is not the absolute path to the
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
428 * executable or a symbolic link of it. Until this issue is resolved
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
429 * we prohibit the GUI from being used.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
430 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
431 if (STRCMP(initstr, argv[0]) == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
432 disallow_gui = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
433 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
434
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
435 #ifdef FEAT_EVAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
436 set_vim_var_string(VV_PROGNAME, initstr, -1);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
437 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
438
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
439 /* TODO: On MacOS X default to gui if argv[0] ends in:
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
440 * /vim.app/Contents/MacOS/Vim */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
441
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
442 if (TOLOWER_ASC(initstr[0]) == 'r')
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
443 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
444 restricted = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
445 ++initstr;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
446 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
447
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
448 /* Avoid using evim mode for "editor". */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
449 if (TOLOWER_ASC(initstr[0]) == 'e'
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
450 && (TOLOWER_ASC(initstr[1]) == 'v'
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
451 || TOLOWER_ASC(initstr[1]) == 'g'))
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
452 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
453 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
454 gui.starting = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
455 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
456 evim_mode = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
457 ++initstr;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
458 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
459
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
460 if (TOLOWER_ASC(initstr[0]) == 'g' || initstr[0] == 'k')
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
461 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
462 main_start_gui();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
463 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
464 ++initstr;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
465 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
466 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
467
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
468 if (STRNICMP(initstr, "view", 4) == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
469 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
470 readonlymode = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
471 curbuf->b_p_ro = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
472 p_uc = 10000; /* don't update very often */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
473 initstr += 4;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
474 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
475 else if (STRNICMP(initstr, "vim", 3) == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
476 initstr += 3;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
477
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
478 /* Catch "[r][g]vimdiff" and "[r][g]viewdiff". */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
479 if (STRICMP(initstr, "diff") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
480 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
481 #ifdef FEAT_DIFF
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
482 diff_mode = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
483 #else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
484 mch_errmsg(_("This Vim was not compiled with the diff feature."));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
485 mch_errmsg("\n");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
486 mch_exit(2);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
487 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
488 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
489
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
490 if (STRNICMP(initstr, "ex", 2) == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
491 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
492 if (STRNICMP(initstr + 2, "im", 2) == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
493 exmode_active = EXMODE_VIM;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
494 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
495 exmode_active = EXMODE_NORMAL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
496 change_compatible(TRUE); /* set 'compatible' */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
497 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
498
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
499 initstr = gettail((char_u *)argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
500 ++argv;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
501 --argc;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
502
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
503 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
504 * Process the command line arguments.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
505 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
506 argv_idx = 1; /* active option letter is argv[0][argv_idx] */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
507 while (argc > 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
508 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
509 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
510 * "+" or "+{number}" or "+/{pat}" or "+{command}" argument.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
511 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
512 if (argv[0][0] == '+' && !had_minmin)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
513 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
514 if (n_commands >= MAX_ARG_CMDS)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
515 mainerr(ME_EXTRA_CMD, NULL);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
516 argv_idx = -1; /* skip to next argument */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
517 if (argv[0][1] == NUL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
518 commands[n_commands++] = (char_u *)"$";
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
519 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
520 commands[n_commands++] = (char_u *)&(argv[0][1]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
521 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
522
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
523 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
524 * Optional argument.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
525 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
526 else if (argv[0][0] == '-' && !had_minmin)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
527 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
528 want_argument = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
529 c = argv[0][argv_idx++];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
530 #ifdef VMS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
531 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
532 * VMS only uses upper case command lines. Interpret "-X" as "-x"
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
533 * and "-/X" as "-X".
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
534 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
535 if (c == '/')
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
536 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
537 c = argv[0][argv_idx++];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
538 c = TOUPPER_ASC(c);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
539 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
540 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
541 c = TOLOWER_ASC(c);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
542 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
543 switch (c)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
544 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
545 case NUL: /* "vim -" read from stdin */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
546 /* "ex -" silent mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
547 if (exmode_active)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
548 silent_mode = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
549 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
550 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
551 if (edit_type != EDIT_NONE)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
552 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
553 edit_type = EDIT_STDIN;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
554 read_cmd_fd = 2; /* read from stderr instead of stdin */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
555 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
556 argv_idx = -1; /* skip to next argument */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
557 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
558
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
559 case '-': /* "--" don't take any more options */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
560 /* "--help" give help message */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
561 /* "--version" give version message */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
562 /* "--literal" take files literally */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
563 /* "--nofork" don't fork */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
564 /* "--noplugin[s]" skip plugins */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
565 /* "--cmd <cmd>" execute cmd before vimrc */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
566 if (STRICMP(argv[0] + argv_idx, "help") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
567 usage();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
568 else if (STRICMP(argv[0] + argv_idx, "version") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
569 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
570 Columns = 80; /* need to init Columns */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
571 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
572 list_version();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
573 msg_putchar('\n');
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
574 msg_didout = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
575 mch_exit(0);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
576 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
577 else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
578 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
579 #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
580 literal = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
581 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
582 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
583 else if (STRNICMP(argv[0] + argv_idx, "nofork", 6) == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
584 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
585 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
586 gui.dofork = FALSE; /* don't fork() when starting GUI */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
587 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
588 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
589 else if (STRNICMP(argv[0] + argv_idx, "noplugin", 8) == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
590 p_lpl = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
591 #ifdef FEAT_PRECOMMANDS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
592 else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
593 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
594 want_argument = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
595 argv_idx += 3;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
596 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
597 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
598 #ifdef FEAT_CLIENTSERVER
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
599 else if (STRNICMP(argv[0] + argv_idx, "serverlist", 10) == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
600 ; /* already processed -- no arg */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
601 else if (STRNICMP(argv[0] + argv_idx, "servername", 10) == 0
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
602 || STRNICMP(argv[0] + argv_idx, "serversend", 10) == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
603 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
604 /* already processed -- snatch the following arg */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
605 if (argc > 1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
606 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
607 --argc;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
608 ++argv;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
609 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
610 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
611 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
612 #ifdef FEAT_GUI_GTK
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
613 else if (STRNICMP(argv[0] + argv_idx, "socketid", 8) == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
614 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
615 /* already processed -- snatch the following arg */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
616 if (argc > 1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
617 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
618 --argc;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
619 ++argv;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
620 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
621 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
622 else if (STRNICMP(argv[0] + argv_idx, "echo-wid", 8) == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
623 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
624 /* already processed, skip */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
625 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
626 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
627 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
628 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
629 if (argv[0][argv_idx])
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
630 mainerr(ME_UNKNOWN_OPTION, (char_u *)argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
631 had_minmin = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
632 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
633 if (!want_argument)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
634 argv_idx = -1; /* skip to next argument */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
635 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
636
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
637 case 'A': /* "-A" start in Arabic mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
638 #ifdef FEAT_ARABIC
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
639 set_option_value((char_u *)"arabic", 1L, NULL, 0);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
640 #else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
641 mch_errmsg(_(e_noarabic));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
642 mch_exit(2);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
643 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
644 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
645
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
646 case 'b': /* "-b" binary mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
647 bin_mode = TRUE; /* postpone to after reading .exrc files */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
648 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
649
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
650 case 'C': /* "-C" Compatible */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
651 change_compatible(TRUE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
652 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
653
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
654 case 'e': /* "-e" Ex mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
655 exmode_active = EXMODE_NORMAL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
656 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
657
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
658 case 'E': /* "-E" Improved Ex mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
659 exmode_active = EXMODE_VIM;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
660 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
661
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
662 case 'f': /* "-f" GUI: run in foreground. Amiga: open
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
663 window directly, not with newcli */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
664 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
665 gui.dofork = FALSE; /* don't fork() when starting GUI */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
666 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
667 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
668
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
669 case 'g': /* "-g" start GUI */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
670 main_start_gui();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
671 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
672
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
673 case 'F': /* "-F" start in Farsi mode: rl + fkmap set */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
674 #ifdef FEAT_FKMAP
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
675 curwin->w_p_rl = p_fkmap = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
676 #else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
677 mch_errmsg(_(e_nofarsi));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
678 mch_exit(2);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
679 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
680 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
681
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
682 case 'h': /* "-h" give help message */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
683 #ifdef FEAT_GUI_GNOME
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
684 /* Tell usage() to exit for "gvim". */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
685 gui.starting = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
686 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
687 usage();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
688 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
689
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
690 case 'H': /* "-H" start in Hebrew mode: rl + hkmap set */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
691 #ifdef FEAT_RIGHTLEFT
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
692 curwin->w_p_rl = p_hkmap = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
693 #else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
694 mch_errmsg(_(e_nohebrew));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
695 mch_exit(2);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
696 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
697 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
698
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
699 case 'l': /* "-l" lisp mode, 'lisp' and 'showmatch' on */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
700 #ifdef FEAT_LISP
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
701 set_option_value((char_u *)"lisp", 1L, NULL, 0);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
702 p_sm = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
703 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
704 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
705
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
706 #ifdef TARGET_API_MAC_OSX
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
707 /* For some reason on MacOS X, an argument like:
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
708 -psn_0_10223617 is passed in when invoke from Finder
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
709 or with the 'open' command */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
710 case 'p':
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
711 argv_idx = -1; /* bypass full -psn */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
712 main_start_gui();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
713 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
714 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
715 case 'M': /* "-M" no changes or writing of files */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
716 reset_modifiable();
237
73354c21f1e4 updated for version 7.0066
vimboss
parents: 218
diff changeset
717 /* FALLTHROUGH */
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
718
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
719 case 'm': /* "-m" no writing of files */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
720 p_write = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
721 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
722
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
723 case 'y': /* "-y" easy mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
724 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
725 gui.starting = TRUE; /* start GUI a bit later */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
726 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
727 evim_mode = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
728 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
729
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
730 case 'N': /* "-N" Nocompatible */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
731 change_compatible(FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
732 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
733
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
734 case 'n': /* "-n" no swap file */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
735 no_swap_file = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
736 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
737
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
738 case 'o': /* "-o[N]" open N horizontal split windows */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
739 #ifdef FEAT_WINDOWS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
740 /* default is 0: open window for each file */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
741 window_count = get_number_arg((char_u *)argv[0], &argv_idx, 0);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
742 vert_windows = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
743 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
744 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
745
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
746 case 'O': /* "-O[N]" open N vertical split windows */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
747 #if defined(FEAT_VERTSPLIT) && defined(FEAT_WINDOWS)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
748 /* default is 0: open window for each file */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
749 window_count = get_number_arg((char_u *)argv[0], &argv_idx, 0);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
750 vert_windows = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
751 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
752 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
753
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
754 #ifdef FEAT_QUICKFIX
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
755 case 'q': /* "-q" QuickFix mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
756 if (edit_type != EDIT_NONE)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
757 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
758 edit_type = EDIT_QF;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
759 if (argv[0][argv_idx]) /* "-q{errorfile}" */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
760 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
761 use_ef = (char_u *)argv[0] + argv_idx;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
762 argv_idx = -1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
763 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
764 else if (argc > 1) /* "-q {errorfile}" */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
765 want_argument = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
766 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
767 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
768
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
769 case 'R': /* "-R" readonly mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
770 readonlymode = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
771 curbuf->b_p_ro = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
772 p_uc = 10000; /* don't update very often */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
773 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
774
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
775 case 'r': /* "-r" recovery mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
776 case 'L': /* "-L" recovery mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
777 recoverymode = 1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
778 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
779
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
780 case 's':
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
781 if (exmode_active) /* "-s" silent (batch) mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
782 silent_mode = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
783 else /* "-s {scriptin}" read from script file */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
784 want_argument = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
785 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
786
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
787 case 't': /* "-t {tag}" or "-t{tag}" jump to tag */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
788 if (edit_type != EDIT_NONE)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
789 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
790 edit_type = EDIT_TAG;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
791 if (argv[0][argv_idx]) /* "-t{tag}" */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
792 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
793 tagname = (char_u *)argv[0] + argv_idx;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
794 argv_idx = -1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
795 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
796 else /* "-t {tag}" */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
797 want_argument = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
798 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
799
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
800 #ifdef FEAT_EVAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
801 case 'D': /* "-D" Debugging */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
802 use_debug_break_level = 9999;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
803 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
804 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
805 #ifdef FEAT_DIFF
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
806 case 'd': /* "-d" 'diff' */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
807 # ifdef AMIGA
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
808 /* check for "-dev {device}" */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
809 if (argv[0][argv_idx] == 'e' && argv[0][argv_idx + 1] == 'v')
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
810 want_argument = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
811 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
812 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
813 diff_mode = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
814 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
815 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
816 case 'V': /* "-V{N}" Verbose level */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
817 /* default is 10: a little bit verbose */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
818 p_verbose = get_number_arg((char_u *)argv[0], &argv_idx, 10);
294
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 242
diff changeset
819 if (argv[0][argv_idx] != NUL)
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 242
diff changeset
820 {
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 242
diff changeset
821 set_option_value((char_u *)"verbosefile", 0L,
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 242
diff changeset
822 (char_u *)argv[0] + argv_idx, 0);
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 242
diff changeset
823 argv_idx = STRLEN(argv[0]);
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 242
diff changeset
824 }
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
825 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
826
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
827 case 'v': /* "-v" Vi-mode (as if called "vi") */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
828 exmode_active = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
829 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
830 gui.starting = FALSE; /* don't start GUI */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
831 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
832 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
833
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
834 case 'w': /* "-w{number}" set window height */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
835 /* "-w {scriptout}" write to script */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
836 if (vim_isdigit(((char_u *)argv[0])[argv_idx]))
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
837 {
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
838 i = get_number_arg((char_u *)argv[0], &argv_idx, 10);
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
839 set_option_value((char_u *)"window", (long)i, NULL, 0);
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
840 break;
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
841 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
842 want_argument = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
843 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
844
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
845 #ifdef FEAT_CRYPT
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
846 case 'x': /* "-x" encrypted reading/writing of files */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
847 ask_for_key = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
848 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
849 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
850
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
851 case 'X': /* "-X" don't connect to X server */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
852 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_X11)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
853 x_no_connect = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
854 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
855 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
856
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
857 case 'Z': /* "-Z" restricted mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
858 restricted = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
859 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
860
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
861 case 'c': /* "-c{command}" or "-c {command}" execute
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
862 command */
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
863 if (argv[0][argv_idx] != NUL)
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
864 {
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
865 if (n_commands >= MAX_ARG_CMDS)
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
866 mainerr(ME_EXTRA_CMD, NULL);
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
867 commands[n_commands++] = (char_u *)argv[0] + argv_idx;
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
868 argv_idx = -1;
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
869 break;
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
870 }
237
73354c21f1e4 updated for version 7.0066
vimboss
parents: 218
diff changeset
871 /*FALLTHROUGH*/
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
872 case 'S': /* "-S {file}" execute Vim script */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
873 case 'i': /* "-i {viminfo}" use for viminfo */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
874 #ifndef FEAT_DIFF
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
875 case 'd': /* "-d {device}" device (for Amiga) */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
876 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
877 case 'T': /* "-T {terminal}" terminal name */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
878 case 'u': /* "-u {vimrc}" vim inits file */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
879 case 'U': /* "-U {gvimrc}" gvim inits file */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
880 case 'W': /* "-W {scriptout}" overwrite */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
881 #ifdef FEAT_GUI_W32
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
882 case 'P': /* "-P {parent title}" MDI parent */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
883 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
884 want_argument = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
885 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
886
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
887 default:
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
888 mainerr(ME_UNKNOWN_OPTION, (char_u *)argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
889 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
890
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
891 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
892 * Handle options with argument.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
893 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
894 if (want_argument)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
895 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
896 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
897 * Check for garbage immediately after the option letter.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
898 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
899 if (argv[0][argv_idx] != NUL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
900 mainerr(ME_GARBAGE, (char_u *)argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
901
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
902 --argc;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
903 if (argc < 1 && c != 'S')
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
904 mainerr_arg_missing((char_u *)argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
905 ++argv;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
906 argv_idx = -1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
907
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
908 switch (c)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
909 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
910 case 'c': /* "-c {command}" execute command */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
911 case 'S': /* "-S {file}" execute Vim script */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
912 if (n_commands >= MAX_ARG_CMDS)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
913 mainerr(ME_EXTRA_CMD, NULL);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
914 if (c == 'S')
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
915 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
916 char *a;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
917
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
918 if (argc < 1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
919 /* "-S" without argument: use default session file
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
920 * name. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
921 a = SESSION_FILE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
922 else if (argv[0][0] == '-')
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
923 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
924 /* "-S" followed by another option: use default
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
925 * session file name. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
926 a = SESSION_FILE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
927 ++argc;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
928 --argv;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
929 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
930 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
931 a = argv[0];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
932 p = alloc((unsigned)(STRLEN(a) + 4));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
933 if (p == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
934 mch_exit(2);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
935 sprintf((char *)p, "so %s", a);
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 294
diff changeset
936 cmds_tofree[n_commands] = TRUE;
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
937 commands[n_commands++] = p;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
938 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
939 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
940 commands[n_commands++] = (char_u *)argv[0];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
941 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
942
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
943 #ifdef FEAT_PRECOMMANDS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
944 case '-': /* "--cmd {command}" execute command */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
945 if (p_commands >= MAX_ARG_CMDS)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
946 mainerr(ME_EXTRA_CMD, NULL);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
947 pre_commands[p_commands++] = (char_u *)argv[0];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
948 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
949 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
950
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
951 /* case 'd': -d {device} is handled in mch_check_win() for the
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
952 * Amiga */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
953
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
954 #ifdef FEAT_QUICKFIX
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
955 case 'q': /* "-q {errorfile}" QuickFix mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
956 use_ef = (char_u *)argv[0];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
957 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
958 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
959
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
960 case 'i': /* "-i {viminfo}" use for viminfo */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
961 use_viminfo = (char_u *)argv[0];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
962 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
963
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
964 case 's': /* "-s {scriptin}" read from script file */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
965 if (scriptin[0] != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
966 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
967 scripterror:
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
968 mch_errmsg(_("Attempt to open script file again: \""));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
969 mch_errmsg(argv[-1]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
970 mch_errmsg(" ");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
971 mch_errmsg(argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
972 mch_errmsg("\"\n");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
973 mch_exit(2);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
974 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
975 if ((scriptin[0] = mch_fopen(argv[0], READBIN)) == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
976 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
977 mch_errmsg(_("Cannot open for reading: \""));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
978 mch_errmsg(argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
979 mch_errmsg("\"\n");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
980 mch_exit(2);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
981 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
982 if (save_typebuf() == FAIL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
983 mch_exit(2); /* out of memory */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
984 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
985
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
986 case 't': /* "-t {tag}" */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
987 tagname = (char_u *)argv[0];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
988 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
989
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
990 case 'T': /* "-T {terminal}" terminal name */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
991 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
992 * The -T term option is always available and when
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
993 * HAVE_TERMLIB is supported it overrides the environment
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
994 * variable TERM.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
995 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
996 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
997 if (term_is_gui((char_u *)argv[0]))
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
998 gui.starting = TRUE; /* start GUI a bit later */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
999 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1000 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1001 term = (char_u *)argv[0];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1002 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1003
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1004 case 'u': /* "-u {vimrc}" vim inits file */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1005 use_vimrc = (char_u *)argv[0];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1006 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1007
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1008 case 'U': /* "-U {gvimrc}" gvim inits file */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1009 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1010 use_gvimrc = (char_u *)argv[0];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1011 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1012 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1013
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
1014 case 'w': /* "-w {nr}" 'window' value */
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
1015 /* "-w {scriptout}" append to script file */
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
1016 if (vim_isdigit(*((char_u *)argv[0])))
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
1017 {
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
1018 argv_idx = 0;
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
1019 i = get_number_arg((char_u *)argv[0], &argv_idx, 10);
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
1020 set_option_value((char_u *)"window", (long)i, NULL, 0);
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
1021 argv_idx = -1;
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
1022 break;
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 159
diff changeset
1023 }
237
73354c21f1e4 updated for version 7.0066
vimboss
parents: 218
diff changeset
1024 /*FALLTHROUGH*/
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1025 case 'W': /* "-W {scriptout}" overwrite script file */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1026 if (scriptout != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1027 goto scripterror;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1028 if ((scriptout = mch_fopen(argv[0],
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1029 c == 'w' ? APPENDBIN : WRITEBIN)) == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1030 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1031 mch_errmsg(_("Cannot open for script output: \""));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1032 mch_errmsg(argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1033 mch_errmsg("\"\n");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1034 mch_exit(2);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1035 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1036 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1037
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1038 #ifdef FEAT_GUI_W32
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1039 case 'P': /* "-P {parent title}" MDI parent */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1040 gui_mch_set_parent(argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1041 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1042 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1043 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1044 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1045 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1046
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1047 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1048 * File name argument.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1049 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1050 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1051 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1052 argv_idx = -1; /* skip to next argument */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1053
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1054 /* Check for only one type of editing. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1055 if (edit_type != EDIT_NONE && edit_type != EDIT_FILE)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1056 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1057 edit_type = EDIT_FILE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1058
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1059 #ifdef MSWIN
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1060 /* Remember if the argument was a full path before changing
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1061 * slashes to backslashes. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1062 if (argv[0][0] != NUL && argv[0][1] == ':' && argv[0][2] == '\\')
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1063 full_path = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1064 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1065
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1066 /* Add the file to the global argument list. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1067 if (ga_grow(&global_alist.al_ga, 1) == FAIL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1068 || (p = vim_strsave((char_u *)argv[0])) == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1069 mch_exit(2);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1070 #ifdef FEAT_DIFF
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1071 if (diff_mode && mch_isdir(p) && GARGCOUNT > 0
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1072 && !mch_isdir(alist_name(&GARGLIST[0])))
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1073 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1074 char_u *r;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1075
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1076 r = concat_fnames(p, gettail(alist_name(&GARGLIST[0])), TRUE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1077 if (r != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1078 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1079 vim_free(p);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1080 p = r;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1081 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1082 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1083 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1084 #if defined(__CYGWIN32__) && !defined(WIN32)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1085 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1086 * If vim is invoked by non-Cygwin tools, convert away any
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1087 * DOS paths, so things like .swp files are created correctly.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1088 * Look for evidence of non-Cygwin paths before we bother.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1089 * This is only for when using the Unix files.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1090 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1091 if (strpbrk(p, "\\:") != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1092 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1093 char posix_path[PATH_MAX];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1094
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1095 cygwin_conv_to_posix_path(p, posix_path);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1096 vim_free(p);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1097 p = vim_strsave(posix_path);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1098 if (p == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1099 mch_exit(2);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1100 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1101 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1102 alist_add(&global_alist, p,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1103 #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1104 literal ? 2 : 0 /* add buffer number after expanding */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1105 #else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1106 2 /* add buffer number now and use curbuf */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1107 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1108 );
23
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1109
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1110 #if defined(FEAT_MBYTE) && defined(WIN32)
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1111 {
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1112 extern void used_file_arg(char *, int, int);
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1113
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1114 /* Remember this argument has been added to the argument list.
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1115 * Needed when 'encoding' is changed. */
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1116 used_file_arg(argv[0], literal, full_path);
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1117 }
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1118 #endif
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1119 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1120
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1121 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1122 * If there are no more letters after the current "-", go to next
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1123 * argument. argv_idx is set to -1 when the current argument is to be
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1124 * skipped.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1125 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1126 if (argv_idx <= 0 || argv[0][argv_idx] == NUL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1127 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1128 --argc;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1129 ++argv;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1130 argv_idx = 1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1131 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1132 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1133 TIME_MSG("parsing arguments");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1134
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1135 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1136 * On some systems, when we compile with the GUI, we always use it. On Mac
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1137 * there is no terminal version, and on Windows we can't figure out how to
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1138 * fork one off with :gui.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1139 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1140 #ifdef ALWAYS_USE_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1141 gui.starting = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1142 #else
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
1143 # if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1144 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1145 * Check if the GUI can be started. Reset gui.starting if not.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1146 * Don't know about other systems, stay on the safe side and don't check.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1147 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1148 if (gui.starting && gui_init_check() == FAIL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1149 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1150 gui.starting = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1151
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1152 /* When running "evim" or "gvim -y" we need the menus, exit if we
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1153 * don't have them. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1154 if (evim_mode)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1155 mch_exit(1);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1156 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1157 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1158 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1159
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1160 /* "-b" argument used. Check before expanding file names, because for
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1161 * Win32 this makes us edit a shortcut file itself, instead of the file it
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1162 * links to. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1163 if (bin_mode)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1164 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1165 set_options_bin(curbuf->b_p_bin, 1, 0);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1166 curbuf->b_p_bin = 1; /* binary file I/O */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1167 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1168
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1169 if (GARGCOUNT > 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1170 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1171 #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1172 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1173 * Expand wildcards in file names.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1174 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1175 if (!literal)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1176 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1177 /* Temporarily add '(' and ')' to 'isfname'. These are valid
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1178 * filename characters but are excluded from 'isfname' to make
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1179 * "gf" work on a file name in parenthesis (e.g.: see vim.h). */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1180 do_cmdline_cmd((char_u *)":set isf+=(,)");
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
1181 alist_expand(NULL, 0);
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1182 do_cmdline_cmd((char_u *)":set isf&");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1183 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1184 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1185 fname = alist_name(&GARGLIST[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1186 }
23
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1187
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1188 #if defined(WIN32) && defined(FEAT_MBYTE)
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1189 {
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1190 extern void set_alist_count(void);
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1191
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1192 /* Remember the number of entries in the argument list. If it changes
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1193 * we don't react on setting 'encoding'. */
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1194 set_alist_count();
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1195 }
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1196 #endif
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1197
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1198 #ifdef MSWIN
169
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
1199 if (GARGCOUNT == 1 && full_path)
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1200 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1201 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1202 * If there is one filename, fully qualified, we have very probably
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1203 * been invoked from explorer, so change to the file's directory.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1204 * Hint: to avoid this when typing a command use a forward slash.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1205 * If the cd fails, it doesn't matter.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1206 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1207 (void)vim_chdirfile(fname);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1208 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1209 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1210 TIME_MSG("expanding arguments");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1211
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1212 #ifdef FEAT_DIFF
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1213 if (diff_mode)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1214 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1215 if (window_count == -1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1216 window_count = 0; /* open up to 3 files in a window */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1217 if (vert_windows == MAYBE)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1218 vert_windows = TRUE; /* use vertical split */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1219 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1220 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1221
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1222 ++RedrawingDisabled;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1223
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1224 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1225 * When listing swap file names, don't do cursor positioning et. al.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1226 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1227 if (recoverymode && fname == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1228 want_full_screen = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1229
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1230 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1231 * When certain to start the GUI, don't check capabilities of terminal.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1232 * For GTK we can't be sure, but when started from the desktop it doesn't
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1233 * make sense to try using a terminal.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1234 */
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
1235 #if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1236 if (gui.starting
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1237 # ifdef FEAT_GUI_GTK
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1238 && !isatty(2)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1239 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1240 )
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1241 want_full_screen = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1242 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1243
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1244 #if defined(FEAT_GUI_MAC) && defined(MACOS_X_UNIX)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1245 /* When the GUI is started from Finder, need to display messages in a
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1246 * message box. isatty(2) returns TRUE anyway, thus we need to check the
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1247 * name to know we're not started from a terminal. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1248 if (gui.starting && (!isatty(2) || strcmp("/dev/console", ttyname(2)) == 0))
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1249 want_full_screen = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1250 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1251
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1252 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1253 * mch_init() sets up the terminal (window) for use. This must be
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1254 * done after resetting full_screen, otherwise it may move the cursor
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1255 * (MSDOS).
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1256 * Note that we may use mch_exit() before mch_init()!
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1257 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1258 mch_init();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1259 TIME_MSG("shell init");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1260
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1261 #ifdef USE_XSMP
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1262 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1263 * For want of anywhere else to do it, try to connect to xsmp here.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1264 * Fitting it in after gui_mch_init, but before gui_init (via termcapinit).
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1265 * Hijacking -X 'no X connection' to also disable XSMP connection as that
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1266 * has a similar delay upon failure.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1267 * Only try if SESSION_MANAGER is set to something non-null.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1268 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1269 if (!x_no_connect)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1270 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1271 p = (char_u *)getenv("SESSION_MANAGER");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1272 if (p != NULL && *p != NUL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1273 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1274 xsmp_init();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1275 TIME_MSG("xsmp init");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1276 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1277 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1278 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1279
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1280 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1281 * Print a warning if stdout is not a terminal.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1282 * When starting in Ex mode and commands come from a file, set Silent mode.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1283 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1284 input_isatty = mch_input_isatty();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1285 if (exmode_active)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1286 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1287 if (!input_isatty)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1288 silent_mode = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1289 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1290 else if (want_full_screen && (!stdout_isatty || !input_isatty)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1291 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1292 /* don't want the delay when started from the desktop */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1293 && !gui.starting
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1294 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1295 )
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1296 {
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 23
diff changeset
1297 #ifdef NBDEBUG
7f788cd27415 updated for version 7.0020
vimboss
parents: 23
diff changeset
1298 /*
7f788cd27415 updated for version 7.0020
vimboss
parents: 23
diff changeset
1299 * This shouldn't be necessary. But if I run netbeans with the log
7f788cd27415 updated for version 7.0020
vimboss
parents: 23
diff changeset
1300 * output coming to the console and XOpenDisplay fails, I get vim
7f788cd27415 updated for version 7.0020
vimboss
parents: 23
diff changeset
1301 * trying to start with input/output to my console tty. This fills my
7f788cd27415 updated for version 7.0020
vimboss
parents: 23
diff changeset
1302 * input buffer so fast I can't even kill the process in under 2
7f788cd27415 updated for version 7.0020
vimboss
parents: 23
diff changeset
1303 * minutes (and it beeps continuosly the whole time :-)
7f788cd27415 updated for version 7.0020
vimboss
parents: 23
diff changeset
1304 */
7f788cd27415 updated for version 7.0020
vimboss
parents: 23
diff changeset
1305 if (usingNetbeans && (!stdout_isatty || !input_isatty))
7f788cd27415 updated for version 7.0020
vimboss
parents: 23
diff changeset
1306 {
7f788cd27415 updated for version 7.0020
vimboss
parents: 23
diff changeset
1307 mch_errmsg(_("Vim: Error: Failure to start gvim from NetBeans\n"));
7f788cd27415 updated for version 7.0020
vimboss
parents: 23
diff changeset
1308 exit(1);
7f788cd27415 updated for version 7.0020
vimboss
parents: 23
diff changeset
1309 }
7f788cd27415 updated for version 7.0020
vimboss
parents: 23
diff changeset
1310 #endif
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1311 if (!stdout_isatty)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1312 mch_errmsg(_("Vim: Warning: Output is not to a terminal\n"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1313 if (!input_isatty)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1314 mch_errmsg(_("Vim: Warning: Input is not from a terminal\n"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1315 out_flush();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1316 if (scriptin[0] == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1317 ui_delay(2000L, TRUE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1318 TIME_MSG("Warning delay");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1319 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1320
169
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
1321 /* This message comes before term inits, but after setting "silent_mode"
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
1322 * when the input is not a tty. */
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
1323 if (GARGCOUNT > 1 && !silent_mode)
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
1324 printf(_("%d files to edit\n"), GARGCOUNT);
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
1325
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
1326 if (want_full_screen && !silent_mode)
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1327 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1328 termcapinit(term); /* set terminal name and get terminal
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1329 capabilities (will set full_screen) */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1330 screen_start(); /* don't know where cursor is now */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1331 TIME_MSG("Termcap init");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1332 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1333
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1334 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1335 * Set the default values for the options that use Rows and Columns.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1336 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1337 ui_get_shellsize(); /* inits Rows and Columns */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1338 #ifdef FEAT_NETBEANS_INTG
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1339 if (usingNetbeans)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1340 Columns += 2; /* leave room for glyph gutter */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1341 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1342 firstwin->w_height = Rows - p_ch;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1343 topframe->fr_height = Rows - p_ch;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1344 #ifdef FEAT_VERTSPLIT
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1345 firstwin->w_width = Columns;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1346 topframe->fr_width = Columns;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1347 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1348 #ifdef FEAT_DIFF
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1349 /* Set the 'diff' option now, so that it can be checked for in a .vimrc
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1350 * file. There is no buffer yet though. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1351 if (diff_mode)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1352 diff_win_options(firstwin, FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1353 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1354
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1355 cmdline_row = Rows - p_ch;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1356 msg_row = cmdline_row;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1357 screenalloc(FALSE); /* allocate screen buffers */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1358 set_init_2();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1359 TIME_MSG("inits 2");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1360
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1361 msg_scroll = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1362 no_wait_return = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1363
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1364 init_mappings(); /* set up initial mappings */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1365
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1366 init_highlight(TRUE, FALSE); /* set the default highlight groups */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1367 TIME_MSG("init highlight");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1368 #ifdef CURSOR_SHAPE
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1369 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1370 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1371 #ifdef FEAT_MOUSESHAPE
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1372 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1373 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1374 #ifdef FEAT_PRINTER
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1375 parse_list_options(p_popt, printer_opts, OPT_PRINT_NUM_OPTIONS);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1376 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1377
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1378 #ifdef FEAT_EVAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1379 /* Set the break level after the terminal is initialized. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1380 debug_break_level = use_debug_break_level;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1381 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1382
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1383 #ifdef FEAT_PRECOMMANDS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1384 if (p_commands > 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1385 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1386 curwin->w_cursor.lnum = 0; /* just in case.. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1387 sourcing_name = (char_u *)_("pre-vimrc command line");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1388 # ifdef FEAT_EVAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1389 current_SID = SID_CMDARG;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1390 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1391 for (i = 0; i < p_commands; ++i)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1392 do_cmdline_cmd(pre_commands[i]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1393 sourcing_name = NULL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1394 # ifdef FEAT_EVAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1395 current_SID = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1396 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1397 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1398 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1399
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1400 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1401 * For "evim" source evim.vim first of all, so that the user can overrule
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1402 * any things he doesn't like.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1403 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1404 if (evim_mode)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1405 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1406 (void)do_source((char_u *)EVIM_FILE, FALSE, FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1407 TIME_MSG("source evim file");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1408 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1409
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1410 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1411 * If -u option given, use only the initializations from that file and
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1412 * nothing else.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1413 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1414 if (use_vimrc != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1415 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1416 if (STRCMP(use_vimrc, "NONE") == 0 || STRCMP(use_vimrc, "NORC") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1417 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1418 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1419 if (use_gvimrc == NULL) /* don't load gvimrc either */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1420 use_gvimrc = use_vimrc;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1421 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1422 if (use_vimrc[2] == 'N')
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1423 p_lpl = FALSE; /* don't load plugins either */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1424 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1425 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1426 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1427 if (do_source(use_vimrc, FALSE, FALSE) != OK)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1428 EMSG2(_("E282: Cannot read from \"%s\""), use_vimrc);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1429 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1430 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1431 else if (!silent_mode)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1432 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1433 #ifdef AMIGA
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1434 struct Process *proc = (struct Process *)FindTask(0L);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1435 APTR save_winptr = proc->pr_WindowPtr;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1436
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1437 /* Avoid a requester here for a volume that doesn't exist. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1438 proc->pr_WindowPtr = (APTR)-1L;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1439 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1440
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1441 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1442 * Get system wide defaults, if the file name is defined.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1443 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1444 #ifdef SYS_VIMRC_FILE
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1445 (void)do_source((char_u *)SYS_VIMRC_FILE, FALSE, FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1446 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1447
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1448 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1449 * Try to read initialization commands from the following places:
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1450 * - environment variable VIMINIT
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1451 * - user vimrc file (s:.vimrc for Amiga, ~/.vimrc otherwise)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1452 * - second user vimrc file ($VIM/.vimrc for Dos)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1453 * - environment variable EXINIT
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1454 * - user exrc file (s:.exrc for Amiga, ~/.exrc otherwise)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1455 * - second user exrc file ($VIM/.exrc for Dos)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1456 * The first that exists is used, the rest is ignored.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1457 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1458 if (process_env((char_u *)"VIMINIT", TRUE) != OK)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1459 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1460 if (do_source((char_u *)USR_VIMRC_FILE, TRUE, TRUE) == FAIL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1461 #ifdef USR_VIMRC_FILE2
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1462 && do_source((char_u *)USR_VIMRC_FILE2, TRUE, TRUE) == FAIL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1463 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1464 #ifdef USR_VIMRC_FILE3
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1465 && do_source((char_u *)USR_VIMRC_FILE3, TRUE, TRUE) == FAIL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1466 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1467 && process_env((char_u *)"EXINIT", FALSE) == FAIL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1468 && do_source((char_u *)USR_EXRC_FILE, FALSE, FALSE) == FAIL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1469 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1470 #ifdef USR_EXRC_FILE2
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1471 (void)do_source((char_u *)USR_EXRC_FILE2, FALSE, FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1472 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1473 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1474 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1475
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1476 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1477 * Read initialization commands from ".vimrc" or ".exrc" in current
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1478 * directory. This is only done if the 'exrc' option is set.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1479 * Because of security reasons we disallow shell and write commands
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1480 * now, except for unix if the file is owned by the user or 'secure'
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1481 * option has been reset in environmet of global ".exrc" or ".vimrc".
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1482 * Only do this if VIMRC_FILE is not the same as USR_VIMRC_FILE or
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1483 * SYS_VIMRC_FILE.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1484 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1485 if (p_exrc)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1486 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1487 #if defined(UNIX) || defined(VMS)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1488 /* If ".vimrc" file is not owned by user, set 'secure' mode. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1489 if (!file_owned(VIMRC_FILE))
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1490 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1491 secure = p_secure;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1492
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1493 i = FAIL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1494 if (fullpathcmp((char_u *)USR_VIMRC_FILE,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1495 (char_u *)VIMRC_FILE, FALSE) != FPC_SAME
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1496 #ifdef USR_VIMRC_FILE2
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1497 && fullpathcmp((char_u *)USR_VIMRC_FILE2,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1498 (char_u *)VIMRC_FILE, FALSE) != FPC_SAME
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1499 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1500 #ifdef USR_VIMRC_FILE3
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1501 && fullpathcmp((char_u *)USR_VIMRC_FILE3,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1502 (char_u *)VIMRC_FILE, FALSE) != FPC_SAME
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1503 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1504 #ifdef SYS_VIMRC_FILE
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1505 && fullpathcmp((char_u *)SYS_VIMRC_FILE,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1506 (char_u *)VIMRC_FILE, FALSE) != FPC_SAME
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1507 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1508 )
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1509 i = do_source((char_u *)VIMRC_FILE, TRUE, TRUE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1510
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1511 if (i == FAIL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1512 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1513 #if defined(UNIX) || defined(VMS)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1514 /* if ".exrc" is not owned by user set 'secure' mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1515 if (!file_owned(EXRC_FILE))
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1516 secure = p_secure;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1517 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1518 secure = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1519 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1520 if ( fullpathcmp((char_u *)USR_EXRC_FILE,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1521 (char_u *)EXRC_FILE, FALSE) != FPC_SAME
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1522 #ifdef USR_EXRC_FILE2
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1523 && fullpathcmp((char_u *)USR_EXRC_FILE2,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1524 (char_u *)EXRC_FILE, FALSE) != FPC_SAME
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1525 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1526 )
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1527 (void)do_source((char_u *)EXRC_FILE, FALSE, FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1528 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1529 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1530 if (secure == 2)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1531 need_wait_return = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1532 secure = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1533 #ifdef AMIGA
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1534 proc->pr_WindowPtr = save_winptr;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1535 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1536 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1537 TIME_MSG("sourcing vimrc file(s)");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1538
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1539 #ifdef FEAT_EVAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1540 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1541 * Read all the plugin files.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1542 * Only when compiled with +eval, since most plugins need it.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1543 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1544 if (p_lpl)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1545 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1546 cmd_runtime((char_u *)"plugin/*.vim", TRUE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1547 TIME_MSG("loading plugins");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1548 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1549 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1550
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1551 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1552 * Recovery mode without a file name: List swap files.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1553 * This uses the 'dir' option, therefore it must be after the
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1554 * initializations.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1555 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1556 if (recoverymode && fname == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1557 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1558 recover_names(NULL, TRUE, 0);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1559 mch_exit(0);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1560 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1561
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1562 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1563 * Set a few option defaults after reading .vimrc files:
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1564 * 'title' and 'icon', Unix: 'shellpipe' and 'shellredir'.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1565 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1566 set_init_3();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1567 TIME_MSG("inits 3");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1568
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1569 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1570 * "-n" argument: Disable swap file by setting 'updatecount' to 0.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1571 * Note that this overrides anything from a vimrc file.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1572 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1573 if (no_swap_file)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1574 p_uc = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1575
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1576 #ifdef FEAT_FKMAP
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1577 if (curwin->w_p_rl && p_altkeymap)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1578 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1579 p_hkmap = FALSE; /* Reset the Hebrew keymap mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1580 # ifdef FEAT_ARABIC
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1581 curwin->w_p_arab = FALSE; /* Reset the Arabic keymap mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1582 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1583 p_fkmap = TRUE; /* Set the Farsi keymap mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1584 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1585 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1586
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1587 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1588 if (gui.starting)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1589 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1590 #if defined(UNIX) || defined(VMS)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1591 /* When something caused a message from a vimrc script, need to output
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1592 * an extra newline before the shell prompt. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1593 if (did_emsg || msg_didout)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1594 putchar('\n');
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1595 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1596
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1597 gui_start(); /* will set full_screen to TRUE */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1598 TIME_MSG("starting GUI");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1599
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1600 /* When running "evim" or "gvim -y" we need the menus, exit if we
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1601 * don't have them. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1602 if (!gui.in_use && evim_mode)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1603 mch_exit(1);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1604 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1605 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1606
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1607 #ifdef SPAWNO /* special MSDOS swapping library */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1608 init_SPAWNO("", SWAP_ANY);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1609 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1610
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1611 #ifdef FEAT_VIMINFO
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1612 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1613 * Read in registers, history etc, but not marks, from the viminfo file
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1614 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1615 if (*p_viminfo != NUL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1616 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1617 read_viminfo(NULL, TRUE, FALSE, FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1618 TIME_MSG("reading viminfo");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1619 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1620 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1621
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1622 #ifdef FEAT_QUICKFIX
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1623 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1624 * "-q errorfile": Load the error file now.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1625 * If the error file can't be read, exit before doing anything else.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1626 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1627 if (edit_type == EDIT_QF)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1628 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1629 if (use_ef != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1630 set_string_option_direct((char_u *)"ef", -1, use_ef, OPT_FREE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1631 if (qf_init(p_ef, p_efm, TRUE) < 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1632 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1633 out_char('\n');
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1634 mch_exit(3);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1635 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1636 TIME_MSG("reading errorfile");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1637 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1638 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1639
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1640 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1641 * Start putting things on the screen.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1642 * Scroll screen down before drawing over it
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1643 * Clear screen now, so file message will not be cleared.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1644 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1645 starting = NO_BUFFERS;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1646 no_wait_return = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1647 if (!exmode_active)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1648 msg_scroll = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1649
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1650 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1651 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1652 * This seems to be required to make callbacks to be called now, instead
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1653 * of after things have been put on the screen, which then may be deleted
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1654 * when getting a resize callback.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1655 * For the Mac this handles putting files dropped on the Vim icon to
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1656 * global_alist.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1657 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1658 if (gui.in_use)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1659 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1660 # ifdef FEAT_SUN_WORKSHOP
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1661 if (!usingSunWorkShop)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1662 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1663 gui_wait_for_chars(50L);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1664 TIME_MSG("GUI delay");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1665 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1666 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1667
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1668 #if defined(FEAT_GUI_PHOTON) && defined(FEAT_CLIPBOARD)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1669 qnx_clip_init();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1670 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1671
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1672 #ifdef FEAT_XCLIPBOARD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1673 /* Start using the X clipboard, unless the GUI was started. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1674 # ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1675 if (!gui.in_use)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1676 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1677 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1678 setup_term_clip();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1679 TIME_MSG("setup clipboard");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1680 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1681 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1682
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1683 #if defined(FEAT_CLIENTSERVER) && defined(FEAT_X11)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1684 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1685 * Register for remote command execution with :serversend and --remote
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1686 * unless there was a -X or a --servername '' on the command line.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1687 * Only register nongui-vim's with an explicit --servername argument.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1688 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1689 if (X_DISPLAY != NULL && servername != NULL && (
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1690 # ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1691 gui.in_use ||
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1692 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1693 serverName_arg != NULL))
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1694 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1695 (void)serverRegisterName(X_DISPLAY, servername);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1696 vim_free(servername);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1697 TIME_MSG("register server name");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1698 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1699 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1700 serverDelayedStartName = servername;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1701 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1702
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1703 #ifdef FEAT_CLIENTSERVER
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1704 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1705 * Execute command ourselves if we're here because the send failed (or
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1706 * else we would have exited above).
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1707 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1708 if (serverStr != NULL)
43
f55897d6921d updated for version 7.0026
vimboss
parents: 41
diff changeset
1709 {
f55897d6921d updated for version 7.0026
vimboss
parents: 41
diff changeset
1710 server_to_input_buf(serverConvert(serverStrEnc, serverStr, &p));
f55897d6921d updated for version 7.0026
vimboss
parents: 41
diff changeset
1711 vim_free(p);
f55897d6921d updated for version 7.0026
vimboss
parents: 41
diff changeset
1712 }
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1713 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1714
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1715 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1716 * If "-" argument given: Read file from stdin.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1717 * Do this before starting Raw mode, because it may change things that the
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1718 * writing end of the pipe doesn't like, e.g., in case stdin and stderr
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1719 * are the same terminal: "cat | vim -".
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1720 * Using autocommands here may cause trouble...
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1721 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1722 if (edit_type == EDIT_STDIN && !recoverymode)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1723 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1724 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1725 /* When getting the ATTENTION prompt here, use a dialog */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1726 swap_exists_action = SEA_DIALOG;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1727 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1728 no_wait_return = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1729 i = msg_didany;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1730 set_buflisted(TRUE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1731 (void)open_buffer(TRUE, NULL); /* create memfile and read file */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1732 no_wait_return = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1733 msg_didany = i;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1734 TIME_MSG("reading stdin");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1735 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1736 check_swap_exists_action();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1737 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1738 #if !(defined(AMIGA) || defined(MACOS))
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1739 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1740 * Close stdin and dup it from stderr. Required for GPM to work
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1741 * properly, and for running external commands.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1742 * Is there any other system that cannot do this?
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1743 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1744 close(0);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1745 dup(2);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1746 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1747 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1748
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1749 #if defined(UNIX) || defined(VMS)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1750 /* When switching screens and something caused a message from a vimrc
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1751 * script, need to output an extra newline on exit. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1752 if ((did_emsg || msg_didout) && *T_TI != NUL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1753 newline_on_exit = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1754 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1755
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1756 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1757 * When done something that is not allowed or error message call
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1758 * wait_return. This must be done before starttermcap(), because it may
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1759 * switch to another screen. It must be done after settmode(TMODE_RAW),
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1760 * because we want to react on a single key stroke.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1761 * Call settmode and starttermcap here, so the T_KS and T_TI may be
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1762 * defined by termcapinit and redifined in .exrc.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1763 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1764 settmode(TMODE_RAW);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1765 TIME_MSG("setting raw mode");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1766
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1767 if (need_wait_return || msg_didany)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1768 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1769 wait_return(TRUE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1770 TIME_MSG("waiting for return");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1771 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1772
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1773 starttermcap(); /* start termcap if not done by wait_return() */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1774 TIME_MSG("start termcap");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1775
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1776 #ifdef FEAT_MOUSE
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1777 setmouse(); /* may start using the mouse */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1778 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1779 if (scroll_region)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1780 scroll_region_reset(); /* In case Rows changed */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1781
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1782 scroll_start();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1783
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1784 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1785 * Don't clear the screen when starting in Ex mode, unless using the GUI.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1786 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1787 if (exmode_active
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1788 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1789 && !gui.in_use
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1790 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1791 )
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1792 must_redraw = CLEAR;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1793 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1794 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1795 screenclear(); /* clear screen */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1796 TIME_MSG("clearing screen");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1797 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1798
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1799 #ifdef FEAT_CRYPT
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1800 if (ask_for_key)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1801 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1802 (void)get_crypt_key(TRUE, TRUE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1803 TIME_MSG("getting crypt key");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1804 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1805 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1806
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1807 no_wait_return = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1808
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1809 #ifdef FEAT_WINDOWS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1810 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1811 * Create the number of windows that was requested.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1812 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1813 if (window_count == -1) /* was not set */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1814 window_count = 1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1815 if (window_count == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1816 window_count = GARGCOUNT;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1817 if (window_count > 1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1818 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1819 /* Don't change the windows if there was a command in .vimrc that
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1820 * already split some windows */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1821 if (vert_windows == MAYBE)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1822 vert_windows = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1823 if (firstwin->w_next == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1824 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1825 window_count = make_windows(window_count, vert_windows);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1826 TIME_MSG("making windows");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1827 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1828 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1829 window_count = win_count();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1830 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1831 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1832 window_count = 1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1833 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1834
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1835 if (recoverymode) /* do recover */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1836 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1837 msg_scroll = TRUE; /* scroll message up */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1838 ml_recover();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1839 if (curbuf->b_ml.ml_mfp == NULL) /* failed */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1840 getout(1);
23
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 22
diff changeset
1841 do_modelines(FALSE); /* do modelines */
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1842 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1843 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1844 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1845 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1846 * Open a buffer for windows that don't have one yet.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1847 * Commands in the .vimrc might have loaded a file or split the window.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1848 * Watch out for autocommands that delete a window.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1849 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1850 #ifdef FEAT_AUTOCMD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1851 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1852 * Don't execute Win/Buf Enter/Leave autocommands here
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1853 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1854 ++autocmd_no_enter;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1855 ++autocmd_no_leave;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1856 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1857 #ifdef FEAT_WINDOWS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1858 for (curwin = firstwin; curwin != NULL; curwin = W_NEXT(curwin))
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1859 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1860 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1861 curbuf = curwin->w_buffer;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1862 if (curbuf->b_ml.ml_mfp == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1863 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1864 #ifdef FEAT_FOLDING
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1865 /* Set 'foldlevel' to 'foldlevelstart' if it's not negative. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1866 if (p_fdls >= 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1867 curwin->w_p_fdl = p_fdls;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1868 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1869 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1870 /* When getting the ATTENTION prompt here, use a dialog */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1871 swap_exists_action = SEA_DIALOG;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1872 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1873 set_buflisted(TRUE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1874 (void)open_buffer(FALSE, NULL); /* create memfile, read file */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1875
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1876 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1877 check_swap_exists_action();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1878 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1879 #ifdef FEAT_AUTOCMD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1880 curwin = firstwin; /* start again */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1881 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1882 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1883 #ifdef FEAT_WINDOWS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1884 ui_breakcheck();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1885 if (got_int)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1886 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1887 (void)vgetc(); /* only break the file loading, not the rest */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1888 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1889 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1890 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1891 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1892 #ifdef FEAT_AUTOCMD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1893 --autocmd_no_enter;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1894 --autocmd_no_leave;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1895 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1896 #ifdef FEAT_WINDOWS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1897 curwin = firstwin;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1898 curbuf = curwin->w_buffer;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1899 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1900 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1901 TIME_MSG("opening buffers");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1902
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1903 /* Ex starts at last line of the file */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1904 if (exmode_active)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1905 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1906
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1907 #ifdef FEAT_AUTOCMD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1908 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1909 TIME_MSG("BufEnter autocommands");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1910 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1911 setpcmark();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1912
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1913 #ifdef FEAT_QUICKFIX
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1914 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1915 * When started with "-q errorfile" jump to first error now.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1916 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1917 if (edit_type == EDIT_QF)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1918 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1919 qf_jump(0, 0, FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1920 TIME_MSG("jump to first error");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1921 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1922 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1923
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1924 #ifdef FEAT_WINDOWS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1925 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1926 * If opened more than one window, start editing files in the other
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1927 * windows. Make_windows() has already opened the windows.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1928 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1929 # ifdef FEAT_AUTOCMD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1930 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1931 * Don't execute Win/Buf Enter/Leave autocommands here
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1932 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1933 ++autocmd_no_enter;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1934 ++autocmd_no_leave;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1935 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1936 arg_idx = 1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1937 for (i = 1; i < window_count; ++i)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1938 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1939 if (curwin->w_next == NULL) /* just checking */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1940 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1941 win_enter(curwin->w_next, FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1942
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1943 /* Only open the file if there is no file in this window yet (that can
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1944 * happen when .vimrc contains ":sall") */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1945 if (curbuf == firstwin->w_buffer || curbuf->b_ffname == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1946 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1947 curwin->w_arg_idx = arg_idx;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1948 /* edit file from arg list, if there is one */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1949 (void)do_ecmd(0, arg_idx < GARGCOUNT
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1950 ? alist_name(&GARGLIST[arg_idx]) : NULL,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1951 NULL, NULL, ECMD_LASTL, ECMD_HIDE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1952 if (arg_idx == GARGCOUNT - 1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1953 arg_had_last = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1954 ++arg_idx;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1955 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1956 ui_breakcheck();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1957 if (got_int)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1958 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1959 (void)vgetc(); /* only break the file loading, not the rest */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1960 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1961 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1962 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1963 # ifdef FEAT_AUTOCMD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1964 --autocmd_no_enter;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1965 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1966 win_enter(firstwin, FALSE); /* back to first window */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1967 # ifdef FEAT_AUTOCMD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1968 --autocmd_no_leave;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1969 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1970 TIME_MSG("editing files in windows");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1971 if (window_count > 1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1972 win_equal(curwin, FALSE, 'b'); /* adjust heights */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1973 #endif /* FEAT_WINDOWS */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1974
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1975 #ifdef FEAT_DIFF
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1976 if (diff_mode)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1977 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1978 win_T *wp;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1979
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1980 /* set options in each window for "vimdiff". */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1981 for (wp = firstwin; wp != NULL; wp = wp->w_next)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1982 diff_win_options(wp, TRUE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1983 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1984 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1985
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1986 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1987 * Shorten any of the filenames, but only when absolute.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1988 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1989 shorten_fnames(FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1990
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1991 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1992 * Need to jump to the tag before executing the '-c command'.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1993 * Makes "vim -c '/return' -t main" work.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1994 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1995 if (tagname != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1996 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1997 STRCPY(IObuff, "ta ");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1998
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
1999 STRNCAT(IObuff, tagname, IOSIZE - 4);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2000 IObuff[IOSIZE - 1] = NUL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2001 do_cmdline_cmd(IObuff);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2002 TIME_MSG("jumping to tag");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2003 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2004
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2005 if (n_commands > 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2006 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2007 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2008 * We start commands on line 0, make "vim +/pat file" match a
218
0d6554dfc71e updated for version 7.0061
vimboss
parents: 170
diff changeset
2009 * pattern on line 1. But don't move the cursor when an autocommand
0d6554dfc71e updated for version 7.0061
vimboss
parents: 170
diff changeset
2010 * with g`" was used.
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2011 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2012 msg_scroll = TRUE;
218
0d6554dfc71e updated for version 7.0061
vimboss
parents: 170
diff changeset
2013 if (tagname == NULL && curwin->w_cursor.lnum <= 1)
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2014 curwin->w_cursor.lnum = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2015 sourcing_name = (char_u *)"command line";
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2016 #ifdef FEAT_EVAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2017 current_SID = SID_CARG;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2018 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2019 for (i = 0; i < n_commands; ++i)
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 294
diff changeset
2020 {
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2021 do_cmdline_cmd(commands[i]);
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 294
diff changeset
2022 if (cmds_tofree[i])
6c62b9b939bd updated for version 7.0093
vimboss
parents: 294
diff changeset
2023 vim_free(commands[i]);
6c62b9b939bd updated for version 7.0093
vimboss
parents: 294
diff changeset
2024 }
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2025 sourcing_name = NULL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2026 #ifdef FEAT_EVAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2027 current_SID = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2028 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2029 if (curwin->w_cursor.lnum == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2030 curwin->w_cursor.lnum = 1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2031
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2032 if (!exmode_active)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2033 msg_scroll = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2034
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2035 #ifdef FEAT_QUICKFIX
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2036 /* When started with "-q errorfile" jump to first error again. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2037 if (edit_type == EDIT_QF)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2038 qf_jump(0, 0, FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2039 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2040 TIME_MSG("executing command arguments");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2041 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2042
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2043 RedrawingDisabled = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2044 redraw_all_later(NOT_VALID);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2045 no_wait_return = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2046 starting = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2047
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2048 /* start in insert mode */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2049 if (p_im)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2050 need_start_insertmode = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2051
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2052 #ifdef FEAT_AUTOCMD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2053 apply_autocmds(EVENT_VIMENTER, NULL, NULL, FALSE, curbuf);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2054 TIME_MSG("VimEnter autocommands");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2055 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2056
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2057 #if defined(FEAT_DIFF) && defined(FEAT_SCROLLBIND)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2058 /* When a startup script or session file setup for diff'ing and
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2059 * scrollbind, sync the scrollbind now. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2060 if (curwin->w_p_diff && curwin->w_p_scb)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2061 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2062 update_topline();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2063 check_scrollbind((linenr_T)0, 0L);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2064 TIME_MSG("diff scrollbinding");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2065 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2066 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2067
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2068 #if defined(WIN3264) && !defined(FEAT_GUI_W32)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2069 mch_set_winsize_now(); /* Allow winsize changes from now on */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2070 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2071
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2072 /* If ":startinsert" command used, stuff a dummy command to be able to
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2073 * call normal_cmd(), which will then start Insert mode. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2074 if (restart_edit != 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2075 stuffcharReadbuff(K_IGNORE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2076
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2077 #ifdef FEAT_NETBEANS_INTG
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2078 if (usingNetbeans)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2079 /* Tell the client that it can start sending commands. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2080 netbeans_startup_done();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2081 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2082
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2083 TIME_MSG("before starting main loop");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2084
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2085 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2086 * Call the main command loop. This never returns.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2087 */
169
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2088 main_loop(FALSE, FALSE);
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2089
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2090 return 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2091 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2092 #endif /* PROTO */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2093
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2094 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2095 * Main loop: Execute Normal mode commands until exiting Vim.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2096 * Also used to handle commands in the command-line window, until the window
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2097 * is closed.
169
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2098 * Also used to handle ":visual" command after ":global": execute Normal mode
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2099 * commands, return when entering Ex mode. "noexmode" is TRUE then.
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2100 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2101 void
169
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2102 main_loop(cmdwin, noexmode)
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2103 int cmdwin; /* TRUE when working in the command-line window */
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2104 int noexmode; /* TRUE when return on entering Ex mode */
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2105 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2106 oparg_T oa; /* operator arguments */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2107
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2108 #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2109 /* Setup to catch a terminating error from the X server. Just ignore
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2110 * it, restore the state and continue. This might not always work
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2111 * properly, but at least we don't exit unexpectedly when the X server
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2112 * exists while Vim is running in a console. */
169
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2113 if (!cmdwin && !noexmode && SETJMP(x_jump_env))
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2114 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2115 State = NORMAL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2116 # ifdef FEAT_VISUAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2117 VIsual_active = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2118 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2119 got_int = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2120 need_wait_return = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2121 global_busy = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2122 exmode_active = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2123 skip_redraw = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2124 RedrawingDisabled = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2125 no_wait_return = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2126 # ifdef FEAT_EVAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2127 emsg_skip = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2128 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2129 emsg_off = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2130 # ifdef FEAT_MOUSE
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2131 setmouse();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2132 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2133 settmode(TMODE_RAW);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2134 starttermcap();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2135 scroll_start();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2136 redraw_later_clear();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2137 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2138 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2139
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2140 clear_oparg(&oa);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2141 while (!cmdwin
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2142 #ifdef FEAT_CMDWIN
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2143 || cmdwin_result == 0
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2144 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2145 )
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2146 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2147 if (stuff_empty())
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2148 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2149 did_check_timestamps = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2150 if (need_check_timestamps)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2151 check_timestamps(FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2152 if (need_wait_return) /* if wait_return still needed ... */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2153 wait_return(FALSE); /* ... call it now */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2154 if (need_start_insertmode && goto_im()
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2155 #ifdef FEAT_VISUAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2156 && !VIsual_active
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2157 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2158 )
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2159 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2160 need_start_insertmode = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2161 stuffReadbuff((char_u *)"i"); /* start insert mode next */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2162 /* skip the fileinfo message now, because it would be shown
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2163 * after insert mode finishes! */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2164 need_fileinfo = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2165 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2166 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2167 if (got_int && !global_busy)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2168 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2169 if (!quit_more)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2170 (void)vgetc(); /* flush all buffers */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2171 got_int = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2172 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2173 if (!exmode_active)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2174 msg_scroll = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2175 quit_more = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2176
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2177 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2178 * If skip redraw is set (for ":" in wait_return()), don't redraw now.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2179 * If there is nothing in the stuff_buffer or do_redraw is TRUE,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2180 * update cursor and redraw.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2181 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2182 if (skip_redraw || exmode_active)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2183 skip_redraw = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2184 else if (do_redraw || stuff_empty())
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2185 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2186 #if defined(FEAT_FOLDING) && defined(FEAT_VISUAL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2187 /* Include a closed fold completely in the Visual area. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2188 foldAdjustVisual();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2189 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2190 #ifdef FEAT_FOLDING
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2191 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2192 * When 'foldclose' is set, apply 'foldlevel' to folds that don't
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2193 * contain the cursor.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2194 * When 'foldopen' is "all", open the fold(s) under the cursor.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2195 * This may mark the window for redrawing.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2196 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2197 if (hasAnyFolding(curwin) && !char_avail())
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2198 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2199 foldCheckClose();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2200 if (fdo_flags & FDO_ALL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2201 foldOpenCursor();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2202 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2203 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2204
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2205 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2206 * Before redrawing, make sure w_topline is correct, and w_leftcol
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2207 * if lines don't wrap, and w_skipcol if lines wrap.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2208 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2209 update_topline();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2210 validate_cursor();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2211
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2212 #ifdef FEAT_VISUAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2213 if (VIsual_active)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2214 update_curbuf(INVERTED);/* update inverted part */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2215 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2216 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2217 if (must_redraw)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2218 update_screen(0);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2219 else if (redraw_cmdline || clear_cmdline)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2220 showmode();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2221 #ifdef FEAT_WINDOWS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2222 redraw_statuslines();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2223 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2224 #ifdef FEAT_TITLE
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2225 if (need_maketitle)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2226 maketitle();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2227 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2228 /* display message after redraw */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2229 if (keep_msg != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2230 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2231 char_u *p;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2232
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2233 /* msg_attr_keep() will set keep_msg to NULL, must free the
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2234 * string here. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2235 p = keep_msg;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2236 msg_attr(p, keep_msg_attr);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2237 vim_free(p);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2238 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2239 if (need_fileinfo) /* show file info after redraw */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2240 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2241 fileinfo(FALSE, TRUE, FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2242 need_fileinfo = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2243 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2244
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2245 emsg_on_display = FALSE; /* can delete error message now */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2246 did_emsg = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2247 msg_didany = FALSE; /* reset lines_left in msg_start() */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2248 showruler(FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2249
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2250 setcursor();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2251 cursor_on();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2252
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2253 do_redraw = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2254 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2255 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2256 if (need_mouse_correct)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2257 gui_mouse_correct();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2258 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2259
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2260 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2261 * Update w_curswant if w_set_curswant has been set.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2262 * Postponed until here to avoid computing w_virtcol too often.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2263 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2264 update_curswant();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2265
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2266 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2267 * If we're invoked as ex, do a round of ex commands.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2268 * Otherwise, get and execute a normal mode command.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2269 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2270 if (exmode_active)
169
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2271 {
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2272 if (noexmode) /* End of ":global/path/visual" commands */
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2273 return;
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2274 do_exmode(exmode_active == EXMODE_VIM);
169
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2275 }
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2276 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2277 normal_cmd(&oa, TRUE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2278 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2279 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2280
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2281
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2282 #if defined(USE_XSMP) || defined(FEAT_GUI_MSWIN) || defined(PROTO)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2283 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2284 * Exit, but leave behind swap files for modified buffers.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2285 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2286 void
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2287 getout_preserve_modified(exitval)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2288 int exitval;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2289 {
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
2290 # if defined(SIGHUP) && defined(SIG_IGN)
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
2291 /* Ignore SIGHUP, because a dropped connection causes a read error, which
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
2292 * makes Vim exit and then handling SIGHUP causes various reentrance
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
2293 * problems. */
36
125e80798a85 updated for version 7.0021
vimboss
parents: 34
diff changeset
2294 signal(SIGHUP, SIG_IGN);
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
2295 # endif
36
125e80798a85 updated for version 7.0021
vimboss
parents: 34
diff changeset
2296
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2297 ml_close_notmod(); /* close all not-modified buffers */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2298 ml_sync_all(FALSE, FALSE); /* preserve all swap files */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2299 ml_close_all(FALSE); /* close all memfiles, without deleting */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2300 getout(exitval); /* exit Vim properly */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2301 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2302 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2303
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2304
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2305 /* Exit properly */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2306 void
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2307 getout(exitval)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2308 int exitval;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2309 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2310 #ifdef FEAT_AUTOCMD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2311 buf_T *buf;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2312 win_T *wp;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2313 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2314
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2315 exiting = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2316
169
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2317 /* When running in Ex mode an error causes us to exit with a non-zero exit
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2318 * code. POSIX requires this, although it's not 100% clear from the
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2319 * standard. */
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2320 if (exmode_active)
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2321 exitval += ex_exitval;
0e902b8f511f updated for version 7.0051
vimboss
parents: 164
diff changeset
2322
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2323 /* Position the cursor on the last screen line, below all the text */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2324 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2325 if (!gui.in_use)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2326 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2327 windgoto((int)Rows - 1, 0);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2328
242
a711f7a6852d updated for version 7.0067
vimboss
parents: 237
diff changeset
2329 #if defined(FEAT_EVAL) || defined(FEAT_SYN_HL)
a711f7a6852d updated for version 7.0067
vimboss
parents: 237
diff changeset
2330 /* Optionally print hashtable efficiency. */
a711f7a6852d updated for version 7.0067
vimboss
parents: 237
diff changeset
2331 hash_debug_results();
a711f7a6852d updated for version 7.0067
vimboss
parents: 237
diff changeset
2332 #endif
a711f7a6852d updated for version 7.0067
vimboss
parents: 237
diff changeset
2333
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2334 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2335 msg_didany = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2336 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2337
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2338 #ifdef FEAT_AUTOCMD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2339 /* Trigger BufWinLeave for all windows, but only once per buffer. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2340 for (wp = firstwin; wp != NULL; )
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2341 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2342 buf = wp->w_buffer;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2343 if (buf->b_changedtick != -1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2344 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2345 apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, buf->b_fname,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2346 FALSE, buf);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2347 buf->b_changedtick = -1; /* note that we did it already */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2348 wp = firstwin; /* restart, window may be closed */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2349 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2350 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2351 wp = wp->w_next;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2352 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2353 /* Trigger BufUnload for buffers that are loaded */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2354 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2355 if (buf->b_ml.ml_mfp != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2356 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2357 apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2358 FALSE, buf);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2359 if (!buf_valid(buf)) /* autocmd may delete the buffer */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2360 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2361 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2362 apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2363 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2364
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2365 #ifdef FEAT_VIMINFO
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2366 if (*p_viminfo != NUL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2367 /* Write out the registers, history, marks etc, to the viminfo file */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2368 write_viminfo(NULL, FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2369 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2370
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2371 #ifdef FEAT_AUTOCMD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2372 apply_autocmds(EVENT_VIMLEAVE, NULL, NULL, FALSE, curbuf);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2373 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2374
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
2375 #ifdef FEAT_PROFILE
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
2376 profile_dump();
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
2377 #endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
2378
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2379 if (did_emsg
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2380 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2381 || (gui.in_use && msg_didany && p_verbose > 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2382 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2383 )
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2384 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2385 /* give the user a chance to read the (error) message */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2386 no_wait_return = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2387 wait_return(FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2388 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2389
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2390 #ifdef FEAT_AUTOCMD
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2391 /* Position the cursor again, the autocommands may have moved it */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2392 # ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2393 if (!gui.in_use)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2394 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2395 windgoto((int)Rows - 1, 0);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2396 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2397
14
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
2398 #ifdef FEAT_MZSCHEME
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
2399 mzscheme_end();
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
2400 #endif
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2401 #ifdef FEAT_TCL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2402 tcl_end();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2403 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2404 #ifdef FEAT_RUBY
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2405 ruby_end();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2406 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2407 #ifdef FEAT_PYTHON
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2408 python_end();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2409 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2410 #ifdef FEAT_PERL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2411 perl_end();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2412 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2413 #if defined(USE_ICONV) && defined(DYNAMIC_ICONV)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2414 iconv_end();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2415 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2416 #ifdef FEAT_NETBEANS_INTG
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2417 netbeans_end();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2418 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2419
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2420 mch_exit(exitval);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2421 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2422
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2423 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2424 * Get a (optional) count for a Vim argument.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2425 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2426 static int
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2427 get_number_arg(p, idx, def)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2428 char_u *p; /* pointer to argument */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2429 int *idx; /* index in argument, is incremented */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2430 int def; /* default value */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2431 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2432 if (vim_isdigit(p[*idx]))
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2433 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2434 def = atoi((char *)&(p[*idx]));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2435 while (vim_isdigit(p[*idx]))
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2436 *idx = *idx + 1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2437 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2438 return def;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2439 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2440
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2441 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2442 * Setup to start using the GUI. Exit with an error when not available.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2443 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2444 static void
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2445 main_start_gui()
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2446 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2447 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2448 gui.starting = TRUE; /* start GUI a bit later */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2449 #else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2450 mch_errmsg(_(e_nogvim));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2451 mch_errmsg("\n");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2452 mch_exit(2);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2453 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2454 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2455
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2456 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2457 * Get an evironment variable, and execute it as Ex commands.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2458 * Returns FAIL if the environment variable was not executed, OK otherwise.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2459 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2460 int
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2461 process_env(env, is_viminit)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2462 char_u *env;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2463 int is_viminit; /* when TRUE, called for VIMINIT */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2464 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2465 char_u *initstr;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2466 char_u *save_sourcing_name;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2467 linenr_T save_sourcing_lnum;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2468 #ifdef FEAT_EVAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2469 scid_T save_sid;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2470 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2471
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2472 if ((initstr = mch_getenv(env)) != NULL && *initstr != NUL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2473 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2474 if (is_viminit)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2475 vimrc_found();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2476 save_sourcing_name = sourcing_name;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2477 save_sourcing_lnum = sourcing_lnum;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2478 sourcing_name = env;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2479 sourcing_lnum = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2480 #ifdef FEAT_EVAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2481 save_sid = current_SID;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2482 current_SID = SID_ENV;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2483 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2484 do_cmdline_cmd(initstr);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2485 sourcing_name = save_sourcing_name;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2486 sourcing_lnum = save_sourcing_lnum;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2487 #ifdef FEAT_EVAL
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2488 current_SID = save_sid;;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2489 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2490 return OK;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2491 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2492 return FAIL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2493 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2494
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2495 #if defined(UNIX) || defined(VMS)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2496 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2497 * Return TRUE if we are certain the user owns the file "fname".
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2498 * Used for ".vimrc" and ".exrc".
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2499 * Use both stat() and lstat() for extra security.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2500 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2501 static int
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2502 file_owned(fname)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2503 char *fname;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2504 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2505 struct stat s;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2506 # ifdef UNIX
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2507 uid_t uid = getuid();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2508 # else /* VMS */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2509 uid_t uid = ((getgid() << 16) | getuid());
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2510 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2511
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2512 return !(mch_stat(fname, &s) != 0 || s.st_uid != uid
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2513 # ifdef HAVE_LSTAT
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2514 || mch_lstat(fname, &s) != 0 || s.st_uid != uid
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2515 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2516 );
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2517 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2518 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2519
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2520 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2521 * Give an error message main_errors["n"] and exit.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2522 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2523 static void
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2524 mainerr(n, str)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2525 int n; /* one of the ME_ defines */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2526 char_u *str; /* extra argument or NULL */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2527 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2528 #if defined(UNIX) || defined(__EMX__) || defined(VMS)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2529 reset_signals(); /* kill us with CTRL-C here, if you like */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2530 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2531
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2532 mch_errmsg(longVersion);
159
389c8abd5925 updated for version 7.0048
vimboss
parents: 155
diff changeset
2533 mch_errmsg("\n");
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2534 mch_errmsg(_(main_errors[n]));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2535 if (str != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2536 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2537 mch_errmsg(": \"");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2538 mch_errmsg((char *)str);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2539 mch_errmsg("\"");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2540 }
159
389c8abd5925 updated for version 7.0048
vimboss
parents: 155
diff changeset
2541 mch_errmsg(_("\nMore info with: \"vim -h\"\n"));
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2542
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2543 mch_exit(1);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2544 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2545
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2546 void
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2547 mainerr_arg_missing(str)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2548 char_u *str;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2549 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2550 mainerr(ME_ARG_MISSING, str);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2551 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2552
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2553 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2554 * print a message with three spaces prepended and '\n' appended.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2555 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2556 static void
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2557 main_msg(s)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2558 char *s;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2559 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2560 mch_msg(" ");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2561 mch_msg(s);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2562 mch_msg("\n");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2563 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2564
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2565 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2566 * Print messages for "vim -h" or "vim --help" and exit.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2567 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2568 static void
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2569 usage()
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2570 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2571 int i;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2572 static char *(use[]) =
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2573 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2574 N_("[file ..] edit specified file(s)"),
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2575 N_("- read text from stdin"),
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2576 N_("-t tag edit file where tag is defined"),
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2577 #ifdef FEAT_QUICKFIX
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2578 N_("-q [errorfile] edit file with first error")
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2579 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2580 };
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2581
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2582 #if defined(UNIX) || defined(__EMX__) || defined(VMS)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2583 reset_signals(); /* kill us with CTRL-C here, if you like */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2584 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2585
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2586 mch_msg(longVersion);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2587 mch_msg(_("\n\nusage:"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2588 for (i = 0; ; ++i)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2589 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2590 mch_msg(_(" vim [arguments] "));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2591 mch_msg(_(use[i]));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2592 if (i == (sizeof(use) / sizeof(char_u *)) - 1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2593 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2594 mch_msg(_("\n or:"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2595 }
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 16
diff changeset
2596 #ifdef VMS
cc049b00ee70 updated for version 7.0014
vimboss
parents: 16
diff changeset
2597 mch_msg(_("where case is ignored prepend / to make flag upper case"));
cc049b00ee70 updated for version 7.0014
vimboss
parents: 16
diff changeset
2598 #endif
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2599
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2600 mch_msg(_("\n\nArguments:\n"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2601 main_msg(_("--\t\t\tOnly file names after this"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2602 #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2603 main_msg(_("--literal\t\tDon't expand wildcards"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2604 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2605 #ifdef FEAT_OLE
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2606 main_msg(_("-register\t\tRegister this gvim for OLE"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2607 main_msg(_("-unregister\t\tUnregister gvim for OLE"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2608 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2609 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2610 main_msg(_("-g\t\t\tRun using GUI (like \"gvim\")"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2611 main_msg(_("-f or --nofork\tForeground: Don't fork when starting GUI"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2612 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2613 main_msg(_("-v\t\t\tVi mode (like \"vi\")"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2614 main_msg(_("-e\t\t\tEx mode (like \"ex\")"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2615 main_msg(_("-s\t\t\tSilent (batch) mode (only for \"ex\")"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2616 #ifdef FEAT_DIFF
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2617 main_msg(_("-d\t\t\tDiff mode (like \"vimdiff\")"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2618 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2619 main_msg(_("-y\t\t\tEasy mode (like \"evim\", modeless)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2620 main_msg(_("-R\t\t\tReadonly mode (like \"view\")"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2621 main_msg(_("-Z\t\t\tRestricted mode (like \"rvim\")"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2622 main_msg(_("-m\t\t\tModifications (writing files) not allowed"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2623 main_msg(_("-M\t\t\tModifications in text not allowed"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2624 main_msg(_("-b\t\t\tBinary mode"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2625 #ifdef FEAT_LISP
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2626 main_msg(_("-l\t\t\tLisp mode"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2627 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2628 main_msg(_("-C\t\t\tCompatible with Vi: 'compatible'"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2629 main_msg(_("-N\t\t\tNot fully Vi compatible: 'nocompatible'"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2630 main_msg(_("-V[N]\t\tVerbose level"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2631 main_msg(_("-D\t\t\tDebugging mode"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2632 main_msg(_("-n\t\t\tNo swap file, use memory only"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2633 main_msg(_("-r\t\t\tList swap files and exit"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2634 main_msg(_("-r (with file name)\tRecover crashed session"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2635 main_msg(_("-L\t\t\tSame as -r"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2636 #ifdef AMIGA
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2637 main_msg(_("-f\t\t\tDon't use newcli to open window"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2638 main_msg(_("-dev <device>\t\tUse <device> for I/O"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2639 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2640 #ifdef FEAT_ARABIC
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2641 main_msg(_("-A\t\t\tstart in Arabic mode"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2642 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2643 #ifdef FEAT_RIGHTLEFT
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2644 main_msg(_("-H\t\t\tStart in Hebrew mode"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2645 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2646 #ifdef FEAT_FKMAP
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2647 main_msg(_("-F\t\t\tStart in Farsi mode"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2648 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2649 main_msg(_("-T <terminal>\tSet terminal type to <terminal>"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2650 main_msg(_("-u <vimrc>\t\tUse <vimrc> instead of any .vimrc"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2651 #ifdef FEAT_GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2652 main_msg(_("-U <gvimrc>\t\tUse <gvimrc> instead of any .gvimrc"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2653 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2654 main_msg(_("--noplugin\t\tDon't load plugin scripts"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2655 main_msg(_("-o[N]\t\tOpen N windows (default: one for each file)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2656 main_msg(_("-O[N]\t\tLike -o but split vertically"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2657 main_msg(_("+\t\t\tStart at end of file"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2658 main_msg(_("+<lnum>\t\tStart at line <lnum>"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2659 #ifdef FEAT_PRECOMMANDS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2660 main_msg(_("--cmd <command>\tExecute <command> before loading any vimrc file"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2661 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2662 main_msg(_("-c <command>\t\tExecute <command> after loading the first file"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2663 main_msg(_("-S <session>\t\tSource file <session> after loading the first file"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2664 main_msg(_("-s <scriptin>\tRead Normal mode commands from file <scriptin>"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2665 main_msg(_("-w <scriptout>\tAppend all typed commands to file <scriptout>"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2666 main_msg(_("-W <scriptout>\tWrite all typed commands to file <scriptout>"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2667 #ifdef FEAT_CRYPT
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2668 main_msg(_("-x\t\t\tEdit encrypted files"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2669 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2670 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_X11)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2671 # if defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2672 main_msg(_("-display <display>\tConnect vim to this particular X-server"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2673 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2674 main_msg(_("-X\t\t\tDo not connect to X server"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2675 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2676 #ifdef FEAT_CLIENTSERVER
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2677 main_msg(_("--remote <files>\tEdit <files> in a Vim server if possible"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2678 main_msg(_("--remote-silent <files> Same, don't complain if there is no server"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2679 main_msg(_("--remote-wait <files> As --remote but wait for files to have been edited"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2680 main_msg(_("--remote-wait-silent <files> Same, don't complain if there is no server"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2681 main_msg(_("--remote-send <keys>\tSend <keys> to a Vim server and exit"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2682 main_msg(_("--remote-expr <expr>\tEvaluate <expr> in a Vim server and print result"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2683 main_msg(_("--serverlist\t\tList available Vim server names and exit"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2684 main_msg(_("--servername <name>\tSend to/become the Vim server <name>"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2685 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2686 #ifdef FEAT_VIMINFO
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2687 main_msg(_("-i <viminfo>\t\tUse <viminfo> instead of .viminfo"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2688 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2689 main_msg(_("-h or --help\tPrint Help (this message) and exit"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2690 main_msg(_("--version\t\tPrint version information and exit"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2691
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2692 #ifdef FEAT_GUI_X11
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2693 # ifdef FEAT_GUI_MOTIF
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2694 mch_msg(_("\nArguments recognised by gvim (Motif version):\n"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2695 # else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2696 # ifdef FEAT_GUI_ATHENA
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2697 # ifdef FEAT_GUI_NEXTAW
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2698 mch_msg(_("\nArguments recognised by gvim (neXtaw version):\n"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2699 # else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2700 mch_msg(_("\nArguments recognised by gvim (Athena version):\n"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2701 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2702 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2703 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2704 main_msg(_("-display <display>\tRun vim on <display>"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2705 main_msg(_("-iconic\t\tStart vim iconified"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2706 # if 0
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2707 main_msg(_("-name <name>\t\tUse resource as if vim was <name>"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2708 mch_msg(_("\t\t\t (Unimplemented)\n"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2709 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2710 main_msg(_("-background <color>\tUse <color> for the background (also: -bg)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2711 main_msg(_("-foreground <color>\tUse <color> for normal text (also: -fg)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2712 main_msg(_("-font <font>\t\tUse <font> for normal text (also: -fn)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2713 main_msg(_("-boldfont <font>\tUse <font> for bold text"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2714 main_msg(_("-italicfont <font>\tUse <font> for italic text"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2715 main_msg(_("-geometry <geom>\tUse <geom> for initial geometry (also: -geom)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2716 main_msg(_("-borderwidth <width>\tUse a border width of <width> (also: -bw)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2717 main_msg(_("-scrollbarwidth <width> Use a scrollbar width of <width> (also: -sw)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2718 # ifdef FEAT_GUI_ATHENA
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2719 main_msg(_("-menuheight <height>\tUse a menu bar height of <height> (also: -mh)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2720 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2721 main_msg(_("-reverse\t\tUse reverse video (also: -rv)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2722 main_msg(_("+reverse\t\tDon't use reverse video (also: +rv)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2723 main_msg(_("-xrm <resource>\tSet the specified resource"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2724 #endif /* FEAT_GUI_X11 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2725 #if defined(FEAT_GUI) && defined(RISCOS)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2726 mch_msg(_("\nArguments recognised by gvim (RISC OS version):\n"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2727 main_msg(_("--columns <number>\tInitial width of window in columns"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2728 main_msg(_("--rows <number>\tInitial height of window in rows"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2729 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2730 #ifdef FEAT_GUI_GTK
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2731 mch_msg(_("\nArguments recognised by gvim (GTK+ version):\n"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2732 main_msg(_("-font <font>\t\tUse <font> for normal text (also: -fn)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2733 main_msg(_("-geometry <geom>\tUse <geom> for initial geometry (also: -geom)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2734 main_msg(_("-reverse\t\tUse reverse video (also: -rv)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2735 main_msg(_("-display <display>\tRun vim on <display> (also: --display)"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2736 # ifdef HAVE_GTK2
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2737 main_msg(_("--role <role>\tSet a unique role to identify the main window"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2738 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2739 main_msg(_("--socketid <xid>\tOpen Vim inside another GTK widget"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2740 #endif
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
2741 #ifdef FEAT_GUI_KDE
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
2742 mch_msg(_("\nArguments recognised by kvim (KDE version):\n"));
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
2743 main_msg(_("-black\t\tUse reverse video"));
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
2744 #if QT_VERSION>=300
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
2745 main_msg(_("-tip\t\t\tDisplay the tip dialog on startup"));
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
2746 main_msg(_("-notip\t\tDisable the tip dialog"));
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
2747 #endif
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
2748 main_msg(_("-font <font>\t\tUse <font> for normal text (also: -fn)"));
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
2749 main_msg(_("-geometry <geom>\tUse <geom> for initial geometry (also: -geom)"));
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
2750 main_msg(_("--display <display>\tRun vim on <display>"));
4424b47a0797 updated for version 7.0003
vimboss
parents: 6
diff changeset
2751 #endif
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2752 #ifdef FEAT_GUI_W32
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2753 main_msg(_("-P <parent title>\tOpen Vim inside parent application"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2754 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2755
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2756 #ifdef FEAT_GUI_GNOME
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2757 /* Gnome gives extra messages for --help if we continue, but not for -h. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2758 if (gui.starting)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2759 mch_msg("\n");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2760 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2761 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2762 mch_exit(0);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2763 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2764
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2765 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2766 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2767 * Check the result of the ATTENTION dialog:
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2768 * When "Quit" selected, exit Vim.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2769 * When "Recover" selected, recover the file.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2770 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2771 static void
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2772 check_swap_exists_action()
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2773 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2774 if (swap_exists_action == SEA_QUIT)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2775 getout(1);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2776 handle_swap_exists(NULL);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2777 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2778 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2779
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2780 #if defined(STARTUPTIME) || defined(PROTO)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2781 static void time_diff __ARGS((struct timeval *then, struct timeval *now));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2782
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2783 static struct timeval prev_timeval;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2784
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2785 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2786 * Save the previous time before doing something that could nest.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2787 * set "*tv_rel" to the time elapsed so far.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2788 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2789 void
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2790 time_push(tv_rel, tv_start)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2791 void *tv_rel, *tv_start;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2792 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2793 *((struct timeval *)tv_rel) = prev_timeval;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2794 gettimeofday(&prev_timeval, NULL);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2795 ((struct timeval *)tv_rel)->tv_usec = prev_timeval.tv_usec
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2796 - ((struct timeval *)tv_rel)->tv_usec;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2797 ((struct timeval *)tv_rel)->tv_sec = prev_timeval.tv_sec
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2798 - ((struct timeval *)tv_rel)->tv_sec;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2799 if (((struct timeval *)tv_rel)->tv_usec < 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2800 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2801 ((struct timeval *)tv_rel)->tv_usec += 1000000;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2802 --((struct timeval *)tv_rel)->tv_sec;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2803 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2804 *(struct timeval *)tv_start = prev_timeval;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2805 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2806
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2807 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2808 * Compute the previous time after doing something that could nest.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2809 * Subtract "*tp" from prev_timeval;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2810 * Note: The arguments are (void *) to avoid trouble with systems that don't
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2811 * have struct timeval.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2812 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2813 void
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2814 time_pop(tp)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2815 void *tp; /* actually (struct timeval *) */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2816 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2817 prev_timeval.tv_usec -= ((struct timeval *)tp)->tv_usec;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2818 prev_timeval.tv_sec -= ((struct timeval *)tp)->tv_sec;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2819 if (prev_timeval.tv_usec < 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2820 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2821 prev_timeval.tv_usec += 1000000;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2822 --prev_timeval.tv_sec;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2823 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2824 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2825
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2826 static void
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2827 time_diff(then, now)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2828 struct timeval *then;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2829 struct timeval *now;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2830 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2831 long usec;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2832 long msec;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2833
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2834 usec = now->tv_usec - then->tv_usec;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2835 msec = (now->tv_sec - then->tv_sec) * 1000L + usec / 1000L,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2836 usec = usec % 1000L;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2837 fprintf(time_fd, "%03ld.%03ld", msec, usec >= 0 ? usec : usec + 1000L);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2838 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2839
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2840 void
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2841 time_msg(msg, tv_start)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2842 char *msg;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2843 void *tv_start; /* only for do_source: start time; actually
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2844 (struct timeval *) */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2845 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2846 static struct timeval start;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2847 struct timeval now;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2848
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2849 if (time_fd != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2850 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2851 if (strstr(msg, "STARTING") != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2852 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2853 gettimeofday(&start, NULL);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2854 prev_timeval = start;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2855 fprintf(time_fd, "\n\ntimes in msec\n");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2856 fprintf(time_fd, " clock self+sourced self: sourced script\n");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2857 fprintf(time_fd, " clock elapsed: other lines\n\n");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2858 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2859 gettimeofday(&now, NULL);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2860 time_diff(&start, &now);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2861 if (((struct timeval *)tv_start) != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2862 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2863 fprintf(time_fd, " ");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2864 time_diff(((struct timeval *)tv_start), &now);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2865 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2866 fprintf(time_fd, " ");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2867 time_diff(&prev_timeval, &now);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2868 prev_timeval = now;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2869 fprintf(time_fd, ": %s\n", msg);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2870 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2871 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2872
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2873 # ifdef WIN3264
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2874 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2875 * Windows doesn't have gettimeofday(), although it does have struct timeval.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2876 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2877 int
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2878 gettimeofday(struct timeval *tv, char *dummy)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2879 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2880 long t = clock();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2881 tv->tv_sec = t / CLOCKS_PER_SEC;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2882 tv->tv_usec = (t - tv->tv_sec * CLOCKS_PER_SEC) * 1000000 / CLOCKS_PER_SEC;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2883 return 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2884 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2885 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2886
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2887 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2888
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2889 #if defined(FEAT_CLIENTSERVER) || defined(PROTO)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2890
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2891 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2892 * Common code for the X command server and the Win32 command server.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2893 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2894
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2895 static char_u *build_drop_cmd __ARGS((int filec, char **filev, int sendReply));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2896
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2897 static void
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2898 cmdsrv_main(argc, argv, serverName_arg, serverStr)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2899 int *argc;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2900 char **argv;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2901 char_u *serverName_arg;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2902 char_u **serverStr;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2903 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2904 char_u *res;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2905 int i;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2906 char_u *sname;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2907 int ret;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2908 int didone = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2909 int exiterr = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2910 char **newArgV = argv + 1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2911 int newArgC = 1,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2912 Argc = *argc;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2913 int argtype;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2914 #define ARGTYPE_OTHER 0
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2915 #define ARGTYPE_EDIT 1
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2916 #define ARGTYPE_EDIT_WAIT 2
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2917 #define ARGTYPE_SEND 3
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2918 int silent = FALSE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2919 # ifndef FEAT_X11
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2920 HWND srv;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2921 # else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2922 Window srv;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2923
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2924 setup_term_clip();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2925 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2926
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2927 sname = serverMakeName(serverName_arg, argv[0]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2928 if (sname == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2929 return;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2930
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2931 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2932 * Execute the command server related arguments and remove them
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2933 * from the argc/argv array; We may have to return into main()
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2934 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2935 for (i = 1; i < Argc; i++)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2936 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2937 res = NULL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2938 if (STRCMP(argv[i], "--") == 0) /* end of options */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2939 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2940 for (; i < *argc; i++)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2941 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2942 *newArgV++ = argv[i];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2943 newArgC++;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2944 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2945 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2946 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2947
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2948 if (STRICMP(argv[i], "--remote") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2949 argtype = ARGTYPE_EDIT;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2950 else if (STRICMP(argv[i], "--remote-silent") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2951 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2952 argtype = ARGTYPE_EDIT;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2953 silent = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2954 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2955 else if (STRICMP(argv[i], "--remote-wait") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2956 argtype = ARGTYPE_EDIT_WAIT;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2957 else if (STRICMP(argv[i], "--remote-wait-silent") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2958 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2959 argtype = ARGTYPE_EDIT_WAIT;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2960 silent = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2961 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2962 else if (STRICMP(argv[i], "--remote-send") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2963 argtype = ARGTYPE_SEND;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2964 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2965 argtype = ARGTYPE_OTHER;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2966 if (argtype != ARGTYPE_OTHER)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2967 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2968 if (i == *argc - 1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2969 mainerr_arg_missing((char_u *)argv[i]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2970 if (argtype == ARGTYPE_SEND)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2971 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2972 *serverStr = (char_u *)argv[i + 1];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2973 i++;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2974 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2975 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2976 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2977 *serverStr = build_drop_cmd(*argc - i - 1, argv + i + 1,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2978 argtype == ARGTYPE_EDIT_WAIT);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2979 if (*serverStr == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2980 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2981 /* Probably out of memory, exit. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2982 didone = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2983 exiterr = 1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2984 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2985 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2986 Argc = i;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2987 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2988 # ifdef FEAT_X11
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2989 if (xterm_dpy == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2990 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2991 mch_errmsg(_("No display"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2992 ret = -1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2993 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2994 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2995 ret = serverSendToVim(xterm_dpy, sname, *serverStr,
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2996 NULL, &srv, 0, 0, silent);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2997 # else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2998 /* Win32 always works? */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
2999 ret = serverSendToVim(sname, *serverStr, NULL, &srv, 0, silent);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3000 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3001 if (ret < 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3002 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3003 if (argtype == ARGTYPE_SEND)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3004 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3005 /* Failed to send, abort. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3006 mch_errmsg(_(": Send failed.\n"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3007 didone = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3008 exiterr = 1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3009 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3010 else if (!silent)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3011 /* Let vim start normally. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3012 mch_errmsg(_(": Send failed. Trying to execute locally\n"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3013 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3014 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3015
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3016 # ifdef FEAT_GUI_W32
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3017 /* Guess that when the server name starts with "g" it's a GUI
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3018 * server, which we can bring to the foreground here.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3019 * Foreground() in the server doesn't work very well. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3020 if (argtype != ARGTYPE_SEND && TOUPPER_ASC(*sname) == 'G')
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3021 SetForegroundWindow(srv);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3022 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3023
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3024 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3025 * For --remote-wait: Wait until the server did edit each
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3026 * file. Also detect that the server no longer runs.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3027 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3028 if (ret >= 0 && argtype == ARGTYPE_EDIT_WAIT)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3029 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3030 int numFiles = *argc - i - 1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3031 int j;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3032 char_u *done = alloc(numFiles);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3033 char_u *p;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3034 # ifdef FEAT_GUI_W32
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3035 NOTIFYICONDATA ni;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3036 int count = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3037 extern HWND message_window;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3038 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3039
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3040 if (numFiles > 0 && argv[i + 1][0] == '+')
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3041 /* Skip "+cmd" argument, don't wait for it to be edited. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3042 --numFiles;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3043
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3044 # ifdef FEAT_GUI_W32
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3045 ni.cbSize = sizeof(ni);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3046 ni.hWnd = message_window;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3047 ni.uID = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3048 ni.uFlags = NIF_ICON|NIF_TIP;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3049 ni.hIcon = LoadIcon((HINSTANCE)GetModuleHandle(0), "IDR_VIM");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3050 sprintf(ni.szTip, _("%d of %d edited"), count, numFiles);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3051 Shell_NotifyIcon(NIM_ADD, &ni);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3052 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3053
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3054 /* Wait for all files to unload in remote */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3055 memset(done, 0, numFiles);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3056 while (memchr(done, 0, numFiles) != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3057 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3058 # ifdef WIN32
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3059 p = serverGetReply(srv, NULL, TRUE, TRUE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3060 if (p == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3061 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3062 # else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3063 if (serverReadReply(xterm_dpy, srv, &p, TRUE) < 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3064 break;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3065 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3066 j = atoi((char *)p);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3067 if (j >= 0 && j < numFiles)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3068 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3069 # ifdef FEAT_GUI_W32
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3070 ++count;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3071 sprintf(ni.szTip, _("%d of %d edited"),
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3072 count, numFiles);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3073 Shell_NotifyIcon(NIM_MODIFY, &ni);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3074 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3075 done[j] = 1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3076 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3077 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3078 # ifdef FEAT_GUI_W32
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3079 Shell_NotifyIcon(NIM_DELETE, &ni);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3080 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3081 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3082 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3083 else if (STRICMP(argv[i], "--remote-expr") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3084 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3085 if (i == *argc - 1)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3086 mainerr_arg_missing((char_u *)argv[i]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3087 # ifdef WIN32
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3088 /* Win32 always works? */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3089 if (serverSendToVim(sname, (char_u *)argv[i + 1],
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3090 &res, NULL, 1, FALSE) < 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3091 # else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3092 if (xterm_dpy == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3093 mch_errmsg(_("No display: Send expression failed.\n"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3094 else if (serverSendToVim(xterm_dpy, sname, (char_u *)argv[i + 1],
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3095 &res, NULL, 1, 1, FALSE) < 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3096 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3097 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3098 if (res != NULL && *res != NUL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3099 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3100 /* Output error from remote */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3101 mch_errmsg((char *)res);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3102 vim_free(res);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3103 res = NULL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3104 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3105 mch_errmsg(_(": Send expression failed.\n"));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3106 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3107 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3108 else if (STRICMP(argv[i], "--serverlist") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3109 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3110 # ifdef WIN32
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3111 /* Win32 always works? */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3112 res = serverGetVimNames();
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3113 # else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3114 if (xterm_dpy != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3115 res = serverGetVimNames(xterm_dpy);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3116 # endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3117 if (called_emsg)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3118 mch_errmsg("\n");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3119 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3120 else if (STRICMP(argv[i], "--servername") == 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3121 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3122 /* Alredy processed. Take it out of the command line */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3123 i++;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3124 continue;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3125 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3126 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3127 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3128 *newArgV++ = argv[i];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3129 newArgC++;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3130 continue;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3131 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3132 didone = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3133 if (res != NULL && *res != NUL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3134 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3135 mch_msg((char *)res);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3136 if (res[STRLEN(res) - 1] != '\n')
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3137 mch_msg("\n");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3138 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3139 vim_free(res);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3140 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3141
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3142 if (didone)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3143 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3144 display_errors(); /* display any collected messages */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3145 exit(exiterr); /* Mission accomplished - get out */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3146 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3147
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3148 /* Return back into main() */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3149 *argc = newArgC;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3150 vim_free(sname);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3151 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3152
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3153 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3154 * Build a ":drop" command to send to a Vim server.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3155 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3156 static char_u *
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3157 build_drop_cmd(filec, filev, sendReply)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3158 int filec;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3159 char **filev;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3160 int sendReply;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3161 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3162 garray_T ga;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3163 int i;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3164 char_u *inicmd = NULL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3165 char_u *p;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3166 char_u cwd[MAXPATHL];
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3167
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3168 if (filec > 0 && filev[0][0] == '+')
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3169 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3170 inicmd = (char_u *)filev[0] + 1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3171 filev++;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3172 filec--;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3173 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3174 /* Check if we have at least one argument. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3175 if (filec <= 0)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3176 mainerr_arg_missing((char_u *)filev[-1]);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3177 if (mch_dirname(cwd, MAXPATHL) != OK)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3178 return NULL;
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 14
diff changeset
3179 if ((p = vim_strsave_escaped_ext(cwd, PATH_ESC_CHARS, '\\', TRUE)) == NULL)
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3180 return NULL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3181 ga_init2(&ga, 1, 100);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3182 ga_concat(&ga, (char_u *)"<C-\\><C-N>:cd ");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3183 ga_concat(&ga, p);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3184 /* Call inputsave() so that a prompt for an encryption key works. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3185 ga_concat(&ga, (char_u *)"<CR>:if exists('*inputsave')|call inputsave()|endif|drop");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3186 vim_free(p);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3187 for (i = 0; i < filec; i++)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3188 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3189 /* On Unix the shell has already expanded the wildcards, don't want to
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
3190 * do it again in the Vim server. On MS-Windows only escape
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
3191 * non-wildcard characters. */
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3192 p = vim_strsave_escaped((char_u *)filev[i],
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3193 #ifdef UNIX
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3194 PATH_ESC_CHARS
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3195 #else
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
3196 (char_u *)" \t%#"
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3197 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3198 );
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3199 if (p == NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3200 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3201 vim_free(ga.ga_data);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3202 return NULL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3203 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3204 ga_concat(&ga, (char_u *)" ");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3205 ga_concat(&ga, p);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3206 vim_free(p);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3207 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3208 /* The :drop commands goes to Insert mode when 'insertmode' is set, use
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3209 * CTRL-\ CTRL-N again. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3210 ga_concat(&ga, (char_u *)"|if exists('*inputrestore')|call inputrestore()|endif<CR>");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3211 ga_concat(&ga, (char_u *)"<C-\\><C-N>:cd -");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3212 if (sendReply)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3213 ga_concat(&ga, (char_u *)"<CR>:call SetupRemoteReplies()");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3214 ga_concat(&ga, (char_u *)"<CR>:");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3215 if (inicmd != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3216 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3217 /* Can't use <CR> after "inicmd", because an "startinsert" would cause
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3218 * the following commands to be inserted as text. Use a "|",
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3219 * hopefully "inicmd" does allow this... */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3220 ga_concat(&ga, inicmd);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3221 ga_concat(&ga, (char_u *)"|");
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3222 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3223 /* Bring the window to the foreground, goto Insert mode when 'im' set and
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3224 * clear command line. */
46
46d39f2eff86 updated for version 7.0027
vimboss
parents: 43
diff changeset
3225 ga_concat(&ga, (char_u *)"cal foreground()|if &im|star|en|redr|f<CR>");
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3226 ga_append(&ga, NUL);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3227 return ga.ga_data;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3228 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3229
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3230 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3231 * Replace termcodes such as <CR> and insert as key presses if there is room.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3232 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3233 void
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3234 server_to_input_buf(str)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3235 char_u *str;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3236 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3237 char_u *ptr = NULL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3238 char_u *cpo_save = p_cpo;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3239
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3240 /* Set 'cpoptions' the way we want it.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3241 * B set - backslashes are *not* treated specially
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3242 * k set - keycodes are *not* reverse-engineered
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3243 * < unset - <Key> sequences *are* interpreted
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3244 * The last parameter of replace_termcodes() is TRUE so that the <lt>
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3245 * sequence is recognised - needed for a real backslash.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3246 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3247 p_cpo = (char_u *)"Bk";
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3248 str = replace_termcodes((char_u *)str, &ptr, FALSE, TRUE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3249 p_cpo = cpo_save;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3250
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3251 if (*ptr != NUL) /* trailing CTRL-V results in nothing */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3252 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3253 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3254 * Add the string to the input stream.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3255 * Can't use add_to_input_buf() here, we now have K_SPECIAL bytes.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3256 *
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3257 * First clear typed characters from the typeahead buffer, there could
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3258 * be half a mapping there. Then append to the existing string, so
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3259 * that multiple commands from a client are concatenated.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3260 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3261 if (typebuf.tb_maplen < typebuf.tb_len)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3262 del_typebuf(typebuf.tb_len - typebuf.tb_maplen, typebuf.tb_maplen);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3263 (void)ins_typebuf(str, REMAP_NONE, typebuf.tb_len, TRUE, FALSE);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3264
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3265 /* Let input_available() know we inserted text in the typeahead
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3266 * buffer. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3267 received_from_client = TRUE;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3268 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3269 vim_free((char_u *)ptr);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3270 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3271
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3272 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3273 * Evaluate an expression that the client sent to a string.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3274 * Handles disabling error messages and disables debugging, otherwise Vim
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3275 * hangs, waiting for "cont" to be typed.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3276 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3277 char_u *
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3278 eval_client_expr_to_string(expr)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3279 char_u *expr;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3280 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3281 char_u *res;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3282 int save_dbl = debug_break_level;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3283 int save_ro = redir_off;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3284
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3285 debug_break_level = -1;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3286 redir_off = 0;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3287 ++emsg_skip;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3288
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3289 res = eval_to_string(expr, NULL);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3290
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3291 debug_break_level = save_dbl;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3292 redir_off = save_ro;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3293 --emsg_skip;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3294
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3295 return res;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3296 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3297
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3298 /*
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3299 * If conversion is needed, convert "data" from "client_enc" to 'encoding' and
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3300 * return an allocated string. Otherwise return "data".
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3301 * "*tofree" is set to the result when it needs to be freed later.
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3302 */
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3303 /*ARGSUSED*/
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3304 char_u *
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3305 serverConvert(client_enc, data, tofree)
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3306 char_u *client_enc;
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3307 char_u *data;
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3308 char_u **tofree;
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3309 {
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3310 char_u *res = data;
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3311
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3312 *tofree = NULL;
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3313 # ifdef FEAT_MBYTE
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3314 if (client_enc != NULL && p_enc != NULL)
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3315 {
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3316 vimconv_T vimconv;
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3317
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3318 vimconv.vc_type = CONV_NONE;
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3319 if (convert_setup(&vimconv, client_enc, p_enc) != FAIL
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3320 && vimconv.vc_type != CONV_NONE)
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3321 {
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3322 res = string_convert(&vimconv, data, NULL);
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3323 if (res == NULL)
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3324 res = data;
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3325 else
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3326 *tofree = res;
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3327 }
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3328 convert_setup(&vimconv, NULL, NULL);
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3329 }
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3330 # endif
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3331 return res;
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3332 }
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3333
6
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3334
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3335 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3336 * Make our basic server name: use the specified "arg" if given, otherwise use
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3337 * the tail of the command "cmd" we were started with.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3338 * Return the name in allocated memory. This doesn't include a serial number.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3339 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3340 static char_u *
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3341 serverMakeName(arg, cmd)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3342 char_u *arg;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3343 char *cmd;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3344 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3345 char_u *p;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3346
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3347 if (arg != NULL && *arg != NUL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3348 p = vim_strsave_up(arg);
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3349 else
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3350 {
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3351 p = vim_strsave_up(gettail((char_u *)cmd));
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3352 /* Remove .exe or .bat from the name. */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3353 if (p != NULL && vim_strchr(p, '.') != NULL)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3354 *vim_strchr(p, '.') = NUL;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3355 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3356 return p;
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3357 }
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3358 #endif /* FEAT_CLIENTSERVER */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3359
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3360 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3361 * When FEAT_FKMAP is defined, also compile the Farsi source code.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3362 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3363 #if defined(FEAT_FKMAP) || defined(PROTO)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3364 # include "farsi.c"
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3365 #endif
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3366
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3367 /*
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3368 * When FEAT_ARABIC is defined, also compile the Arabic source code.
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3369 */
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3370 #if defined(FEAT_ARABIC) || defined(PROTO)
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3371 # include "arabic.c"
c2daee826b8f updated for version 7.0001
vimboss
parents:
diff changeset
3372 #endif