Mirror of the Vim source from https://github.com/vim/vim
Revision | c773cb978acfd216004c871e883d2b31cd4cc0bf (tree) |
---|---|
Zeit | 2005-07-26 05:46:57 |
Autor | vimboss |
Commiter | vimboss |
updated for version 7.0116
@@ -1,4 +1,4 @@ | ||
1 | -*quickfix.txt* For Vim version 7.0aa. Last change: 2005 May 20 | |
1 | +*quickfix.txt* For Vim version 7.0aa. Last change: 2005 Jul 25 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -334,6 +334,8 @@ | ||
334 | 334 | Examples: > |
335 | 335 | :vimgrep /an error/ *.c |
336 | 336 | :vimgrep /\<FileName\>/ *.h include/* |
337 | + :vimgrep /myfunc/ **/*.c | |
338 | +< For the use of "**" see |starstar-wildcard|. | |
337 | 339 | |
338 | 340 | :vim[grep][!] {pattern} {file} ... |
339 | 341 | Like above, but instead of enclosing the pattern in a |
@@ -1,4 +1,4 @@ | ||
1 | -*todo.txt* For Vim version 7.0aa. Last change: 2005 Jul 24 | |
1 | +*todo.txt* For Vim version 7.0aa. Last change: 2005 Jul 25 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -52,18 +52,12 @@ | ||
52 | 52 | - Win32: tearoff menu window should have a scrollbar when it's taller than |
53 | 53 | the screen. |
54 | 54 | - mblen(NULL, 0) also in Vim 6.3? |
55 | - | |
56 | -Win32: Crash when pasting Simplified Chinese in utf-8. (rainux, 2005 June 20) | |
55 | +- Win32: Crash when pasting Simplified Chinese in utf-8. (rainux, 2005 June | |
56 | + 20) | |
57 | 57 | |
58 | 58 | |
59 | 59 | PLANNED FOR VERSION 7.0: |
60 | 60 | |
61 | -- REFACTORING: | |
62 | - Improve the interface between the generic GUI code and the system-specific | |
63 | - code. Generic code handles text window with scrollbars, system-specific | |
64 | - code menu, toolbar, etc. | |
65 | -- Support using "**" in filename for ":next", ":vimgrep", etc., so that a | |
66 | - directory tree can be searched. | |
67 | 61 | - Store messages to allow SCROLLING BACK for all commands. And other "less" |
68 | 62 | like commands. |
69 | 63 | - "INTELLISENSE". First cleanup the Insert-mode completion. |
@@ -313,6 +307,7 @@ | ||
313 | 307 | (2003 May 13) |
314 | 308 | raisewin() raise gvim window (see HierAssist patch for |
315 | 309 | Tcl implementation ~/vim/HierAssist/ ) |
310 | + 7 Make globpath() also work with upwards search. (Brian Medley) | |
316 | 311 | 7 Add patch from Benoit Cerrina to integrate Vim and Perl functions |
317 | 312 | better. Now also works for Ruby (2001 Nov 10) |
318 | 313 | - Patch from Herculano de Lima Einloft Neto for better formatting of the |
@@ -1573,7 +1568,6 @@ | ||
1573 | 1568 | Alternative: Support packages. {package-name}:{function-name}(). |
1574 | 1569 | Packages are loaded automatically when first used, from |
1575 | 1570 | $VIMRUNTIME/packages (or use a search path). |
1576 | -7 Make globpath() also work with "**" and upwards search. (Brian Medley) | |
1577 | 1571 | 7 Add the markclear() function to delete a mark in another buffer. Charles |
1578 | 1572 | Campbell (2004 Jan 9) |
1579 | 1573 | http://mysite.verizon.net/astronaut/vim/index.html#Patch |
@@ -3156,7 +3150,6 @@ | ||
3156 | 3150 | 9 Support ACLs on more systems. |
3157 | 3151 | 7 Add ModeMsgVisual, ModeMsgInsert, etc. so that each mode message can be |
3158 | 3152 | highlighted differently. |
3159 | -8 Allow using "**" as a wildcard in commands like ":next" and ":args". | |
3160 | 3153 | 7 Add a message area for the user. Set some option to reserve space (above |
3161 | 3154 | the command line?). Use an ":echouser" command to display the message |
3162 | 3155 | (truncated to fit in the space). |
@@ -1,4 +1,4 @@ | ||
1 | -*version7.txt* For Vim version 7.0aa. Last change: 2005 Jul 21 | |
1 | +*version7.txt* For Vim version 7.0aa. Last change: 2005 Jul 25 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -222,6 +222,10 @@ | ||
222 | 222 | If you want to use the search results in a script you can use the |
223 | 223 | |getqflist()| function. |
224 | 224 | |
225 | +To search in files in various directories the "**" pattern can be used. It | |
226 | +expands into an arbitrary depth of directories. "**" can be used in all | |
227 | +places where file names are expanded, thus also with |:next| and |:args|. | |
228 | + | |
225 | 229 | |
226 | 230 | POSIX compatibility *new-posix* |
227 | 231 | ------------------- |
@@ -614,7 +618,7 @@ | ||
614 | 618 | ":redir => variable" and ":redir =>> variable" write or append to a variable. |
615 | 619 | (Yegappan Lakshmanan) |:redir| |
616 | 620 | |
617 | -":redir @{a-z}>>" appends to register a to z. | |
621 | +":redir @{a-z}>>" appends to register a to z. (Yegappan Lakshmanan) | |
618 | 622 | |
619 | 623 | The 'verbosefile' option can be used to log messages in a file. Verbose |
620 | 624 | messages are not displayed then. The "-V{filename}" argument can be used to |
@@ -693,11 +697,15 @@ | ||
693 | 697 | |
694 | 698 | Added the "customlist" completion argument to a user-defined command. The |
695 | 699 | user-defined completion function should return the completion candidates as a |
696 | -Vim List and the returned results are not filtered by Vim. | |
700 | +Vim List and the returned results are not filtered by Vim. (Yegappan | |
701 | +Lakshmanan) | |
697 | 702 | |
698 | 703 | Win32: Balloons can have multiple lines if common controls supports it. |
699 | 704 | (Sergey Khorev) |
700 | 705 | |
706 | +The 's' flag is added to the search() and searchpair() function to set the | |
707 | +' mark if the cursor is moved. (Yegappan Lakshmanan) | |
708 | + | |
701 | 709 | ============================================================================== |
702 | 710 | COMPILE TIME CHANGES *compile-changes-7* |
703 | 711 |
@@ -720,6 +728,15 @@ | ||
720 | 728 | allocated by X11 library functions and the memory allocated in alloc_cmdbuff() |
721 | 729 | to store the ":quit" command. |
722 | 730 | |
731 | +Moved the code for printing to src/hardcopy.c. | |
732 | + | |
733 | +Moved some code from main() to separate functions to make it easier to see | |
734 | +what is being done. Use a structure to avoid a lot of arguments to the | |
735 | +functions. | |
736 | + | |
737 | +Moved unix_expandpath() to misc1.c, so that it can also be used by os_mac.c | |
738 | +without copying the code. | |
739 | + | |
723 | 740 | ============================================================================== |
724 | 741 | BUG FIXES *bug-fixes-7* |
725 | 742 |
@@ -12724,6 +12724,7 @@ | ||
12724 | 12724 | #define SP_NOMOVE 1 /* don't move cursor */ |
12725 | 12725 | #define SP_REPEAT 2 /* repeat to find outer pair */ |
12726 | 12726 | #define SP_RETCOUNT 4 /* return matchcount */ |
12727 | +#define SP_SETPCMARK 8 /* set previous context mark */ | |
12727 | 12728 | |
12728 | 12729 | static int get_search_arg __ARGS((typval_T *varp, int *flagsp)); |
12729 | 12730 |
@@ -12761,6 +12762,7 @@ | ||
12761 | 12762 | case 'n': mask = SP_NOMOVE; break; |
12762 | 12763 | case 'r': mask = SP_REPEAT; break; |
12763 | 12764 | case 'm': mask = SP_RETCOUNT; break; |
12765 | + case 's': mask = SP_SETPCMARK; break; | |
12764 | 12766 | } |
12765 | 12767 | if (mask == 0) |
12766 | 12768 | { |
@@ -12799,7 +12801,14 @@ | ||
12799 | 12801 | dir = get_search_arg(&argvars[1], &flags); /* may set p_ws */ |
12800 | 12802 | if (dir == 0) |
12801 | 12803 | goto theend; |
12802 | - if ((flags & ~SP_NOMOVE) != 0) | |
12804 | + /* | |
12805 | + * This function accepts only SP_NOMOVE and SP_SETPCMARK flags. | |
12806 | + * Check to make sure only those flags are set. | |
12807 | + * Also, Only the SP_NOMOVE or the SP_SETPCMARK flag can be set. Both | |
12808 | + * flags cannot be set. Check for that condition also. | |
12809 | + */ | |
12810 | + if (((flags & ~(SP_NOMOVE | SP_SETPCMARK)) != 0) || | |
12811 | + ((flags & SP_NOMOVE) && (flags & SP_SETPCMARK))) | |
12803 | 12812 | { |
12804 | 12813 | EMSG2(_(e_invarg2), get_tv_string(&argvars[1])); |
12805 | 12814 | goto theend; |
@@ -12810,6 +12819,8 @@ | ||
12810 | 12819 | SEARCH_KEEP, RE_SEARCH) != FAIL) |
12811 | 12820 | { |
12812 | 12821 | rettv->vval.v_number = pos.lnum; |
12822 | + if (flags & SP_SETPCMARK) | |
12823 | + setpcmark(); | |
12813 | 12824 | curwin->w_cursor = pos; |
12814 | 12825 | /* "/$" will put the cursor after the end of the line, may need to |
12815 | 12826 | * correct that here */ |
@@ -12853,6 +12864,14 @@ | ||
12853 | 12864 | dir = get_search_arg(&argvars[3], &flags); /* may set p_ws */ |
12854 | 12865 | if (dir == 0) |
12855 | 12866 | goto theend; |
12867 | + /* | |
12868 | + * Only one of the SP_NOMOVE or SP_SETPCMARK flags can be set. | |
12869 | + */ | |
12870 | + if ((flags & SP_NOMOVE) && (flags & SP_SETPCMARK)) | |
12871 | + { | |
12872 | + EMSG2(_(e_invarg2), get_tv_string(&argvars[1])); | |
12873 | + goto theend; | |
12874 | + } | |
12856 | 12875 | |
12857 | 12876 | /* Optional fifth argument: skip expresion */ |
12858 | 12877 | if (argvars[3].v_type == VAR_UNKNOWN |
@@ -12980,6 +12999,8 @@ | ||
12980 | 12999 | ++retval; |
12981 | 13000 | else |
12982 | 13001 | retval = pos.lnum; |
13002 | + if (flags & SP_SETPCMARK) | |
13003 | + setpcmark(); | |
12983 | 13004 | curwin->w_cursor = pos; |
12984 | 13005 | if (!(flags & SP_REPEAT)) |
12985 | 13006 | break; |
@@ -5369,13 +5369,15 @@ | ||
5369 | 5369 | char_u *s, *d; |
5370 | 5370 | int i; |
5371 | 5371 | static char *(mtable[]) = {"*", "g*", "[*", "]*", ":*", |
5372 | - "/*", "/\\*", "\"*", "/\\(\\)", | |
5372 | + "/*", "/\\*", "\"*", "**", | |
5373 | + "/\\(\\)", | |
5373 | 5374 | "?", ":?", "?<CR>", "g?", "g?g?", "g??", "z?", |
5374 | 5375 | "/\\?", "/\\z(\\)", "\\=", ":s\\=", |
5375 | 5376 | "[count]", "[quotex]", "[range]", |
5376 | 5377 | "[pattern]", "\\|", "\\%$"}; |
5377 | 5378 | static char *(rtable[]) = {"star", "gstar", "[star", "]star", ":star", |
5378 | - "/star", "/\\\\star", "quotestar", "/\\\\(\\\\)", | |
5379 | + "/star", "/\\\\star", "quotestar", "starstar", | |
5380 | + "/\\\\(\\\\)", | |
5379 | 5381 | "?", ":?", "?<CR>", "g?", "g?g?", "g??", "z?", |
5380 | 5382 | "/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=", |
5381 | 5383 | "\\[count]", "\\[quotex]", "\\[range]", |
@@ -4066,8 +4066,11 @@ | ||
4066 | 4066 | } |
4067 | 4067 | #endif /* HAVE_GTK2 */ |
4068 | 4068 | |
4069 | +/* | |
4070 | + * Adjust gui.char_height (after 'linespace' was changed). | |
4071 | + */ | |
4069 | 4072 | int |
4070 | -gui_mch_adjust_charsize(void) | |
4073 | +gui_mch_adjust_charheight(void) | |
4071 | 4074 | { |
4072 | 4075 | #ifdef HAVE_GTK2 |
4073 | 4076 | PangoFontMetrics *metrics; |
@@ -4082,14 +4085,14 @@ | ||
4082 | 4085 | pango_font_metrics_unref(metrics); |
4083 | 4086 | |
4084 | 4087 | gui.char_height = (ascent + descent + PANGO_SCALE - 1) / PANGO_SCALE |
4085 | - + p_linespace; | |
4088 | + + p_linespace; | |
4086 | 4089 | /* LINTED: avoid warning: bitwise operation on signed value */ |
4087 | 4090 | gui.char_ascent = PANGO_PIXELS(ascent + p_linespace * PANGO_SCALE / 2); |
4088 | 4091 | |
4089 | 4092 | #else /* !HAVE_GTK2 */ |
4090 | 4093 | |
4091 | 4094 | gui.char_height = gui.current_font->ascent + gui.current_font->descent |
4092 | - + p_linespace; | |
4095 | + + p_linespace; | |
4093 | 4096 | gui.char_ascent = gui.current_font->ascent + p_linespace / 2; |
4094 | 4097 | |
4095 | 4098 | #endif /* !HAVE_GTK2 */ |
@@ -4553,7 +4556,7 @@ | ||
4553 | 4556 | if (gui.char_width <= 0) |
4554 | 4557 | gui.char_width = 8; |
4555 | 4558 | |
4556 | - gui_mch_adjust_charsize(); | |
4559 | + gui_mch_adjust_charheight(); | |
4557 | 4560 | |
4558 | 4561 | /* Set the fontname, which will be used for information purposes */ |
4559 | 4562 | hl_set_font_name(font_name); |
@@ -632,15 +632,14 @@ | ||
632 | 632 | #if (defined(FEAT_NETBEANS_INTG) || defined(FEAT_SUN_WORKSHOP)) \ |
633 | 633 | || defined(PROTO) |
634 | 634 | /* |
635 | - * This function fills in the XRectangle object with the current | |
636 | - * x,y coordinates and height, width so that an XtVaSetValues to | |
637 | - * the same shell of those resources will restore the window to its | |
638 | - * formar position and dimensions. | |
635 | + * This function fills in the XRectangle object with the current x,y | |
636 | + * coordinates and height, width so that an XtVaSetValues to the same shell of | |
637 | + * those resources will restore the window to its formar position and | |
638 | + * dimensions. | |
639 | 639 | * |
640 | - * Note: This function may fail, in which case the XRectangle will | |
641 | - * be unchanged. Be sure to have the XRectangle set with the | |
642 | - * proper values for a failed condition prior to calling this | |
643 | - * function. | |
640 | + * Note: This function may fail, in which case the XRectangle will be | |
641 | + * unchanged. Be sure to have the XRectangle set with the proper values for a | |
642 | + * failed condition prior to calling this function. | |
644 | 643 | */ |
645 | 644 | static void |
646 | 645 | shellRectangle(Widget shell, XRectangle *r) |
@@ -1807,7 +1806,7 @@ | ||
1807 | 1806 | } |
1808 | 1807 | |
1809 | 1808 | /* |
1810 | - * Allow 10 pixels for horizontal borders, 30 for vertical borders. | |
1809 | + * Allow 10 pixels for horizontal borders, 'guiheadroom' for vertical borders. | |
1811 | 1810 | * Is there no way in X to find out how wide the borders really are? |
1812 | 1811 | */ |
1813 | 1812 | void |
@@ -2019,8 +2018,11 @@ | ||
2019 | 2018 | } |
2020 | 2019 | #endif |
2021 | 2020 | |
2021 | +/* | |
2022 | + * Adjust gui.char_height (after 'linespace' was changed). | |
2023 | + */ | |
2022 | 2024 | int |
2023 | -gui_mch_adjust_charsize() | |
2025 | +gui_mch_adjust_charheight() | |
2024 | 2026 | { |
2025 | 2027 | #ifdef FEAT_XFONTSET |
2026 | 2028 | if (gui.fontset != NOFONTSET) |
@@ -2076,24 +2078,6 @@ | ||
2076 | 2078 | } |
2077 | 2079 | #endif |
2078 | 2080 | |
2079 | -#if 0 /* not used */ | |
2080 | -/* | |
2081 | - * Return TRUE if the two fonts given are equivalent. | |
2082 | - */ | |
2083 | - int | |
2084 | -gui_mch_same_font(f1, f2) | |
2085 | - GuiFont f1; | |
2086 | - GuiFont f2; | |
2087 | -{ | |
2088 | -#ifdef FEAT_XFONTSET | |
2089 | - if (gui.fontset != NULL) | |
2090 | - return f1 == f2; | |
2091 | - else | |
2092 | -#endif | |
2093 | - return ((XFontStruct *)f1)->fid == ((XFontStruct *)f2)->fid; | |
2094 | -} | |
2095 | -#endif | |
2096 | - | |
2097 | 2081 | /* |
2098 | 2082 | * If a font is not going to be used, free its structure. |
2099 | 2083 | */ |
@@ -39,7 +39,6 @@ | ||
39 | 39 | char **argv; |
40 | 40 | |
41 | 41 | int evim_mode; /* started as "evim" */ |
42 | - int bin_mode; /* -b argument used */ | |
43 | 42 | char_u *use_vimrc; /* vimrc from -u argument */ |
44 | 43 | |
45 | 44 | int n_commands; /* no. of commands from + or -c */ |
@@ -367,15 +366,6 @@ | ||
367 | 366 | # endif |
368 | 367 | #endif |
369 | 368 | |
370 | - /* "-b" argument used. Check before expanding file names, because for | |
371 | - * Win32 this makes us edit a shortcut file itself, instead of the file it | |
372 | - * links to. */ | |
373 | - if (params.bin_mode) | |
374 | - { | |
375 | - set_options_bin(curbuf->b_p_bin, 1, 0); | |
376 | - curbuf->b_p_bin = 1; /* binary file I/O */ | |
377 | - } | |
378 | - | |
379 | 369 | if (GARGCOUNT > 0) |
380 | 370 | { |
381 | 371 | #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE) |
@@ -420,8 +410,13 @@ | ||
420 | 410 | TIME_MSG("expanding arguments"); |
421 | 411 | |
422 | 412 | #ifdef FEAT_DIFF |
423 | - if (params.diff_mode && params.window_count == -1) | |
424 | - params.window_count = 0; /* open up to 3 files in a window */ | |
413 | + if (params.diff_mode) | |
414 | + { | |
415 | + if (params.window_count == -1) | |
416 | + params.window_count = 0; /* open up to 3 windows */ | |
417 | + if (params.vert_windows == MAYBE) | |
418 | + params.vert_windows = TRUE; /* use vertical split */ | |
419 | + } | |
425 | 420 | #endif |
426 | 421 | |
427 | 422 | /* Don't redraw until much later. */ |
@@ -1453,7 +1448,7 @@ | ||
1453 | 1448 | int had_minmin = FALSE; /* found "--" argument */ |
1454 | 1449 | int want_argument; /* option argument with argument */ |
1455 | 1450 | int c; |
1456 | - char_u *p; | |
1451 | + char_u *p = NULL; | |
1457 | 1452 | long n; |
1458 | 1453 | |
1459 | 1454 | --argc; |
@@ -1597,7 +1592,11 @@ | ||
1597 | 1592 | break; |
1598 | 1593 | |
1599 | 1594 | case 'b': /* "-b" binary mode */ |
1600 | - parmp->bin_mode = TRUE; /* postpone to after reading .exrc files */ | |
1595 | + /* Needs to be effective before expanding file names, because | |
1596 | + * for Win32 this makes us edit a shortcut file itself, | |
1597 | + * instead of the file it links to. */ | |
1598 | + set_options_bin(curbuf->b_p_bin, 1, 0); | |
1599 | + curbuf->b_p_bin = 1; /* binary file I/O */ | |
1601 | 1600 | break; |
1602 | 1601 | |
1603 | 1602 | case 'C': /* "-C" Compatible */ |
@@ -1691,7 +1690,8 @@ | ||
1691 | 1690 | case 'o': /* "-o[N]" open N horizontal split windows */ |
1692 | 1691 | #ifdef FEAT_WINDOWS |
1693 | 1692 | /* default is 0: open window for each file */ |
1694 | - parmp->window_count = get_number_arg((char_u *)argv[0], &argv_idx, 0); | |
1693 | + parmp->window_count = get_number_arg((char_u *)argv[0], | |
1694 | + &argv_idx, 0); | |
1695 | 1695 | parmp->vert_windows = FALSE; |
1696 | 1696 | #endif |
1697 | 1697 | break; |
@@ -1699,7 +1699,8 @@ | ||
1699 | 1699 | case 'O': /* "-O[N]" open N vertical split windows */ |
1700 | 1700 | #if defined(FEAT_VERTSPLIT) && defined(FEAT_WINDOWS) |
1701 | 1701 | /* default is 0: open window for each file */ |
1702 | - parmp->window_count = get_number_arg((char_u *)argv[0], &argv_idx, 0); | |
1702 | + parmp->window_count = get_number_arg((char_u *)argv[0], | |
1703 | + &argv_idx, 0); | |
1703 | 1704 | parmp->vert_windows = TRUE; |
1704 | 1705 | #endif |
1705 | 1706 | break; |
@@ -1817,7 +1818,8 @@ | ||
1817 | 1818 | { |
1818 | 1819 | if (parmp->n_commands >= MAX_ARG_CMDS) |
1819 | 1820 | mainerr(ME_EXTRA_CMD, NULL); |
1820 | - parmp->commands[parmp->n_commands++] = (char_u *)argv[0] + argv_idx; | |
1821 | + parmp->commands[parmp->n_commands++] = (char_u *)argv[0] | |
1822 | + + argv_idx; | |
1821 | 1823 | argv_idx = -1; |
1822 | 1824 | break; |
1823 | 1825 | } |
@@ -1890,13 +1892,15 @@ | ||
1890 | 1892 | parmp->commands[parmp->n_commands++] = p; |
1891 | 1893 | } |
1892 | 1894 | else |
1893 | - parmp->commands[parmp->n_commands++] = (char_u *)argv[0]; | |
1895 | + parmp->commands[parmp->n_commands++] = | |
1896 | + (char_u *)argv[0]; | |
1894 | 1897 | break; |
1895 | 1898 | |
1896 | 1899 | case '-': /* "--cmd {command}" execute command */ |
1897 | 1900 | if (parmp->n_pre_commands >= MAX_ARG_CMDS) |
1898 | 1901 | mainerr(ME_EXTRA_CMD, NULL); |
1899 | - parmp->pre_commands[parmp->n_pre_commands++] = (char_u *)argv[0]; | |
1902 | + parmp->pre_commands[parmp->n_pre_commands++] = | |
1903 | + (char_u *)argv[0]; | |
1900 | 1904 | break; |
1901 | 1905 | |
1902 | 1906 | /* case 'd': -d {device} is handled in mch_check_win() for the |
@@ -2052,7 +2056,7 @@ | ||
2052 | 2056 | #endif |
2053 | 2057 | alist_add(&global_alist, p, |
2054 | 2058 | #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE) |
2055 | - parmp->literal ? 2 : 0 /* add buffer number after expanding */ | |
2059 | + parmp->literal ? 2 : 0 /* add buffer nr after exp. */ | |
2056 | 2060 | #else |
2057 | 2061 | 2 /* add buffer number now and use curbuf */ |
2058 | 2062 | #endif |
@@ -2425,7 +2429,8 @@ | ||
2425 | 2429 | */ |
2426 | 2430 | if (parmp->use_vimrc != NULL) |
2427 | 2431 | { |
2428 | - if (STRCMP(parmp->use_vimrc, "NONE") == 0 || STRCMP(parmp->use_vimrc, "NORC") == 0) | |
2432 | + if (STRCMP(parmp->use_vimrc, "NONE") == 0 | |
2433 | + || STRCMP(parmp->use_vimrc, "NORC") == 0) | |
2429 | 2434 | { |
2430 | 2435 | #ifdef FEAT_GUI |
2431 | 2436 | if (use_gvimrc == NULL) /* don't load gvimrc either */ |
@@ -8158,24 +8158,33 @@ | ||
8158 | 8158 | # endif |
8159 | 8159 | |
8160 | 8160 | /* |
8161 | - * Recursively build up a list of files in "gap" matching the first wildcard | |
8162 | - * in `path'. Called by expand_wildcards(). | |
8161 | + * Recursively expand one path component into all matching files and/or | |
8162 | + * directories. Adds matches to "gap". Handles "*", "?", "[a-z]", "**", etc. | |
8163 | 8163 | * Return the number of matches found. |
8164 | 8164 | * "path" has backslashes before chars that are not to be expanded, starting |
8165 | 8165 | * at "path[wildoff]". |
8166 | + * Return the number of matches found. | |
8167 | + * NOTE: much of this is identical to unix_expandpath(), keep in sync! | |
8166 | 8168 | */ |
8167 | 8169 | static int |
8168 | 8170 | dos_expandpath( |
8169 | 8171 | garray_T *gap, |
8170 | 8172 | char_u *path, |
8171 | 8173 | int wildoff, |
8172 | - int flags) /* EW_* flags */ | |
8173 | -{ | |
8174 | - char_u *buf; | |
8175 | - char_u *path_end; | |
8176 | - char_u *p, *s, *e; | |
8177 | - int start_len = gap->ga_len; | |
8178 | - int ok; | |
8174 | + int flags, /* EW_* flags */ | |
8175 | + int didstar) /* expaneded "**" once already */ | |
8176 | +{ | |
8177 | + char_u *buf; | |
8178 | + char_u *path_end; | |
8179 | + char_u *p, *s, *e; | |
8180 | + int start_len = gap->ga_len; | |
8181 | + char_u *pat; | |
8182 | + regmatch_T regmatch; | |
8183 | + int starts_with_dot; | |
8184 | + int matches; | |
8185 | + int len; | |
8186 | + int starstar = FALSE; | |
8187 | + static int stardepth = 0; /* depth for "**" expansion */ | |
8179 | 8188 | #ifdef WIN3264 |
8180 | 8189 | WIN32_FIND_DATA fb; |
8181 | 8190 | HANDLE hFind = (HANDLE)0; |
@@ -8186,15 +8195,19 @@ | ||
8186 | 8195 | #else |
8187 | 8196 | struct ffblk fb; |
8188 | 8197 | #endif |
8189 | - int matches; | |
8190 | - int starts_with_dot; | |
8191 | - int len; | |
8192 | - char_u *pat; | |
8193 | - regmatch_T regmatch; | |
8194 | 8198 | char_u *matchname; |
8199 | + int ok; | |
8200 | + | |
8201 | + /* Expanding "**" may take a long time, check for CTRL-C. */ | |
8202 | + if (stardepth > 0) | |
8203 | + { | |
8204 | + ui_breakcheck(); | |
8205 | + if (got_int) | |
8206 | + return 0; | |
8207 | + } | |
8195 | 8208 | |
8196 | 8209 | /* make room for file name */ |
8197 | - buf = alloc((unsigned int)STRLEN(path) + BASENAMELEN + 5); | |
8210 | + buf = alloc((int)STRLEN(path) + BASENAMELEN + 5); | |
8198 | 8211 | if (buf == NULL) |
8199 | 8212 | return 0; |
8200 | 8213 |
@@ -8247,6 +8260,11 @@ | ||
8247 | 8260 | --s; |
8248 | 8261 | } |
8249 | 8262 | |
8263 | + /* Check for "**" between "s" and "e". */ | |
8264 | + for (p = s; p < e; ++p) | |
8265 | + if (p[0] == '*' && p[1] == '*') | |
8266 | + starstar = TRUE; | |
8267 | + | |
8250 | 8268 | starts_with_dot = (*s == '.'); |
8251 | 8269 | pat = file_pat_to_reg_pat(s, e, NULL, FALSE); |
8252 | 8270 | if (pat == NULL) |
@@ -8269,6 +8287,17 @@ | ||
8269 | 8287 | /* remember the pattern or file name being looked for */ |
8270 | 8288 | matchname = vim_strsave(s); |
8271 | 8289 | |
8290 | + /* If "**" is by itself, this is the first time we encounter it and more | |
8291 | + * is following then find matches without any directory. */ | |
8292 | + if (!didstar && stardepth < 100 && starstar && e - s == 2 | |
8293 | + && *path_end == '/') | |
8294 | + { | |
8295 | + STRCPY(s, path_end + 1); | |
8296 | + ++stardepth; | |
8297 | + (void)dos_expandpath(gap, buf, (int)(s - buf), flags, TRUE); | |
8298 | + --stardepth; | |
8299 | + } | |
8300 | + | |
8272 | 8301 | /* Scan all files in the directory with "dir/ *.*" */ |
8273 | 8302 | STRCPY(s, "*.*"); |
8274 | 8303 | #ifdef WIN3264 |
@@ -8325,12 +8354,24 @@ | ||
8325 | 8354 | namelowcpy(s, p); |
8326 | 8355 | #endif |
8327 | 8356 | len = (int)STRLEN(buf); |
8357 | + | |
8358 | + if (starstar && stardepth < 100) | |
8359 | + { | |
8360 | + /* For "**" in the pattern first go deeper in the tree to | |
8361 | + * find matches. */ | |
8362 | + STRCPY(buf + len, "/**"); | |
8363 | + STRCPY(buf + len + 3, path_end); | |
8364 | + ++stardepth; | |
8365 | + (void)dos_expandpath(gap, buf, len + 1, flags, TRUE); | |
8366 | + --stardepth; | |
8367 | + } | |
8368 | + | |
8328 | 8369 | STRCPY(buf + len, path_end); |
8329 | 8370 | if (mch_has_exp_wildcard(path_end)) |
8330 | 8371 | { |
8331 | 8372 | /* need to expand another component of the path */ |
8332 | 8373 | /* remove backslashes for the remaining components only */ |
8333 | - (void)dos_expandpath(gap, buf, len + 1, flags); | |
8374 | + (void)dos_expandpath(gap, buf, len + 1, flags, FALSE); | |
8334 | 8375 | } |
8335 | 8376 | else |
8336 | 8377 | { |
@@ -8408,10 +8449,232 @@ | ||
8408 | 8449 | char_u *path, |
8409 | 8450 | int flags) /* EW_* flags */ |
8410 | 8451 | { |
8411 | - return dos_expandpath(gap, path, 0, flags); | |
8452 | + return dos_expandpath(gap, path, 0, flags, FALSE); | |
8412 | 8453 | } |
8413 | 8454 | # endif /* MSDOS || FEAT_GUI_W16 || WIN3264 */ |
8414 | 8455 | |
8456 | +#if (defined(UNIX) && !defined(VMS)) || defined(USE_UNIXFILENAME) \ | |
8457 | + || defined(PROTO) | |
8458 | +/* | |
8459 | + * Unix style wildcard expansion code. | |
8460 | + * It's here because it's used both for Unix and Mac. | |
8461 | + */ | |
8462 | +static int pstrcmp __ARGS((const void *, const void *)); | |
8463 | + | |
8464 | + static int | |
8465 | +pstrcmp(a, b) | |
8466 | + const void *a, *b; | |
8467 | +{ | |
8468 | + return (pathcmp(*(char **)a, *(char **)b, -1)); | |
8469 | +} | |
8470 | + | |
8471 | +/* | |
8472 | + * Recursively expand one path component into all matching files and/or | |
8473 | + * directories. Adds matches to "gap". Handles "*", "?", "[a-z]", "**", etc. | |
8474 | + * "path" has backslashes before chars that are not to be expanded, starting | |
8475 | + * at "path + wildoff". | |
8476 | + * Return the number of matches found. | |
8477 | + * NOTE: much of this is identical to dos_expandpath(), keep in sync! | |
8478 | + */ | |
8479 | + int | |
8480 | +unix_expandpath(gap, path, wildoff, flags, didstar) | |
8481 | + garray_T *gap; | |
8482 | + char_u *path; | |
8483 | + int wildoff; | |
8484 | + int flags; /* EW_* flags */ | |
8485 | + int didstar; /* expanded "**" once already */ | |
8486 | +{ | |
8487 | + char_u *buf; | |
8488 | + char_u *path_end; | |
8489 | + char_u *p, *s, *e; | |
8490 | + int start_len = gap->ga_len; | |
8491 | + char_u *pat; | |
8492 | + regmatch_T regmatch; | |
8493 | + int starts_with_dot; | |
8494 | + int matches; | |
8495 | + int len; | |
8496 | + int starstar = FALSE; | |
8497 | + static int stardepth = 0; /* depth for "**" expansion */ | |
8498 | + | |
8499 | + DIR *dirp; | |
8500 | + struct dirent *dp; | |
8501 | + | |
8502 | + /* Expanding "**" may take a long time, check for CTRL-C. */ | |
8503 | + if (stardepth > 0) | |
8504 | + { | |
8505 | + ui_breakcheck(); | |
8506 | + if (got_int) | |
8507 | + return 0; | |
8508 | + } | |
8509 | + | |
8510 | + /* make room for file name */ | |
8511 | + buf = alloc((int)STRLEN(path) + BASENAMELEN + 5); | |
8512 | + if (buf == NULL) | |
8513 | + return 0; | |
8514 | + | |
8515 | + /* | |
8516 | + * Find the first part in the path name that contains a wildcard. | |
8517 | + * Copy it into "buf", including the preceding characters. | |
8518 | + */ | |
8519 | + p = buf; | |
8520 | + s = buf; | |
8521 | + e = NULL; | |
8522 | + path_end = path; | |
8523 | + while (*path_end != NUL) | |
8524 | + { | |
8525 | + /* May ignore a wildcard that has a backslash before it; it will | |
8526 | + * be removed by rem_backslash() or file_pat_to_reg_pat() below. */ | |
8527 | + if (path_end >= path + wildoff && rem_backslash(path_end)) | |
8528 | + *p++ = *path_end++; | |
8529 | + else if (*path_end == '/') | |
8530 | + { | |
8531 | + if (e != NULL) | |
8532 | + break; | |
8533 | + s = p + 1; | |
8534 | + } | |
8535 | + else if (path_end >= path + wildoff | |
8536 | + && vim_strchr((char_u *)"*?[{~$", *path_end) != NULL) | |
8537 | + e = p; | |
8538 | +#ifdef FEAT_MBYTE | |
8539 | + if (has_mbyte) | |
8540 | + { | |
8541 | + len = (*mb_ptr2len_check)(path_end); | |
8542 | + STRNCPY(p, path_end, len); | |
8543 | + p += len; | |
8544 | + path_end += len; | |
8545 | + } | |
8546 | + else | |
8547 | +#endif | |
8548 | + *p++ = *path_end++; | |
8549 | + } | |
8550 | + e = p; | |
8551 | + *e = NUL; | |
8552 | + | |
8553 | + /* now we have one wildcard component between "s" and "e" */ | |
8554 | + /* Remove backslashes between "wildoff" and the start of the wildcard | |
8555 | + * component. */ | |
8556 | + for (p = buf + wildoff; p < s; ++p) | |
8557 | + if (rem_backslash(p)) | |
8558 | + { | |
8559 | + STRCPY(p, p + 1); | |
8560 | + --e; | |
8561 | + --s; | |
8562 | + } | |
8563 | + | |
8564 | + /* Check for "**" between "s" and "e". */ | |
8565 | + for (p = s; p < e; ++p) | |
8566 | + if (p[0] == '*' && p[1] == '*') | |
8567 | + starstar = TRUE; | |
8568 | + | |
8569 | + /* convert the file pattern to a regexp pattern */ | |
8570 | + starts_with_dot = (*s == '.'); | |
8571 | + pat = file_pat_to_reg_pat(s, e, NULL, FALSE); | |
8572 | + if (pat == NULL) | |
8573 | + { | |
8574 | + vim_free(buf); | |
8575 | + return 0; | |
8576 | + } | |
8577 | + | |
8578 | + /* compile the regexp into a program */ | |
8579 | +#ifdef MACOS_X /* Can/Should we use CASE_INSENSITIVE_FILENAME instead ?*/ | |
8580 | + regmatch.rm_ic = TRUE; /* Behave like Terminal.app */ | |
8581 | +#else | |
8582 | + regmatch.rm_ic = FALSE; /* Don't ever ignore case */ | |
8583 | +#endif | |
8584 | + regmatch.regprog = vim_regcomp(pat, RE_MAGIC); | |
8585 | + vim_free(pat); | |
8586 | + | |
8587 | + if (regmatch.regprog == NULL) | |
8588 | + { | |
8589 | + vim_free(buf); | |
8590 | + return 0; | |
8591 | + } | |
8592 | + | |
8593 | + /* If "**" is by itself, this is the first time we encounter it and more | |
8594 | + * is following then find matches without any directory. */ | |
8595 | + if (!didstar && stardepth < 100 && starstar && e - s == 2 | |
8596 | + && *path_end == '/') | |
8597 | + { | |
8598 | + STRCPY(s, path_end + 1); | |
8599 | + ++stardepth; | |
8600 | + (void)unix_expandpath(gap, buf, (int)(s - buf), flags, TRUE); | |
8601 | + --stardepth; | |
8602 | + } | |
8603 | + | |
8604 | + /* open the directory for scanning */ | |
8605 | + *s = NUL; | |
8606 | + dirp = opendir(*buf == NUL ? "." : (char *)buf); | |
8607 | + | |
8608 | + /* Find all matching entries */ | |
8609 | + if (dirp != NULL) | |
8610 | + { | |
8611 | + for (;;) | |
8612 | + { | |
8613 | + dp = readdir(dirp); | |
8614 | + if (dp == NULL) | |
8615 | + break; | |
8616 | + if ((dp->d_name[0] != '.' || starts_with_dot) | |
8617 | + && vim_regexec(®match, (char_u *)dp->d_name, (colnr_T)0)) | |
8618 | + { | |
8619 | + STRCPY(s, dp->d_name); | |
8620 | + len = STRLEN(buf); | |
8621 | + | |
8622 | + if (starstar && stardepth < 100) | |
8623 | + { | |
8624 | + /* For "**" in the pattern first go deeper in the tree to | |
8625 | + * find matches. */ | |
8626 | + STRCPY(buf + len, "/**"); | |
8627 | + STRCPY(buf + len + 3, path_end); | |
8628 | + ++stardepth; | |
8629 | + (void)unix_expandpath(gap, buf, len + 1, flags, TRUE); | |
8630 | + --stardepth; | |
8631 | + } | |
8632 | + | |
8633 | + STRCPY(buf + len, path_end); | |
8634 | + if (mch_has_exp_wildcard(path_end)) /* handle more wildcards */ | |
8635 | + { | |
8636 | + /* need to expand another component of the path */ | |
8637 | + /* remove backslashes for the remaining components only */ | |
8638 | + (void)unix_expandpath(gap, buf, len + 1, flags, FALSE); | |
8639 | + } | |
8640 | + else | |
8641 | + { | |
8642 | + /* no more wildcards, check if there is a match */ | |
8643 | + /* remove backslashes for the remaining components only */ | |
8644 | + if (*path_end != NUL) | |
8645 | + backslash_halve(buf + len + 1); | |
8646 | + if (mch_getperm(buf) >= 0) /* add existing file */ | |
8647 | + { | |
8648 | +#if defined(MACOS_X) && defined(FEAT_MBYTE) | |
8649 | + size_t precomp_len = STRLEN(buf)+1; | |
8650 | + char_u *precomp_buf = | |
8651 | + mac_precompose_path(buf, precomp_len, &precomp_len); | |
8652 | + if (precomp_buf) | |
8653 | + { | |
8654 | + mch_memmove(buf, precomp_buf, precomp_len); | |
8655 | + vim_free(precomp_buf); | |
8656 | + } | |
8657 | +#endif | |
8658 | + addfile(gap, buf, flags); | |
8659 | + } | |
8660 | + } | |
8661 | + } | |
8662 | + } | |
8663 | + | |
8664 | + closedir(dirp); | |
8665 | + } | |
8666 | + | |
8667 | + vim_free(buf); | |
8668 | + vim_free(regmatch.regprog); | |
8669 | + | |
8670 | + matches = gap->ga_len - start_len; | |
8671 | + if (matches > 0) | |
8672 | + qsort(((char_u **)gap->ga_data) + start_len, matches, | |
8673 | + sizeof(char_u *), pstrcmp); | |
8674 | + return matches; | |
8675 | +} | |
8676 | +#endif | |
8677 | + | |
8415 | 8678 | /* |
8416 | 8679 | * Generic wildcard expansion code. |
8417 | 8680 | * |
@@ -15,7 +15,7 @@ | ||
15 | 15 | void gui_mch_get_screen_dimensions __ARGS((int *screen_w, int *screen_h)); |
16 | 16 | int gui_mch_init_font __ARGS((char_u *font_name, int do_fontset)); |
17 | 17 | GuiFont gui_mch_get_font __ARGS((char_u *name, int giveErrorIfMissing)); |
18 | -int gui_mch_adjust_charsize __ARGS((void)); | |
18 | +int gui_mch_adjust_charheight __ARGS((void)); | |
19 | 19 | void gui_mch_set_font __ARGS((GuiFont font)); |
20 | 20 | void gui_mch_set_fontset __ARGS((GuiFontset fontset)); |
21 | 21 | void gui_mch_free_font __ARGS((GuiFont font)); |
@@ -16,7 +16,7 @@ | ||
16 | 16 | int gui_mch_init_font __ARGS((char_u *font_name, int do_fontset)); |
17 | 17 | GuiFont gui_mch_get_font __ARGS((char_u *name, int giveErrorIfMissing)); |
18 | 18 | char_u *gui_mch_get_fontname __ARGS((GuiFont font, char_u *name)); |
19 | -int gui_mch_adjust_charsize __ARGS((void)); | |
19 | +int gui_mch_adjust_charheight __ARGS((void)); | |
20 | 20 | void gui_mch_set_font __ARGS((GuiFont font)); |
21 | 21 | void gui_mch_set_fontset __ARGS((GuiFontset fontset)); |
22 | 22 | void gui_mch_free_font __ARGS((GuiFont font)); |
@@ -84,6 +84,7 @@ | ||
84 | 84 | void fast_breakcheck __ARGS((void)); |
85 | 85 | int expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags)); |
86 | 86 | int match_suffix __ARGS((char_u *fname)); |
87 | +int unix_expandpath __ARGS((garray_T *gap, char_u *path, int wildoff, int flags, int didstar)); | |
87 | 88 | int gen_expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags)); |
88 | 89 | void addfile __ARGS((garray_T *gap, char_u *f, int flags)); |
89 | 90 | char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags)); |