annotate src/dosinst.c @ 1048:73c0eeeee0b7 v7.0.174

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