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