Mercurial > vim
annotate src/dosinst.c @ 3320:45467d77047d v7.3.427
updated for version 7.3.427
Problem: readfile() can be slow with long lines.
Solution: Use realloc() instead of alloc(). (John Little)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 05 Feb 2012 00:39:18 +0100 |
parents | 073ff46fe397 |
children | 918d7df425af |
rev | line source |
---|---|
7 | 1 /* vi:set ts=8 sts=4 sw=4: |
2 * | |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * dosinst.c: Install program for Vim on MS-DOS and MS-Windows | |
12 * | |
13 * Compile with Make_mvc.mak, Make_bc3.mak, Make_bc5.mak or Make_djg.mak. | |
14 */ | |
15 | |
16 /* | |
17 * Include common code for dosinst.c and uninstal.c. | |
18 */ | |
19 #define DOSINST | |
20 #include "dosinst.h" | |
21 | |
22 /* Macro to do an error check I was typing over and over */ | |
23 #define CHECK_REG_ERROR(code) if (code != ERROR_SUCCESS) { printf("%ld error number: %ld\n", (long)__LINE__, (long)code); return 1; } | |
24 | |
25 int has_vim = 0; /* installable vim.exe exists */ | |
26 int has_gvim = 0; /* installable gvim.exe exists */ | |
27 | |
28 char oldvimrc[BUFSIZE]; /* name of existing vimrc file */ | |
29 char vimrc[BUFSIZE]; /* name of vimrc file to create */ | |
30 | |
31 char *default_bat_dir = NULL; /* when not NULL, use this as the default | |
32 directory to write .bat files in */ | |
33 char *default_vim_dir = NULL; /* when not NULL, use this as the default | |
34 install dir for NSIS */ | |
35 | |
36 /* | |
37 * Structure used for each choice the user can make. | |
38 */ | |
39 struct choice | |
40 { | |
41 int active; /* non-zero when choice is active */ | |
42 char *text; /* text displayed for this choice */ | |
43 void (*changefunc)(int idx); /* function to change this choice */ | |
44 int arg; /* argument for function */ | |
45 void (*installfunc)(int idx); /* function to install this choice */ | |
46 }; | |
47 | |
48 struct choice choices[30]; /* choices the user can make */ | |
49 int choice_count = 0; /* number of choices available */ | |
50 | |
51 #define TABLE_SIZE(s) (int)(sizeof(s) / sizeof(*s)) | |
52 | |
53 enum | |
54 { | |
55 compat_vi = 1, | |
56 compat_some_enhancements, | |
57 compat_all_enhancements | |
58 }; | |
59 char *(compat_choices[]) = | |
60 { | |
61 "\nChoose the default way to run Vim:", | |
62 "Vi compatible", | |
2154
7c8c7c95a865
First step in the Vim 7.3 branch. Changed version numbers.
Bram Moolenaar <bram@zimbu.org>
parents:
1569
diff
changeset
|
63 "with some Vim enhancements", |
7 | 64 "with syntax highlighting and other features switched on", |
65 }; | |
66 int compat_choice = (int)compat_all_enhancements; | |
67 char *compat_text = "- run Vim %s"; | |
68 | |
69 enum | |
70 { | |
71 remap_no = 1, | |
72 remap_win | |
73 }; | |
74 char *(remap_choices[]) = | |
75 { | |
76 "\nChoose:", | |
77 "Do not remap keys for Windows behavior", | |
78 "Remap a few keys for Windows behavior (<C-V>, <C-C>, etc)", | |
79 }; | |
80 int remap_choice = (int)remap_win; | |
81 char *remap_text = "- %s"; | |
82 | |
83 enum | |
84 { | |
85 mouse_xterm = 1, | |
86 mouse_mswin | |
87 }; | |
88 char *(mouse_choices[]) = | |
89 { | |
90 "\nChoose the way how Vim uses the mouse:", | |
91 "right button extends selection (the Unix way)", | |
92 "right button has a popup menu (the Windows way)", | |
93 }; | |
94 int mouse_choice = (int)mouse_mswin; | |
95 char *mouse_text = "- The mouse %s"; | |
96 | |
97 enum | |
98 { | |
99 vimfiles_dir_none = 1, | |
100 vimfiles_dir_vim, | |
101 vimfiles_dir_home | |
102 }; | |
103 static char *(vimfiles_dir_choices[]) = | |
104 { | |
105 "\nCreate plugin directories:", | |
106 "No", | |
107 "In the VIM directory", | |
108 "In your HOME directory", | |
109 }; | |
110 static int vimfiles_dir_choice; | |
111 | |
112 /* non-zero when selected to install the popup menu entry. */ | |
113 static int install_popup = 0; | |
114 | |
115 /* non-zero when selected to install the "Open with" entry. */ | |
116 static int install_openwith = 0; | |
117 | |
118 /* non-zero when need to add an uninstall entry in the registry */ | |
119 static int need_uninstall_entry = 0; | |
120 | |
121 /* | |
122 * Definitions of the directory name (under $VIM) of the vimfiles directory | |
123 * and its subdirectories: | |
124 */ | |
125 static char *(vimfiles_subdirs[]) = | |
126 { | |
127 "colors", | |
128 "compiler", | |
129 "doc", | |
130 "ftdetect", | |
131 "ftplugin", | |
132 "indent", | |
133 "keymap", | |
134 "plugin", | |
135 "syntax", | |
136 }; | |
137 | |
138 /* | |
139 * Obtain a choice from a table. | |
140 * First entry is a question, others are choices. | |
141 */ | |
142 static int | |
143 get_choice(char **table, int entries) | |
144 { | |
145 int answer; | |
146 int idx; | |
147 char dummy[100]; | |
148 | |
149 do | |
150 { | |
151 for (idx = 0; idx < entries; ++idx) | |
152 { | |
153 if (idx) | |
154 printf("%2d ", idx); | |
155 printf(table[idx]); | |
156 printf("\n"); | |
157 } | |
158 printf("Choice: "); | |
159 if (scanf("%d", &answer) != 1) | |
160 { | |
161 scanf("%99s", dummy); | |
162 answer = 0; | |
163 } | |
164 } | |
165 while (answer < 1 || answer >= entries); | |
166 | |
167 return answer; | |
168 } | |
169 | |
170 /* | |
171 * Check if the user unpacked the archives properly. | |
172 * Sets "runtimeidx". | |
173 */ | |
174 static void | |
175 check_unpack(void) | |
176 { | |
177 char buf[BUFSIZE]; | |
178 FILE *fd; | |
179 struct stat st; | |
180 | |
181 /* check for presence of the correct version number in installdir[] */ | |
182 runtimeidx = strlen(installdir) - strlen(VIM_VERSION_NODOT); | |
183 if (runtimeidx <= 0 | |
184 || stricmp(installdir + runtimeidx, VIM_VERSION_NODOT) != 0 | |
185 || (installdir[runtimeidx - 1] != '/' | |
186 && installdir[runtimeidx - 1] != '\\')) | |
187 { | |
188 printf("ERROR: Install program not in directory \"%s\"\n", | |
189 VIM_VERSION_NODOT); | |
190 printf("This program can only work when it is located in its original directory\n"); | |
191 myexit(1); | |
192 } | |
193 | |
194 /* check if filetype.vim is present, which means the runtime archive has | |
195 * been unpacked */ | |
196 sprintf(buf, "%s\\filetype.vim", installdir); | |
197 if (stat(buf, &st) < 0) | |
198 { | |
199 printf("ERROR: Cannot find filetype.vim in \"%s\"\n", installdir); | |
200 printf("It looks like you did not unpack the runtime archive.\n"); | |
201 printf("You must unpack the runtime archive \"vim%srt.zip\" before installing.\n", | |
202 VIM_VERSION_NODOT + 3); | |
203 myexit(1); | |
204 } | |
205 | |
206 /* Check if vim.exe or gvim.exe is in the current directory. */ | |
207 if ((fd = fopen("gvim.exe", "r")) != NULL) | |
208 { | |
209 fclose(fd); | |
210 has_gvim = 1; | |
211 } | |
212 if ((fd = fopen("vim.exe", "r")) != NULL) | |
213 { | |
214 fclose(fd); | |
215 has_vim = 1; | |
216 } | |
217 if (!has_gvim && !has_vim) | |
218 { | |
219 printf("ERROR: Cannot find any Vim executables in \"%s\"\n\n", | |
220 installdir); | |
221 myexit(1); | |
222 } | |
223 } | |
224 | |
225 /* | |
226 * Compare paths "p[plen]" to "q[qlen]". Return 0 if they match. | |
227 * Ignores case and differences between '/' and '\'. | |
228 * "plen" and "qlen" can be negative, strlen() is used then. | |
229 */ | |
230 static int | |
231 pathcmp(char *p, int plen, char *q, int qlen) | |
232 { | |
233 int i; | |
234 | |
235 if (plen < 0) | |
236 plen = strlen(p); | |
237 if (qlen < 0) | |
238 qlen = strlen(q); | |
239 for (i = 0; ; ++i) | |
240 { | |
241 /* End of "p": check if "q" also ends or just has a slash. */ | |
242 if (i == plen) | |
243 { | |
244 if (i == qlen) /* match */ | |
245 return 0; | |
246 if (i == qlen - 1 && (q[i] == '\\' || q[i] == '/')) | |
247 return 0; /* match with trailing slash */ | |
248 return 1; /* no match */ | |
249 } | |
250 | |
251 /* End of "q": check if "p" also ends or just has a slash. */ | |
252 if (i == qlen) | |
253 { | |
254 if (i == plen) /* match */ | |
255 return 0; | |
256 if (i == plen - 1 && (p[i] == '\\' || p[i] == '/')) | |
257 return 0; /* match with trailing slash */ | |
258 return 1; /* no match */ | |
259 } | |
260 | |
261 if (!(mytoupper(p[i]) == mytoupper(q[i]) | |
262 || ((p[i] == '/' || p[i] == '\\') | |
263 && (q[i] == '/' || q[i] == '\\')))) | |
264 return 1; /* no match */ | |
265 } | |
266 /*NOTREACHED*/ | |
267 } | |
268 | |
269 /* | |
270 * If the executable "**destination" is in the install directory, find another | |
271 * one in $PATH. | |
272 * On input "**destination" is the path of an executable in allocated memory | |
273 * (or NULL). | |
274 * "*destination" is set to NULL or the location of the file. | |
275 */ | |
276 static void | |
277 findoldfile(char **destination) | |
278 { | |
279 char *bp = *destination; | |
280 size_t indir_l = strlen(installdir); | |
281 char *cp = bp + indir_l; | |
282 char *tmpname; | |
283 char *farname; | |
284 | |
285 /* | |
286 * No action needed if exe not found or not in this directory. | |
287 */ | |
288 if (bp == NULL | |
289 || strnicmp(bp, installdir, indir_l) != 0 | |
290 || strchr("/\\", *cp++) == NULL | |
291 || strchr(cp, '\\') != NULL | |
292 || strchr(cp, '/') != NULL) | |
293 return; | |
294 | |
295 tmpname = alloc((int)strlen(cp) + 1); | |
296 strcpy(tmpname, cp); | |
297 tmpname[strlen(tmpname) - 1] = 'x'; /* .exe -> .exx */ | |
298 | |
299 if (access(tmpname, 0) == 0) | |
300 { | |
301 printf("\nERROR: %s and %s clash. Remove or rename %s.\n", | |
302 tmpname, cp, tmpname); | |
303 myexit(1); | |
304 } | |
305 | |
306 if (rename(cp, tmpname) != 0) | |
307 { | |
308 printf("\nERROR: failed to rename %s to %s: %s\n", | |
309 cp, tmpname, strerror(0)); | |
310 myexit(1); | |
311 } | |
312 | |
313 farname = searchpath_save(cp); | |
314 | |
315 if (rename(tmpname, cp) != 0) | |
316 { | |
317 printf("\nERROR: failed to rename %s back to %s: %s\n", | |
318 tmpname, cp, strerror(0)); | |
319 myexit(1); | |
320 } | |
321 | |
322 free(*destination); | |
323 free(tmpname); | |
324 *destination = farname; | |
325 } | |
326 | |
327 /* | |
328 * Check if there is a vim.[exe|bat|, gvim.[exe|bat|, etc. in the path. | |
329 * When "check_bat_only" is TRUE, only find "default_bat_dir". | |
330 */ | |
331 static void | |
332 find_bat_exe(int check_bat_only) | |
333 { | |
334 int i; | |
335 | |
806 | 336 /* avoid looking in the "installdir" by chdir to system root */ |
337 mch_chdir(sysdrive); | |
338 mch_chdir("\\"); | |
7 | 339 |
340 for (i = 1; i < TARGET_COUNT; ++i) | |
341 { | |
342 targets[i].oldbat = searchpath_save(targets[i].batname); | |
343 if (!check_bat_only) | |
344 targets[i].oldexe = searchpath_save(targets[i].exename); | |
345 | |
346 if (default_bat_dir == NULL && targets[i].oldbat != NULL) | |
347 { | |
348 default_bat_dir = alloc(strlen(targets[i].oldbat) + 1); | |
349 strcpy(default_bat_dir, targets[i].oldbat); | |
350 remove_tail(default_bat_dir); | |
351 } | |
352 if (check_bat_only && targets[i].oldbat != NULL) | |
806 | 353 { |
7 | 354 free(targets[i].oldbat); |
806 | 355 targets[i].oldbat = NULL; |
356 } | |
7 | 357 } |
358 | |
359 mch_chdir(installdir); | |
360 } | |
361 | |
362 #ifdef WIN3264 | |
363 /* | |
364 * Get the value of $VIMRUNTIME or $VIM and write it in $TEMP/vimini.ini, so | |
365 * that NSIS can read it. | |
366 * When not set, use the directory of a previously installed Vim. | |
367 */ | |
368 static void | |
369 get_vim_env(void) | |
370 { | |
371 char *vim; | |
372 char buf[BUFSIZE]; | |
373 FILE *fd; | |
374 char fname[BUFSIZE]; | |
375 | |
376 /* First get $VIMRUNTIME. If it's set, remove the tail. */ | |
377 vim = getenv("VIMRUNTIME"); | |
378 if (vim != NULL && *vim != 0) | |
379 { | |
380 strcpy(buf, vim); | |
381 remove_tail(buf); | |
382 vim = buf; | |
383 } | |
384 else | |
385 { | |
386 vim = getenv("VIM"); | |
387 if (vim == NULL || *vim == 0) | |
388 { | |
389 /* Use the directory from an old uninstall entry. */ | |
390 if (default_vim_dir != NULL) | |
391 vim = default_vim_dir; | |
392 else | |
393 /* Let NSIS know there is no default, it should use | |
1222 | 394 * $PROGRAMFILES. */ |
7 | 395 vim = ""; |
396 } | |
397 } | |
398 | |
399 /* NSIS also uses GetTempPath(), thus we should get the same directory | |
400 * name as where NSIS will look for vimini.ini. */ | |
401 GetTempPath(BUFSIZE, fname); | |
402 add_pathsep(fname); | |
403 strcat(fname, "vimini.ini"); | |
404 | |
405 fd = fopen(fname, "w"); | |
406 if (fd != NULL) | |
407 { | |
408 /* Make it look like an .ini file, so that NSIS can read it with a | |
409 * ReadINIStr command. */ | |
410 fprintf(fd, "[vimini]\n"); | |
411 fprintf(fd, "dir=\"%s\"\n", vim); | |
412 fclose(fd); | |
413 } | |
414 else | |
415 { | |
416 printf("Failed to open %s\n", fname); | |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
417 sleep(2); |
7 | 418 } |
419 } | |
420 | |
2220
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
421 static int num_windows; |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
422 |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
423 /* |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
424 * Callback used for EnumWindows(): |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
425 * Count the window if the title looks like it is for the uninstaller. |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
426 */ |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
427 /*ARGSUSED*/ |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
428 static BOOL CALLBACK |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
429 window_cb(HWND hwnd, LPARAM lparam) |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
430 { |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
431 char title[256]; |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
432 |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
433 title[0] = 0; |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
434 GetWindowText(hwnd, title, 256); |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
435 if (strstr(title, "Vim ") != NULL && strstr(title, "Uninstall:") != NULL) |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
436 ++num_windows; |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
437 return TRUE; |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
438 } |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
439 |
7 | 440 /* |
441 * Check for already installed Vims. | |
442 * Return non-zero when found one. | |
443 */ | |
444 static int | |
2217
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
445 uninstall_check(int skip_question) |
7 | 446 { |
447 HKEY key_handle; | |
448 HKEY uninstall_key_handle; | |
449 char *uninstall_key = "software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; | |
450 char subkey_name_buff[BUFSIZE]; | |
451 char temp_string_buffer[BUFSIZE]; | |
452 DWORD local_bufsize = BUFSIZE; | |
453 FILETIME temp_pfiletime; | |
454 DWORD key_index; | |
455 char input; | |
456 long code; | |
457 DWORD value_type; | |
458 DWORD orig_num_keys; | |
459 DWORD new_num_keys; | |
460 int foundone = 0; | |
461 | |
2449
943280505f72
Fix that uninstaller isn't found on 64-bit Windows.
Bram Moolenaar <bram@vim.org>
parents:
2448
diff
changeset
|
462 code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, uninstall_key, 0, |
943280505f72
Fix that uninstaller isn't found on 64-bit Windows.
Bram Moolenaar <bram@vim.org>
parents:
2448
diff
changeset
|
463 KEY_WOW64_64KEY | KEY_READ, &key_handle); |
7 | 464 CHECK_REG_ERROR(code); |
465 | |
466 for (key_index = 0; | |
467 RegEnumKeyEx(key_handle, key_index, subkey_name_buff, &local_bufsize, | |
468 NULL, NULL, NULL, &temp_pfiletime) != ERROR_NO_MORE_ITEMS; | |
469 key_index++) | |
470 { | |
471 local_bufsize = BUFSIZE; | |
472 if (strncmp("Vim", subkey_name_buff, 3) == 0) | |
473 { | |
474 /* Open the key named Vim* */ | |
2449
943280505f72
Fix that uninstaller isn't found on 64-bit Windows.
Bram Moolenaar <bram@vim.org>
parents:
2448
diff
changeset
|
475 code = RegOpenKeyEx(key_handle, subkey_name_buff, 0, |
943280505f72
Fix that uninstaller isn't found on 64-bit Windows.
Bram Moolenaar <bram@vim.org>
parents:
2448
diff
changeset
|
476 KEY_WOW64_64KEY | KEY_READ, &uninstall_key_handle); |
7 | 477 CHECK_REG_ERROR(code); |
478 | |
479 /* get the DisplayName out of it to show the user */ | |
480 code = RegQueryValueEx(uninstall_key_handle, "displayname", 0, | |
481 &value_type, (LPBYTE)temp_string_buffer, | |
482 &local_bufsize); | |
483 local_bufsize = BUFSIZE; | |
484 CHECK_REG_ERROR(code); | |
485 | |
486 foundone = 1; | |
487 printf("\n*********************************************************\n"); | |
488 printf("Vim Install found what looks like an existing Vim version.\n"); | |
489 printf("The name of the entry is:\n"); | |
490 printf("\n \"%s\"\n\n", temp_string_buffer); | |
491 | |
492 printf("Installing the new version will disable part of the existing version.\n"); | |
493 printf("(The batch files used in a console and the \"Edit with Vim\" entry in\n"); | |
494 printf("the popup menu will use the new version)\n"); | |
495 | |
2217
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
496 if (skip_question) |
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
497 printf("\nRunning uninstall program for \"%s\"\n", temp_string_buffer); |
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
498 else |
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
499 printf("\nDo you want to uninstall \"%s\" now?\n(y)es/(n)o) ", temp_string_buffer); |
7 | 500 fflush(stdout); |
501 | |
502 /* get the UninstallString */ | |
503 code = RegQueryValueEx(uninstall_key_handle, "uninstallstring", 0, | |
504 &value_type, (LPBYTE)temp_string_buffer, &local_bufsize); | |
505 local_bufsize = BUFSIZE; | |
506 CHECK_REG_ERROR(code); | |
507 | |
508 /* Remember the directory, it is used as the default for NSIS. */ | |
509 default_vim_dir = alloc(strlen(temp_string_buffer) + 1); | |
510 strcpy(default_vim_dir, temp_string_buffer); | |
511 remove_tail(default_vim_dir); | |
512 remove_tail(default_vim_dir); | |
513 | |
514 input = 'n'; | |
515 do | |
516 { | |
517 if (input != 'n') | |
518 printf("%c is an invalid reply. Please enter either 'y' or 'n'\n", input); | |
519 | |
2217
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
520 if (skip_question) |
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
521 input = 'y'; |
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
522 else |
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
523 { |
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
524 rewind(stdin); |
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
525 scanf("%c", &input); |
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
526 } |
7 | 527 switch (input) |
528 { | |
529 case 'y': | |
530 case 'Y': | |
531 /* save the number of uninstall keys so we can know if | |
532 * it changed */ | |
533 RegQueryInfoKey(key_handle, NULL, NULL, NULL, | |
534 &orig_num_keys, NULL, NULL, NULL, | |
535 NULL, NULL, NULL, NULL); | |
536 | |
2217
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
537 /* Find existing .bat files before deleting them. */ |
7 | 538 find_bat_exe(TRUE); |
539 | |
540 /* Execute the uninstall program. Put it in double | |
541 * quotes if there is an embedded space. */ | |
542 { | |
543 char buf[BUFSIZE]; | |
544 | |
2220
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
545 if (strchr(temp_string_buffer, ' ') != NULL) |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
546 sprintf(buf, "\"%s\"", temp_string_buffer); |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
547 else |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
548 strcpy(buf, temp_string_buffer); |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
549 run_command(buf); |
7 | 550 } |
551 | |
2220
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
552 /* Count the number of windows with a title that match |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
553 * the installer, so that we can check when it's done. |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
554 * The uninstaller copies itself, executes the copy |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
555 * and exits, thus we can't wait for the process to |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
556 * finish. */ |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
557 sleep(1); /* wait for uninstaller to start up */ |
2220
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
558 num_windows = 0; |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
559 EnumWindows(window_cb, 0); |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
560 sleep(1); /* wait for windows to be counted */ |
2220
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
561 if (num_windows == 0) |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
562 { |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
563 /* Did not find the uninstaller, ask user to press |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
564 * Enter when done. Just in case. */ |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
565 printf("Press Enter when the uninstaller is finished\n"); |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
566 rewind(stdin); |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
567 (void)getchar(); |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
568 } |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
569 else |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
570 { |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
571 printf("Waiting for the uninstaller to finish (press CTRL-C to abort)."); |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
572 do |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
573 { |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
574 printf("."); |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
575 fflush(stdout); |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
576 num_windows = 0; |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
577 EnumWindows(window_cb, 0); |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
578 sleep(1); /* wait for windows to be counted */ |
2220
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
579 } while (num_windows > 0); |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
580 } |
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
581 printf("\nDone!\n"); |
7 | 582 |
2154
7c8c7c95a865
First step in the Vim 7.3 branch. Changed version numbers.
Bram Moolenaar <bram@zimbu.org>
parents:
1569
diff
changeset
|
583 /* Check if an uninstall reg key was deleted. |
7 | 584 * if it was, we want to decrement key_index. |
585 * if we don't do this, we will skip the key | |
586 * immediately after any key that we delete. */ | |
587 RegQueryInfoKey(key_handle, NULL, NULL, NULL, | |
588 &new_num_keys, NULL, NULL, NULL, | |
589 NULL, NULL, NULL, NULL); | |
590 if (new_num_keys < orig_num_keys) | |
591 key_index--; | |
592 | |
593 input = 'y'; | |
594 break; | |
595 | |
596 case 'n': | |
597 case 'N': | |
598 /* Do not uninstall */ | |
599 input = 'n'; | |
600 break; | |
601 | |
602 default: /* just drop through and redo the loop */ | |
603 break; | |
604 } | |
605 | |
606 } while (input != 'n' && input != 'y'); | |
607 | |
608 RegCloseKey(uninstall_key_handle); | |
609 } | |
610 } | |
611 RegCloseKey(key_handle); | |
612 | |
613 return foundone; | |
614 } | |
615 #endif | |
616 | |
617 /* | |
618 * Find out information about the system. | |
619 */ | |
620 static void | |
621 inspect_system(void) | |
622 { | |
623 char *p; | |
624 char buf[BUFSIZE]; | |
625 FILE *fd; | |
626 int i; | |
627 int foundone; | |
628 | |
629 /* This may take a little while, let the user know what we're doing. */ | |
630 printf("Inspecting system...\n"); | |
631 | |
632 /* | |
633 * If $VIM is set, check that it's pointing to our directory. | |
634 */ | |
635 p = getenv("VIM"); | |
636 if (p != NULL && pathcmp(p, -1, installdir, runtimeidx - 1) != 0) | |
637 { | |
638 printf("------------------------------------------------------\n"); | |
639 printf("$VIM is set to \"%s\".\n", p); | |
640 printf("This is different from where this version of Vim is:\n"); | |
641 strcpy(buf, installdir); | |
642 *(buf + runtimeidx - 1) = NUL; | |
643 printf("\"%s\"\n", buf); | |
644 printf("You must adjust or remove the setting of $VIM,\n"); | |
645 if (interactive) | |
646 { | |
647 printf("to be able to use this install program.\n"); | |
648 myexit(1); | |
649 } | |
650 printf("otherwise Vim WILL NOT WORK properly!\n"); | |
651 printf("------------------------------------------------------\n"); | |
652 } | |
653 | |
654 /* | |
655 * If $VIMRUNTIME is set, check that it's pointing to our runtime directory. | |
656 */ | |
657 p = getenv("VIMRUNTIME"); | |
658 if (p != NULL && pathcmp(p, -1, installdir, -1) != 0) | |
659 { | |
660 printf("------------------------------------------------------\n"); | |
661 printf("$VIMRUNTIME is set to \"%s\".\n", p); | |
662 printf("This is different from where this version of Vim is:\n"); | |
663 printf("\"%s\"\n", installdir); | |
664 printf("You must adjust or remove the setting of $VIMRUNTIME,\n"); | |
665 if (interactive) | |
666 { | |
667 printf("to be able to use this install program.\n"); | |
668 myexit(1); | |
669 } | |
670 printf("otherwise Vim WILL NOT WORK properly!\n"); | |
671 printf("------------------------------------------------------\n"); | |
672 } | |
673 | |
674 /* | |
675 * Check if there is a vim.[exe|bat|, gvim.[exe|bat|, etc. in the path. | |
676 */ | |
677 find_bat_exe(FALSE); | |
678 | |
679 /* | |
680 * A .exe in the install directory may be found anyway on Windows 2000. | |
681 * Check for this situation and find another executable if necessary. | |
682 * w.briscoe@ponl.com 2001-01-20 | |
683 */ | |
684 foundone = 0; | |
685 for (i = 1; i < TARGET_COUNT; ++i) | |
686 { | |
687 findoldfile(&(targets[i].oldexe)); | |
688 if (targets[i].oldexe != NULL) | |
689 foundone = 1; | |
690 } | |
691 | |
692 if (foundone) | |
693 { | |
694 printf("Warning: Found Vim executable(s) in your $PATH:\n"); | |
695 for (i = 1; i < TARGET_COUNT; ++i) | |
696 if (targets[i].oldexe != NULL) | |
697 printf("%s\n", targets[i].oldexe); | |
698 printf("It will be used instead of the version you are installing.\n"); | |
699 printf("Please delete or rename it, or adjust your $PATH setting.\n"); | |
700 } | |
701 | |
702 /* | |
703 * Check if there is an existing ../_vimrc or ../.vimrc file. | |
704 */ | |
705 strcpy(oldvimrc, installdir); | |
706 strcpy(oldvimrc + runtimeidx, "_vimrc"); | |
707 if ((fd = fopen(oldvimrc, "r")) == NULL) | |
708 { | |
709 strcpy(oldvimrc + runtimeidx, "vimrc~1"); /* short version of .vimrc */ | |
710 if ((fd = fopen(oldvimrc, "r")) == NULL) | |
711 { | |
712 strcpy(oldvimrc + runtimeidx, ".vimrc"); | |
713 fd = fopen(oldvimrc, "r"); | |
714 } | |
715 } | |
716 if (fd != NULL) | |
717 fclose(fd); | |
718 else | |
719 *oldvimrc = NUL; | |
720 } | |
721 | |
722 /* | |
723 * Add a dummy choice to avoid that the numbering changes depending on items | |
724 * in the environment. The user may type a number he remembered without | |
725 * looking. | |
726 */ | |
727 static void | |
728 add_dummy_choice(void) | |
729 { | |
730 choices[choice_count].installfunc = NULL; | |
731 choices[choice_count].active = 0; | |
732 choices[choice_count].changefunc = NULL; | |
733 choices[choice_count].installfunc = NULL; | |
734 ++choice_count; | |
735 } | |
736 | |
737 /*********************************************** | |
738 * stuff for creating the batch files. | |
739 */ | |
740 | |
741 /* | |
742 * Install the vim.bat, gvim.bat, etc. files. | |
743 */ | |
744 static void | |
745 install_bat_choice(int idx) | |
746 { | |
747 char *batpath = targets[choices[idx].arg].batpath; | |
748 char *oldname = targets[choices[idx].arg].oldbat; | |
749 char *exename = targets[choices[idx].arg].exenamearg; | |
750 char *vimarg = targets[choices[idx].arg].exearg; | |
751 FILE *fd; | |
752 | |
753 if (*batpath != NUL) | |
754 { | |
755 fd = fopen(batpath, "w"); | |
756 if (fd == NULL) | |
757 printf("\nERROR: Cannot open \"%s\" for writing.\n", batpath); | |
758 else | |
759 { | |
760 need_uninstall_entry = 1; | |
761 | |
762 fprintf(fd, "@echo off\n"); | |
782 | 763 fprintf(fd, "rem -- Run Vim --\n"); |
764 fprintf(fd, "\n"); | |
7 | 765 |
782 | 766 /* Don't use double quotes for the "set" argument, also when it |
7 | 767 * contains a space. The quotes would be included in the value |
782 | 768 * for MSDOS and NT. |
769 * The order of preference is: | |
770 * 1. $VIMRUNTIME/vim.exe (user preference) | |
771 * 2. $VIM/vim70/vim.exe (hard coded version) | |
772 * 3. installdir/vim.exe (hard coded install directory) | |
773 */ | |
774 fprintf(fd, "set VIM_EXE_DIR=%s\n", installdir); | |
775 fprintf(fd, "if exist \"%%VIM%%\\%s\\%s\" set VIM_EXE_DIR=%%VIM%%\\%s\n", | |
776 VIM_VERSION_NODOT, exename, VIM_VERSION_NODOT); | |
777 fprintf(fd, "if exist \"%%VIMRUNTIME%%\\%s\" set VIM_EXE_DIR=%%VIMRUNTIME%%\n", exename); | |
778 fprintf(fd, "\n"); | |
7 | 779 |
780 /* Give an error message when the executable could not be found. */ | |
782 | 781 fprintf(fd, "if exist \"%%VIM_EXE_DIR%%\\%s\" goto havevim\n", |
782 exename); | |
783 fprintf(fd, "echo \"%%VIM_EXE_DIR%%\\%s\" not found\n", exename); | |
784 fprintf(fd, "goto eof\n"); | |
785 fprintf(fd, "\n"); | |
7 | 786 fprintf(fd, ":havevim\n"); |
787 | |
788 fprintf(fd, "rem collect the arguments in VIMARGS for Win95\n"); | |
789 fprintf(fd, "set VIMARGS=\n"); | |
790 if (*exename == 'g') | |
791 fprintf(fd, "set VIMNOFORK=\n"); | |
792 fprintf(fd, ":loopstart\n"); | |
793 fprintf(fd, "if .%%1==. goto loopend\n"); | |
794 if (*exename == 'g') | |
795 { | |
796 fprintf(fd, "if NOT .%%1==.-f goto noforkarg\n"); | |
797 fprintf(fd, "set VIMNOFORK=1\n"); | |
798 fprintf(fd, ":noforkarg\n"); | |
799 } | |
800 fprintf(fd, "set VIMARGS=%%VIMARGS%% %%1\n"); | |
801 fprintf(fd, "shift\n"); | |
782 | 802 fprintf(fd, "goto loopstart\n"); |
7 | 803 fprintf(fd, ":loopend\n"); |
782 | 804 fprintf(fd, "\n"); |
7 | 805 |
782 | 806 fprintf(fd, "if .%%OS%%==.Windows_NT goto ntaction\n"); |
807 fprintf(fd, "\n"); | |
7 | 808 |
809 /* For gvim.exe use "start" to avoid that the console window stays | |
810 * open. */ | |
811 if (*exename == 'g') | |
812 { | |
813 fprintf(fd, "if .%%VIMNOFORK%%==.1 goto nofork\n"); | |
814 fprintf(fd, "start "); | |
815 } | |
816 | |
782 | 817 /* Always use quotes, $VIM or $VIMRUNTIME might have a space. */ |
818 fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%VIMARGS%%\n", | |
819 exename, vimarg); | |
820 fprintf(fd, "goto eof\n"); | |
821 fprintf(fd, "\n"); | |
7 | 822 |
823 if (*exename == 'g') | |
824 { | |
825 fprintf(fd, ":nofork\n"); | |
826 fprintf(fd, "start /w "); | |
782 | 827 /* Always use quotes, $VIM or $VIMRUNTIME might have a space. */ |
828 fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%VIMARGS%%\n", | |
829 exename, vimarg); | |
830 fprintf(fd, "goto eof\n"); | |
831 fprintf(fd, "\n"); | |
7 | 832 } |
833 | |
834 fprintf(fd, ":ntaction\n"); | |
835 fprintf(fd, "rem for WinNT we can use %%*\n"); | |
836 | |
837 /* For gvim.exe use "start /b" to avoid that the console window | |
838 * stays open. */ | |
839 if (*exename == 'g') | |
840 { | |
841 fprintf(fd, "if .%%VIMNOFORK%%==.1 goto noforknt\n"); | |
842 fprintf(fd, "start \"dummy\" /b "); | |
843 } | |
844 | |
782 | 845 /* Always use quotes, $VIM or $VIMRUNTIME might have a space. */ |
846 fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n", exename, vimarg); | |
847 fprintf(fd, "goto eof\n"); | |
848 fprintf(fd, "\n"); | |
7 | 849 |
850 if (*exename == 'g') | |
851 { | |
852 fprintf(fd, ":noforknt\n"); | |
853 fprintf(fd, "start \"dummy\" /b /wait "); | |
782 | 854 /* Always use quotes, $VIM or $VIMRUNTIME might have a space. */ |
855 fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n", | |
856 exename, vimarg); | |
7 | 857 } |
858 | |
859 fprintf(fd, "\n:eof\n"); | |
860 fprintf(fd, "set VIMARGS=\n"); | |
861 if (*exename == 'g') | |
862 fprintf(fd, "set VIMNOFORK=\n"); | |
863 | |
864 fclose(fd); | |
865 printf("%s has been %s\n", batpath, | |
866 oldname == NULL ? "created" : "overwritten"); | |
867 } | |
868 } | |
869 } | |
870 | |
871 /* | |
872 * Make the text string for choice "idx". | |
873 * The format "fmt" is must have one %s item, which "arg" is used for. | |
874 */ | |
875 static void | |
876 alloc_text(int idx, char *fmt, char *arg) | |
877 { | |
878 if (choices[idx].text != NULL) | |
879 free(choices[idx].text); | |
880 | |
881 choices[idx].text = alloc((int)(strlen(fmt) + strlen(arg)) - 1); | |
882 sprintf(choices[idx].text, fmt, arg); | |
883 } | |
884 | |
885 /* | |
886 * Toggle the "Overwrite .../vim.bat" to "Don't overwrite". | |
887 */ | |
888 static void | |
889 toggle_bat_choice(int idx) | |
890 { | |
891 char *batname = targets[choices[idx].arg].batpath; | |
892 char *oldname = targets[choices[idx].arg].oldbat; | |
893 | |
894 if (*batname == NUL) | |
895 { | |
896 alloc_text(idx, " Overwrite %s", oldname); | |
897 strcpy(batname, oldname); | |
898 } | |
899 else | |
900 { | |
901 alloc_text(idx, " Do NOT overwrite %s", oldname); | |
902 *batname = NUL; | |
903 } | |
904 } | |
905 | |
906 /* | |
907 * Do some work for a batch file entry: Append the batch file name to the path | |
908 * and set the text for the choice. | |
909 */ | |
910 static void | |
911 set_bat_text(int idx, char *batpath, char *name) | |
912 { | |
913 strcat(batpath, name); | |
914 | |
915 alloc_text(idx, " Create %s", batpath); | |
916 } | |
917 | |
918 /* | |
919 * Select a directory to write the batch file line. | |
920 */ | |
921 static void | |
922 change_bat_choice(int idx) | |
923 { | |
924 char *path; | |
925 char *batpath; | |
926 char *name; | |
927 int n; | |
928 char *s; | |
929 char *p; | |
930 int count; | |
931 char **names = NULL; | |
932 int i; | |
933 int target = choices[idx].arg; | |
934 | |
935 name = targets[target].batname; | |
936 batpath = targets[target].batpath; | |
937 | |
938 path = getenv("PATH"); | |
939 if (path == NULL) | |
940 { | |
941 printf("\nERROR: The variable $PATH is not set\n"); | |
942 return; | |
943 } | |
944 | |
945 /* | |
946 * first round: count number of names in path; | |
947 * second round: save names to names[]. | |
948 */ | |
949 for (;;) | |
950 { | |
951 count = 1; | |
952 for (p = path; *p; ) | |
953 { | |
954 s = strchr(p, ';'); | |
955 if (s == NULL) | |
956 s = p + strlen(p); | |
957 if (names != NULL) | |
958 { | |
959 names[count] = alloc((int)(s - p) + 1); | |
960 strncpy(names[count], p, s - p); | |
961 names[count][s - p] = NUL; | |
962 } | |
963 ++count; | |
964 p = s; | |
965 if (*p != NUL) | |
966 ++p; | |
967 } | |
968 if (names != NULL) | |
969 break; | |
970 names = alloc((int)(count + 1) * sizeof(char *)); | |
971 } | |
972 names[0] = alloc(50); | |
973 sprintf(names[0], "Select directory to create %s in:", name); | |
974 names[count] = alloc(50); | |
975 if (choices[idx].arg == 0) | |
976 sprintf(names[count], "Do not create any .bat file."); | |
977 else | |
978 sprintf(names[count], "Do not create a %s file.", name); | |
979 n = get_choice(names, count + 1); | |
980 | |
981 if (n == count) | |
982 { | |
983 /* Selected last item, don't create bat file. */ | |
984 *batpath = NUL; | |
985 if (choices[idx].arg != 0) | |
986 alloc_text(idx, " Do NOT create %s", name); | |
987 } | |
988 else | |
989 { | |
990 /* Selected one of the paths. For the first item only keep the path, | |
991 * for the others append the batch file name. */ | |
992 strcpy(batpath, names[n]); | |
993 add_pathsep(batpath); | |
994 if (choices[idx].arg != 0) | |
995 set_bat_text(idx, batpath, name); | |
996 } | |
997 | |
998 for (i = 0; i <= count; ++i) | |
999 free(names[i]); | |
1000 free(names); | |
1001 } | |
1002 | |
1003 char *bat_text_yes = "Install .bat files to use Vim at the command line:"; | |
1004 char *bat_text_no = "do NOT install .bat files to use Vim at the command line"; | |
1005 | |
1006 static void | |
1007 change_main_bat_choice(int idx) | |
1008 { | |
1009 int i; | |
1010 | |
1011 /* let the user select a default directory or NONE */ | |
1012 change_bat_choice(idx); | |
1013 | |
1014 if (targets[0].batpath[0] != NUL) | |
1015 choices[idx].text = bat_text_yes; | |
1016 else | |
1017 choices[idx].text = bat_text_no; | |
1018 | |
1019 /* update the individual batch file selections */ | |
1020 for (i = 1; i < TARGET_COUNT; ++i) | |
1021 { | |
1022 /* Only make it active when the first item has a path and the vim.exe | |
1023 * or gvim.exe exists (there is a changefunc then). */ | |
1024 if (targets[0].batpath[0] != NUL | |
1025 && choices[idx + i].changefunc != NULL) | |
1026 { | |
1027 choices[idx + i].active = 1; | |
1028 if (choices[idx + i].changefunc == change_bat_choice | |
1029 && targets[i].batpath[0] != NUL) | |
1030 { | |
1031 strcpy(targets[i].batpath, targets[0].batpath); | |
1032 set_bat_text(idx + i, targets[i].batpath, targets[i].batname); | |
1033 } | |
1034 } | |
1035 else | |
1036 choices[idx + i].active = 0; | |
1037 } | |
1038 } | |
1039 | |
1040 /* | |
1041 * Initialize a choice for creating a batch file. | |
1042 */ | |
1043 static void | |
1044 init_bat_choice(int target) | |
1045 { | |
1046 char *batpath = targets[target].batpath; | |
1047 char *oldbat = targets[target].oldbat; | |
1048 char *p; | |
1049 int i; | |
1050 | |
1051 choices[choice_count].arg = target; | |
1052 choices[choice_count].installfunc = install_bat_choice; | |
1053 choices[choice_count].active = 1; | |
1054 choices[choice_count].text = NULL; /* will be set below */ | |
1055 if (oldbat != NULL) | |
1056 { | |
1057 /* A [g]vim.bat exists: Only choice is to overwrite it or not. */ | |
1058 choices[choice_count].changefunc = toggle_bat_choice; | |
1059 *batpath = NUL; | |
1060 toggle_bat_choice(choice_count); | |
1061 } | |
1062 else | |
1063 { | |
1064 if (default_bat_dir != NULL) | |
1065 /* Prefer using the same path as an existing .bat file. */ | |
1066 strcpy(batpath, default_bat_dir); | |
1067 else | |
1068 { | |
1069 /* No [g]vim.bat exists: Write it to a directory in $PATH. Use | |
1070 * $WINDIR by default, if it's empty the first item in $PATH. */ | |
1071 p = getenv("WINDIR"); | |
1072 if (p != NULL && *p != NUL) | |
1073 strcpy(batpath, p); | |
1074 else | |
1075 { | |
1076 p = getenv("PATH"); | |
1077 if (p == NULL || *p == NUL) /* "cannot happen" */ | |
1078 strcpy(batpath, "C:/Windows"); | |
1079 else | |
1080 { | |
1081 i = 0; | |
1082 while (*p != NUL && *p != ';') | |
1083 batpath[i++] = *p++; | |
1084 batpath[i] = NUL; | |
1085 } | |
1086 } | |
1087 } | |
1088 add_pathsep(batpath); | |
1089 set_bat_text(choice_count, batpath, targets[target].batname); | |
1090 | |
1091 choices[choice_count].changefunc = change_bat_choice; | |
1092 } | |
1093 ++choice_count; | |
1094 } | |
1095 | |
1096 /* | |
1097 * Set up the choices for installing .bat files. | |
1098 * For these items "arg" is the index in targets[]. | |
1099 */ | |
1100 static void | |
1101 init_bat_choices(void) | |
1102 { | |
1103 int i; | |
1104 | |
1105 /* The first item is used to switch installing batch files on/off and | |
1106 * setting the default path. */ | |
1107 choices[choice_count].text = bat_text_yes; | |
1108 choices[choice_count].changefunc = change_main_bat_choice; | |
1109 choices[choice_count].installfunc = NULL; | |
1110 choices[choice_count].active = 1; | |
1111 choices[choice_count].arg = 0; | |
1112 ++choice_count; | |
1113 | |
1114 /* Add items for each batch file target. Only used when not disabled by | |
1115 * the first item. When a .exe exists, don't offer to create a .bat. */ | |
1116 for (i = 1; i < TARGET_COUNT; ++i) | |
1117 if (targets[i].oldexe == NULL | |
1118 && (targets[i].exenamearg[0] == 'g' ? has_gvim : has_vim)) | |
1119 init_bat_choice(i); | |
1120 else | |
1121 add_dummy_choice(); | |
1122 } | |
1123 | |
1124 /* | |
1125 * Install the vimrc file. | |
1126 */ | |
1127 static void | |
1128 install_vimrc(int idx) | |
1129 { | |
1130 FILE *fd, *tfd; | |
1131 char *fname; | |
1132 | |
1133 /* If an old vimrc file exists, overwrite it. | |
1134 * Otherwise create a new one. */ | |
1135 if (*oldvimrc != NUL) | |
1136 fname = oldvimrc; | |
1137 else | |
1138 fname = vimrc; | |
1139 | |
1140 fd = fopen(fname, "w"); | |
1141 if (fd == NULL) | |
1142 { | |
1143 printf("\nERROR: Cannot open \"%s\" for writing.\n", fname); | |
1144 return; | |
1145 } | |
1146 switch (compat_choice) | |
1147 { | |
1148 case compat_vi: | |
1149 fprintf(fd, "set compatible\n"); | |
1150 break; | |
1151 case compat_some_enhancements: | |
1152 fprintf(fd, "set nocompatible\n"); | |
1153 break; | |
1154 case compat_all_enhancements: | |
1155 fprintf(fd, "set nocompatible\n"); | |
1156 fprintf(fd, "source $VIMRUNTIME/vimrc_example.vim\n"); | |
1157 break; | |
1158 } | |
1159 switch (remap_choice) | |
1160 { | |
1161 case remap_no: | |
1162 break; | |
1163 case remap_win: | |
1164 fprintf(fd, "source $VIMRUNTIME/mswin.vim\n"); | |
1165 break; | |
1166 } | |
1167 switch (mouse_choice) | |
1168 { | |
1169 case mouse_xterm: | |
1170 fprintf(fd, "behave xterm\n"); | |
1171 break; | |
1172 case mouse_mswin: | |
1173 fprintf(fd, "behave mswin\n"); | |
1174 break; | |
1175 } | |
1176 if ((tfd = fopen("diff.exe", "r")) != NULL) | |
1177 { | |
1178 /* Use the diff.exe that comes with the self-extracting gvim.exe. */ | |
1179 fclose(tfd); | |
1180 fprintf(fd, "\n"); | |
1181 fprintf(fd, "set diffexpr=MyDiff()\n"); | |
1182 fprintf(fd, "function MyDiff()\n"); | |
1183 fprintf(fd, " let opt = '-a --binary '\n"); | |
1184 fprintf(fd, " if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif\n"); | |
1185 fprintf(fd, " if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif\n"); | |
1186 /* Use quotes only when needed, they may cause trouble. */ | |
1187 fprintf(fd, " let arg1 = v:fname_in\n"); | |
1188 fprintf(fd, " if arg1 =~ ' ' | let arg1 = '\"' . arg1 . '\"' | endif\n"); | |
1189 fprintf(fd, " let arg2 = v:fname_new\n"); | |
1190 fprintf(fd, " if arg2 =~ ' ' | let arg2 = '\"' . arg2 . '\"' | endif\n"); | |
1191 fprintf(fd, " let arg3 = v:fname_out\n"); | |
1192 fprintf(fd, " if arg3 =~ ' ' | let arg3 = '\"' . arg3 . '\"' | endif\n"); | |
640 | 1193 |
1194 /* If the path has a space: When using cmd.exe (Win NT/2000/XP) put | |
1195 * quotes around the whole command and around the diff command. | |
1196 * Otherwise put a double quote just before the space and at the | |
1197 * end of the command. Putting quotes around the whole thing | |
1198 * doesn't work on Win 95/98/ME. This is mostly guessed! */ | |
1199 fprintf(fd, " let eq = ''\n"); | |
1200 fprintf(fd, " if $VIMRUNTIME =~ ' '\n"); | |
1201 fprintf(fd, " if &sh =~ '\\<cmd'\n"); | |
1202 fprintf(fd, " let cmd = '\"\"' . $VIMRUNTIME . '\\diff\"'\n"); | |
1203 fprintf(fd, " let eq = '\"'\n"); | |
1204 fprintf(fd, " else\n"); | |
1205 fprintf(fd, " let cmd = substitute($VIMRUNTIME, ' ', '\" ', '') . '\\diff\"'\n"); | |
1206 fprintf(fd, " endif\n"); | |
1207 fprintf(fd, " else\n"); | |
1208 fprintf(fd, " let cmd = $VIMRUNTIME . '\\diff'\n"); | |
1209 fprintf(fd, " endif\n"); | |
1210 fprintf(fd, " silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq\n"); | |
1211 | |
7 | 1212 fprintf(fd, "endfunction\n"); |
1213 fprintf(fd, "\n"); | |
1214 } | |
1215 fclose(fd); | |
1216 printf("%s has been written\n", fname); | |
1217 } | |
1218 | |
1219 static void | |
1220 change_vimrc_choice(int idx) | |
1221 { | |
1222 if (choices[idx].installfunc != NULL) | |
1223 { | |
1224 /* Switch to NOT change or create a vimrc file. */ | |
1225 if (*oldvimrc != NUL) | |
1226 alloc_text(idx, "Do NOT change startup file %s", oldvimrc); | |
1227 else | |
1228 alloc_text(idx, "Do NOT create startup file %s", vimrc); | |
1229 choices[idx].installfunc = NULL; | |
1230 choices[idx + 1].active = 0; | |
1231 choices[idx + 2].active = 0; | |
1232 choices[idx + 3].active = 0; | |
1233 } | |
1234 else | |
1235 { | |
1236 /* Switch to change or create a vimrc file. */ | |
1237 if (*oldvimrc != NUL) | |
1238 alloc_text(idx, "Overwrite startup file %s with:", oldvimrc); | |
1239 else | |
1240 alloc_text(idx, "Create startup file %s with:", vimrc); | |
1241 choices[idx].installfunc = install_vimrc; | |
1242 choices[idx + 1].active = 1; | |
1243 choices[idx + 2].active = 1; | |
1244 choices[idx + 3].active = 1; | |
1245 } | |
1246 } | |
1247 | |
1248 /* | |
1249 * Change the choice how to run Vim. | |
1250 */ | |
1251 static void | |
1252 change_run_choice(int idx) | |
1253 { | |
1254 compat_choice = get_choice(compat_choices, TABLE_SIZE(compat_choices)); | |
1255 alloc_text(idx, compat_text, compat_choices[compat_choice]); | |
1256 } | |
1257 | |
1258 /* | |
1259 * Change the choice if keys are to be remapped. | |
1260 */ | |
1261 static void | |
1262 change_remap_choice(int idx) | |
1263 { | |
1264 remap_choice = get_choice(remap_choices, TABLE_SIZE(remap_choices)); | |
1265 alloc_text(idx, remap_text, remap_choices[remap_choice]); | |
1266 } | |
1267 | |
1268 /* | |
1269 * Change the choice how to select text. | |
1270 */ | |
1271 static void | |
1272 change_mouse_choice(int idx) | |
1273 { | |
1274 mouse_choice = get_choice(mouse_choices, TABLE_SIZE(mouse_choices)); | |
1275 alloc_text(idx, mouse_text, mouse_choices[mouse_choice]); | |
1276 } | |
1277 | |
1278 static void | |
1279 init_vimrc_choices(void) | |
1280 { | |
1281 /* set path for a new _vimrc file (also when not used) */ | |
1282 strcpy(vimrc, installdir); | |
1283 strcpy(vimrc + runtimeidx, "_vimrc"); | |
1284 | |
1285 /* Set opposite value and then toggle it by calling change_vimrc_choice() */ | |
1286 if (*oldvimrc == NUL) | |
1287 choices[choice_count].installfunc = NULL; | |
1288 else | |
1289 choices[choice_count].installfunc = install_vimrc; | |
1290 choices[choice_count].text = NULL; | |
1291 change_vimrc_choice(choice_count); | |
1292 choices[choice_count].changefunc = change_vimrc_choice; | |
1293 choices[choice_count].active = 1; | |
1294 ++choice_count; | |
1295 | |
1296 /* default way to run Vim */ | |
1297 alloc_text(choice_count, compat_text, compat_choices[compat_choice]); | |
1298 choices[choice_count].changefunc = change_run_choice; | |
1299 choices[choice_count].installfunc = NULL; | |
1300 choices[choice_count].active = (*oldvimrc == NUL); | |
1301 ++choice_count; | |
1302 | |
1303 /* Whether to remap keys */ | |
1304 alloc_text(choice_count, remap_text , remap_choices[remap_choice]); | |
1305 choices[choice_count].changefunc = change_remap_choice; | |
1306 choices[choice_count].installfunc = NULL;; | |
1307 choices[choice_count].active = (*oldvimrc == NUL); | |
1308 ++choice_count; | |
1309 | |
1310 /* default way to use the mouse */ | |
1311 alloc_text(choice_count, mouse_text, mouse_choices[mouse_choice]); | |
1312 choices[choice_count].changefunc = change_mouse_choice; | |
1313 choices[choice_count].installfunc = NULL;; | |
1314 choices[choice_count].active = (*oldvimrc == NUL); | |
1315 ++choice_count; | |
1316 } | |
1317 | |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
1318 #if defined(WIN3264) |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1319 static LONG |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1320 reg_create_key( |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1321 HKEY root, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1322 const char *subkey, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1323 PHKEY phKey) |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1324 { |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1325 DWORD disp; |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1326 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1327 *phKey = NULL; |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1328 return RegCreateKeyEx( |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1329 root, subkey, |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1330 0, NULL, REG_OPTION_NON_VOLATILE, |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1331 KEY_WOW64_64KEY | KEY_WRITE, |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1332 NULL, phKey, &disp); |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1333 } |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1334 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1335 static LONG |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1336 reg_set_string_value( |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1337 HKEY hKey, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1338 const char *value_name, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1339 const char *data) |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1340 { |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1341 return RegSetValueEx(hKey, value_name, 0, REG_SZ, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1342 (LPBYTE)data, (DWORD)(1 + strlen(data))); |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1343 } |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1344 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1345 static LONG |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1346 reg_create_key_and_value( |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1347 HKEY hRootKey, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1348 const char *subkey, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1349 const char *value_name, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1350 const char *data) |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1351 { |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1352 HKEY hKey; |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1353 LONG lRet = reg_create_key(hRootKey, subkey, &hKey); |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1354 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1355 if (ERROR_SUCCESS == lRet) |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1356 { |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1357 lRet = reg_set_string_value(hKey, value_name, data); |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1358 RegCloseKey(hKey); |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1359 } |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1360 return lRet; |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1361 } |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1362 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1363 static LONG |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1364 register_inproc_server( |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1365 HKEY hRootKey, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1366 const char *clsid, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1367 const char *extname, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1368 const char *module, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1369 const char *threading_model) |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1370 { |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1371 CHAR subkey[BUFSIZE]; |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1372 LONG lRet; |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1373 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1374 sprintf(subkey, "CLSID\\%s", clsid); |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1375 lRet = reg_create_key_and_value(hRootKey, subkey, NULL, extname); |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1376 if (ERROR_SUCCESS == lRet) |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1377 { |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1378 sprintf(subkey, "CLSID\\%s\\InProcServer32", clsid); |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1379 lRet = reg_create_key_and_value(hRootKey, subkey, NULL, module); |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1380 if (ERROR_SUCCESS == lRet) |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1381 { |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1382 lRet = reg_create_key_and_value(hRootKey, subkey, |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1383 "ThreadingModel", threading_model); |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1384 } |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1385 } |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1386 return lRet; |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1387 } |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1388 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1389 static LONG |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1390 register_shellex( |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1391 HKEY hRootKey, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1392 const char *clsid, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1393 const char *name, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1394 const char *exe_path) |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1395 { |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1396 LONG lRet = reg_create_key_and_value( |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1397 hRootKey, |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1398 "*\\shellex\\ContextMenuHandlers\\gvim", |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1399 NULL, |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1400 clsid); |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1401 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1402 if (ERROR_SUCCESS == lRet) |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1403 { |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1404 lRet = reg_create_key_and_value( |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1405 HKEY_LOCAL_MACHINE, |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1406 "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1407 clsid, |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1408 name); |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1409 |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1410 if (ERROR_SUCCESS == lRet) |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1411 { |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1412 lRet = reg_create_key_and_value( |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1413 HKEY_LOCAL_MACHINE, |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1414 "Software\\Vim\\Gvim", |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1415 "path", |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1416 exe_path); |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1417 } |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1418 } |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1419 return lRet; |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1420 } |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1421 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1422 static LONG |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1423 register_openwith( |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1424 HKEY hRootKey, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1425 const char *exe_path) |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1426 { |
2448
628147a4b3b2
Fix: on MS-Windows the "open with..." menu starts Vim without a file.
Bram Moolenaar <bram@vim.org>
parents:
2344
diff
changeset
|
1427 char exe_cmd[BUFSIZE]; |
628147a4b3b2
Fix: on MS-Windows the "open with..." menu starts Vim without a file.
Bram Moolenaar <bram@vim.org>
parents:
2344
diff
changeset
|
1428 LONG lRet; |
628147a4b3b2
Fix: on MS-Windows the "open with..." menu starts Vim without a file.
Bram Moolenaar <bram@vim.org>
parents:
2344
diff
changeset
|
1429 |
2470
481f808ab5e1
Put quotes around the gvim.exe path for the "Open with" menu entry.
Bram Moolenaar <bram@vim.org>
parents:
2449
diff
changeset
|
1430 sprintf(exe_cmd, "\"%s\" \"%%1\"", exe_path); |
2448
628147a4b3b2
Fix: on MS-Windows the "open with..." menu starts Vim without a file.
Bram Moolenaar <bram@vim.org>
parents:
2344
diff
changeset
|
1431 lRet = reg_create_key_and_value( |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1432 hRootKey, |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1433 "Applications\\gvim.exe\\shell\\edit\\command", |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1434 NULL, |
2448
628147a4b3b2
Fix: on MS-Windows the "open with..." menu starts Vim without a file.
Bram Moolenaar <bram@vim.org>
parents:
2344
diff
changeset
|
1435 exe_cmd); |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1436 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1437 if (ERROR_SUCCESS == lRet) |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1438 { |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1439 int i; |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1440 static const char *openwith[] = { |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1441 ".htm\\OpenWithList\\gvim.exe", |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1442 ".vim\\OpenWithList\\gvim.exe", |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1443 "*\\OpenWithList\\gvim.exe", |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1444 }; |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1445 |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1446 for (i = 0; ERROR_SUCCESS == lRet |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1447 && i < sizeof(openwith) / sizeof(openwith[0]); i++) |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1448 { |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1449 lRet = reg_create_key_and_value(hRootKey, openwith[i], NULL, ""); |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1450 } |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1451 } |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1452 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1453 return lRet; |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1454 } |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1455 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1456 static LONG |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1457 register_uninstall( |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1458 HKEY hRootKey, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1459 const char *appname, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1460 const char *display_name, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1461 const char *uninstall_string) |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1462 { |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1463 LONG lRet = reg_create_key_and_value(hRootKey, appname, |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1464 "DisplayName", display_name); |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1465 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1466 if (ERROR_SUCCESS == lRet) |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1467 lRet = reg_create_key_and_value(hRootKey, appname, |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1468 "UninstallString", uninstall_string); |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1469 return lRet; |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1470 } |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
1471 #endif /* WIN3264 */ |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1472 |
7 | 1473 /* |
1474 * Add some entries to the registry: | |
1475 * - to add "Edit with Vim" to the context * menu | |
1476 * - to add Vim to the "Open with..." list | |
1477 * - to uninstall Vim | |
1478 */ | |
1479 /*ARGSUSED*/ | |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
1480 static int |
7 | 1481 install_registry(void) |
1482 { | |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
1483 #ifdef WIN3264 |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1484 LONG lRet = ERROR_SUCCESS; |
7 | 1485 const char *vim_ext_ThreadingModel = "Apartment"; |
1486 const char *vim_ext_name = "Vim Shell Extension"; | |
1487 const char *vim_ext_clsid = "{51EEE242-AD87-11d3-9C1E-0090278BBD99}"; | |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1488 char vim_exe_path[BUFSIZE]; |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1489 char display_name[BUFSIZE]; |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1490 char uninstall_string[BUFSIZE]; |
7 | 1491 |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1492 sprintf(vim_exe_path, "%s\\gvim.exe", installdir); |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1493 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1494 if (install_popup) |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1495 { |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1496 char bufg[BUFSIZE]; |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1497 struct stat st; |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1498 |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1499 if (stat("gvimext.dll", &st) >= 0) |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1500 sprintf(bufg, "%s\\gvimext.dll", installdir); |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1501 else |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1502 /* gvimext.dll is in gvimext subdir */ |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1503 sprintf(bufg, "%s\\gvimext\\gvimext.dll", installdir); |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1504 |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1505 printf("Creating \"Edit with Vim\" popup menu entry\n"); |
7 | 1506 |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1507 lRet = register_inproc_server( |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1508 HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name, |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1509 bufg, vim_ext_ThreadingModel); |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1510 if (ERROR_SUCCESS != lRet) |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
1511 return FAIL; |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1512 lRet = register_shellex( |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1513 HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name, vim_exe_path); |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1514 if (ERROR_SUCCESS != lRet) |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
1515 return FAIL; |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1516 } |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1517 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1518 if (install_openwith) |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1519 { |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1520 printf("Creating \"Open with ...\" list entry\n"); |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1521 |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1522 lRet = register_openwith(HKEY_CLASSES_ROOT, vim_exe_path); |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1523 if (ERROR_SUCCESS != lRet) |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
1524 return FAIL; |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1525 } |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1526 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1527 printf("Creating an uninstall entry\n"); |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1528 |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1529 /* For the NSIS installer use the generated uninstaller. */ |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1530 if (interactive) |
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1531 { |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1532 sprintf(display_name, "Vim " VIM_VERSION_SHORT); |
2344
a2b15b1e626d
Fix: MS-Windows installer used wrong path for uninstaller key.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
1533 sprintf(uninstall_string, "%s\\uninstal.exe", installdir); |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1534 } |
7 | 1535 else |
1536 { | |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1537 sprintf(display_name, "Vim " VIM_VERSION_SHORT " (self-installing)"); |
2344
a2b15b1e626d
Fix: MS-Windows installer used wrong path for uninstaller key.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
1538 sprintf(uninstall_string, "%s\\uninstall-gui.exe", installdir); |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1539 } |
7 | 1540 |
2286
144aa6167799
Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents:
2220
diff
changeset
|
1541 lRet = register_uninstall( |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1542 HKEY_LOCAL_MACHINE, |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1543 "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Vim " VIM_VERSION_SHORT, |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1544 display_name, |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2287
diff
changeset
|
1545 uninstall_string); |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
1546 if (ERROR_SUCCESS != lRet) |
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
1547 return FAIL; |
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
1548 #endif /* WIN3264 */ |
7 | 1549 |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
1550 return OK; |
7 | 1551 } |
1552 | |
1553 static void | |
1554 change_popup_choice(int idx) | |
1555 { | |
1556 if (install_popup == 0) | |
1557 { | |
1558 choices[idx].text = "Install an entry for Vim in the popup menu for the right\n mouse button so that you can edit any file with Vim"; | |
1559 install_popup = 1; | |
1560 } | |
1561 else | |
1562 { | |
1563 choices[idx].text = "Do NOT install an entry for Vim in the popup menu for the\n right mouse button to edit any file with Vim"; | |
1564 install_popup = 0; | |
1565 } | |
1566 } | |
1567 | |
1568 /* | |
1569 * Only add the choice for the popup menu entry when gvim.exe was found and | |
1570 * both gvimext.dll and regedit.exe exist. | |
1571 */ | |
1572 static void | |
1573 init_popup_choice(void) | |
1574 { | |
1575 struct stat st; | |
1576 | |
1577 if (has_gvim | |
1578 && (stat("gvimext.dll", &st) >= 0 | |
1579 || stat("gvimext/gvimext.dll", &st) >= 0) | |
1580 #ifndef WIN3264 | |
1581 && searchpath("regedit.exe") != NULL | |
1582 #endif | |
1583 ) | |
1584 { | |
1585 choices[choice_count].changefunc = change_popup_choice; | |
1586 choices[choice_count].installfunc = NULL; | |
1587 choices[choice_count].active = 1; | |
1588 change_popup_choice(choice_count); /* set the text */ | |
1589 ++choice_count; | |
1590 } | |
1591 else | |
1592 add_dummy_choice(); | |
1593 } | |
1594 | |
1595 static void | |
1596 change_openwith_choice(int idx) | |
1597 { | |
1598 if (install_openwith == 0) | |
1599 { | |
1600 choices[idx].text = "Add Vim to the \"Open With...\" list in the popup menu for the right\n mouse button so that you can edit any file with Vim"; | |
1601 install_openwith = 1; | |
1602 } | |
1603 else | |
1604 { | |
1605 choices[idx].text = "Do NOT add Vim to the \"Open With...\" list in the popup menu for the\n right mouse button to edit any file with Vim"; | |
1606 install_openwith = 0; | |
1607 } | |
1608 } | |
1609 | |
1610 /* | |
1611 * Only add the choice for the open-with menu entry when gvim.exe was found | |
1612 * and and regedit.exe exist. | |
1613 */ | |
1614 static void | |
1615 init_openwith_choice(void) | |
1616 { | |
1617 if (has_gvim | |
1618 #ifndef WIN3264 | |
1619 && searchpath("regedit.exe") != NULL | |
1620 #endif | |
1621 ) | |
1622 { | |
1623 choices[choice_count].changefunc = change_openwith_choice; | |
1624 choices[choice_count].installfunc = NULL; | |
1625 choices[choice_count].active = 1; | |
1626 change_openwith_choice(choice_count); /* set the text */ | |
1627 ++choice_count; | |
1628 } | |
1629 else | |
1630 add_dummy_choice(); | |
1631 } | |
1632 | |
1633 #ifdef WIN3264 | |
1634 /* create_shortcut | |
1635 * | |
1636 * Create a shell link. | |
1637 * | |
1638 * returns 0 on failure, non-zero on successful completion. | |
1639 * | |
1640 * NOTE: Currently untested with mingw. | |
1641 */ | |
1642 int | |
1643 create_shortcut( | |
1644 const char *shortcut_name, | |
1645 const char *iconfile_path, | |
1646 int iconindex, | |
1647 const char *shortcut_target, | |
1648 const char *shortcut_args, | |
1649 const char *workingdir | |
1650 ) | |
1651 { | |
1652 IShellLink *shelllink_ptr; | |
1653 HRESULT hres; | |
1654 IPersistFile *persistfile_ptr; | |
1655 | |
1656 /* Initialize COM library */ | |
1657 hres = CoInitialize(NULL); | |
1658 if (!SUCCEEDED(hres)) | |
1659 { | |
1660 printf("Error: Could not open the COM library. Not creating shortcut.\n"); | |
1661 return FAIL; | |
1662 } | |
1663 | |
1664 /* Instantiate a COM object for the ShellLink, store a pointer to it | |
1665 * in shelllink_ptr. */ | |
1666 hres = CoCreateInstance(&CLSID_ShellLink, | |
1667 NULL, | |
1668 CLSCTX_INPROC_SERVER, | |
1669 &IID_IShellLink, | |
1670 (void **) &shelllink_ptr); | |
1671 | |
1672 if (SUCCEEDED(hres)) /* If the instantiation was successful... */ | |
1673 { | |
1674 /* ...Then build a PersistFile interface for the ShellLink so we can | |
1675 * save it as a file after we build it. */ | |
1676 hres = shelllink_ptr->lpVtbl->QueryInterface(shelllink_ptr, | |
1677 &IID_IPersistFile, (void **) &persistfile_ptr); | |
1678 | |
1679 if (SUCCEEDED(hres)) | |
1680 { | |
1681 wchar_t wsz[BUFSIZE]; | |
1682 | |
1683 /* translate the (possibly) multibyte shortcut filename to windows | |
1684 * Unicode so it can be used as a file name. | |
1685 */ | |
1686 MultiByteToWideChar(CP_ACP, 0, shortcut_name, -1, wsz, BUFSIZE); | |
1687 | |
1688 /* set the attributes */ | |
1689 shelllink_ptr->lpVtbl->SetPath(shelllink_ptr, shortcut_target); | |
1690 shelllink_ptr->lpVtbl->SetWorkingDirectory(shelllink_ptr, | |
1691 workingdir); | |
1692 shelllink_ptr->lpVtbl->SetIconLocation(shelllink_ptr, | |
1693 iconfile_path, iconindex); | |
1694 shelllink_ptr->lpVtbl->SetArguments(shelllink_ptr, shortcut_args); | |
1695 | |
1696 /* save the shortcut to a file and return the PersistFile object*/ | |
1697 persistfile_ptr->lpVtbl->Save(persistfile_ptr, wsz, 1); | |
1698 persistfile_ptr->lpVtbl->Release(persistfile_ptr); | |
1699 } | |
1700 else | |
1701 { | |
1702 printf("QueryInterface Error\n"); | |
1703 return FAIL; | |
1704 } | |
1705 | |
1706 /* Return the ShellLink object */ | |
1707 shelllink_ptr->lpVtbl->Release(shelllink_ptr); | |
1708 } | |
1709 else | |
1710 { | |
1711 printf("CoCreateInstance Error - hres = %08x\n", (int)hres); | |
1712 return FAIL; | |
1713 } | |
1714 | |
1715 return OK; | |
1716 } | |
1717 | |
1718 /* | |
1719 * Build a path to where we will put a specified link. | |
1720 * | |
1721 * Return 0 on error, non-zero on success | |
1722 */ | |
1723 int | |
1724 build_link_name( | |
1725 char *link_path, | |
1726 const char *link_name, | |
1727 const char *shell_folder_name) | |
1728 { | |
1729 char shell_folder_path[BUFSIZE]; | |
1730 | |
1731 if (get_shell_folder_path(shell_folder_path, shell_folder_name) == FAIL) | |
1732 { | |
1733 printf("An error occurred while attempting to find the path to %s.\n", | |
1734 shell_folder_name); | |
1735 return FAIL; | |
1736 } | |
1737 | |
1738 /* Make sure the directory exists (create Start Menu\Programs\Vim). | |
1739 * Ignore errors if it already exists. */ | |
1740 vim_mkdir(shell_folder_path, 0755); | |
1741 | |
1742 /* build the path to the shortcut and the path to gvim.exe */ | |
1743 sprintf(link_path, "%s\\%s.lnk", shell_folder_path, link_name); | |
1744 | |
1745 return OK; | |
1746 } | |
1747 | |
1748 static int | |
1749 build_shortcut( | |
1750 const char *name, /* Name of the shortcut */ | |
1751 const char *exename, /* Name of the executable (e.g., vim.exe) */ | |
1752 const char *args, | |
1753 const char *shell_folder, | |
1754 const char *workingdir) | |
1755 { | |
1756 char executable_path[BUFSIZE]; | |
1757 char link_name[BUFSIZE]; | |
1758 | |
1759 sprintf(executable_path, "%s\\%s", installdir, exename); | |
1760 | |
1761 if (build_link_name(link_name, name, shell_folder) == FAIL) | |
1762 { | |
1763 printf("An error has occurred. A shortcut to %s will not be created %s.\n", | |
1764 name, | |
1765 *shell_folder == 'd' ? "on the desktop" : "in the Start menu"); | |
1766 return FAIL; | |
1767 } | |
1768 | |
1769 /* Create the shortcut: */ | |
1770 return create_shortcut(link_name, executable_path, 0, | |
1771 executable_path, args, workingdir); | |
1772 } | |
1773 | |
1774 /* | |
1775 * We used to use "homedir" as the working directory, but that is a bad choice | |
1776 * on multi-user systems. Not specifying a directory appears to work best. | |
1777 */ | |
1778 #define WORKDIR "" | |
1779 | |
1780 /* | |
1781 * Create shortcut(s) in the Start Menu\Programs\Vim folder. | |
1782 */ | |
1783 static void | |
1784 install_start_menu(int idx) | |
1785 { | |
1786 need_uninstall_entry = 1; | |
1787 printf("Creating start menu\n"); | |
1788 if (has_vim) | |
1789 { | |
1790 if (build_shortcut("Vim", "vim.exe", "", | |
1791 VIM_STARTMENU, WORKDIR) == FAIL) | |
1792 return; | |
1793 if (build_shortcut("Vim Read-only", "vim.exe", "-R", | |
1794 VIM_STARTMENU, WORKDIR) == FAIL) | |
1795 return; | |
1796 if (build_shortcut("Vim Diff", "vim.exe", "-d", | |
1797 VIM_STARTMENU, WORKDIR) == FAIL) | |
1798 return; | |
1799 } | |
1800 if (has_gvim) | |
1801 { | |
1802 if (build_shortcut("gVim", "gvim.exe", "", | |
1803 VIM_STARTMENU, WORKDIR) == FAIL) | |
1804 return; | |
1805 if (build_shortcut("gVim Easy", "gvim.exe", "-y", | |
1806 VIM_STARTMENU, WORKDIR) == FAIL) | |
1807 return; | |
1808 if (build_shortcut("gVim Read-only", "gvim.exe", "-R", | |
1809 VIM_STARTMENU, WORKDIR) == FAIL) | |
1810 return; | |
1811 if (build_shortcut("gVim Diff", "gvim.exe", "-d", | |
1812 VIM_STARTMENU, WORKDIR) == FAIL) | |
1813 return; | |
1814 } | |
1815 if (build_shortcut("Uninstall", | |
1816 interactive ? "uninstal.exe" : "uninstall-gui.exe", "", | |
1817 VIM_STARTMENU, installdir) == FAIL) | |
1818 return; | |
1819 /* For Windows NT the working dir of the vimtutor.bat must be right, | |
1820 * otherwise gvim.exe won't be found and using gvimbat doesn't work. */ | |
1821 if (build_shortcut("Vim tutor", "vimtutor.bat", "", | |
1822 VIM_STARTMENU, installdir) == FAIL) | |
1823 return; | |
1824 if (build_shortcut("Help", has_gvim ? "gvim.exe" : "vim.exe", "-c h", | |
1825 VIM_STARTMENU, WORKDIR) == FAIL) | |
1826 return; | |
1827 { | |
1828 char shell_folder_path[BUFSIZE]; | |
1829 | |
1830 /* Creating the URL shortcut works a bit differently... */ | |
1831 if (get_shell_folder_path(shell_folder_path, VIM_STARTMENU) == FAIL) | |
1832 { | |
1833 printf("Finding the path of the Start menu failed\n"); | |
1834 return ; | |
1835 } | |
1836 add_pathsep(shell_folder_path); | |
1837 strcat(shell_folder_path, "Vim Online.url"); | |
1838 if (!WritePrivateProfileString("InternetShortcut", "URL", | |
1839 "http://vim.sf.net/", shell_folder_path)) | |
1840 { | |
1841 printf("Creating the Vim online URL failed\n"); | |
1842 return; | |
1843 } | |
1844 } | |
1845 } | |
1846 | |
1847 static void | |
1848 toggle_startmenu_choice(int idx) | |
1849 { | |
1850 if (choices[idx].installfunc == NULL) | |
1851 { | |
1852 choices[idx].installfunc = install_start_menu; | |
1853 choices[idx].text = "Add Vim to the Start menu"; | |
1854 } | |
1855 else | |
1856 { | |
1857 choices[idx].installfunc = NULL; | |
1858 choices[idx].text = "Do NOT add Vim to the Start menu"; | |
1859 } | |
1860 } | |
1861 | |
1862 /* | |
1863 * Function to actually create the shortcuts | |
1864 * | |
1865 * Currently I am supplying no working directory to the shortcut. This | |
1866 * means that the initial working dir will be: | |
1867 * - the location of the shortcut if no file is supplied | |
1868 * - the location of the file being edited if a file is supplied (ie via | |
1869 * drag and drop onto the shortcut). | |
1870 */ | |
1871 void | |
1872 install_shortcut_gvim(int idx) | |
1873 { | |
1874 /* Create shortcut(s) on the desktop */ | |
1875 if (choices[idx].arg) | |
1876 { | |
1877 (void)build_shortcut(icon_names[0], "gvim.exe", | |
1878 "", "desktop", WORKDIR); | |
1879 need_uninstall_entry = 1; | |
1880 } | |
1881 } | |
1882 | |
1883 void | |
1884 install_shortcut_evim(int idx) | |
1885 { | |
1886 if (choices[idx].arg) | |
1887 { | |
1888 (void)build_shortcut(icon_names[1], "gvim.exe", | |
1889 "-y", "desktop", WORKDIR); | |
1890 need_uninstall_entry = 1; | |
1891 } | |
1892 } | |
1893 | |
1894 void | |
1895 install_shortcut_gview(int idx) | |
1896 { | |
1897 if (choices[idx].arg) | |
1898 { | |
1899 (void)build_shortcut(icon_names[2], "gvim.exe", | |
1900 "-R", "desktop", WORKDIR); | |
1901 need_uninstall_entry = 1; | |
1902 } | |
1903 } | |
1904 | |
1905 void | |
1906 toggle_shortcut_choice(int idx) | |
1907 { | |
1908 char *arg; | |
1909 | |
1910 if (choices[idx].installfunc == install_shortcut_gvim) | |
1911 arg = "gVim"; | |
1912 else if (choices[idx].installfunc == install_shortcut_evim) | |
1913 arg = "gVim Easy"; | |
1914 else | |
1915 arg = "gVim Read-only"; | |
1916 if (choices[idx].arg) | |
1917 { | |
1918 choices[idx].arg = 0; | |
1919 alloc_text(idx, "Do NOT create a desktop icon for %s", arg); | |
1920 } | |
1921 else | |
1922 { | |
1923 choices[idx].arg = 1; | |
1924 alloc_text(idx, "Create a desktop icon for %s", arg); | |
1925 } | |
1926 } | |
1927 #endif /* WIN3264 */ | |
1928 | |
1929 static void | |
1930 init_startmenu_choice(void) | |
1931 { | |
1932 #ifdef WIN3264 | |
1933 /* Start menu */ | |
1934 choices[choice_count].changefunc = toggle_startmenu_choice; | |
1935 choices[choice_count].installfunc = NULL; | |
1936 choices[choice_count].active = 1; | |
1937 toggle_startmenu_choice(choice_count); /* set the text */ | |
1938 ++choice_count; | |
1939 #else | |
1940 add_dummy_choice(); | |
1941 #endif | |
1942 } | |
1943 | |
1944 /* | |
1945 * Add the choice for the desktop shortcuts. | |
1946 */ | |
1947 static void | |
1948 init_shortcut_choices(void) | |
1949 { | |
1950 #ifdef WIN3264 | |
1951 /* Shortcut to gvim */ | |
1952 choices[choice_count].text = NULL; | |
1953 choices[choice_count].arg = 0; | |
1954 choices[choice_count].active = has_gvim; | |
1955 choices[choice_count].changefunc = toggle_shortcut_choice; | |
1956 choices[choice_count].installfunc = install_shortcut_gvim; | |
1957 toggle_shortcut_choice(choice_count); | |
1958 ++choice_count; | |
1959 | |
1960 /* Shortcut to evim */ | |
1961 choices[choice_count].text = NULL; | |
1962 choices[choice_count].arg = 0; | |
1963 choices[choice_count].active = has_gvim; | |
1964 choices[choice_count].changefunc = toggle_shortcut_choice; | |
1965 choices[choice_count].installfunc = install_shortcut_evim; | |
1966 toggle_shortcut_choice(choice_count); | |
1967 ++choice_count; | |
1968 | |
1969 /* Shortcut to gview */ | |
1970 choices[choice_count].text = NULL; | |
1971 choices[choice_count].arg = 0; | |
1972 choices[choice_count].active = has_gvim; | |
1973 choices[choice_count].changefunc = toggle_shortcut_choice; | |
1974 choices[choice_count].installfunc = install_shortcut_gview; | |
1975 toggle_shortcut_choice(choice_count); | |
1976 ++choice_count; | |
1977 #else | |
1978 add_dummy_choice(); | |
1979 add_dummy_choice(); | |
1980 add_dummy_choice(); | |
1981 #endif | |
1982 } | |
1983 | |
1984 #ifdef WIN3264 | |
1985 /* | |
1986 * Attempt to register OLE for Vim. | |
1987 */ | |
1988 static void | |
1989 install_OLE_register(void) | |
1990 { | |
1991 char register_command_string[BUFSIZE + 30]; | |
1992 | |
1993 printf("\n--- Attempting to register Vim with OLE ---\n"); | |
1994 printf("(There is no message whether this works or not.)\n"); | |
1995 | |
1996 #ifndef __CYGWIN__ | |
1997 sprintf(register_command_string, "\"%s\\gvim.exe\" -silent -register", installdir); | |
1998 #else | |
1999 /* handle this differently for Cygwin which sometimes has trouble with | |
2000 * Windows-style pathnames here. */ | |
2001 sprintf(register_command_string, "./gvim.exe -silent -register"); | |
2002 #endif | |
2003 system(register_command_string); | |
2004 } | |
2005 #endif /* WIN3264 */ | |
2006 | |
2007 /* | |
2008 * Remove the last part of directory "path[]" to get its parent, and put the | |
2009 * result in "to[]". | |
2010 */ | |
2011 static void | |
2012 dir_remove_last(const char *path, char to[BUFSIZE]) | |
2013 { | |
2014 char c; | |
2015 long last_char_to_copy; | |
2016 long path_length = strlen(path); | |
2017 | |
2018 /* skip the last character just in case it is a '\\' */ | |
2019 last_char_to_copy = path_length - 2; | |
2020 c = path[last_char_to_copy]; | |
2021 | |
2022 while (c != '\\') | |
2023 { | |
2024 last_char_to_copy--; | |
2025 c = path[last_char_to_copy]; | |
2026 } | |
2027 | |
2028 strncpy(to, path, (size_t)last_char_to_copy); | |
2029 to[last_char_to_copy] = NUL; | |
2030 } | |
2031 | |
2032 static void | |
2033 set_directories_text(int idx) | |
2034 { | |
2035 if (vimfiles_dir_choice == (int)vimfiles_dir_none) | |
2036 alloc_text(idx, "Do NOT create plugin directories%s", ""); | |
2037 else | |
2038 alloc_text(idx, "Create plugin directories: %s", | |
2039 vimfiles_dir_choices[vimfiles_dir_choice]); | |
2040 } | |
2041 | |
2042 /* | |
2043 * Change the directory that the vim plugin directories will be created in: | |
2044 * $HOME, $VIM or nowhere. | |
2045 */ | |
2046 static void | |
2047 change_directories_choice(int idx) | |
2048 { | |
2049 int choice_count = TABLE_SIZE(vimfiles_dir_choices); | |
2050 | |
2051 /* Don't offer the $HOME choice if $HOME isn't set. */ | |
2052 if (getenv("HOME") == NULL) | |
2053 --choice_count; | |
2054 vimfiles_dir_choice = get_choice(vimfiles_dir_choices, choice_count); | |
2055 set_directories_text(idx); | |
2056 } | |
2057 | |
2058 /* | |
2059 * Create the plugin directories... | |
2060 */ | |
2061 /*ARGSUSED*/ | |
2062 static void | |
2063 install_vimfilesdir(int idx) | |
2064 { | |
2065 int i; | |
2066 char *p; | |
2067 char vimdir_path[BUFSIZE]; | |
2068 char vimfiles_path[BUFSIZE]; | |
2069 char tmp_dirname[BUFSIZE]; | |
2070 | |
2071 /* switch on the location that the user wants the plugin directories | |
2072 * built in */ | |
2073 switch (vimfiles_dir_choice) | |
2074 { | |
2075 case vimfiles_dir_vim: | |
2076 { | |
2077 /* Go to the %VIM% directory - check env first, then go one dir | |
2078 * below installdir if there is no %VIM% environment variable. | |
2079 * The accuracy of $VIM is checked in inspect_system(), so we | |
2080 * can be sure it is ok to use here. */ | |
2081 p = getenv("VIM"); | |
2082 if (p == NULL) /* No $VIM in path */ | |
2083 dir_remove_last(installdir, vimdir_path); | |
2084 else | |
2085 strcpy(vimdir_path, p); | |
2086 break; | |
2087 } | |
2088 case vimfiles_dir_home: | |
2089 { | |
2090 /* Find the $HOME directory. Its existence was already checked. */ | |
2091 p = getenv("HOME"); | |
2092 if (p == NULL) | |
2093 { | |
2094 printf("Internal error: $HOME is NULL\n"); | |
2095 p = "c:\\"; | |
2096 } | |
2097 strcpy(vimdir_path, p); | |
2098 break; | |
2099 } | |
2100 case vimfiles_dir_none: | |
2101 { | |
2102 /* Do not create vim plugin directory */ | |
2103 return; | |
2104 } | |
2105 } | |
2106 | |
2107 /* Now, just create the directory. If it already exists, it will fail | |
2108 * silently. */ | |
2109 sprintf(vimfiles_path, "%s\\vimfiles", vimdir_path); | |
2110 vim_mkdir(vimfiles_path, 0755); | |
2111 | |
2112 printf("Creating the following directories in \"%s\":\n", vimfiles_path); | |
2113 for (i = 0; i < TABLE_SIZE(vimfiles_subdirs); i++) | |
2114 { | |
2115 sprintf(tmp_dirname, "%s\\%s", vimfiles_path, vimfiles_subdirs[i]); | |
2116 printf(" %s", vimfiles_subdirs[i]); | |
2117 vim_mkdir(tmp_dirname, 0755); | |
2118 } | |
2119 printf("\n"); | |
2120 } | |
2121 | |
2122 /* | |
2123 * Add the creation of runtime files to the setup sequence. | |
2124 */ | |
2125 static void | |
2126 init_directories_choice(void) | |
2127 { | |
2128 struct stat st; | |
2129 char tmp_dirname[BUFSIZE]; | |
2130 char *p; | |
2131 | |
2132 choices[choice_count].text = alloc(150); | |
2133 choices[choice_count].changefunc = change_directories_choice; | |
2134 choices[choice_count].installfunc = install_vimfilesdir; | |
2135 choices[choice_count].active = 1; | |
2136 | |
2137 /* Check if the "compiler" directory already exists. That's a good | |
2138 * indication that the plugin directories were already created. */ | |
2139 if (getenv("HOME") != NULL) | |
2140 { | |
2141 vimfiles_dir_choice = (int)vimfiles_dir_home; | |
2142 sprintf(tmp_dirname, "%s\\vimfiles\\compiler", getenv("HOME")); | |
2143 if (stat(tmp_dirname, &st) == 0) | |
2144 vimfiles_dir_choice = (int)vimfiles_dir_none; | |
2145 } | |
2146 else | |
2147 { | |
2148 vimfiles_dir_choice = (int)vimfiles_dir_vim; | |
2149 p = getenv("VIM"); | |
2150 if (p == NULL) /* No $VIM in path, use the install dir */ | |
2151 dir_remove_last(installdir, tmp_dirname); | |
2152 else | |
2153 strcpy(tmp_dirname, p); | |
2154 strcat(tmp_dirname, "\\vimfiles\\compiler"); | |
2155 if (stat(tmp_dirname, &st) == 0) | |
2156 vimfiles_dir_choice = (int)vimfiles_dir_none; | |
2157 } | |
2158 | |
2159 set_directories_text(choice_count); | |
2160 ++choice_count; | |
2161 } | |
2162 | |
2163 /* | |
2164 * Setup the choices and the default values. | |
2165 */ | |
2166 static void | |
2167 setup_choices(void) | |
2168 { | |
2169 /* install the batch files */ | |
2170 init_bat_choices(); | |
2171 | |
2172 /* (over) write _vimrc file */ | |
2173 init_vimrc_choices(); | |
2174 | |
2175 /* Whether to add Vim to the popup menu */ | |
2176 init_popup_choice(); | |
2177 | |
2178 /* Whether to add Vim to the "Open With..." menu */ | |
2179 init_openwith_choice(); | |
2180 | |
2181 /* Whether to add Vim to the Start Menu. */ | |
2182 init_startmenu_choice(); | |
2183 | |
2184 /* Whether to add shortcuts to the Desktop. */ | |
2185 init_shortcut_choices(); | |
2186 | |
2187 /* Whether to create the runtime directories. */ | |
2188 init_directories_choice(); | |
2189 } | |
2190 | |
2191 static void | |
2192 print_cmd_line_help(void) | |
2193 { | |
2194 printf("Vim installer non-interactive command line arguments:\n"); | |
2195 printf("\n"); | |
2196 printf("-create-batfiles [vim gvim evim view gview vimdiff gvimdiff]\n"); | |
2197 printf(" Create .bat files for Vim variants in the Windows directory.\n"); | |
2198 printf("-create-vimrc\n"); | |
2199 printf(" Create a default _vimrc file if one does not already exist.\n"); | |
2200 printf("-install-popup\n"); | |
2201 printf(" Install the Edit-with-Vim context menu entry\n"); | |
2202 printf("-install-openwith\n"); | |
2203 printf(" Add Vim to the \"Open With...\" context menu list\n"); | |
2204 #ifdef WIN3264 | |
2205 printf("-add-start-menu"); | |
2206 printf(" Add Vim to the start menu\n"); | |
2207 printf("-install-icons"); | |
2208 printf(" Create icons for gVim executables on the desktop\n"); | |
2209 #endif | |
2210 printf("-create-directories [vim|home]\n"); | |
2211 printf(" Create runtime directories to drop plugins into; in the $VIM\n"); | |
2212 printf(" or $HOME directory\n"); | |
2213 #ifdef WIN3264 | |
2214 printf("-register-OLE"); | |
419 | 2215 printf(" Ignored\n"); |
7 | 2216 #endif |
2217 printf("\n"); | |
2218 } | |
2219 | |
2220 /* | |
2221 * Setup installation choices based on command line switches | |
2222 */ | |
2223 static void | |
2224 command_line_setup_choices(int argc, char **argv) | |
2225 { | |
2226 int i, j; | |
2227 | |
2228 for (i = 1; i < argc; i++) | |
2229 { | |
2230 if (strcmp(argv[i], "-create-batfiles") == 0) | |
2231 { | |
2232 if (i + 1 == argc) | |
2233 continue; | |
2234 while (argv[i + 1][0] != '-' && i < argc) | |
2235 { | |
2236 i++; | |
2237 for (j = 1; j < TARGET_COUNT; ++j) | |
2238 if ((targets[j].exenamearg[0] == 'g' ? has_gvim : has_vim) | |
2239 && strcmp(argv[i], targets[j].name) == 0) | |
2240 { | |
2241 init_bat_choice(j); | |
2242 break; | |
2243 } | |
2244 if (j == TARGET_COUNT) | |
2245 printf("%s is not a valid choice for -create-batfiles\n", | |
2246 argv[i]); | |
2247 | |
2248 if (i + 1 == argc) | |
2249 break; | |
2250 } | |
2251 } | |
2252 else if (strcmp(argv[i], "-create-vimrc") == 0) | |
2253 { | |
2254 /* Setup default vimrc choices. If there is already a _vimrc file, | |
2255 * it will NOT be overwritten. | |
2256 */ | |
2257 init_vimrc_choices(); | |
2258 } | |
2259 else if (strcmp(argv[i], "-install-popup") == 0) | |
2260 { | |
2261 init_popup_choice(); | |
2262 } | |
2263 else if (strcmp(argv[i], "-install-openwith") == 0) | |
2264 { | |
2265 init_openwith_choice(); | |
2266 } | |
2267 else if (strcmp(argv[i], "-add-start-menu") == 0) | |
2268 { | |
2269 init_startmenu_choice(); | |
2270 } | |
2271 else if (strcmp(argv[i], "-install-icons") == 0) | |
2272 { | |
2273 init_shortcut_choices(); | |
2274 } | |
2275 else if (strcmp(argv[i], "-create-directories") == 0) | |
2276 { | |
2277 init_directories_choice(); | |
2278 if (argv[i + 1][0] != '-') | |
2279 { | |
2280 i++; | |
2281 if (strcmp(argv[i], "vim") == 0) | |
2282 vimfiles_dir_choice = (int)vimfiles_dir_vim; | |
2283 else if (strcmp(argv[i], "home") == 0) | |
2284 { | |
2285 if (getenv("HOME") == NULL) /* No $HOME in environment */ | |
2286 vimfiles_dir_choice = (int)vimfiles_dir_vim; | |
2287 else | |
2288 vimfiles_dir_choice = (int)vimfiles_dir_home; | |
2289 } | |
2290 else | |
2291 { | |
2292 printf("Unknown argument for -create-directories: %s\n", | |
2293 argv[i]); | |
2294 print_cmd_line_help(); | |
2295 } | |
2296 } | |
2297 else /* No choice specified, default to vim directory */ | |
2298 vimfiles_dir_choice = (int)vimfiles_dir_vim; | |
2299 } | |
2300 #ifdef WIN3264 | |
2301 else if (strcmp(argv[i], "-register-OLE") == 0) | |
2302 { | |
2303 /* This is always done when gvim is found */ | |
2304 } | |
2305 #endif | |
2306 else /* Unknown switch */ | |
2307 { | |
2308 printf("Got unknown argument argv[%d] = %s\n", i, argv[i]); | |
2309 print_cmd_line_help(); | |
2310 } | |
2311 } | |
2312 } | |
2313 | |
2314 | |
2315 /* | |
2316 * Show a few screens full of helpful information. | |
2317 */ | |
2318 static void | |
2319 show_help(void) | |
2320 { | |
2321 static char *(items[]) = | |
2322 { | |
2323 "Installing .bat files\n" | |
2324 "---------------------\n" | |
2325 "The vim.bat file is written in one of the directories in $PATH.\n" | |
2326 "This makes it possible to start Vim from the command line.\n" | |
2327 "If vim.exe can be found in $PATH, the choice for vim.bat will not be\n" | |
2328 "present. It is assumed you will use the existing vim.exe.\n" | |
2329 "If vim.bat can already be found in $PATH this is probably for an old\n" | |
2330 "version of Vim (but this is not checked!). You can overwrite it.\n" | |
2331 "If no vim.bat already exists, you can select one of the directories in\n" | |
2332 "$PATH for creating the batch file, or disable creating a vim.bat file.\n" | |
2333 "\n" | |
2334 "If you choose not to create the vim.bat file, Vim can still be executed\n" | |
2335 "in other ways, but not from the command line.\n" | |
2336 "\n" | |
2337 "The same applies to choices for gvim, evim, (g)view, and (g)vimdiff.\n" | |
2338 "The first item can be used to change the path for all of them.\n" | |
2339 , | |
2340 "Creating a _vimrc file\n" | |
2341 "----------------------\n" | |
2342 "The _vimrc file is used to set options for how Vim behaves.\n" | |
2343 "The install program can create a _vimrc file with a few basic choices.\n" | |
2344 "You can edit this file later to tune your preferences.\n" | |
2345 "If you already have a _vimrc or .vimrc file it can be overwritten.\n" | |
2346 "Don't do that if you have made changes to it.\n" | |
2347 , | |
2348 "Vim features\n" | |
2349 "------------\n" | |
2350 "(this choice is only available when creating a _vimrc file)\n" | |
2351 "1. Vim can run in Vi-compatible mode. Many nice Vim features are then\n" | |
2352 " disabled. In the not-Vi-compatible mode Vim is still mostly Vi\n" | |
2353 " compatible, but adds nice features like multi-level undo. Only\n" | |
2354 " choose Vi-compatible if you really need full Vi compatibility.\n" | |
2355 "2. Running Vim with some enhancements is useful when you want some of\n" | |
2356 " the nice Vim features, but have a slow computer and want to keep it\n" | |
2357 " really fast.\n" | |
2358 "3. Syntax highlighting shows many files in color. Not only does this look\n" | |
2359 " nice, it also makes it easier to spot errors and you can work faster.\n" | |
2360 " The other features include editing compressed files.\n" | |
2361 , | |
2362 "Windows key mapping\n" | |
2363 "-------------------\n" | |
2364 "(this choice is only available when creating a _vimrc file)\n" | |
2365 "Under MS-Windows the CTRL-C key copies text to the clipboard and CTRL-V\n" | |
2366 "pastes text from the clipboard. There are a few more keys like these.\n" | |
2367 "Unfortunately, in Vim these keys normally have another meaning.\n" | |
2368 "1. Choose to have the keys like they normally are in Vim (useful if you\n" | |
2369 " also use Vim on other systems).\n" | |
2370 "2. Choose to have the keys work like they are used on MS-Windows (useful\n" | |
2371 " if you mostly work on MS-Windows).\n" | |
2372 , | |
2373 "Mouse use\n" | |
2374 "---------\n" | |
2375 "(this choice is only available when creating a _vimrc file)\n" | |
2376 "The right mouse button can be used in two ways:\n" | |
2377 "1. The Unix way is to extend an existing selection. The popup menu is\n" | |
2378 " not available.\n" | |
2379 "2. The MS-Windows way is to show a popup menu, which allows you to\n" | |
2380 " copy/paste text, undo/redo, etc. Extending the selection can still be\n" | |
2381 " done by keeping SHIFT pressed while using the left mouse button\n" | |
2382 , | |
2383 "Edit-with-Vim context menu entry\n" | |
2384 "--------------------------------\n" | |
2385 "(this choice is only available when gvim.exe and gvimext.dll are present)\n" | |
2386 "You can associate different file types with Vim, so that you can (double)\n" | |
2387 "click on a file to edit it with Vim. This means you have to individually\n" | |
2388 "select each file type.\n" | |
2389 "An alternative is the option offered here: Install an \"Edit with Vim\"\n" | |
2390 "entry in the popup menu for the right mouse button. This means you can\n" | |
2391 "edit any file with Vim.\n" | |
2392 , | |
2393 "\"Open With...\" context menu entry\n" | |
2394 "--------------------------------\n" | |
2395 "(this choice is only available when gvim.exe is present)\n" | |
2396 "This option adds Vim to the \"Open With...\" entry in the popup menu for\n" | |
2397 "the right mouse button. This also makes it possible to edit HTML files\n" | |
2398 "directly from Internet Explorer.\n" | |
2399 , | |
2400 "Add Vim to the Start menu\n" | |
2401 "-------------------------\n" | |
2402 "In Windows 95 and later, Vim can be added to the Start menu. This will\n" | |
2403 "create a submenu with an entry for vim, gvim, evim, vimdiff, etc..\n" | |
2404 , | |
2405 "Icons on the desktop\n" | |
2406 "--------------------\n" | |
2407 "(these choices are only available when installing gvim)\n" | |
2408 "In Windows 95 and later, shortcuts (icons) can be created on the Desktop.\n" | |
2409 , | |
2410 "Create plugin directories\n" | |
2411 "-------------------------\n" | |
2412 "Plugin directories allow extending Vim by dropping a file into a directory.\n" | |
2413 "This choice allows creating them in $HOME (if you have a home directory) or\n" | |
2414 "$VIM (used for everybody on the system).\n" | |
2415 , | |
2416 NULL | |
2417 }; | |
2418 int i; | |
2419 int c; | |
2420 | |
2421 rewind(stdin); | |
2422 printf("\n"); | |
2423 for (i = 0; items[i] != NULL; ++i) | |
2424 { | |
2425 printf(items[i]); | |
2426 printf("\n"); | |
2427 printf("Hit Enter to continue, b (back) or q (quit help): "); | |
2428 c = getchar(); | |
2429 rewind(stdin); | |
2430 if (c == 'b' || c == 'B') | |
2431 { | |
2432 if (i == 0) | |
2433 --i; | |
2434 else | |
2435 i -= 2; | |
2436 } | |
2437 if (c == 'q' || c == 'Q') | |
2438 break; | |
2439 printf("\n"); | |
2440 } | |
2441 } | |
2442 | |
2443 /* | |
2444 * Install the choices. | |
2445 */ | |
2446 static void | |
2447 install(void) | |
2448 { | |
2449 int i; | |
2450 | |
2451 /* Install the selected choices. */ | |
2452 for (i = 0; i < choice_count; ++i) | |
2453 if (choices[i].installfunc != NULL && choices[i].active) | |
2454 (choices[i].installfunc)(i); | |
2455 | |
2456 /* Add some entries to the registry, if needed. */ | |
2457 if (install_popup | |
2458 || install_openwith | |
2459 || (need_uninstall_entry && interactive) | |
2460 || !interactive) | |
2461 install_registry(); | |
2462 | |
2463 #ifdef WIN3264 | |
2464 /* Register gvim with OLE. */ | |
2465 if (has_gvim) | |
2466 install_OLE_register(); | |
2467 #endif | |
2468 } | |
2469 | |
2470 /* | |
2471 * request_choice | |
2472 */ | |
2473 static void | |
2474 request_choice(void) | |
2475 { | |
2476 int i; | |
2477 | |
2478 printf("\n\nInstall will do for you:\n"); | |
2479 for (i = 0; i < choice_count; ++i) | |
2480 if (choices[i].active) | |
2481 printf("%2d %s\n", i + 1, choices[i].text); | |
2482 printf("To change an item, enter its number\n\n"); | |
2483 printf("Enter item number, h (help), d (do it) or q (quit): "); | |
2484 } | |
2485 | |
2486 int | |
2487 main(int argc, char **argv) | |
2488 { | |
2489 int i; | |
2490 char buf[BUFSIZE]; | |
2491 | |
2492 /* | |
2493 * Run interactively if there are no command line arguments. | |
2494 */ | |
2495 if (argc > 1) | |
2496 interactive = 0; | |
2497 else | |
2498 interactive = 1; | |
2499 | |
2500 /* Initialize this program. */ | |
2501 do_inits(argv); | |
2502 | |
2503 #ifdef WIN3264 | |
2504 if (argc > 1 && strcmp(argv[1], "-uninstall-check") == 0) | |
2505 { | |
2506 /* Only check for already installed Vims. Used by NSIS installer. */ | |
2217
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
2507 i = uninstall_check(1); |
7 | 2508 |
2509 /* Find the value of $VIM, because NSIS isn't able to do this by | |
2510 * itself. */ | |
2511 get_vim_env(); | |
2512 | |
2513 /* When nothing found exit quietly. If something found wait for | |
2220
b1c70c500de4
Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents:
2217
diff
changeset
|
2514 * a little while, so that the user can read the messages. */ |
7 | 2515 if (i) |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
2516 sleep(3); |
7 | 2517 exit(0); |
2518 } | |
2519 #endif | |
2520 | |
2521 printf("This program sets up the installation of Vim " | |
2522 VIM_VERSION_MEDIUM "\n\n"); | |
2523 | |
2524 /* Check if the user unpacked the archives properly. */ | |
2525 check_unpack(); | |
2526 | |
2527 #ifdef WIN3264 | |
2528 /* Check for already installed Vims. */ | |
2529 if (interactive) | |
2217
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
2530 uninstall_check(0); |
7 | 2531 #endif |
2532 | |
2533 /* Find out information about the system. */ | |
2534 inspect_system(); | |
2535 | |
2536 if (interactive) | |
2537 { | |
2538 /* Setup all the choices. */ | |
2539 setup_choices(); | |
2540 | |
2541 /* Let the user change choices and finally install (or quit). */ | |
2542 for (;;) | |
2543 { | |
2544 request_choice(); | |
2545 rewind(stdin); | |
2546 if (scanf("%99s", buf) == 1) | |
2547 { | |
2548 if (isdigit(buf[0])) | |
2549 { | |
2550 /* Change a choice. */ | |
2551 i = atoi(buf); | |
2552 if (i > 0 && i <= choice_count && choices[i - 1].active) | |
2553 (choices[i - 1].changefunc)(i - 1); | |
2554 else | |
2555 printf("\nIllegal choice\n"); | |
2556 } | |
2557 else if (buf[0] == 'h' || buf[0] == 'H') | |
2558 { | |
2559 /* Help */ | |
2560 show_help(); | |
2561 } | |
2562 else if (buf[0] == 'd' || buf[0] == 'D') | |
2563 { | |
2564 /* Install! */ | |
2565 install(); | |
2566 printf("\nThat finishes the installation. Happy Vimming!\n"); | |
2567 break; | |
2568 } | |
2569 else if (buf[0] == 'q' || buf[0] == 'Q') | |
2570 { | |
2571 /* Quit */ | |
2572 printf("\nExiting without anything done\n"); | |
2573 break; | |
2574 } | |
2575 else | |
2576 printf("\nIllegal choice\n"); | |
2577 } | |
2578 } | |
2579 printf("\n"); | |
2217
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
2580 myexit(0); |
7 | 2581 } |
2582 else | |
2583 { | |
2584 /* | |
2585 * Run non-interactive - setup according to the command line switches | |
2586 */ | |
2587 command_line_setup_choices(argc, argv); | |
2588 install(); | |
2217
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
2589 |
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
2590 /* Avoid that the user has to hit Enter, just wait a little bit to |
120502692d82
Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
2591 * allow reading the messages. */ |
2287
573da4dac306
Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents:
2286
diff
changeset
|
2592 sleep(2); |
7 | 2593 } |
2594 | |
2595 return 0; | |
2596 } |