]>
Commit | Line | Data |
---|---|---|
d02ad552 AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 6.2.211 (extra) | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 6.2.211 (extra) | |
11 | Problem: Code for handling file dropped on Vim is duplicated. | |
12 | Solution: Move the common code to gui_handle_drop(). | |
13 | Add code to drop the files in the window under the cursor. | |
14 | Support drag&drop on the Macintosh. (Taro Muraoka) | |
15 | When dropping a directory name edit that directory (using the | |
16 | explorer plugin) | |
17 | Fix that changing directory with Shift pressed didn't work for | |
18 | relative path names. | |
19 | Files: src/fileio.c, src/gui.c, src/gui_gtk_x11.c, src/gui_mac.c, | |
20 | src/gui_w48.c, src/proto/fileio.pro, src/proto/gui.pro | |
21 | ||
22 | ||
23 | *** ../vim-6.2.210/src/fileio.c Sun Jan 18 21:31:56 2004 | |
24 | --- src/fileio.c Wed Jan 21 14:49:33 2004 | |
25 | *************** | |
26 | *** 4834,4839 **** | |
27 | --- 4834,4840 ---- | |
28 | } | |
29 | ||
30 | /* | |
31 | + * Shorten filenames for all buffers. | |
32 | * When "force" is TRUE: Use full path from now on for files currently being | |
33 | * edited, both for file name and swap file name. Try to shorten the file | |
34 | * names a bit, if safe to do so. | |
35 | *************** | |
36 | *** 4879,4884 **** | |
37 | --- 4880,4919 ---- | |
38 | #endif | |
39 | } | |
40 | ||
41 | + #if (defined(FEAT_DND) && defined(FEAT_GUI_GTK)) \ | |
42 | + || defined(FEAT_GUI_MSWIN) \ | |
43 | + || defined(FEAT_GUI_MAC) \ | |
44 | + || defined(PROTO) | |
45 | + /* | |
46 | + * Shorten all filenames in "fnames[count]" by current directory. | |
47 | + */ | |
48 | + void | |
49 | + shorten_filenames(fnames, count) | |
50 | + char_u **fnames; | |
51 | + int count; | |
52 | + { | |
53 | + int i; | |
54 | + char_u dirname[MAXPATHL]; | |
55 | + char_u *p; | |
56 | + | |
57 | + if (fnames == NULL || count < 1) | |
58 | + return; | |
59 | + mch_dirname(dirname, sizeof(dirname)); | |
60 | + for (i = 0; i < count; ++i) | |
61 | + { | |
62 | + if ((p = shorten_fname(fnames[i], dirname)) != NULL) | |
63 | + { | |
64 | + /* shorten_fname() returns pointer in given "fnames[i]". If free | |
65 | + * "fnames[i]" first, "p" becomes invalid. So we need to copy | |
66 | + * "p" first then free fnames[i]. */ | |
67 | + p = vim_strsave(p); | |
68 | + vim_free(fnames[i]); | |
69 | + fnames[i] = p; | |
70 | + } | |
71 | + } | |
72 | + } | |
73 | + #endif | |
74 | + | |
75 | /* | |
76 | * add extention to file name - change path/fo.o.h to path/fo.o.h.ext or | |
77 | * fo_o_h.ext for MSDOS or when shortname option set. | |
78 | *** ../vim-6.2.210/src/gui.c Thu Jan 8 20:54:45 2004 | |
79 | --- src/gui.c Thu Jan 22 16:53:48 2004 | |
80 | *************** | |
81 | *** 4481,4483 **** | |
82 | --- 4481,4615 ---- | |
83 | } | |
84 | ||
85 | #endif | |
86 | + | |
87 | + #if (defined(FEAT_DND) && defined(FEAT_GUI_GTK)) \ | |
88 | + || defined(FEAT_GUI_MSWIN) \ | |
89 | + || defined(FEAT_GUI_MAC) \ | |
90 | + || defined(PROTO) | |
91 | + | |
92 | + #ifdef FEAT_WINDOWS | |
93 | + static void gui_wingoto_xy __ARGS((int x, int y)); | |
94 | + | |
95 | + /* | |
96 | + * Jump to the window at specified point (x, y). | |
97 | + */ | |
98 | + static void | |
99 | + gui_wingoto_xy(x, y) | |
100 | + int x; | |
101 | + int y; | |
102 | + { | |
103 | + int row = Y_2_ROW(y); | |
104 | + int col = X_2_COL(x); | |
105 | + win_T *wp; | |
106 | + | |
107 | + if (row >= 0 && col >= 0) | |
108 | + { | |
109 | + wp = mouse_find_win(&row, &col); | |
110 | + if (wp != NULL && wp != curwin) | |
111 | + win_goto(wp); | |
112 | + } | |
113 | + } | |
114 | + #endif | |
115 | + | |
116 | + /* | |
117 | + * Process file drop. Mouse cursor position, key modifiers, name of files | |
118 | + * and count of files are given. Argument "fnames[count]" has full pathnames | |
119 | + * of dropped files, they will be freed in this function, and caller can't use | |
120 | + * fnames after call this function. | |
121 | + */ | |
122 | + /*ARGSUSED*/ | |
123 | + void | |
124 | + gui_handle_drop(x, y, modifiers, fnames, count) | |
125 | + int x; | |
126 | + int y; | |
127 | + int_u modifiers; | |
128 | + char_u **fnames; | |
129 | + int count; | |
130 | + { | |
131 | + int i; | |
132 | + char_u *p; | |
133 | + | |
134 | + /* | |
135 | + * When the cursor is at the command line, add the file names to the | |
136 | + * command line, don't edit the files. | |
137 | + */ | |
138 | + if (State & CMDLINE) | |
139 | + { | |
140 | + shorten_filenames(fnames, count); | |
141 | + for (i = 0; i < count; ++i) | |
142 | + { | |
143 | + if (fnames[i] != NULL) | |
144 | + { | |
145 | + if (i > 0) | |
146 | + add_to_input_buf((char_u*)" ", 1); | |
147 | + | |
148 | + /* We don't know what command is used thus we can't be sure | |
149 | + * about which characters need to be escaped. Only escape the | |
150 | + * most common ones. */ | |
151 | + # ifdef BACKSLASH_IN_FILENAME | |
152 | + p = vim_strsave_escaped(fnames[i], (char_u *)" \t\"|"); | |
153 | + # else | |
154 | + p = vim_strsave_escaped(fnames[i], (char_u *)"\\ \t\"|"); | |
155 | + # endif | |
156 | + if (p != NULL) | |
157 | + add_to_input_buf(p, (int)STRLEN(p)); | |
158 | + vim_free(p); | |
159 | + vim_free(fnames[i]); | |
160 | + } | |
161 | + } | |
162 | + vim_free(fnames); | |
163 | + } | |
164 | + else | |
165 | + { | |
166 | + /* Go to the window under mouse cursor, then shorten given "fnames" by | |
167 | + * current window, because a window can have local current dir. */ | |
168 | + # ifdef FEAT_WINDOWS | |
169 | + gui_wingoto_xy(x, y); | |
170 | + # endif | |
171 | + shorten_filenames(fnames, count); | |
172 | + | |
173 | + /* If Shift held down, remember the first item. */ | |
174 | + if ((modifiers & MOUSE_SHIFT) != 0) | |
175 | + p = vim_strsave(fnames[0]); | |
176 | + else | |
177 | + p = NULL; | |
178 | + | |
179 | + /* Handle the drop, :edit or :split to get to the file. This also | |
180 | + * frees fnames[]. Skip this if there is only one item it's a | |
181 | + * directory and Shift is held down. */ | |
182 | + if (count == 1 && (modifiers & MOUSE_SHIFT) != 0 | |
183 | + && mch_isdir(fnames[0])) | |
184 | + { | |
185 | + vim_free(fnames[0]); | |
186 | + vim_free(fnames); | |
187 | + } | |
188 | + else | |
189 | + handle_drop(count, fnames, (modifiers & MOUSE_CTRL) != 0); | |
190 | + | |
191 | + /* If Shift held down, change to first file's directory. If the first | |
192 | + * item is a directory, change to that directory (and let the explorer | |
193 | + * plugin show the contents). */ | |
194 | + if (p != NULL) | |
195 | + { | |
196 | + if (mch_isdir(p)) | |
197 | + { | |
198 | + if (mch_chdir((char *)p) == 0) | |
199 | + shorten_fnames(TRUE); | |
200 | + } | |
201 | + else if (vim_chdirfile(p) == OK) | |
202 | + shorten_fnames(TRUE); | |
203 | + vim_free(p); | |
204 | + } | |
205 | + | |
206 | + /* Update the screen display */ | |
207 | + update_screen(NOT_VALID); | |
208 | + # ifdef FEAT_MENU | |
209 | + gui_update_menus(0); | |
210 | + # endif | |
211 | + setcursor(); | |
212 | + out_flush(); | |
213 | + gui_update_cursor(FALSE, FALSE); | |
214 | + gui_mch_flush(); | |
215 | + } | |
216 | + } | |
217 | + #endif | |
218 | *** ../vim-6.2.210/src/gui_gtk_x11.c Sun Jan 11 12:45:02 2004 | |
219 | --- src/gui_gtk_x11.c Wed Jan 21 16:07:00 2004 | |
220 | *************** | |
221 | *** 1823,1981 **** | |
222 | * Drag aNd Drop support handlers. | |
223 | */ | |
224 | ||
225 | ! static void | |
226 | ! drag_handle_uri_list(GdkDragContext *context, | |
227 | ! GtkSelectionData *data, | |
228 | ! guint time_, | |
229 | ! GdkModifierType state) | |
230 | { | |
231 | ! char_u **fnames; | |
232 | ! int redo_dirs = FALSE; | |
233 | ! int i; | |
234 | ! int n; | |
235 | ! char_u *start; | |
236 | ! char_u *copy; | |
237 | ! char_u *names; | |
238 | ! int nfiles = 0; | |
239 | ! int url = FALSE; | |
240 | ||
241 | ! names = data->data; | |
242 | ! copy = alloc((unsigned)(data->length + 1)); | |
243 | ! if (copy == NULL) | |
244 | ! return; | |
245 | ! /* | |
246 | ! * Count how many items there may be and separate them with a NUL. | |
247 | ! * Apparently the items are separated with \r\n. This is not documented, | |
248 | ! * thus be careful not to go past the end. Also allow separation with NUL | |
249 | ! * characters. | |
250 | ! */ | |
251 | ! start = copy; | |
252 | ! for (i = 0; i < data->length; ++i) | |
253 | { | |
254 | ! if (names[i] == NUL || names[i] == '\n' || names[i] == '\r') | |
255 | { | |
256 | ! if (start > copy && start[-1] != NUL) | |
257 | { | |
258 | ! ++nfiles; | |
259 | ! *start++ = NUL; | |
260 | } | |
261 | } | |
262 | ! else if (names[i] == '%' && i + 2 < data->length | |
263 | ! && hexhex2nr(names + i + 1) > 0) | |
264 | { | |
265 | ! *start++ = hexhex2nr(names + i + 1); | |
266 | i += 2; | |
267 | } | |
268 | else | |
269 | ! *start++ = names[i]; | |
270 | } | |
271 | ! if (start > copy && start[-1] != NUL) | |
272 | { | |
273 | ! *start = NUL; /* last item didn't have \r or \n */ | |
274 | ! ++nfiles; | |
275 | } | |
276 | ||
277 | ! fnames = (char_u **)alloc((unsigned)(nfiles * sizeof(char_u *))); | |
278 | ! if (fnames == NULL) | |
279 | ! { | |
280 | ! vim_free(copy); | |
281 | ! return; | |
282 | ! } | |
283 | ! url = FALSE; /* Set when a non-file URL was found. */ | |
284 | ! start = copy; | |
285 | ! for (n = 0; n < nfiles; ++n) | |
286 | { | |
287 | ! if (STRNCMP(start, "file://localhost", 16) == 0) | |
288 | ! start += 16; | |
289 | ! else | |
290 | { | |
291 | ! if (STRNCMP(start, "file:", 5) != 0) | |
292 | ! url = TRUE; | |
293 | ! else | |
294 | ! { | |
295 | ! start += 5; | |
296 | ! while (start[0] == '/' && start[1] == '/') | |
297 | ! ++start; | |
298 | ! } | |
299 | } | |
300 | ! fnames[n] = vim_strsave(start); | |
301 | ! start += STRLEN(start) + 1; | |
302 | } | |
303 | ||
304 | ! /* accept */ | |
305 | ! gtk_drag_finish(context, TRUE, FALSE, time_); | |
306 | ||
307 | ! /* Special handling when all items are real files. */ | |
308 | ! if (url == FALSE) | |
309 | ! { | |
310 | ! if (nfiles == 1) | |
311 | ! { | |
312 | ! if (fnames[0] != NULL && mch_isdir(fnames[0])) | |
313 | ! { | |
314 | ! /* Handle dropping a directory on Vim. */ | |
315 | ! if (mch_chdir((char *)fnames[0]) == 0) | |
316 | ! { | |
317 | ! vim_free(fnames[0]); | |
318 | ! fnames[0] = NULL; | |
319 | ! redo_dirs = TRUE; | |
320 | ! } | |
321 | ! } | |
322 | ! } | |
323 | ! else | |
324 | ! { | |
325 | ! /* Ignore any directories */ | |
326 | ! for (i = 0; i < nfiles; ++i) | |
327 | ! { | |
328 | ! if (fnames[i] != NULL && mch_isdir(fnames[i])) | |
329 | ! { | |
330 | ! vim_free(fnames[i]); | |
331 | ! fnames[i] = NULL; | |
332 | ! } | |
333 | ! } | |
334 | ! } | |
335 | ||
336 | ! if (state & GDK_SHIFT_MASK) | |
337 | ! { | |
338 | ! /* Shift held down, change to first file's directory */ | |
339 | ! if (fnames[0] != NULL && vim_chdirfile(fnames[0]) == OK) | |
340 | ! redo_dirs = TRUE; | |
341 | ! } | |
342 | ! else | |
343 | ! { | |
344 | ! char_u dirname[MAXPATHL]; | |
345 | ! char_u *s; | |
346 | ||
347 | ! /* Shorten dropped file names. */ | |
348 | ! if (mch_dirname(dirname, MAXPATHL) == OK) | |
349 | ! for (i = 0; i < nfiles; ++i) | |
350 | ! if (fnames[i] != NULL) | |
351 | ! { | |
352 | ! s = shorten_fname(fnames[i], dirname); | |
353 | ! if (s != NULL && (s = vim_strsave(s)) != NULL) | |
354 | ! { | |
355 | ! vim_free(fnames[i]); | |
356 | ! fnames[i] = s; | |
357 | ! } | |
358 | ! } | |
359 | ! } | |
360 | ! } | |
361 | ! vim_free(copy); | |
362 | ||
363 | ! /* Handle the drop, :edit or :split to get to the file */ | |
364 | ! handle_drop(nfiles, fnames, (state & GDK_CONTROL_MASK) != 0); | |
365 | ||
366 | ! if (redo_dirs) | |
367 | ! shorten_fnames(TRUE); | |
368 | ||
369 | ! /* Update the screen display */ | |
370 | ! update_screen(NOT_VALID); | |
371 | ! # ifdef FEAT_MENU | |
372 | ! gui_update_menus(0); | |
373 | ! # endif | |
374 | ! setcursor(); | |
375 | ! out_flush(); | |
376 | ! gui_update_cursor(FALSE, FALSE); | |
377 | ! gui_mch_flush(); | |
378 | } | |
379 | ||
380 | static void | |
381 | --- 1823,1940 ---- | |
382 | * Drag aNd Drop support handlers. | |
383 | */ | |
384 | ||
385 | ! /* | |
386 | ! * Count how many items there may be and separate them with a NUL. | |
387 | ! * Apparently the items are separated with \r\n. This is not documented, | |
388 | ! * thus be careful not to go past the end. Also allow separation with | |
389 | ! * NUL characters. | |
390 | ! */ | |
391 | ! static int | |
392 | ! count_and_decode_uri_list(char_u *out, char_u *raw, int len) | |
393 | { | |
394 | ! int i; | |
395 | ! char_u *p = out; | |
396 | ! int count = 0; | |
397 | ||
398 | ! for (i = 0; i < len; ++i) | |
399 | { | |
400 | ! if (raw[i] == NUL || raw[i] == '\n' || raw[i] == '\r') | |
401 | { | |
402 | ! if (p > out && p[-1] != NUL) | |
403 | { | |
404 | ! ++count; | |
405 | ! *p++ = NUL; | |
406 | } | |
407 | } | |
408 | ! else if (raw[i] == '%' && i + 2 < len && hexhex2nr(raw + i + 1) > 0) | |
409 | { | |
410 | ! *p++ = hexhex2nr(raw + i + 1); | |
411 | i += 2; | |
412 | } | |
413 | else | |
414 | ! *p++ = raw[i]; | |
415 | } | |
416 | ! if (p > out && p[-1] != NUL) | |
417 | { | |
418 | ! *p = NUL; /* last item didn't have \r or \n */ | |
419 | ! ++count; | |
420 | } | |
421 | + return count; | |
422 | + } | |
423 | ||
424 | ! /* | |
425 | ! * Parse NUL separated "src" strings. Make it an array "outlist" form. On | |
426 | ! * this process, URI which protocol is not "file:" are removed. Return | |
427 | ! * length of array (less than "max"). | |
428 | ! */ | |
429 | ! static int | |
430 | ! filter_uri_list(char_u **outlist, int max, char_u *src) | |
431 | ! { | |
432 | ! int i, j; | |
433 | ! | |
434 | ! for (i = j = 0; i < max; ++i) | |
435 | { | |
436 | ! outlist[i] = NULL; | |
437 | ! if (STRNCMP(src, "file:", 5) == 0) | |
438 | { | |
439 | ! src += 5; | |
440 | ! if (STRNCMP(src, "//localhost", 11) == 0) | |
441 | ! src += 11; | |
442 | ! while (src[0] == '/' && src[1] == '/') | |
443 | ! ++src; | |
444 | ! outlist[j++] = vim_strsave(src); | |
445 | } | |
446 | ! src += STRLEN(src) + 1; | |
447 | } | |
448 | + return j; | |
449 | + } | |
450 | ||
451 | ! static char_u ** | |
452 | ! parse_uri_list(int *count, char_u *data, int len) | |
453 | ! { | |
454 | ! int n = 0; | |
455 | ! char_u *tmp = NULL; | |
456 | ! char_u **array = NULL;; | |
457 | ! | |
458 | ! if (data != NULL && len > 0 && (tmp = (char_u *)alloc(len + 1)) != NULL) | |
459 | ! { | |
460 | ! n = count_and_decode_uri_list(tmp, data, len); | |
461 | ! if (n > 0 && (array = (char_u **)alloc(n * sizeof(char_u *))) != NULL) | |
462 | ! n = filter_uri_list(array, n, tmp); | |
463 | ! } | |
464 | ! vim_free(tmp); | |
465 | ! *count = n; | |
466 | ! return array; | |
467 | ! } | |
468 | ||
469 | ! static void | |
470 | ! drag_handle_uri_list(GdkDragContext *context, | |
471 | ! GtkSelectionData *data, | |
472 | ! guint time_, | |
473 | ! GdkModifierType state, | |
474 | ! gint x, | |
475 | ! gint y) | |
476 | ! { | |
477 | ! char_u **fnames; | |
478 | ! int nfiles = 0; | |
479 | ||
480 | ! fnames = parse_uri_list(&nfiles, data->data, data->length); | |
481 | ||
482 | ! if (fnames != NULL && nfiles > 0) | |
483 | ! { | |
484 | ! int_u modifiers = 0; | |
485 | ||
486 | ! gtk_drag_finish(context, TRUE, FALSE, time_); /* accept */ | |
487 | ||
488 | ! if (state & GDK_SHIFT_MASK) | |
489 | ! modifiers |= MOUSE_SHIFT; | |
490 | ! if (state & GDK_CONTROL_MASK) | |
491 | ! modifiers |= MOUSE_CTRL; | |
492 | ! if (state & GDK_MOD1_MASK) | |
493 | ! modifiers |= MOUSE_ALT; | |
494 | ||
495 | ! gui_handle_drop(x, y, modifiers, fnames, nfiles); | |
496 | ! } | |
497 | } | |
498 | ||
499 | static void | |
500 | *************** | |
501 | *** 2071,2077 **** | |
502 | ||
503 | /* Not sure about the role of "text/plain" here... */ | |
504 | if (info == (guint)TARGET_TEXT_URI_LIST) | |
505 | ! drag_handle_uri_list(context, data, time_, state); | |
506 | else | |
507 | drag_handle_text(context, data, time_, state); | |
508 | ||
509 | --- 2030,2036 ---- | |
510 | ||
511 | /* Not sure about the role of "text/plain" here... */ | |
512 | if (info == (guint)TARGET_TEXT_URI_LIST) | |
513 | ! drag_handle_uri_list(context, data, time_, state, x, y); | |
514 | else | |
515 | drag_handle_text(context, data, time_, state); | |
516 | ||
517 | *** ../vim-6.2.210/src/gui_mac.c Sun Jan 25 20:42:15 2004 | |
518 | --- src/gui_mac.c Thu Jan 22 10:44:31 2004 | |
519 | *************** | |
520 | *** 2653,2658 **** | |
521 | --- 2653,2712 ---- | |
522 | } | |
523 | #endif | |
524 | ||
525 | + static OSErr | |
526 | + receiveHandler(WindowRef theWindow, void* handlerRefCon, DragRef theDrag) | |
527 | + { | |
528 | + int x, y; | |
529 | + int_u modifiers; | |
530 | + char_u **fnames = NULL; | |
531 | + int count; | |
532 | + int i, j; | |
533 | + | |
534 | + /* Get drop position, modifiers and count of items */ | |
535 | + { | |
536 | + Point point; | |
537 | + SInt16 mouseUpModifiers; | |
538 | + UInt16 countItem; | |
539 | + | |
540 | + GetDragMouse(theDrag, &point, NULL); | |
541 | + GlobalToLocal(&point); | |
542 | + x = point.h; | |
543 | + y = point.v; | |
544 | + GetDragModifiers(theDrag, NULL, NULL, &mouseUpModifiers); | |
545 | + modifiers = EventModifiers2VimMouseModifiers(mouseUpModifiers); | |
546 | + CountDragItems(theDrag, &countItem); | |
547 | + count = countItem; | |
548 | + } | |
549 | + | |
550 | + fnames = (char_u **)alloc(count * sizeof(char_u *)); | |
551 | + if (fnames == NULL) | |
552 | + return dragNotAcceptedErr; | |
553 | + | |
554 | + /* Get file names dropped */ | |
555 | + for (i = j = 0; i < count; ++i) | |
556 | + { | |
557 | + DragItemRef item; | |
558 | + OSErr err; | |
559 | + Size size; | |
560 | + FlavorType type = flavorTypeHFS; | |
561 | + HFSFlavor hfsFlavor; | |
562 | + | |
563 | + fnames[i] = NULL; | |
564 | + GetDragItemReferenceNumber(theDrag, i + 1, &item); | |
565 | + err = GetFlavorDataSize(theDrag, item, type, &size); | |
566 | + if (err != noErr || size > sizeof(hfsFlavor)) | |
567 | + continue; | |
568 | + err = GetFlavorData(theDrag, item, type, &hfsFlavor, &size, 0); | |
569 | + if (err != noErr) | |
570 | + continue; | |
571 | + fnames[j++] = FullPathFromFSSpec_save(hfsFlavor.fileSpec); | |
572 | + } | |
573 | + count = j; | |
574 | + | |
575 | + gui_handle_drop(x, y, modifiers, fnames, count); | |
576 | + return noErr; | |
577 | + } | |
578 | + | |
579 | /* | |
580 | * Initialise the GUI. Create all the windows, set up all the call-backs | |
581 | * etc. | |
582 | *************** | |
583 | *** 2721,2726 **** | |
584 | --- 2775,2782 ---- | |
585 | ||
586 | gui.VimWindow = NewCWindow(nil, &windRect, "\pgVim on Macintosh", true, documentProc, | |
587 | (WindowPtr) -1L, false, 0); | |
588 | + InstallReceiveHandler((DragReceiveHandlerUPP)receiveHandler, | |
589 | + gui.VimWindow, NULL); | |
590 | #ifdef USE_CARBONIZED | |
591 | SetPortWindowPort ( gui.VimWindow ); | |
592 | #else | |
593 | *** ../vim-6.2.210/src/gui_w48.c Sun Jan 25 20:24:03 2004 | |
594 | --- src/gui_w48.c Wed Jan 21 16:11:49 2004 | |
595 | *************** | |
596 | *** 2841,2924 **** | |
597 | char szFile[BUFPATHLEN]; | |
598 | UINT cFiles = DragQueryFile(hDrop, DRAGQVAL, szFile, BUFPATHLEN); | |
599 | UINT i; | |
600 | - char_u *fname; | |
601 | char_u **fnames; | |
602 | char_u redo_dirs = FALSE; | |
603 | ||
604 | /* TRACE("_OnDropFiles: %d files dropped\n", cFiles); */ | |
605 | ||
606 | # ifdef FEAT_VISUAL | |
607 | reset_VIsual(); | |
608 | # endif | |
609 | ||
610 | fnames = (char_u **)alloc(cFiles * sizeof(char_u *)); | |
611 | ||
612 | ! for (i = 0; i < cFiles; ++i) | |
613 | ! { | |
614 | ! DragQueryFile(hDrop, i, szFile, BUFPATHLEN); | |
615 | ! | |
616 | ! mch_dirname(IObuff, IOSIZE); | |
617 | ! fname = shorten_fname(szFile, IObuff); | |
618 | ! if (fname == NULL) | |
619 | ! fname = szFile; | |
620 | ! fnames[i] = vim_strsave(fname); | |
621 | ! } | |
622 | ! DragFinish(hDrop); | |
623 | ! | |
624 | ! /* | |
625 | ! * When the cursor is at the command line, add the file names to the | |
626 | ! * command line, don't edit the files. | |
627 | ! */ | |
628 | ! if (State & CMDLINE) | |
629 | ! { | |
630 | for (i = 0; i < cFiles; ++i) | |
631 | { | |
632 | ! if (fnames[i] != NULL) | |
633 | ! { | |
634 | ! if (i > 0) | |
635 | ! add_to_input_buf(" ", 1); | |
636 | ! add_to_input_buf(fnames[i], (int)STRLEN(fnames[i])); | |
637 | ! } | |
638 | ! } | |
639 | ! } | |
640 | ! else | |
641 | ! { | |
642 | ! /* | |
643 | ! * Handle dropping a directory on Vim. | |
644 | ! * Change to that directory and don't open any file. | |
645 | ! */ | |
646 | ! if (cFiles == 1 && mch_isdir(fnames[0])) | |
647 | ! { | |
648 | ! if (mch_chdir(fnames[0]) == 0) | |
649 | ! { | |
650 | ! msg_str((char_u *)":cd %s", fnames[0]); | |
651 | ! vim_free(fnames[0]); | |
652 | ! fnames[0] = NULL; | |
653 | ! redo_dirs = TRUE; | |
654 | ! } | |
655 | } | |
656 | ||
657 | ! if (fnames[0] != NULL) | |
658 | ! { | |
659 | ! /* If Shift held down, change to first file's directory */ | |
660 | ! if (GetKeyState(VK_SHIFT) & 0x8000) | |
661 | ! if (vim_chdirfile(fnames[0]) == OK) | |
662 | ! redo_dirs = TRUE; | |
663 | ! | |
664 | ! /* Handle the drop, :edit or :split to get to the file */ | |
665 | ! handle_drop(cFiles, fnames, | |
666 | ! ((GetKeyState(VK_CONTROL) & 0x8000) != 0)); | |
667 | ! } | |
668 | ||
669 | ! if (redo_dirs) | |
670 | ! shorten_fnames(TRUE); | |
671 | ||
672 | ! /* Update the screen display */ | |
673 | ! update_screen(NOT_VALID); | |
674 | ! setcursor(); | |
675 | ! out_flush(); | |
676 | } | |
677 | - s_need_activate = TRUE; | |
678 | #endif | |
679 | } | |
680 | ||
681 | --- 2841,2885 ---- | |
682 | char szFile[BUFPATHLEN]; | |
683 | UINT cFiles = DragQueryFile(hDrop, DRAGQVAL, szFile, BUFPATHLEN); | |
684 | UINT i; | |
685 | char_u **fnames; | |
686 | char_u redo_dirs = FALSE; | |
687 | + POINT pt; | |
688 | + int_u modifiers = 0; | |
689 | ||
690 | /* TRACE("_OnDropFiles: %d files dropped\n", cFiles); */ | |
691 | ||
692 | + /* Obtain dropped position */ | |
693 | + DragQueryPoint(hDrop, &pt); | |
694 | + MapWindowPoints(s_hwnd, s_textArea, &pt, 1); | |
695 | + | |
696 | # ifdef FEAT_VISUAL | |
697 | reset_VIsual(); | |
698 | # endif | |
699 | ||
700 | fnames = (char_u **)alloc(cFiles * sizeof(char_u *)); | |
701 | ||
702 | ! if (fnames != NULL) | |
703 | for (i = 0; i < cFiles; ++i) | |
704 | { | |
705 | ! DragQueryFile(hDrop, i, szFile, BUFPATHLEN); | |
706 | ! fnames[i] = vim_strsave(szFile); | |
707 | } | |
708 | ||
709 | ! DragFinish(hDrop); | |
710 | ! | |
711 | ! if (fnames != NULL) | |
712 | ! { | |
713 | ! if ((GetKeyState(VK_SHIFT) & 0x8000) != 0) | |
714 | ! modifiers |= MOUSE_SHIFT; | |
715 | ! if ((GetKeyState(VK_CONTROL) & 0x8000) != 0) | |
716 | ! modifiers |= MOUSE_CTRL; | |
717 | ! if ((GetKeyState(VK_MENU) & 0x8000) != 0) | |
718 | ! modifiers |= MOUSE_ALT; | |
719 | ||
720 | ! gui_handle_drop(pt.x, pt.y, modifiers, fnames, cFiles); | |
721 | ||
722 | ! s_need_activate = TRUE; | |
723 | } | |
724 | #endif | |
725 | } | |
726 | ||
727 | *** ../vim-6.2.210/src/proto/fileio.pro Sun Jun 1 12:26:09 2003 | |
728 | --- src/proto/fileio.pro Wed Jan 21 15:32:29 2004 | |
729 | *************** | |
730 | *** 5,10 **** | |
731 | --- 5,11 ---- | |
732 | int buf_write __ARGS((buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_T end, exarg_T *eap, int append, int forceit, int reset_changed, int filtering)); | |
733 | char_u *shorten_fname __ARGS((char_u *full_path, char_u *dir_name)); | |
734 | void shorten_fnames __ARGS((int force)); | |
735 | + void shorten_filenames __ARGS((char_u **fnames, int count)); | |
736 | char_u *modname __ARGS((char_u *fname, char_u *ext, int prepend_dot)); | |
737 | char_u *buf_modname __ARGS((int shortname, char_u *fname, char_u *ext, int prepend_dot)); | |
738 | int vim_fgets __ARGS((char_u *buf, int size, FILE *fp)); | |
739 | *** ../vim-6.2.210/src/proto/gui.pro Sun Jun 1 12:26:24 2003 | |
740 | --- src/proto/gui.pro Wed Jan 21 15:32:24 2004 | |
741 | *************** | |
742 | *** 57,60 **** | |
743 | --- 57,61 ---- | |
744 | void gui_update_screen __ARGS((void)); | |
745 | char_u *get_find_dialog_text __ARGS((char_u *arg, int *wwordp, int *mcasep)); | |
746 | int gui_do_findrepl __ARGS((int flags, char_u *find_text, char_u *repl_text, int down)); | |
747 | + void gui_handle_drop __ARGS((int x, int y, int_u modifiers, char_u **fnames, int count)); | |
748 | /* vim: set ft=c : */ | |
749 | *** ../vim-6.2.210/src/version.c Sun Jan 25 20:42:15 2004 | |
750 | --- src/version.c Sun Jan 25 20:44:30 2004 | |
751 | *************** | |
752 | *** 639,640 **** | |
753 | --- 639,642 ---- | |
754 | { /* Add new patch number below this line */ | |
755 | + /**/ | |
756 | + 211, | |
757 | /**/ | |
758 | ||
759 | -- | |
760 | NEIL INNES PLAYED: THE FIRST SELF-DESTRUCTIVE MONK, ROBIN'S LEAST FAVORITE | |
761 | MINSTREL, THE PAGE CRUSHED BY A RABBIT, THE OWNER OF A DUCK | |
762 | "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD | |
763 | ||
764 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
765 | /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
766 | \\\ Project leader for A-A-P -- http://www.A-A-P.org /// | |
767 | \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html /// |