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