Mercurial > vim
annotate src/cmdexpand.c @ 32377:3efec53797f3 v9.0.1520
patch 9.0.1520: completion for option name includes all bool options
Commit: https://github.com/vim/vim/commit/048d9d25214049dfde04c468c14bd1708fb692b8
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 6 22:21:11 2023 +0100
patch 9.0.1520: completion for option name includes all bool options
Problem: Completion for option name includes all bool options.
Solution: Do not recognize the "noinv" prefix. Prefix "no" or "inv" when
appropriate.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 06 May 2023 23:30:03 +0200 |
parents | bea4ebf594c6 |
children | 87f59a64efab |
rev | line source |
---|---|
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 * cmdexpand.c: functions for command-line completion |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #include "vim.h" |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 static int cmd_showtail; // Only show path tail in lists ? |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
18 static int ExpandGeneric(char_u *pat, expand_T *xp, regmatch_T *regmatch, |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
19 char_u ***matches, int *numMatches, |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
20 char_u *((*func)(expand_T *, int)), int escaped); |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
21 static int ExpandFromContext(expand_T *xp, char_u *, char_u ***, int *, int); |
31065
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
22 static char_u *showmatches_gettail(char_u *s); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 static int expand_showtail(expand_T *xp); |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
24 static int expand_shellcmd(char_u *filepat, char_u ***matches, int *numMatches, int flagsarg); |
17781
04245f071792
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17779
diff
changeset
|
25 #if defined(FEAT_EVAL) |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
26 static int ExpandUserDefined(char_u *pat, expand_T *xp, regmatch_T *regmatch, char_u ***matches, int *numMatches); |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
27 static int ExpandUserList(expand_T *xp, char_u ***matches, int *numMatches); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 #endif |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
30 // "compl_match_array" points the currently displayed list of entries in the |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
31 // popup menu. It is NULL when there is no popup menu. |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
32 static pumitem_T *compl_match_array = NULL; |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
33 static int compl_match_arraysize; |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
34 // First column in cmdline of the matched item for completion. |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
35 static int compl_startcol; |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
36 static int compl_selected; |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
37 |
31420
dcd73efec7de
patch 9.0.1043: macro has confusing name and is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
31394
diff
changeset
|
38 #define SHOW_MATCH(m) (showtail ? showmatches_gettail(matches[m]) : matches[m]) |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
39 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
40 /* |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
41 * Returns TRUE if fuzzy completion is supported for a given cmdline completion |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
42 * context. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
43 */ |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
44 static int |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
45 cmdline_fuzzy_completion_supported(expand_T *xp) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
46 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
47 return (vim_strchr(p_wop, WOP_FUZZY) != NULL |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
48 && xp->xp_context != EXPAND_BOOL_SETTINGS |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
49 && xp->xp_context != EXPAND_COLORS |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
50 && xp->xp_context != EXPAND_COMPILER |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
51 && xp->xp_context != EXPAND_DIRECTORIES |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
52 && xp->xp_context != EXPAND_FILES |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
53 && xp->xp_context != EXPAND_FILES_IN_PATH |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
54 && xp->xp_context != EXPAND_FILETYPE |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
55 && xp->xp_context != EXPAND_HELP |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
56 && xp->xp_context != EXPAND_OLD_SETTING |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
57 && xp->xp_context != EXPAND_OWNSYNTAX |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
58 && xp->xp_context != EXPAND_PACKADD |
31790
18da1d44878a
patch 9.0.1227: no cmdline completion for :runtime
Bram Moolenaar <Bram@vim.org>
parents:
31667
diff
changeset
|
59 && xp->xp_context != EXPAND_RUNTIME |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
60 && xp->xp_context != EXPAND_SHELLCMD |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
61 && xp->xp_context != EXPAND_TAGS |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
62 && xp->xp_context != EXPAND_TAGS_LISTFILES |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
63 && xp->xp_context != EXPAND_USER_LIST); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
64 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
65 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
66 /* |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
67 * Returns TRUE if fuzzy completion for cmdline completion is enabled and |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
68 * 'fuzzystr' is not empty. If search pattern is empty, then don't use fuzzy |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
69 * matching. |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
70 */ |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
71 int |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
72 cmdline_fuzzy_complete(char_u *fuzzystr) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
73 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
74 return vim_strchr(p_wop, WOP_FUZZY) != NULL && *fuzzystr != NUL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
75 } |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
76 |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
77 /* |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
78 * sort function for the completion matches. |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
79 * <SNR> functions should be sorted to the end. |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
80 */ |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 static int |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 sort_func_compare(const void *s1, const void *s2) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 char_u *p1 = *(char_u **)s1; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 char_u *p2 = *(char_u **)s2; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 if (*p1 != '<' && *p2 == '<') return -1; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 if (*p1 == '<' && *p2 != '<') return 1; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 return STRCMP(p1, p2); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 |
27680
38eab98ef5a9
patch 8.2.4366: not enough tests for command line completion
Bram Moolenaar <Bram@vim.org>
parents:
27661
diff
changeset
|
92 /* |
38eab98ef5a9
patch 8.2.4366: not enough tests for command line completion
Bram Moolenaar <Bram@vim.org>
parents:
27661
diff
changeset
|
93 * Escape special characters in the cmdline completion matches. |
38eab98ef5a9
patch 8.2.4366: not enough tests for command line completion
Bram Moolenaar <Bram@vim.org>
parents:
27661
diff
changeset
|
94 */ |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 static void |
31083
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
96 wildescape( |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
97 expand_T *xp, |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
98 char_u *str, |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
99 int numfiles, |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
100 char_u **files) |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
101 { |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
102 char_u *p; |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
103 int vse_what = xp->xp_context == EXPAND_BUFFERS |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
104 ? VSE_BUFFER : VSE_NONE; |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
105 |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
106 if (xp->xp_context == EXPAND_FILES |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
107 || xp->xp_context == EXPAND_FILES_IN_PATH |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
108 || xp->xp_context == EXPAND_SHELLCMD |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
109 || xp->xp_context == EXPAND_BUFFERS |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
110 || xp->xp_context == EXPAND_DIRECTORIES) |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
111 { |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
112 // Insert a backslash into a file name before a space, \, %, # |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
113 // and wildmatch characters, except '~'. |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
114 for (int i = 0; i < numfiles; ++i) |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
115 { |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
116 // for ":set path=" we need to escape spaces twice |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
117 if (xp->xp_backslash == XP_BS_THREE) |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
118 { |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
119 p = vim_strsave_escaped(files[i], (char_u *)" "); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
120 if (p != NULL) |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
121 { |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
122 vim_free(files[i]); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
123 files[i] = p; |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
124 #if defined(BACKSLASH_IN_FILENAME) |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
125 p = vim_strsave_escaped(files[i], (char_u *)" "); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
126 if (p != NULL) |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
127 { |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
128 vim_free(files[i]); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
129 files[i] = p; |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
130 } |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
131 #endif |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
132 } |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
133 } |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
134 #ifdef BACKSLASH_IN_FILENAME |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
135 p = vim_strsave_fnameescape(files[i], vse_what); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
136 #else |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
137 p = vim_strsave_fnameescape(files[i], |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
138 xp->xp_shell ? VSE_SHELL : vse_what); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
139 #endif |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
140 if (p != NULL) |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
141 { |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
142 vim_free(files[i]); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
143 files[i] = p; |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
144 } |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
145 |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
146 // If 'str' starts with "\~", replace "~" at start of |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
147 // files[i] with "\~". |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
148 if (str[0] == '\\' && str[1] == '~' && files[i][0] == '~') |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
149 escape_fname(&files[i]); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
150 } |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
151 xp->xp_backslash = XP_BS_NONE; |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
152 |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
153 // If the first file starts with a '+' escape it. Otherwise it |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
154 // could be seen as "+cmd". |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
155 if (*files[0] == '+') |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
156 escape_fname(&files[0]); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
157 } |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
158 else if (xp->xp_context == EXPAND_TAGS) |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
159 { |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
160 // Insert a backslash before characters in a tag name that |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
161 // would terminate the ":tag" command. |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
162 for (int i = 0; i < numfiles; ++i) |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
163 { |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
164 p = vim_strsave_escaped(files[i], (char_u *)"\\|\""); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
165 if (p != NULL) |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
166 { |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
167 vim_free(files[i]); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
168 files[i] = p; |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
169 } |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
170 } |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
171 } |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
172 } |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
173 |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
174 /* |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
175 * Escape special characters in the cmdline completion matches. |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
176 */ |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
177 static void |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 ExpandEscape( |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 expand_T *xp, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 char_u *str, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 int numfiles, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 char_u **files, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 int options) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 // May change home directory back to "~" |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 if (options & WILD_HOME_REPLACE) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
187 tilde_replace(str, numfiles, files); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
188 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 if (options & WILD_ESCAPE) |
31083
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
190 wildescape(xp, str, numfiles, files); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 /* |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 * Return FAIL if this is not an appropriate context in which to do |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 * completion of anything, return OK if it is (even if there are no matches). |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 * For the caller, this means that the character is just passed through like a |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 * normal character (instead of being expanded). This allows :s/^I^D etc. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 int |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 nextwild( |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 expand_T *xp, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 int type, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 int options, // extra options for ExpandOne() |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 int escape) // if TRUE, escape the returned matches |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 cmdline_info_T *ccline = get_cmdline_info(); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 int i, j; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 char_u *p1; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 char_u *p2; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 int difflen; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
211 int v; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
213 if (xp->xp_numfiles == -1) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 set_expand_context(xp); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 cmd_showtail = expand_showtail(xp); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 if (xp->xp_context == EXPAND_UNSUCCESSFUL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 beep_flush(); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 return OK; // Something illegal on command line |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 if (xp->xp_context == EXPAND_NOTHING) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 // Caller can use the character as a normal char instead |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 return FAIL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 |
31097
4f709e5f24d2
patch 9.0.0883: a silent mapping may cause dots on the command line
Bram Moolenaar <Bram@vim.org>
parents:
31091
diff
changeset
|
230 // If cmd_silent is set then don't show the dots, because redrawcmd() below |
4f709e5f24d2
patch 9.0.0883: a silent mapping may cause dots on the command line
Bram Moolenaar <Bram@vim.org>
parents:
31091
diff
changeset
|
231 // won't remove them. |
4f709e5f24d2
patch 9.0.0883: a silent mapping may cause dots on the command line
Bram Moolenaar <Bram@vim.org>
parents:
31091
diff
changeset
|
232 if (!cmd_silent) |
4f709e5f24d2
patch 9.0.0883: a silent mapping may cause dots on the command line
Bram Moolenaar <Bram@vim.org>
parents:
31091
diff
changeset
|
233 { |
4f709e5f24d2
patch 9.0.0883: a silent mapping may cause dots on the command line
Bram Moolenaar <Bram@vim.org>
parents:
31091
diff
changeset
|
234 msg_puts("..."); // show that we are busy |
4f709e5f24d2
patch 9.0.0883: a silent mapping may cause dots on the command line
Bram Moolenaar <Bram@vim.org>
parents:
31091
diff
changeset
|
235 out_flush(); |
4f709e5f24d2
patch 9.0.0883: a silent mapping may cause dots on the command line
Bram Moolenaar <Bram@vim.org>
parents:
31091
diff
changeset
|
236 } |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 i = (int)(xp->xp_pattern - ccline->cmdbuff); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 xp->xp_pattern_len = ccline->cmdpos - i; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 |
28109
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
241 if (type == WILD_NEXT || type == WILD_PREV |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
242 || type == WILD_PAGEUP || type == WILD_PAGEDOWN) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 // Get next/previous match for a previous expanded pattern. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 p2 = ExpandOne(xp, NULL, NULL, 0, type); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 else |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 { |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
249 if (cmdline_fuzzy_completion_supported(xp)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
250 // If fuzzy matching, don't modify the search string |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
251 p1 = vim_strsave(xp->xp_pattern); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
252 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
253 p1 = addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
254 |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 // Translate string into pattern and expand it. |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
256 if (p1 == NULL) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 p2 = NULL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 else |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 int use_options = options | |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 if (escape) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 use_options |= WILD_ESCAPE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 if (p_wic) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 use_options += WILD_ICASE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 p2 = ExpandOne(xp, p1, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 vim_strnsave(&ccline->cmdbuff[i], xp->xp_pattern_len), |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 use_options, type); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 vim_free(p1); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 // longest match: make sure it is not shorter, happens with :help |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 if (p2 != NULL && type == WILD_LONGEST) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
274 for (j = 0; j < xp->xp_pattern_len; ++j) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 if (ccline->cmdbuff[i + j] == '*' |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 || ccline->cmdbuff[i + j] == '?') |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 break; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 if ((int)STRLEN(p2) < j) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 VIM_CLEAR(p2); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
280 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
282 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
284 if (p2 != NULL && !got_int) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
285 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 difflen = (int)STRLEN(p2) - xp->xp_pattern_len; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 if (ccline->cmdlen + difflen + 4 > ccline->cmdbufflen) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 v = realloc_cmdbuff(ccline->cmdlen + difflen + 4); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 xp->xp_pattern = ccline->cmdbuff + i; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 else |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 v = OK; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 if (v == OK) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 mch_memmove(&ccline->cmdbuff[ccline->cmdpos + difflen], |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 &ccline->cmdbuff[ccline->cmdpos], |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 (size_t)(ccline->cmdlen - ccline->cmdpos + 1)); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 mch_memmove(&ccline->cmdbuff[i], p2, STRLEN(p2)); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
300 ccline->cmdlen += difflen; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 ccline->cmdpos += difflen; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
302 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 vim_free(p2); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 redrawcmd(); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 cursorcmd(); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
309 // When expanding a ":map" command and no matches are found, assume that |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
310 // the key is supposed to be inserted literally |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
311 if (xp->xp_context == EXPAND_MAPPINGS && p2 == NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 return FAIL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 if (xp->xp_numfiles <= 0 && p2 == NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
315 beep_flush(); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
316 else if (xp->xp_numfiles == 1) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
317 // free expanded pattern |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
318 (void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
319 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
320 return OK; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
321 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
322 |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
323 /* |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
324 * Create and display a cmdline completion popup menu with items from |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
325 * 'matches'. |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
326 */ |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
327 static int |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
328 cmdline_pum_create( |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
329 cmdline_info_T *ccline, |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
330 expand_T *xp, |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
331 char_u **matches, |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
332 int numMatches, |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
333 int showtail) |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
334 { |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
335 int i; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
336 int columns; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
337 |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
338 // Add all the completion matches |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
339 compl_match_arraysize = numMatches; |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
340 compl_match_array = ALLOC_MULT(pumitem_T, compl_match_arraysize); |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
341 for (i = 0; i < numMatches; i++) |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
342 { |
31420
dcd73efec7de
patch 9.0.1043: macro has confusing name and is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
31394
diff
changeset
|
343 compl_match_array[i].pum_text = SHOW_MATCH(i); |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
344 compl_match_array[i].pum_info = NULL; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
345 compl_match_array[i].pum_extra = NULL; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
346 compl_match_array[i].pum_kind = NULL; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
347 } |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
348 |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
349 // Compute the popup menu starting column |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
350 compl_startcol = vim_strsize(ccline->cmdbuff) + 1; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
351 columns = vim_strsize(xp->xp_pattern); |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
352 if (showtail) |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
353 { |
31065
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
354 columns += vim_strsize(showmatches_gettail(matches[0])); |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
355 columns -= vim_strsize(matches[0]); |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
356 } |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
357 if (columns >= compl_startcol) |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
358 compl_startcol = 0; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
359 else |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
360 compl_startcol -= columns; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
361 |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
362 // no default selection |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
363 compl_selected = -1; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
364 |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
365 cmdline_pum_display(); |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
366 |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
367 return EXPAND_OK; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
368 } |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
369 |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
370 /* |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
371 * Display the cmdline completion matches in a popup menu |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
372 */ |
31394
a6b1f1c22374
patch 9.0.1030: using freed memory with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
31097
diff
changeset
|
373 void |
a6b1f1c22374
patch 9.0.1030: using freed memory with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
31097
diff
changeset
|
374 cmdline_pum_display(void) |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
375 { |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
376 pum_display(compl_match_array, compl_match_arraysize, compl_selected); |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
377 } |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
378 |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
379 /* |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
380 * Returns TRUE if the cmdline completion popup menu is being displayed. |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
381 */ |
31394
a6b1f1c22374
patch 9.0.1030: using freed memory with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
31097
diff
changeset
|
382 int |
a6b1f1c22374
patch 9.0.1030: using freed memory with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
31097
diff
changeset
|
383 cmdline_pum_active(void) |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
384 { |
29794
5b46eb13e3bb
patch 9.0.0236: popup menu not removed when 'wildmenu' reset while visible
Bram Moolenaar <Bram@vim.org>
parents:
29784
diff
changeset
|
385 return pum_visible() && compl_match_array != NULL; |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
386 } |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
387 |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
388 /* |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
389 * Remove the cmdline completion popup menu (if present), free the list of |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
390 * items and refresh the screen. |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
391 */ |
31394
a6b1f1c22374
patch 9.0.1030: using freed memory with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
31097
diff
changeset
|
392 void |
a6b1f1c22374
patch 9.0.1030: using freed memory with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
31097
diff
changeset
|
393 cmdline_pum_remove(void) |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
394 { |
27912
be9e6e0b1591
patch 8.2.4481: cmdline popup menu not removed when 'lazyredraw' is set
Bram Moolenaar <Bram@vim.org>
parents:
27908
diff
changeset
|
395 int save_p_lz = p_lz; |
28427
96d53065f309
patch 8.2.4738: Esc on commandline executes command instead of abandoning it
Bram Moolenaar <Bram@vim.org>
parents:
28415
diff
changeset
|
396 int save_KeyTyped = KeyTyped; |
27912
be9e6e0b1591
patch 8.2.4481: cmdline popup menu not removed when 'lazyredraw' is set
Bram Moolenaar <Bram@vim.org>
parents:
27908
diff
changeset
|
397 |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
398 pum_undisplay(); |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
399 VIM_CLEAR(compl_match_array); |
27912
be9e6e0b1591
patch 8.2.4481: cmdline popup menu not removed when 'lazyredraw' is set
Bram Moolenaar <Bram@vim.org>
parents:
27908
diff
changeset
|
400 p_lz = FALSE; // avoid the popup menu hanging around |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
401 update_screen(0); |
27912
be9e6e0b1591
patch 8.2.4481: cmdline popup menu not removed when 'lazyredraw' is set
Bram Moolenaar <Bram@vim.org>
parents:
27908
diff
changeset
|
402 p_lz = save_p_lz; |
27630
9caeb7f8b094
patch 8.2.4341: command line not redrawn when finishing popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
403 redrawcmd(); |
28427
96d53065f309
patch 8.2.4738: Esc on commandline executes command instead of abandoning it
Bram Moolenaar <Bram@vim.org>
parents:
28415
diff
changeset
|
404 |
96d53065f309
patch 8.2.4738: Esc on commandline executes command instead of abandoning it
Bram Moolenaar <Bram@vim.org>
parents:
28415
diff
changeset
|
405 // When a function is called (e.g. for 'foldtext') KeyTyped might be reset |
96d53065f309
patch 8.2.4738: Esc on commandline executes command instead of abandoning it
Bram Moolenaar <Bram@vim.org>
parents:
28415
diff
changeset
|
406 // as a side effect. |
96d53065f309
patch 8.2.4738: Esc on commandline executes command instead of abandoning it
Bram Moolenaar <Bram@vim.org>
parents:
28415
diff
changeset
|
407 KeyTyped = save_KeyTyped; |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
408 } |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
409 |
31394
a6b1f1c22374
patch 9.0.1030: using freed memory with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
31097
diff
changeset
|
410 void |
a6b1f1c22374
patch 9.0.1030: using freed memory with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
31097
diff
changeset
|
411 cmdline_pum_cleanup(cmdline_info_T *cclp) |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
412 { |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
413 cmdline_pum_remove(); |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
414 wildmenu_cleanup(cclp); |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
415 } |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
416 |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
417 /* |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
418 * Returns the starting column number to use for the cmdline completion popup |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
419 * menu. |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
420 */ |
31394
a6b1f1c22374
patch 9.0.1030: using freed memory with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
31097
diff
changeset
|
421 int |
a6b1f1c22374
patch 9.0.1030: using freed memory with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
31097
diff
changeset
|
422 cmdline_compl_startcol(void) |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
423 { |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
424 return compl_startcol; |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
425 } |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
426 |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
427 /* |
31065
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
428 * Return the number of characters that should be skipped in a status match. |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
429 * These are backslashes used for escaping. Do show backslashes in help tags. |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
430 */ |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
431 static int |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
432 skip_status_match_char(expand_T *xp, char_u *s) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
433 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
434 if ((rem_backslash(s) && xp->xp_context != EXPAND_HELP) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
435 #ifdef FEAT_MENU |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
436 || ((xp->xp_context == EXPAND_MENUS |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
437 || xp->xp_context == EXPAND_MENUNAMES) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
438 && (s[0] == '\t' || (s[0] == '\\' && s[1] != NUL))) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
439 #endif |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
440 ) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
441 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
442 #ifndef BACKSLASH_IN_FILENAME |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
443 if (xp->xp_shell && csh_like_shell() && s[1] == '\\' && s[2] == '!') |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
444 return 2; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
445 #endif |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
446 return 1; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
447 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
448 return 0; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
449 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
450 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
451 /* |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
452 * Get the length of an item as it will be shown in the status line. |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
453 */ |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
454 static int |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
455 status_match_len(expand_T *xp, char_u *s) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
456 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
457 int len = 0; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
458 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
459 #ifdef FEAT_MENU |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
460 int emenu = xp->xp_context == EXPAND_MENUS |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
461 || xp->xp_context == EXPAND_MENUNAMES; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
462 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
463 // Check for menu separators - replace with '|'. |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
464 if (emenu && menu_is_separator(s)) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
465 return 1; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
466 #endif |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
467 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
468 while (*s != NUL) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
469 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
470 s += skip_status_match_char(xp, s); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
471 len += ptr2cells(s); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
472 MB_PTR_ADV(s); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
473 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
474 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
475 return len; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
476 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
477 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
478 /* |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
479 * Show wildchar matches in the status line. |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
480 * Show at least the "match" item. |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
481 * We start at item 'first_match' in the list and show all matches that fit. |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
482 * |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
483 * If inversion is possible we use it. Else '=' characters are used. |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
484 */ |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
485 static void |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
486 win_redr_status_matches( |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
487 expand_T *xp, |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
488 int num_matches, |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
489 char_u **matches, // list of matches |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
490 int match, |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
491 int showtail) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
492 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
493 int row; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
494 char_u *buf; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
495 int len; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
496 int clen; // length in screen cells |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
497 int fillchar; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
498 int attr; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
499 int i; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
500 int highlight = TRUE; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
501 char_u *selstart = NULL; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
502 int selstart_col = 0; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
503 char_u *selend = NULL; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
504 static int first_match = 0; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
505 int add_left = FALSE; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
506 char_u *s; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
507 #ifdef FEAT_MENU |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
508 int emenu; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
509 #endif |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
510 int l; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
511 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
512 if (matches == NULL) // interrupted completion? |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
513 return; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
514 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
515 if (has_mbyte) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
516 buf = alloc(Columns * MB_MAXBYTES + 1); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
517 else |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
518 buf = alloc(Columns + 1); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
519 if (buf == NULL) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
520 return; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
521 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
522 if (match == -1) // don't show match but original text |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
523 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
524 match = 0; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
525 highlight = FALSE; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
526 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
527 // count 1 for the ending ">" |
31420
dcd73efec7de
patch 9.0.1043: macro has confusing name and is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
31394
diff
changeset
|
528 clen = status_match_len(xp, SHOW_MATCH(match)) + 3; |
31065
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
529 if (match == 0) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
530 first_match = 0; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
531 else if (match < first_match) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
532 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
533 // jumping left, as far as we can go |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
534 first_match = match; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
535 add_left = TRUE; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
536 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
537 else |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
538 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
539 // check if match fits on the screen |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
540 for (i = first_match; i < match; ++i) |
31420
dcd73efec7de
patch 9.0.1043: macro has confusing name and is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
31394
diff
changeset
|
541 clen += status_match_len(xp, SHOW_MATCH(i)) + 2; |
31065
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
542 if (first_match > 0) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
543 clen += 2; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
544 // jumping right, put match at the left |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
545 if ((long)clen > Columns) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
546 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
547 first_match = match; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
548 // if showing the last match, we can add some on the left |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
549 clen = 2; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
550 for (i = match; i < num_matches; ++i) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
551 { |
31420
dcd73efec7de
patch 9.0.1043: macro has confusing name and is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
31394
diff
changeset
|
552 clen += status_match_len(xp, SHOW_MATCH(i)) + 2; |
31065
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
553 if ((long)clen >= Columns) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
554 break; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
555 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
556 if (i == num_matches) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
557 add_left = TRUE; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
558 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
559 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
560 if (add_left) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
561 while (first_match > 0) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
562 { |
31420
dcd73efec7de
patch 9.0.1043: macro has confusing name and is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
31394
diff
changeset
|
563 clen += status_match_len(xp, SHOW_MATCH(first_match - 1)) + 2; |
31065
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
564 if ((long)clen >= Columns) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
565 break; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
566 --first_match; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
567 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
568 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
569 fillchar = fillchar_status(&attr, curwin); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
570 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
571 if (first_match == 0) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
572 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
573 *buf = NUL; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
574 len = 0; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
575 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
576 else |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
577 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
578 STRCPY(buf, "< "); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
579 len = 2; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
580 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
581 clen = len; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
582 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
583 i = first_match; |
31420
dcd73efec7de
patch 9.0.1043: macro has confusing name and is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
31394
diff
changeset
|
584 while ((long)(clen + status_match_len(xp, SHOW_MATCH(i)) + 2) < Columns) |
31065
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
585 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
586 if (i == match) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
587 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
588 selstart = buf + len; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
589 selstart_col = clen; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
590 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
591 |
31420
dcd73efec7de
patch 9.0.1043: macro has confusing name and is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
31394
diff
changeset
|
592 s = SHOW_MATCH(i); |
31065
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
593 // Check for menu separators - replace with '|' |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
594 #ifdef FEAT_MENU |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
595 emenu = (xp->xp_context == EXPAND_MENUS |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
596 || xp->xp_context == EXPAND_MENUNAMES); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
597 if (emenu && menu_is_separator(s)) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
598 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
599 STRCPY(buf + len, transchar('|')); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
600 l = (int)STRLEN(buf + len); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
601 len += l; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
602 clen += l; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
603 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
604 else |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
605 #endif |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
606 for ( ; *s != NUL; ++s) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
607 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
608 s += skip_status_match_char(xp, s); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
609 clen += ptr2cells(s); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
610 if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
611 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
612 STRNCPY(buf + len, s, l); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
613 s += l - 1; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
614 len += l; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
615 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
616 else |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
617 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
618 STRCPY(buf + len, transchar_byte(*s)); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
619 len += (int)STRLEN(buf + len); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
620 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
621 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
622 if (i == match) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
623 selend = buf + len; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
624 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
625 *(buf + len++) = ' '; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
626 *(buf + len++) = ' '; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
627 clen += 2; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
628 if (++i == num_matches) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
629 break; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
630 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
631 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
632 if (i != num_matches) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
633 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
634 *(buf + len++) = '>'; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
635 ++clen; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
636 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
637 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
638 buf[len] = NUL; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
639 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
640 row = cmdline_row - 1; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
641 if (row >= 0) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
642 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
643 if (wild_menu_showing == 0) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
644 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
645 if (msg_scrolled > 0) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
646 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
647 // Put the wildmenu just above the command line. If there is |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
648 // no room, scroll the screen one line up. |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
649 if (cmdline_row == Rows - 1) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
650 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
651 screen_del_lines(0, 0, 1, (int)Rows, TRUE, 0, NULL); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
652 ++msg_scrolled; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
653 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
654 else |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
655 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
656 ++cmdline_row; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
657 ++row; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
658 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
659 wild_menu_showing = WM_SCROLLED; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
660 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
661 else |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
662 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
663 // Create status line if needed by setting 'laststatus' to 2. |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
664 // Set 'winminheight' to zero to avoid that the window is |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
665 // resized. |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
666 if (lastwin->w_status_height == 0) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
667 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
668 save_p_ls = p_ls; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
669 save_p_wmh = p_wmh; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
670 p_ls = 2; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
671 p_wmh = 0; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
672 last_status(FALSE); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
673 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
674 wild_menu_showing = WM_SHOWN; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
675 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
676 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
677 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
678 screen_puts(buf, row, 0, attr); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
679 if (selstart != NULL && highlight) |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
680 { |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
681 *selend = NUL; |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
682 screen_puts(selstart, row, selstart_col, HL_ATTR(HLF_WM)); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
683 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
684 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
685 screen_fill(row, row + 1, clen, (int)Columns, fillchar, fillchar, attr); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
686 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
687 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
688 win_redraw_last_status(topframe); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
689 vim_free(buf); |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
690 } |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
691 |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
692 /* |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
693 * Get the next or prev cmdline completion match. The index of the match is set |
28109
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
694 * in "p_findex" |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
695 */ |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
696 static char_u * |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
697 get_next_or_prev_match( |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
698 int mode, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
699 expand_T *xp, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
700 int *p_findex, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
701 char_u *orig_save) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
702 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
703 int findex = *p_findex; |
28109
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
704 int ht; |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
705 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
706 if (xp->xp_numfiles <= 0) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
707 return NULL; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
708 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
709 if (mode == WILD_PREV) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
710 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
711 if (findex == -1) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
712 findex = xp->xp_numfiles; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
713 --findex; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
714 } |
28109
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
715 else if (mode == WILD_NEXT) |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
716 ++findex; |
28109
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
717 else if (mode == WILD_PAGEUP) |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
718 { |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
719 if (findex == 0) |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
720 // at the first entry, don't select any entries |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
721 findex = -1; |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
722 else if (findex == -1) |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
723 // no entry is selected. select the last entry |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
724 findex = xp->xp_numfiles - 1; |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
725 else |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
726 { |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
727 // go up by the pum height |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
728 ht = pum_get_height(); |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
729 if (ht > 3) |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
730 ht -= 2; |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
731 findex -= ht; |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
732 if (findex < 0) |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
733 // few entries left, select the first entry |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
734 findex = 0; |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
735 } |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
736 } |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
737 else // mode == WILD_PAGEDOWN |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
738 { |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
739 if (findex == xp->xp_numfiles - 1) |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
740 // at the last entry, don't select any entries |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
741 findex = -1; |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
742 else if (findex == -1) |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
743 // no entry is selected. select the first entry |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
744 findex = 0; |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
745 else |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
746 { |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
747 // go down by the pum height |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
748 ht = pum_get_height(); |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
749 if (ht > 3) |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
750 ht -= 2; |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
751 findex += ht; |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
752 if (findex >= xp->xp_numfiles) |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
753 // few entries left, select the last entry |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
754 findex = xp->xp_numfiles - 1; |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
755 } |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
756 } |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
757 |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
758 // When wrapping around, return the original string, set findex to -1. |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
759 if (findex < 0) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
760 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
761 if (orig_save == NULL) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
762 findex = xp->xp_numfiles - 1; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
763 else |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
764 findex = -1; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
765 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
766 if (findex >= xp->xp_numfiles) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
767 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
768 if (orig_save == NULL) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
769 findex = 0; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
770 else |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
771 findex = -1; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
772 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
773 if (compl_match_array) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
774 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
775 compl_selected = findex; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
776 cmdline_pum_display(); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
777 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
778 else if (p_wmnu) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
779 win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
780 findex, cmd_showtail); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
781 *p_findex = findex; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
782 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
783 if (findex == -1) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
784 return vim_strsave(orig_save); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
785 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
786 return vim_strsave(xp->xp_files[findex]); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
787 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
788 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
789 /* |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
790 * Start the command-line expansion and get the matches. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
791 */ |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
792 static char_u * |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
793 ExpandOne_start(int mode, expand_T *xp, char_u *str, int options) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
794 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
795 int non_suf_match; // number without matching suffix |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
796 int i; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
797 char_u *ss = NULL; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
798 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
799 // Do the expansion. |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
800 if (ExpandFromContext(xp, str, &xp->xp_files, &xp->xp_numfiles, |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
801 options) == FAIL) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
802 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
803 #ifdef FNAME_ILLEGAL |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
804 // Illegal file name has been silently skipped. But when there |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
805 // are wildcards, the real problem is that there was no match, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
806 // causing the pattern to be added, which has illegal characters. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
807 if (!(options & WILD_SILENT) && (options & WILD_LIST_NOTFOUND)) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
808 semsg(_(e_no_match_str_2), str); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
809 #endif |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
810 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
811 else if (xp->xp_numfiles == 0) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
812 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
813 if (!(options & WILD_SILENT)) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
814 semsg(_(e_no_match_str_2), str); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
815 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
816 else |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
817 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
818 // Escape the matches for use on the command line. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
819 ExpandEscape(xp, str, xp->xp_numfiles, xp->xp_files, options); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
820 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
821 // Check for matching suffixes in file names. |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
822 if (mode != WILD_ALL && mode != WILD_ALL_KEEP && mode != WILD_LONGEST) |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
823 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
824 if (xp->xp_numfiles) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
825 non_suf_match = xp->xp_numfiles; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
826 else |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
827 non_suf_match = 1; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
828 if ((xp->xp_context == EXPAND_FILES |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
829 || xp->xp_context == EXPAND_DIRECTORIES) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
830 && xp->xp_numfiles > 1) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
831 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
832 // More than one match; check suffix. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
833 // The files will have been sorted on matching suffix in |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
834 // expand_wildcards, only need to check the first two. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
835 non_suf_match = 0; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
836 for (i = 0; i < 2; ++i) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
837 if (match_suffix(xp->xp_files[i])) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
838 ++non_suf_match; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
839 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
840 if (non_suf_match != 1) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
841 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
842 // Can we ever get here unless it's while expanding |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
843 // interactively? If not, we can get rid of this all |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
844 // together. Don't really want to wait for this message |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
845 // (and possibly have to hit return to continue!). |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
846 if (!(options & WILD_SILENT)) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
847 emsg(_(e_too_many_file_names)); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
848 else if (!(options & WILD_NO_BEEP)) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
849 beep_flush(); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
850 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
851 if (!(non_suf_match != 1 && mode == WILD_EXPAND_FREE)) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
852 ss = vim_strsave(xp->xp_files[0]); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
853 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
854 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
855 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
856 return ss; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
857 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
858 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
859 /* |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
860 * Return the longest common part in the list of cmdline completion matches. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
861 */ |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
862 static char_u * |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
863 find_longest_match(expand_T *xp, int options) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
864 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
865 long_u len; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
866 int mb_len = 1; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
867 int c0, ci; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
868 int i; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
869 char_u *ss; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
870 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
871 for (len = 0; xp->xp_files[0][len]; len += mb_len) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
872 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
873 if (has_mbyte) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
874 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
875 mb_len = (*mb_ptr2len)(&xp->xp_files[0][len]); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
876 c0 =(* mb_ptr2char)(&xp->xp_files[0][len]); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
877 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
878 else |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
879 c0 = xp->xp_files[0][len]; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
880 for (i = 1; i < xp->xp_numfiles; ++i) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
881 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
882 if (has_mbyte) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
883 ci =(* mb_ptr2char)(&xp->xp_files[i][len]); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
884 else |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
885 ci = xp->xp_files[i][len]; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
886 if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
887 || xp->xp_context == EXPAND_FILES |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
888 || xp->xp_context == EXPAND_SHELLCMD |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
889 || xp->xp_context == EXPAND_BUFFERS)) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
890 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
891 if (MB_TOLOWER(c0) != MB_TOLOWER(ci)) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
892 break; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
893 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
894 else if (c0 != ci) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
895 break; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
896 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
897 if (i < xp->xp_numfiles) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
898 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
899 if (!(options & WILD_NO_BEEP)) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
900 vim_beep(BO_WILD); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
901 break; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
902 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
903 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
904 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
905 ss = alloc(len + 1); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
906 if (ss) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
907 vim_strncpy(ss, xp->xp_files[0], (size_t)len); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
908 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
909 return ss; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
910 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
911 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
912 /* |
28109
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
913 * Do wildcard expansion on the string "str". |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 * Chars that should not be expanded must be preceded with a backslash. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 * Return a pointer to allocated memory containing the new string. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 * Return NULL for failure. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 * |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 * "orig" is the originally expanded string, copied to allocated memory. It |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 * should either be kept in orig_save or freed. When "mode" is WILD_NEXT or |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 * WILD_PREV "orig" should be NULL. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 * |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 * Results are cached in xp->xp_files and xp->xp_numfiles, except when "mode" |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 * is WILD_EXPAND_FREE or WILD_ALL. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 * |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
925 * mode = WILD_FREE: just free previously expanded matches |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
926 * mode = WILD_EXPAND_FREE: normal expansion, do not keep matches |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
927 * mode = WILD_EXPAND_KEEP: normal expansion, keep matches |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 * mode = WILD_NEXT: use next match in multiple match, wrap to first |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 * mode = WILD_PREV: use previous match in multiple match, wrap to first |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 * mode = WILD_ALL: return all matches concatenated |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 * mode = WILD_LONGEST: return longest matched part |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 * mode = WILD_ALL_KEEP: get all matches, keep matches |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
933 * mode = WILD_APPLY: apply the item selected in the cmdline completion |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
934 * popup menu and close the menu. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
935 * mode = WILD_CANCEL: cancel and close the cmdline completion popup and |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
936 * use the original text. |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 * |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 * options = WILD_LIST_NOTFOUND: list entries without a match |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 * options = WILD_HOME_REPLACE: do home_replace() for buffer names |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 * options = WILD_USE_NL: Use '\n' for WILD_ALL |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 * options = WILD_NO_BEEP: Don't beep for multiple matches |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 * options = WILD_ADD_SLASH: add a slash after directory names |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
943 * options = WILD_KEEP_ALL: don't remove 'wildignore' entries |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 * options = WILD_SILENT: don't print warning messages |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 * options = WILD_ESCAPE: put backslash before special chars |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
946 * options = WILD_ICASE: ignore case for files |
20818
a0b147774bd4
patch 8.2.0961: MS-Windows: no completion for locales
Bram Moolenaar <Bram@vim.org>
parents:
20751
diff
changeset
|
947 * options = WILD_ALLLINKS; keep broken links |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
948 * |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 * The variables xp->xp_context and xp->xp_backslash must have been set! |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
950 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 char_u * |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
952 ExpandOne( |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
953 expand_T *xp, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
954 char_u *str, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
955 char_u *orig, // allocated copy of original of expanded string |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 int options, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
957 int mode) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
958 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
959 char_u *ss = NULL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 static int findex; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
961 static char_u *orig_save = NULL; // kept value of orig |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 int orig_saved = FALSE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
963 int i; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
964 long_u len; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
965 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 // first handle the case of using an old match |
28109
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
967 if (mode == WILD_NEXT || mode == WILD_PREV |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
28091
diff
changeset
|
968 || mode == WILD_PAGEUP || mode == WILD_PAGEDOWN) |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
969 return get_next_or_prev_match(mode, xp, &findex, orig_save); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
971 if (mode == WILD_CANCEL) |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
972 ss = vim_strsave(orig_save ? orig_save : (char_u *)""); |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
973 else if (mode == WILD_APPLY) |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
974 ss = vim_strsave(findex == -1 ? (orig_save ? |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
975 orig_save : (char_u *)"") : xp->xp_files[findex]); |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
976 |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 // free old names |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
978 if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
980 FreeWild(xp->xp_numfiles, xp->xp_files); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
981 xp->xp_numfiles = -1; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
982 VIM_CLEAR(orig_save); |
31394
a6b1f1c22374
patch 9.0.1030: using freed memory with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
31097
diff
changeset
|
983 |
a6b1f1c22374
patch 9.0.1030: using freed memory with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
31097
diff
changeset
|
984 // The entries from xp_files may be used in the PUM, remove it. |
a6b1f1c22374
patch 9.0.1030: using freed memory with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
31097
diff
changeset
|
985 if (compl_match_array != NULL) |
a6b1f1c22374
patch 9.0.1030: using freed memory with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
31097
diff
changeset
|
986 cmdline_pum_remove(); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
987 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 findex = 0; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
989 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 if (mode == WILD_FREE) // only release file name |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 return NULL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
993 if (xp->xp_numfiles == -1 && mode != WILD_APPLY && mode != WILD_CANCEL) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
994 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 vim_free(orig_save); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 orig_save = orig; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 orig_saved = TRUE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
998 |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
999 ss = ExpandOne_start(mode, xp, str, options); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1000 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1001 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1002 // Find longest common part |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 if (mode == WILD_LONGEST && xp->xp_numfiles > 0) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1004 { |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1005 ss = find_longest_match(xp, options); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1006 findex = -1; // next p_wc gets first one |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1007 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 |
29784
86c203dbf12b
patch 9.0.0231: expanding "**" may loop forever with directory links
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
1009 // Concatenate all matching names. Unless interrupted, this can be slow |
86c203dbf12b
patch 9.0.0231: expanding "**" may loop forever with directory links
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
1010 // and the result probably won't be used. |
86c203dbf12b
patch 9.0.0231: expanding "**" may loop forever with directory links
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
1011 if (mode == WILD_ALL && xp->xp_numfiles > 0 && !got_int) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1012 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1013 len = 0; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1014 for (i = 0; i < xp->xp_numfiles; ++i) |
32377
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1015 { |
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1016 if (i > 0) |
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1017 { |
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1018 if (xp->xp_prefix == XP_PREFIX_NO) |
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1019 len += 2; // prefix "no" |
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1020 else if (xp->xp_prefix == XP_PREFIX_INV) |
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1021 len += 3; // prefix "inv" |
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1022 } |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1023 len += (long_u)STRLEN(xp->xp_files[i]) + 1; |
32377
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1024 } |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1025 ss = alloc(len); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1026 if (ss != NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1027 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 *ss = NUL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 for (i = 0; i < xp->xp_numfiles; ++i) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 { |
32377
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1031 if (i > 0) |
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1032 { |
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1033 if (xp->xp_prefix == XP_PREFIX_NO) |
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1034 STRCAT(ss, "no"); |
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1035 else if (xp->xp_prefix == XP_PREFIX_INV) |
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1036 STRCAT(ss, "inv"); |
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1037 } |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1038 STRCAT(ss, xp->xp_files[i]); |
32377
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1039 |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 if (i != xp->xp_numfiles - 1) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 STRCAT(ss, (options & WILD_USE_NL) ? "\n" : " "); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1043 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1045 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 if (mode == WILD_EXPAND_FREE || mode == WILD_ALL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1047 ExpandCleanup(xp); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1049 // Free "orig" if it wasn't stored in "orig_save". |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 if (!orig_saved) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 vim_free(orig); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 return ss; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1054 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1055 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1056 /* |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1057 * Prepare an expand structure for use. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1058 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 void |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 ExpandInit(expand_T *xp) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1061 { |
21477
8a0362947c3a
patch 8.2.1289: crash when using a custom completion function
Bram Moolenaar <Bram@vim.org>
parents:
21423
diff
changeset
|
1062 CLEAR_POINTER(xp); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 xp->xp_backslash = XP_BS_NONE; |
32377
3efec53797f3
patch 9.0.1520: completion for option name includes all bool options
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1064 xp->xp_prefix = XP_PREFIX_NONE; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1065 xp->xp_numfiles = -1; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1066 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1067 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 /* |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 * Cleanup an expand structure after use. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1071 void |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1072 ExpandCleanup(expand_T *xp) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1073 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1074 if (xp->xp_numfiles >= 0) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1075 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1076 FreeWild(xp->xp_numfiles, xp->xp_files); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1077 xp->xp_numfiles = -1; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1079 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 /* |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1082 * Display one line of completion matches. Multiple matches are displayed in |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1083 * each line (used by wildmode=list and CTRL-D) |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1084 * matches - list of completion match names |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1085 * numMatches - number of completion matches in "matches" |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1086 * lines - number of output lines |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1087 * linenr - line number of matches to display |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1088 * maxlen - maximum number of characters in each line |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1089 * showtail - display only the tail of the full path of a file name |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1090 * dir_attr - highlight attribute to use for directory names |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1091 */ |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1092 static void |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1093 showmatches_oneline( |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1094 expand_T *xp, |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1095 char_u **matches, |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1096 int numMatches, |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1097 int lines, |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1098 int linenr, |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1099 int maxlen, |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1100 int showtail, |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1101 int dir_attr) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1102 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1103 int i, j; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1104 int isdir; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1105 int lastlen; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1106 char_u *p; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1107 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1108 lastlen = 999; |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1109 for (j = linenr; j < numMatches; j += lines) |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1110 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1111 if (xp->xp_context == EXPAND_TAGS_LISTFILES) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1112 { |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1113 msg_outtrans_attr(matches[j], HL_ATTR(HLF_D)); |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1114 p = matches[j] + STRLEN(matches[j]) + 1; |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1115 msg_advance(maxlen + 1); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1116 msg_puts((char *)p); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1117 msg_advance(maxlen + 3); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1118 msg_outtrans_long_attr(p + 2, HL_ATTR(HLF_D)); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1119 break; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1120 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1121 for (i = maxlen - lastlen; --i >= 0; ) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1122 msg_putchar(' '); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1123 if (xp->xp_context == EXPAND_FILES |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1124 || xp->xp_context == EXPAND_SHELLCMD |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1125 || xp->xp_context == EXPAND_BUFFERS) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1126 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1127 // highlight directories |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1128 if (xp->xp_numfiles != -1) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1129 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1130 char_u *halved_slash; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1131 char_u *exp_path; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1132 char_u *path; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1133 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1134 // Expansion was done before and special characters |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1135 // were escaped, need to halve backslashes. Also |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1136 // $HOME has been replaced with ~/. |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1137 exp_path = expand_env_save_opt(matches[j], TRUE); |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1138 path = exp_path != NULL ? exp_path : matches[j]; |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1139 halved_slash = backslash_halve_save(path); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1140 isdir = mch_isdir(halved_slash != NULL ? halved_slash |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1141 : matches[j]); |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1142 vim_free(exp_path); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1143 if (halved_slash != path) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1144 vim_free(halved_slash); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1145 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1146 else |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1147 // Expansion was done here, file names are literal. |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1148 isdir = mch_isdir(matches[j]); |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1149 if (showtail) |
31420
dcd73efec7de
patch 9.0.1043: macro has confusing name and is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
31394
diff
changeset
|
1150 p = SHOW_MATCH(j); |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1151 else |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1152 { |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1153 home_replace(NULL, matches[j], NameBuff, MAXPATHL, |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1154 TRUE); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1155 p = NameBuff; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1156 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1157 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1158 else |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1159 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1160 isdir = FALSE; |
31420
dcd73efec7de
patch 9.0.1043: macro has confusing name and is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
31394
diff
changeset
|
1161 p = SHOW_MATCH(j); |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1162 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1163 lastlen = msg_outtrans_attr(p, isdir ? dir_attr : 0); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1164 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1165 if (msg_col > 0) // when not wrapped around |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1166 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1167 msg_clr_eos(); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1168 msg_putchar('\n'); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1169 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1170 out_flush(); // show one line at a time |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1171 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1172 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1173 /* |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 * Show all matches for completion on the command line. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1175 * Returns EXPAND_NOTHING when the character that triggered expansion should |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1176 * be inserted like a normal character. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1177 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1178 int |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1179 showmatches(expand_T *xp, int wildmenu UNUSED) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1180 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 cmdline_info_T *ccline = get_cmdline_info(); |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1182 int numMatches; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1183 char_u **matches; |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1184 int i, j; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1185 int maxlen; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1186 int lines; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1187 int columns; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1188 int attr; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 int showtail; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1190 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 if (xp->xp_numfiles == -1) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 set_expand_context(xp); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1194 i = expand_cmdline(xp, ccline->cmdbuff, ccline->cmdpos, |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1195 &numMatches, &matches); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1196 showtail = expand_showtail(xp); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 if (i != EXPAND_OK) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 return i; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1199 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1200 else |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 { |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1202 numMatches = xp->xp_numfiles; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1203 matches = xp->xp_files; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 showtail = cmd_showtail; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1205 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1206 |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
1207 if (wildmenu && vim_strchr(p_wop, WOP_PUM) != NULL) |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
1208 // cmdline completion popup menu (with wildoptions=pum) |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1209 return cmdline_pum_create(ccline, xp, matches, numMatches, showtail); |
29881
0cc9a3001717
patch 9.0.0279: the tiny version has the popup menu but not 'wildmenu'
Bram Moolenaar <Bram@vim.org>
parents:
29794
diff
changeset
|
1210 |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1211 if (!wildmenu) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1213 msg_didany = FALSE; // lines_left will be set |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1214 msg_start(); // prepare for paging |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1215 msg_putchar('\n'); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1216 out_flush(); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1217 cmdline_row = msg_row; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 msg_didany = FALSE; // lines_left will be set again |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1219 msg_start(); // prepare for paging |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1220 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1221 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1222 if (got_int) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1223 got_int = FALSE; // only int. the completion, not the cmd line |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 else if (wildmenu) |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1225 win_redr_status_matches(xp, numMatches, matches, -1, showtail); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1226 else |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1227 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1228 // find the length of the longest file name |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 maxlen = 0; |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1230 for (i = 0; i < numMatches; ++i) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1231 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1232 if (!showtail && (xp->xp_context == EXPAND_FILES |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1233 || xp->xp_context == EXPAND_SHELLCMD |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1234 || xp->xp_context == EXPAND_BUFFERS)) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1235 { |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1236 home_replace(NULL, matches[i], NameBuff, MAXPATHL, TRUE); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1237 j = vim_strsize(NameBuff); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1238 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1239 else |
31420
dcd73efec7de
patch 9.0.1043: macro has confusing name and is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
31394
diff
changeset
|
1240 j = vim_strsize(SHOW_MATCH(i)); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1241 if (j > maxlen) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1242 maxlen = j; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1243 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1244 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1245 if (xp->xp_context == EXPAND_TAGS_LISTFILES) |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1246 lines = numMatches; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1247 else |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1248 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1249 // compute the number of columns and lines for the listing |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1250 maxlen += 2; // two spaces between file names |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1251 columns = ((int)Columns + 2) / maxlen; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1252 if (columns < 1) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1253 columns = 1; |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1254 lines = (numMatches + columns - 1) / columns; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1255 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1256 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1257 attr = HL_ATTR(HLF_D); // find out highlighting for directories |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1258 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1259 if (xp->xp_context == EXPAND_TAGS_LISTFILES) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1260 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1261 msg_puts_attr(_("tagname"), HL_ATTR(HLF_T)); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1262 msg_clr_eos(); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 msg_advance(maxlen - 3); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1264 msg_puts_attr(_(" kind file\n"), HL_ATTR(HLF_T)); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1265 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1266 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1267 // list the files line by line |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1268 for (i = 0; i < lines; ++i) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1269 { |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1270 showmatches_oneline(xp, matches, numMatches, lines, i, |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1271 maxlen, showtail, attr); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1272 if (got_int) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1274 got_int = FALSE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1275 break; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1276 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1277 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1278 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1279 // we redraw the command below the lines that we have just listed |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1280 // This is a bit tricky, but it saves a lot of screen updating. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1281 cmdline_row = msg_row; // will put it back later |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1282 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1283 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1284 if (xp->xp_numfiles == -1) |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1285 FreeWild(numMatches, matches); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1286 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1287 return EXPAND_OK; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1288 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1290 /* |
31065
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
1291 * gettail() version for showmatches() and win_redr_status_matches(): |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
1292 * Return the tail of file name path "s", ignoring a trailing "/". |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1293 */ |
31065
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
1294 static char_u * |
50405a481037
patch 9.0.0867: wildmenu redrawing code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
1295 showmatches_gettail(char_u *s) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 char_u *p; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 char_u *t = s; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1299 int had_sep = FALSE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1300 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1301 for (p = s; *p != NUL; ) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1302 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1303 if (vim_ispathsep(*p) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1304 #ifdef BACKSLASH_IN_FILENAME |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1305 && !rem_backslash(p) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1306 #endif |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1307 ) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1308 had_sep = TRUE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1309 else if (had_sep) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1310 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1311 t = p; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1312 had_sep = FALSE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1313 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1314 MB_PTR_ADV(p); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1315 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1316 return t; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1317 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1318 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1319 /* |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1320 * Return TRUE if we only need to show the tail of completion matches. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1321 * When not completing file names or there is a wildcard in the path FALSE is |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1322 * returned. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1323 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1324 static int |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1325 expand_showtail(expand_T *xp) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1326 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1327 char_u *s; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1328 char_u *end; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1330 // When not completing file names a "/" may mean something different. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 if (xp->xp_context != EXPAND_FILES |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 && xp->xp_context != EXPAND_SHELLCMD |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1333 && xp->xp_context != EXPAND_DIRECTORIES) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1334 return FALSE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1335 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1336 end = gettail(xp->xp_pattern); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1337 if (end == xp->xp_pattern) // there is no path separator |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1338 return FALSE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1339 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1340 for (s = xp->xp_pattern; s < end; s++) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1341 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1342 // Skip escaped wildcards. Only when the backslash is not a path |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1343 // separator, on DOS the '*' "path\*\file" must not be skipped. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1344 if (rem_backslash(s)) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1345 ++s; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1346 else if (vim_strchr((char_u *)"*?[", *s) != NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1347 return FALSE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1348 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1349 return TRUE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1350 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1351 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1352 /* |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1353 * Prepare a string for expansion. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1354 * When expanding file names: The string will be used with expand_wildcards(). |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1355 * Copy "fname[len]" into allocated memory and add a '*' at the end. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1356 * When expanding other names: The string will be used with regcomp(). Copy |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1357 * the name into allocated memory and prepend "^". |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1358 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1359 char_u * |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1360 addstar( |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1361 char_u *fname, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1362 int len, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1363 int context) // EXPAND_FILES etc. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1364 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1365 char_u *retval; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1366 int i, j; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1367 int new_len; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1368 char_u *tail; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1369 int ends_in_star; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1370 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1371 if (context != EXPAND_FILES |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1372 && context != EXPAND_FILES_IN_PATH |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1373 && context != EXPAND_SHELLCMD |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1374 && context != EXPAND_DIRECTORIES) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1375 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1376 // Matching will be done internally (on something other than files). |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1377 // So we convert the file-matching-type wildcards into our kind for |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1378 // use with vim_regcomp(). First work out how long it will be: |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1379 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1380 // For help tags the translation is done in find_help_tags(). |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1381 // For a tag pattern starting with "/" no translation is needed. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1382 if (context == EXPAND_HELP |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1383 || context == EXPAND_COLORS |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1384 || context == EXPAND_COMPILER |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1385 || context == EXPAND_OWNSYNTAX |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1386 || context == EXPAND_FILETYPE |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1387 || context == EXPAND_PACKADD |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31811
diff
changeset
|
1388 || context == EXPAND_RUNTIME |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1389 || ((context == EXPAND_TAGS_LISTFILES |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1390 || context == EXPAND_TAGS) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1391 && fname[0] == '/')) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1392 retval = vim_strnsave(fname, len); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1393 else |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1394 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1395 new_len = len + 2; // +2 for '^' at start, NUL at end |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1396 for (i = 0; i < len; i++) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1397 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1398 if (fname[i] == '*' || fname[i] == '~') |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1399 new_len++; // '*' needs to be replaced by ".*" |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1400 // '~' needs to be replaced by "\~" |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1401 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1402 // Buffer names are like file names. "." should be literal |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1403 if (context == EXPAND_BUFFERS && fname[i] == '.') |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1404 new_len++; // "." becomes "\." |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1405 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1406 // Custom expansion takes care of special things, match |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1407 // backslashes literally (perhaps also for other types?) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1408 if ((context == EXPAND_USER_DEFINED |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1409 || context == EXPAND_USER_LIST) && fname[i] == '\\') |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1410 new_len++; // '\' becomes "\\" |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1411 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1412 retval = alloc(new_len); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1413 if (retval != NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1414 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1415 retval[0] = '^'; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1416 j = 1; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1417 for (i = 0; i < len; i++, j++) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1418 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1419 // Skip backslash. But why? At least keep it for custom |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1420 // expansion. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1421 if (context != EXPAND_USER_DEFINED |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1422 && context != EXPAND_USER_LIST |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1423 && fname[i] == '\\' |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1424 && ++i == len) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1425 break; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1426 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1427 switch (fname[i]) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1428 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1429 case '*': retval[j++] = '.'; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1430 break; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1431 case '~': retval[j++] = '\\'; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1432 break; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1433 case '?': retval[j] = '.'; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1434 continue; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1435 case '.': if (context == EXPAND_BUFFERS) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1436 retval[j++] = '\\'; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1437 break; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1438 case '\\': if (context == EXPAND_USER_DEFINED |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1439 || context == EXPAND_USER_LIST) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1440 retval[j++] = '\\'; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1441 break; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1442 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1443 retval[j] = fname[i]; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1444 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1445 retval[j] = NUL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1446 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1447 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1448 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1449 else |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1450 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1451 retval = alloc(len + 4); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1452 if (retval != NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1453 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1454 vim_strncpy(retval, fname, len); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1455 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1456 // Don't add a star to *, ~, ~user, $var or `cmd`. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1457 // * would become **, which walks the whole tree. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1458 // ~ would be at the start of the file name, but not the tail. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1459 // $ could be anywhere in the tail. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1460 // ` could be anywhere in the file name. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1461 // When the name ends in '$' don't add a star, remove the '$'. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1462 tail = gettail(retval); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1463 ends_in_star = (len > 0 && retval[len - 1] == '*'); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1464 #ifndef BACKSLASH_IN_FILENAME |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1465 for (i = len - 2; i >= 0; --i) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1466 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1467 if (retval[i] != '\\') |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1468 break; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1469 ends_in_star = !ends_in_star; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1470 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1471 #endif |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1472 if ((*retval != '~' || tail != retval) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1473 && !ends_in_star |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1474 && vim_strchr(tail, '$') == NULL |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1475 && vim_strchr(retval, '`') == NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1476 retval[len++] = '*'; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1477 else if (len > 0 && retval[len - 1] == '$') |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1478 --len; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1479 retval[len] = NUL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1480 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1481 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1482 return retval; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1483 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1484 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1485 /* |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1486 * Must parse the command line so far to work out what context we are in. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1487 * Completion can then be done based on that context. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1488 * This routine sets the variables: |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1489 * xp->xp_pattern The start of the pattern to be expanded within |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1490 * the command line (ends at the cursor). |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1491 * xp->xp_context The type of thing to expand. Will be one of: |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1492 * |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1493 * EXPAND_UNSUCCESSFUL Used sometimes when there is something illegal on |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1494 * the command line, like an unknown command. Caller |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1495 * should beep. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1496 * EXPAND_NOTHING Unrecognised context for completion, use char like |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1497 * a normal char, rather than for completion. eg |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1498 * :s/^I/ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1499 * EXPAND_COMMANDS Cursor is still touching the command, so complete |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1500 * it. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1501 * EXPAND_BUFFERS Complete file names for :buf and :sbuf commands. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1502 * EXPAND_FILES After command with EX_XFILE set, or after setting |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1503 * with P_EXPAND set. eg :e ^I, :w>>^I |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1504 * EXPAND_DIRECTORIES In some cases this is used instead of the latter |
32295
bea4ebf594c6
patch 9.0.1479: small source file problems; outdated list of distrib. files
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
1505 * when we know only directories are of interest. |
bea4ebf594c6
patch 9.0.1479: small source file problems; outdated list of distrib. files
Bram Moolenaar <Bram@vim.org>
parents:
31819
diff
changeset
|
1506 * E.g. :set dir=^I and :cd ^I |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1507 * EXPAND_SHELLCMD After ":!cmd", ":r !cmd" or ":w !cmd". |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1508 * EXPAND_SETTINGS Complete variable names. eg :set d^I |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1509 * EXPAND_BOOL_SETTINGS Complete boolean variables only, eg :set no^I |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1510 * EXPAND_TAGS Complete tags from the files in p_tags. eg :ta a^I |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1511 * EXPAND_TAGS_LISTFILES As above, but list filenames on ^D, after :tselect |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1512 * EXPAND_HELP Complete tags from the file 'helpfile'/tags |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1513 * EXPAND_EVENTS Complete event names |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1514 * EXPAND_SYNTAX Complete :syntax command arguments |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1515 * EXPAND_HIGHLIGHT Complete highlight (syntax) group names |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1516 * EXPAND_AUGROUP Complete autocommand group names |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1517 * EXPAND_USER_VARS Complete user defined variable names, eg :unlet a^I |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1518 * EXPAND_MAPPINGS Complete mapping and abbreviation names, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1519 * eg :unmap a^I , :cunab x^I |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1520 * EXPAND_FUNCTIONS Complete internal or user defined function names, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1521 * eg :call sub^I |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1522 * EXPAND_USER_FUNC Complete user defined function names, eg :delf F^I |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1523 * EXPAND_EXPRESSION Complete internal or user defined function/variable |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1524 * names in expressions, eg :while s^I |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1525 * EXPAND_ENV_VARS Complete environment variable names |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1526 * EXPAND_USER Complete user names |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1527 */ |
28757
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28427
diff
changeset
|
1528 void |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1529 set_expand_context(expand_T *xp) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1530 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1531 cmdline_info_T *ccline = get_cmdline_info(); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1532 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1533 // only expansion for ':', '>' and '=' command-lines |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1534 if (ccline->cmdfirstc != ':' |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1535 #ifdef FEAT_EVAL |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1536 && ccline->cmdfirstc != '>' && ccline->cmdfirstc != '=' |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1537 && !ccline->input_fn |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1538 #endif |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1539 ) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1540 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1541 xp->xp_context = EXPAND_NOTHING; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1542 return; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1543 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1544 set_cmd_context(xp, ccline->cmdbuff, ccline->cmdlen, ccline->cmdpos, TRUE); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1545 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1546 |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1547 /* |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1548 * Sets the index of a built-in or user defined command 'cmd' in eap->cmdidx. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1549 * For user defined commands, the completion context is set in 'xp' and the |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1550 * completion flags in 'complp'. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1551 * |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1552 * Returns a pointer to the text after the command or NULL for failure. |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1553 */ |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1554 static char_u * |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1555 set_cmd_index(char_u *cmd, exarg_T *eap, expand_T *xp, int *complp) |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1556 { |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1557 char_u *p = NULL; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1558 int len = 0; |
27899
5426a1d3f12d
patch 8.2.4475: fuzzy cmdline completion does not work for lower case
Bram Moolenaar <Bram@vim.org>
parents:
27879
diff
changeset
|
1559 int fuzzy = cmdline_fuzzy_complete(cmd); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1560 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1561 // Isolate the command and search for it in the command table. |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1562 // Exceptions: |
27908
099c2e612827
patch 8.2.4479: no fuzzy completieon for maps and abbreviations
Bram Moolenaar <Bram@vim.org>
parents:
27906
diff
changeset
|
1563 // - the 'k' command can directly be followed by any character, but do |
099c2e612827
patch 8.2.4479: no fuzzy completieon for maps and abbreviations
Bram Moolenaar <Bram@vim.org>
parents:
27906
diff
changeset
|
1564 // accept "keepmarks", "keepalt" and "keepjumps". As fuzzy matching can |
099c2e612827
patch 8.2.4479: no fuzzy completieon for maps and abbreviations
Bram Moolenaar <Bram@vim.org>
parents:
27906
diff
changeset
|
1565 // find matches anywhere in the command name, do this only for command |
099c2e612827
patch 8.2.4479: no fuzzy completieon for maps and abbreviations
Bram Moolenaar <Bram@vim.org>
parents:
27906
diff
changeset
|
1566 // expansion based on regular expression and not for fuzzy matching. |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1567 // - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r' |
27908
099c2e612827
patch 8.2.4479: no fuzzy completieon for maps and abbreviations
Bram Moolenaar <Bram@vim.org>
parents:
27906
diff
changeset
|
1568 if (!fuzzy && (*cmd == 'k' && cmd[1] != 'e')) |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1569 { |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1570 eap->cmdidx = CMD_k; |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1571 p = cmd + 1; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1572 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1573 else |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1574 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1575 p = cmd; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1576 while (ASCII_ISALPHA(*p) || *p == '*') // Allow * wild card |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1577 ++p; |
24256
b471a413d36a
patch 8.2.2669: command line completion does not work after "vim9"
Bram Moolenaar <Bram@vim.org>
parents:
23356
diff
changeset
|
1578 // A user command may contain digits. |
b471a413d36a
patch 8.2.2669: command line completion does not work after "vim9"
Bram Moolenaar <Bram@vim.org>
parents:
23356
diff
changeset
|
1579 // Include "9" for "vim9*" commands; "vim9cmd" and "vim9script". |
b471a413d36a
patch 8.2.2669: command line completion does not work after "vim9"
Bram Moolenaar <Bram@vim.org>
parents:
23356
diff
changeset
|
1580 if (ASCII_ISUPPER(cmd[0]) || STRNCMP("vim9", cmd, 4) == 0) |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1581 while (ASCII_ISALNUM(*p) || *p == '*') |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1582 ++p; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1583 // for python 3.x: ":py3*" commands completion |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1584 if (cmd[0] == 'p' && cmd[1] == 'y' && p == cmd + 2 && *p == '3') |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1585 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1586 ++p; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1587 while (ASCII_ISALPHA(*p) || *p == '*') |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1588 ++p; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1589 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1590 // check for non-alpha command |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1591 if (p == cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1592 ++p; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1593 len = (int)(p - cmd); |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1594 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1595 if (len == 0) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1596 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1597 xp->xp_context = EXPAND_UNSUCCESSFUL; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1598 return NULL; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1599 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1600 |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1601 eap->cmdidx = excmd_get_cmdidx(cmd, len); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1602 |
27899
5426a1d3f12d
patch 8.2.4475: fuzzy cmdline completion does not work for lower case
Bram Moolenaar <Bram@vim.org>
parents:
27879
diff
changeset
|
1603 // User defined commands support alphanumeric characters. |
29495
82b0aeaeaa3c
patch 9.0.0089: fuzzy argument completion doesn't work for shell commands
Bram Moolenaar <Bram@vim.org>
parents:
29175
diff
changeset
|
1604 // Also when doing fuzzy expansion for non-shell commands, support |
82b0aeaeaa3c
patch 9.0.0089: fuzzy argument completion doesn't work for shell commands
Bram Moolenaar <Bram@vim.org>
parents:
29175
diff
changeset
|
1605 // alphanumeric characters. |
82b0aeaeaa3c
patch 9.0.0089: fuzzy argument completion doesn't work for shell commands
Bram Moolenaar <Bram@vim.org>
parents:
29175
diff
changeset
|
1606 if ((cmd[0] >= 'A' && cmd[0] <= 'Z') |
82b0aeaeaa3c
patch 9.0.0089: fuzzy argument completion doesn't work for shell commands
Bram Moolenaar <Bram@vim.org>
parents:
29175
diff
changeset
|
1607 || (fuzzy && eap->cmdidx != CMD_bang && *p != NUL)) |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1608 while (ASCII_ISALNUM(*p) || *p == '*') // Allow * wild card |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1609 ++p; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1610 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1611 |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
1612 // If the cursor is touching the command, and it ends in an alphanumeric |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1613 // character, complete the command name. |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1614 if (*p == NUL && ASCII_ISALNUM(p[-1])) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1615 return NULL; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1616 |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1617 if (eap->cmdidx == CMD_SIZE) |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1618 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1619 if (*cmd == 's' && vim_strchr((char_u *)"cgriI", cmd[1]) != NULL) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1620 { |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1621 eap->cmdidx = CMD_substitute; |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1622 p = cmd + 1; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1623 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1624 else if (cmd[0] >= 'A' && cmd[0] <= 'Z') |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1625 { |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1626 eap->cmd = cmd; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1627 p = find_ucmd(eap, p, NULL, xp, complp); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1628 if (p == NULL) |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1629 eap->cmdidx = CMD_SIZE; // ambiguous user command |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1630 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1631 } |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1632 if (eap->cmdidx == CMD_SIZE) |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1633 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1634 // Not still touching the command and it was an illegal one |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1635 xp->xp_context = EXPAND_UNSUCCESSFUL; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1636 return NULL; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1637 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1638 |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1639 return p; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1640 } |
21140
f86140ad0164
patch 8.2.1121: command completion not working after ++arg
Bram Moolenaar <Bram@vim.org>
parents:
20911
diff
changeset
|
1641 |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1642 /* |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1643 * Set the completion context for a command argument with wild card characters. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1644 */ |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1645 static void |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1646 set_context_for_wildcard_arg( |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1647 exarg_T *eap, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1648 char_u *arg, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1649 int usefilter, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1650 expand_T *xp, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1651 int *complp) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1652 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1653 char_u *p; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1654 int c; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1655 int in_quote = FALSE; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1656 char_u *bow = NULL; // Beginning of word |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1657 int len = 0; |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1658 |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1659 // Allow spaces within back-quotes to count as part of the argument |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1660 // being expanded. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1661 xp->xp_pattern = skipwhite(arg); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1662 p = xp->xp_pattern; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1663 while (*p != NUL) |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1664 { |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1665 if (has_mbyte) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1666 c = mb_ptr2char(p); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1667 else |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1668 c = *p; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1669 if (c == '\\' && p[1] != NUL) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1670 ++p; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1671 else if (c == '`') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1672 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1673 if (!in_quote) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1674 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1675 xp->xp_pattern = p; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1676 bow = p + 1; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1677 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1678 in_quote = !in_quote; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1679 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1680 // An argument can contain just about everything, except |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1681 // characters that end the command and white space. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1682 else if (c == '|' || c == '\n' || c == '"' || (VIM_ISWHITE(c) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1683 #ifdef SPACE_IN_FILENAME |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1684 && (!(eap->argt & EX_NOSPC) || usefilter) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1685 #endif |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1686 )) |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1687 { |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1688 len = 0; // avoid getting stuck when space is in 'isfname' |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1689 while (*p != NUL) |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1690 { |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1691 if (has_mbyte) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1692 c = mb_ptr2char(p); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1693 else |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1694 c = *p; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1695 if (c == '`' || vim_isfilec_or_wc(c)) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1696 break; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1697 if (has_mbyte) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1698 len = (*mb_ptr2len)(p); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1699 else |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1700 len = 1; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1701 MB_PTR_ADV(p); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1702 } |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1703 if (in_quote) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1704 bow = p; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1705 else |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1706 xp->xp_pattern = p; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1707 p -= len; |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1708 } |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1709 MB_PTR_ADV(p); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1710 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1711 |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1712 // If we are still inside the quotes, and we passed a space, just |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1713 // expand from there. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1714 if (bow != NULL && in_quote) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1715 xp->xp_pattern = bow; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1716 xp->xp_context = EXPAND_FILES; |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1717 |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1718 // For a shell command more chars need to be escaped. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1719 if (usefilter || eap->cmdidx == CMD_bang || eap->cmdidx == CMD_terminal) |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1720 { |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1721 #ifndef BACKSLASH_IN_FILENAME |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1722 xp->xp_shell = TRUE; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1723 #endif |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1724 // When still after the command name expand executables. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1725 if (xp->xp_pattern == skipwhite(arg)) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1726 xp->xp_context = EXPAND_SHELLCMD; |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1727 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1728 |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1729 // Check for environment variable. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1730 if (*xp->xp_pattern == '$') |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1731 { |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1732 for (p = xp->xp_pattern + 1; *p != NUL; ++p) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1733 if (!vim_isIDc(*p)) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1734 break; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1735 if (*p == NUL) |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1736 { |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1737 xp->xp_context = EXPAND_ENV_VARS; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1738 ++xp->xp_pattern; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1739 // Avoid that the assignment uses EXPAND_FILES again. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1740 if (*complp != EXPAND_USER_DEFINED && *complp != EXPAND_USER_LIST) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1741 *complp = EXPAND_ENV_VARS; |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1742 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1743 } |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1744 // Check for user names. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1745 if (*xp->xp_pattern == '~') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1746 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1747 for (p = xp->xp_pattern + 1; *p != NUL && *p != '/'; ++p) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1748 ; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1749 // Complete ~user only if it partially matches a user name. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1750 // A full match ~user<Tab> will be replaced by user's home |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1751 // directory i.e. something like ~user<Tab> -> /home/user/ |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1752 if (*p == NUL && p > xp->xp_pattern + 1 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1753 && match_user(xp->xp_pattern + 1) >= 1) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1754 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1755 xp->xp_context = EXPAND_USER; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1756 ++xp->xp_pattern; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1757 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1758 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1759 } |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
1760 |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
1761 /* |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1762 * Set the completion context for the :filter command. Returns a pointer to the |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1763 * next command after the :filter command. |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1764 */ |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1765 static char_u * |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1766 set_context_in_filter_cmd(expand_T *xp, char_u *arg) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1767 { |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1768 if (*arg != NUL) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1769 arg = skip_vimgrep_pat(arg, NULL, NULL); |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1770 if (arg == NULL || *arg == NUL) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1771 { |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1772 xp->xp_context = EXPAND_NOTHING; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1773 return NULL; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1774 } |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1775 return skipwhite(arg); |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1776 } |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1777 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1778 #ifdef FEAT_SEARCH_EXTRA |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1779 /* |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1780 * Set the completion context for the :match command. Returns a pointer to the |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1781 * next command after the :match command. |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1782 */ |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1783 static char_u * |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1784 set_context_in_match_cmd(expand_T *xp, char_u *arg) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1785 { |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1786 if (*arg == NUL || !ends_excmd(*arg)) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1787 { |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1788 // also complete "None" |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1789 set_context_in_echohl_cmd(xp, arg); |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1790 arg = skipwhite(skiptowhite(arg)); |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1791 if (*arg != NUL) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1792 { |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1793 xp->xp_context = EXPAND_NOTHING; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1794 arg = skip_regexp(arg + 1, *arg, magic_isset()); |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1795 } |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1796 } |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1797 return find_nextcmd(arg); |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1798 } |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1799 #endif |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1800 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1801 /* |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1802 * Returns a pointer to the next command after a :global or a :v command. |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1803 * Returns NULL if there is no next command. |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1804 */ |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1805 static char_u * |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1806 find_cmd_after_global_cmd(char_u *arg) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1807 { |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1808 int delim; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1809 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1810 delim = *arg; // get the delimiter |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1811 if (delim) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1812 ++arg; // skip delimiter if there is one |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1813 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1814 while (arg[0] != NUL && arg[0] != delim) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1815 { |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1816 if (arg[0] == '\\' && arg[1] != NUL) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1817 ++arg; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1818 ++arg; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1819 } |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1820 if (arg[0] != NUL) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1821 return arg + 1; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1822 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1823 return NULL; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1824 } |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1825 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1826 /* |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1827 * Returns a pointer to the next command after a :substitute or a :& command. |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1828 * Returns NULL if there is no next command. |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1829 */ |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1830 static char_u * |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1831 find_cmd_after_substitute_cmd(char_u *arg) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1832 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1833 int delim; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1834 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1835 delim = *arg; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1836 if (delim) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1837 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1838 // skip "from" part |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1839 ++arg; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1840 arg = skip_regexp(arg, delim, magic_isset()); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1841 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1842 if (arg[0] != NUL && arg[0] == delim) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1843 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1844 // skip "to" part |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1845 ++arg; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1846 while (arg[0] != NUL && arg[0] != delim) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1847 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1848 if (arg[0] == '\\' && arg[1] != NUL) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1849 ++arg; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1850 ++arg; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1851 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1852 if (arg[0] != NUL) // skip delimiter |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1853 ++arg; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1854 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1855 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1856 while (arg[0] && vim_strchr((char_u *)"|\"#", arg[0]) == NULL) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1857 ++arg; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1858 if (arg[0] != NUL) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1859 return arg; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1860 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1861 return NULL; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1862 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1863 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1864 /* |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1865 * Returns a pointer to the next command after a :isearch/:dsearch/:ilist |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1866 * :dlist/:ijump/:psearch/:djump/:isplit/:dsplit command. |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1867 * Returns NULL if there is no next command. |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1868 */ |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1869 static char_u * |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1870 find_cmd_after_isearch_cmd(expand_T *xp, char_u *arg) |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1871 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1872 arg = skipwhite(skipdigits(arg)); // skip count |
31667
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1873 if (*arg != '/') |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1874 return NULL; |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1875 |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1876 // Match regexp, not just whole words |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1877 for (++arg; *arg && *arg != '/'; arg++) |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1878 if (*arg == '\\' && arg[1] != NUL) |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1879 arg++; |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1880 if (*arg) |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1881 { |
31667
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1882 arg = skipwhite(arg + 1); |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1883 |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1884 // Check for trailing illegal characters |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1885 if (*arg == NUL || vim_strchr((char_u *)"|\"\n", *arg) == NULL) |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1886 xp->xp_context = EXPAND_NOTHING; |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1887 else |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
1888 return arg; |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1889 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1890 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1891 return NULL; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1892 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
1893 |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1894 #ifdef FEAT_EVAL |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1895 /* |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1896 * Set the completion context for the :unlet command. Always returns NULL. |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1897 */ |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1898 static char_u * |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1899 set_context_in_unlet_cmd(expand_T *xp, char_u *arg) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1900 { |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1901 while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1902 arg = xp->xp_pattern + 1; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1903 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1904 xp->xp_context = EXPAND_USER_VARS; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1905 xp->xp_pattern = arg; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1906 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1907 if (*xp->xp_pattern == '$') |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1908 { |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1909 xp->xp_context = EXPAND_ENV_VARS; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1910 ++xp->xp_pattern; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1911 } |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1912 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1913 return NULL; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1914 } |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1915 #endif |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1916 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1917 #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1918 /* |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1919 * Set the completion context for the :language command. Always returns NULL. |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1920 */ |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1921 static char_u * |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1922 set_context_in_lang_cmd(expand_T *xp, char_u *arg) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1923 { |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1924 char_u *p; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1925 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1926 p = skiptowhite(arg); |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1927 if (*p == NUL) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1928 { |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1929 xp->xp_context = EXPAND_LANGUAGE; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1930 xp->xp_pattern = arg; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1931 } |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1932 else |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1933 { |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1934 if ( STRNCMP(arg, "messages", p - arg) == 0 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1935 || STRNCMP(arg, "ctype", p - arg) == 0 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1936 || STRNCMP(arg, "time", p - arg) == 0 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1937 || STRNCMP(arg, "collate", p - arg) == 0) |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1938 { |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1939 xp->xp_context = EXPAND_LOCALES; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1940 xp->xp_pattern = skipwhite(p); |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1941 } |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1942 else |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1943 xp->xp_context = EXPAND_NOTHING; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1944 } |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1945 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1946 return NULL; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1947 } |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1948 #endif |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
1949 |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1950 #ifdef FEAT_EVAL |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1951 static enum |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1952 { |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1953 EXP_BREAKPT_ADD, // expand ":breakadd" sub-commands |
28091
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
1954 EXP_BREAKPT_DEL, // expand ":breakdel" sub-commands |
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
1955 EXP_PROFDEL // expand ":profdel" sub-commands |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1956 } breakpt_expand_what; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1957 |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1958 /* |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1959 * Set the completion context for the :breakadd command. Always returns NULL. |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1960 */ |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1961 static char_u * |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1962 set_context_in_breakadd_cmd(expand_T *xp, char_u *arg, cmdidx_T cmdidx) |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1963 { |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1964 char_u *p; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1965 char_u *subcmd_start; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1966 |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1967 xp->xp_context = EXPAND_BREAKPOINT; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1968 xp->xp_pattern = arg; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1969 |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1970 if (cmdidx == CMD_breakadd) |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1971 breakpt_expand_what = EXP_BREAKPT_ADD; |
28091
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
1972 else if (cmdidx == CMD_breakdel) |
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
1973 breakpt_expand_what = EXP_BREAKPT_DEL; |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1974 else |
28091
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
1975 breakpt_expand_what = EXP_PROFDEL; |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1976 |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1977 p = skipwhite(arg); |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1978 if (*p == NUL) |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1979 return NULL; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1980 subcmd_start = p; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1981 |
28091
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
1982 if (STRNCMP("file ", p, 5) == 0 || STRNCMP("func ", p, 5) == 0) |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1983 { |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1984 // :breakadd file [lnum] <filename> |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1985 // :breakadd func [lnum] <funcname> |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1986 p += 4; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1987 p = skipwhite(p); |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1988 |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1989 // skip line number (if specified) |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1990 if (VIM_ISDIGIT(*p)) |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1991 { |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1992 p = skipdigits(p); |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1993 if (*p != ' ') |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1994 { |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1995 xp->xp_context = EXPAND_NOTHING; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1996 return NULL; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1997 } |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1998 p = skipwhite(p); |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
1999 } |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2000 if (STRNCMP("file", subcmd_start, 4) == 0) |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2001 xp->xp_context = EXPAND_FILES; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2002 else |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2003 xp->xp_context = EXPAND_USER_FUNC; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2004 xp->xp_pattern = p; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2005 } |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2006 else if (STRNCMP("expr ", p, 5) == 0) |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2007 { |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2008 // :breakadd expr <expression> |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2009 xp->xp_context = EXPAND_EXPRESSION; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2010 xp->xp_pattern = skipwhite(p + 5); |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2011 } |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2012 |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2013 return NULL; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2014 } |
28183
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2015 |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2016 static char_u * |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2017 set_context_in_scriptnames_cmd(expand_T *xp, char_u *arg) |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2018 { |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2019 char_u *p; |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2020 |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2021 xp->xp_context = EXPAND_NOTHING; |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2022 xp->xp_pattern = NULL; |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2023 |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2024 p = skipwhite(arg); |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2025 if (VIM_ISDIGIT(*p)) |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2026 return NULL; |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2027 |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2028 xp->xp_context = EXPAND_SCRIPTNAMES; |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2029 xp->xp_pattern = p; |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2030 |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2031 return NULL; |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2032 } |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2033 #endif |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2034 |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2035 /* |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2036 * Set the completion context in 'xp' for command 'cmd' with index 'cmdidx'. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2037 * The argument to the command is 'arg' and the argument flags is 'argt'. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2038 * For user-defined commands and for environment variables, 'compl' has the |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2039 * completion type. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2040 * Returns a pointer to the next command. Returns NULL if there is no next |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2041 * command. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2042 */ |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2043 static char_u * |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2044 set_context_by_cmdname( |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2045 char_u *cmd, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2046 cmdidx_T cmdidx, |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2047 expand_T *xp, |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2048 char_u *arg, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2049 long argt, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2050 int compl, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2051 int forceit) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2052 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2053 switch (cmdidx) |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2054 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2055 case CMD_find: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2056 case CMD_sfind: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2057 case CMD_tabfind: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2058 if (xp->xp_context == EXPAND_FILES) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2059 xp->xp_context = EXPAND_FILES_IN_PATH; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2060 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2061 case CMD_cd: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2062 case CMD_chdir: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2063 case CMD_tcd: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2064 case CMD_tchdir: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2065 case CMD_lcd: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2066 case CMD_lchdir: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2067 if (xp->xp_context == EXPAND_FILES) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2068 xp->xp_context = EXPAND_DIRECTORIES; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2069 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2070 case CMD_help: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2071 xp->xp_context = EXPAND_HELP; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2072 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2073 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2074 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2075 // Command modifiers: return the argument. |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2076 // Also for commands with an argument that is a command. |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2077 case CMD_aboveleft: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2078 case CMD_argdo: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2079 case CMD_belowright: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2080 case CMD_botright: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2081 case CMD_browse: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2082 case CMD_bufdo: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2083 case CMD_cdo: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2084 case CMD_cfdo: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2085 case CMD_confirm: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2086 case CMD_debug: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2087 case CMD_folddoclosed: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2088 case CMD_folddoopen: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2089 case CMD_hide: |
30017
578e71f924fe
patch 9.0.0346: :horizontal modifier not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
29886
diff
changeset
|
2090 case CMD_horizontal: |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2091 case CMD_keepalt: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2092 case CMD_keepjumps: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2093 case CMD_keepmarks: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2094 case CMD_keeppatterns: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2095 case CMD_ldo: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2096 case CMD_leftabove: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2097 case CMD_lfdo: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2098 case CMD_lockmarks: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2099 case CMD_noautocmd: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2100 case CMD_noswapfile: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2101 case CMD_rightbelow: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2102 case CMD_sandbox: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2103 case CMD_silent: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2104 case CMD_tab: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2105 case CMD_tabdo: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2106 case CMD_topleft: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2107 case CMD_verbose: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2108 case CMD_vertical: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2109 case CMD_windo: |
24907
8388176a0954
patch 8.2.2991: Vim9: no completion for :vim9 and :legacy
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
2110 case CMD_vim9cmd: |
8388176a0954
patch 8.2.2991: Vim9: no completion for :vim9 and :legacy
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
2111 case CMD_legacy: |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2112 return arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2113 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2114 case CMD_filter: |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2115 return set_context_in_filter_cmd(xp, arg); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2116 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2117 #ifdef FEAT_SEARCH_EXTRA |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2118 case CMD_match: |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2119 return set_context_in_match_cmd(xp, arg); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2120 #endif |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2121 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2122 // All completion for the +cmdline_compl feature goes here. |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2123 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2124 case CMD_command: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2125 return set_context_in_user_cmd(xp, arg); |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2126 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2127 case CMD_delcommand: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2128 xp->xp_context = EXPAND_USER_COMMANDS; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2129 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2130 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2131 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2132 case CMD_global: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2133 case CMD_vglobal: |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2134 return find_cmd_after_global_cmd(arg); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2135 case CMD_and: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2136 case CMD_substitute: |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2137 return find_cmd_after_substitute_cmd(arg); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2138 case CMD_isearch: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2139 case CMD_dsearch: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2140 case CMD_ilist: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2141 case CMD_dlist: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2142 case CMD_ijump: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2143 case CMD_psearch: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2144 case CMD_djump: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2145 case CMD_isplit: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2146 case CMD_dsplit: |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2147 return find_cmd_after_isearch_cmd(xp, arg); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2148 case CMD_autocmd: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2149 return set_context_in_autocmd(xp, arg, FALSE); |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2150 case CMD_doautocmd: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2151 case CMD_doautoall: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2152 return set_context_in_autocmd(xp, arg, TRUE); |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2153 case CMD_set: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2154 set_context_in_set_cmd(xp, arg, 0); |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2155 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2156 case CMD_setglobal: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2157 set_context_in_set_cmd(xp, arg, OPT_GLOBAL); |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2158 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2159 case CMD_setlocal: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2160 set_context_in_set_cmd(xp, arg, OPT_LOCAL); |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2161 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2162 case CMD_tag: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2163 case CMD_stag: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2164 case CMD_ptag: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2165 case CMD_ltag: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2166 case CMD_tselect: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2167 case CMD_stselect: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2168 case CMD_ptselect: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2169 case CMD_tjump: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2170 case CMD_stjump: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2171 case CMD_ptjump: |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
2172 if (vim_strchr(p_wop, WOP_TAGFILE) != NULL) |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2173 xp->xp_context = EXPAND_TAGS_LISTFILES; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2174 else |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2175 xp->xp_context = EXPAND_TAGS; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2176 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2177 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2178 case CMD_augroup: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2179 xp->xp_context = EXPAND_AUGROUP; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2180 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2181 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2182 #ifdef FEAT_SYN_HL |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2183 case CMD_syntax: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2184 set_context_in_syntax_cmd(xp, arg); |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2185 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2186 #endif |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2187 #ifdef FEAT_EVAL |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
2188 case CMD_final: |
18713
baf890fa1621
patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
2189 case CMD_const: |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2190 case CMD_let: |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
2191 case CMD_var: |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2192 case CMD_if: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2193 case CMD_elseif: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2194 case CMD_while: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2195 case CMD_for: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2196 case CMD_echo: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2197 case CMD_echon: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2198 case CMD_execute: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2199 case CMD_echomsg: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2200 case CMD_echoerr: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2201 case CMD_call: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2202 case CMD_return: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2203 case CMD_cexpr: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2204 case CMD_caddexpr: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2205 case CMD_cgetexpr: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2206 case CMD_lexpr: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2207 case CMD_laddexpr: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2208 case CMD_lgetexpr: |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2209 set_context_for_expression(xp, arg, cmdidx); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2210 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2211 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2212 case CMD_unlet: |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2213 return set_context_in_unlet_cmd(xp, arg); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2214 case CMD_function: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2215 case CMD_delfunction: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2216 xp->xp_context = EXPAND_USER_FUNC; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2217 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2218 break; |
24909
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24907
diff
changeset
|
2219 case CMD_disassemble: |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24907
diff
changeset
|
2220 set_context_in_disassemble_cmd(xp, arg); |
09d222e89a84
patch 8.2.2992: Vim9: completion for :disassemble is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
24907
diff
changeset
|
2221 break; |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2222 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2223 case CMD_echohl: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2224 set_context_in_echohl_cmd(xp, arg); |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2225 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2226 #endif |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2227 case CMD_highlight: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2228 set_context_in_highlight_cmd(xp, arg); |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2229 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2230 #ifdef FEAT_CSCOPE |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2231 case CMD_cscope: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2232 case CMD_lcscope: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2233 case CMD_scscope: |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2234 set_context_in_cscope_cmd(xp, arg, cmdidx); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2235 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2236 #endif |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2237 #ifdef FEAT_SIGNS |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2238 case CMD_sign: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2239 set_context_in_sign_cmd(xp, arg); |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2240 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2241 #endif |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2242 case CMD_bdelete: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2243 case CMD_bwipeout: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2244 case CMD_bunload: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2245 while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2246 arg = xp->xp_pattern + 1; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2247 // FALLTHROUGH |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2248 case CMD_buffer: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2249 case CMD_sbuffer: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2250 case CMD_checktime: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2251 xp->xp_context = EXPAND_BUFFERS; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2252 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2253 break; |
18987
e378907d79bf
patch 8.2.0054: :diffget and :diffput don't have good completion
Bram Moolenaar <Bram@vim.org>
parents:
18713
diff
changeset
|
2254 #ifdef FEAT_DIFF |
e378907d79bf
patch 8.2.0054: :diffget and :diffput don't have good completion
Bram Moolenaar <Bram@vim.org>
parents:
18713
diff
changeset
|
2255 case CMD_diffget: |
e378907d79bf
patch 8.2.0054: :diffget and :diffput don't have good completion
Bram Moolenaar <Bram@vim.org>
parents:
18713
diff
changeset
|
2256 case CMD_diffput: |
e378907d79bf
patch 8.2.0054: :diffget and :diffput don't have good completion
Bram Moolenaar <Bram@vim.org>
parents:
18713
diff
changeset
|
2257 // If current buffer is in diff mode, complete buffer names |
e378907d79bf
patch 8.2.0054: :diffget and :diffput don't have good completion
Bram Moolenaar <Bram@vim.org>
parents:
18713
diff
changeset
|
2258 // which are in diff mode, and different than current buffer. |
e378907d79bf
patch 8.2.0054: :diffget and :diffput don't have good completion
Bram Moolenaar <Bram@vim.org>
parents:
18713
diff
changeset
|
2259 xp->xp_context = EXPAND_DIFF_BUFFERS; |
e378907d79bf
patch 8.2.0054: :diffget and :diffput don't have good completion
Bram Moolenaar <Bram@vim.org>
parents:
18713
diff
changeset
|
2260 xp->xp_pattern = arg; |
e378907d79bf
patch 8.2.0054: :diffget and :diffput don't have good completion
Bram Moolenaar <Bram@vim.org>
parents:
18713
diff
changeset
|
2261 break; |
e378907d79bf
patch 8.2.0054: :diffget and :diffput don't have good completion
Bram Moolenaar <Bram@vim.org>
parents:
18713
diff
changeset
|
2262 #endif |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2263 case CMD_USER: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2264 case CMD_USER_BUF: |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2265 return set_context_in_user_cmdarg(cmd, arg, argt, compl, xp, |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2266 forceit); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2267 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2268 case CMD_map: case CMD_noremap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2269 case CMD_nmap: case CMD_nnoremap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2270 case CMD_vmap: case CMD_vnoremap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2271 case CMD_omap: case CMD_onoremap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2272 case CMD_imap: case CMD_inoremap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2273 case CMD_cmap: case CMD_cnoremap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2274 case CMD_lmap: case CMD_lnoremap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2275 case CMD_smap: case CMD_snoremap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2276 case CMD_tmap: case CMD_tnoremap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2277 case CMD_xmap: case CMD_xnoremap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2278 return set_context_in_map_cmd(xp, cmd, arg, forceit, |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2279 FALSE, FALSE, cmdidx); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2280 case CMD_unmap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2281 case CMD_nunmap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2282 case CMD_vunmap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2283 case CMD_ounmap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2284 case CMD_iunmap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2285 case CMD_cunmap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2286 case CMD_lunmap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2287 case CMD_sunmap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2288 case CMD_tunmap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2289 case CMD_xunmap: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2290 return set_context_in_map_cmd(xp, cmd, arg, forceit, |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2291 FALSE, TRUE, cmdidx); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2292 case CMD_mapclear: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2293 case CMD_nmapclear: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2294 case CMD_vmapclear: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2295 case CMD_omapclear: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2296 case CMD_imapclear: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2297 case CMD_cmapclear: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2298 case CMD_lmapclear: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2299 case CMD_smapclear: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2300 case CMD_tmapclear: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2301 case CMD_xmapclear: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2302 xp->xp_context = EXPAND_MAPCLEAR; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2303 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2304 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2305 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2306 case CMD_abbreviate: case CMD_noreabbrev: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2307 case CMD_cabbrev: case CMD_cnoreabbrev: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2308 case CMD_iabbrev: case CMD_inoreabbrev: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2309 return set_context_in_map_cmd(xp, cmd, arg, forceit, |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2310 TRUE, FALSE, cmdidx); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2311 case CMD_unabbreviate: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2312 case CMD_cunabbrev: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2313 case CMD_iunabbrev: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2314 return set_context_in_map_cmd(xp, cmd, arg, forceit, |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2315 TRUE, TRUE, cmdidx); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2316 #ifdef FEAT_MENU |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2317 case CMD_menu: case CMD_noremenu: case CMD_unmenu: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2318 case CMD_amenu: case CMD_anoremenu: case CMD_aunmenu: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2319 case CMD_nmenu: case CMD_nnoremenu: case CMD_nunmenu: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2320 case CMD_vmenu: case CMD_vnoremenu: case CMD_vunmenu: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2321 case CMD_omenu: case CMD_onoremenu: case CMD_ounmenu: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2322 case CMD_imenu: case CMD_inoremenu: case CMD_iunmenu: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2323 case CMD_cmenu: case CMD_cnoremenu: case CMD_cunmenu: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2324 case CMD_tlmenu: case CMD_tlnoremenu: case CMD_tlunmenu: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2325 case CMD_tmenu: case CMD_tunmenu: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2326 case CMD_popup: case CMD_tearoff: case CMD_emenu: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2327 return set_context_in_menu_cmd(xp, cmd, arg, forceit); |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2328 #endif |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2329 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2330 case CMD_colorscheme: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2331 xp->xp_context = EXPAND_COLORS; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2332 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2333 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2334 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2335 case CMD_compiler: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2336 xp->xp_context = EXPAND_COMPILER; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2337 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2338 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2339 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2340 case CMD_ownsyntax: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2341 xp->xp_context = EXPAND_OWNSYNTAX; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2342 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2343 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2344 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2345 case CMD_setfiletype: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2346 xp->xp_context = EXPAND_FILETYPE; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2347 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2348 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2349 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2350 case CMD_packadd: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2351 xp->xp_context = EXPAND_PACKADD; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2352 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2353 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2354 |
31819
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31811
diff
changeset
|
2355 case CMD_runtime: |
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31811
diff
changeset
|
2356 set_context_in_runtime_cmd(xp, arg); |
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31811
diff
changeset
|
2357 break; |
aec031683d61
patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents:
31811
diff
changeset
|
2358 |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2359 #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2360 case CMD_language: |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2361 return set_context_in_lang_cmd(xp, arg); |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2362 #endif |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2363 #if defined(FEAT_PROFILE) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2364 case CMD_profile: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2365 set_context_in_profile_cmd(xp, arg); |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2366 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2367 #endif |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2368 case CMD_behave: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2369 xp->xp_context = EXPAND_BEHAVE; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2370 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2371 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2372 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2373 case CMD_messages: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2374 xp->xp_context = EXPAND_MESSAGES; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2375 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2376 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2377 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2378 case CMD_history: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2379 xp->xp_context = EXPAND_HISTORY; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2380 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2381 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2382 #if defined(FEAT_PROFILE) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2383 case CMD_syntime: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2384 xp->xp_context = EXPAND_SYNTIME; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2385 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2386 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2387 #endif |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2388 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2389 case CMD_argdelete: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2390 while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2391 arg = xp->xp_pattern + 1; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2392 xp->xp_context = EXPAND_ARGLIST; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2393 xp->xp_pattern = arg; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2394 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2395 |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2396 #ifdef FEAT_EVAL |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2397 case CMD_breakadd: |
28091
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
2398 case CMD_profdel: |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2399 case CMD_breakdel: |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2400 return set_context_in_breakadd_cmd(xp, arg, cmdidx); |
28183
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2401 |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2402 case CMD_scriptnames: |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2403 return set_context_in_scriptnames_cmd(xp, arg); |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2404 #endif |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2405 |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2406 default: |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2407 break; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2408 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2409 return NULL; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2410 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2411 |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2412 /* |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2413 * This is all pretty much copied from do_one_cmd(), with all the extra stuff |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2414 * we don't need/want deleted. Maybe this could be done better if we didn't |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2415 * repeat all this stuff. The only problem is that they may not stay |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2416 * perfectly compatible with each other, but then the command line syntax |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2417 * probably won't change that much -- webb. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2418 */ |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2419 static char_u * |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2420 set_one_cmd_context( |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2421 expand_T *xp, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2422 char_u *buff) // buffer for command string |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2423 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2424 char_u *p; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2425 char_u *cmd, *arg; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2426 int len = 0; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2427 exarg_T ea; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2428 int compl = EXPAND_NOTHING; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2429 int forceit = FALSE; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2430 int usefilter = FALSE; // filter instead of file name |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2431 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2432 ExpandInit(xp); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2433 xp->xp_pattern = buff; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2434 xp->xp_line = buff; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2435 xp->xp_context = EXPAND_COMMANDS; // Default until we get past command |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2436 ea.argt = 0; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2437 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2438 // 1. skip comment lines and leading space, colons or bars |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2439 for (cmd = buff; vim_strchr((char_u *)" \t:|", *cmd) != NULL; cmd++) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2440 ; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2441 xp->xp_pattern = cmd; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2442 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2443 if (*cmd == NUL) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2444 return NULL; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2445 if (*cmd == '"') // ignore comment lines |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2446 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2447 xp->xp_context = EXPAND_NOTHING; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2448 return NULL; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2449 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2450 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2451 // 3. Skip over the range to find the command. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2452 cmd = skip_range(cmd, TRUE, &xp->xp_context); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2453 xp->xp_pattern = cmd; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2454 if (*cmd == NUL) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2455 return NULL; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2456 if (*cmd == '"') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2457 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2458 xp->xp_context = EXPAND_NOTHING; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2459 return NULL; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2460 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2461 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2462 if (*cmd == '|' || *cmd == '\n') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2463 return cmd + 1; // There's another command |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2464 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2465 // Get the command index. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2466 p = set_cmd_index(cmd, &ea, xp, &compl); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2467 if (p == NULL) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2468 return NULL; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2469 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2470 xp->xp_context = EXPAND_NOTHING; // Default now that we're past command |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2471 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2472 if (*p == '!') // forced commands |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2473 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2474 forceit = TRUE; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2475 ++p; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2476 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2477 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2478 // 6. parse arguments |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2479 if (!IS_USER_CMDIDX(ea.cmdidx)) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2480 ea.argt = excmd_get_argt(ea.cmdidx); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2481 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2482 arg = skipwhite(p); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2483 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2484 // Skip over ++argopt argument |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2485 if ((ea.argt & EX_ARGOPT) && *arg != NUL && STRNCMP(arg, "++", 2) == 0) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2486 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2487 p = arg; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2488 while (*p && !vim_isspace(*p)) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2489 MB_PTR_ADV(p); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2490 arg = skipwhite(p); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2491 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2492 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2493 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2494 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2495 if (*arg == '>') // append |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2496 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2497 if (*++arg == '>') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2498 ++arg; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2499 arg = skipwhite(arg); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2500 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2501 else if (*arg == '!' && ea.cmdidx == CMD_write) // :w !filter |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2502 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2503 ++arg; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2504 usefilter = TRUE; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2505 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2506 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2507 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2508 if (ea.cmdidx == CMD_read) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2509 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2510 usefilter = forceit; // :r! filter if forced |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2511 if (*arg == '!') // :r !filter |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2512 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2513 ++arg; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2514 usefilter = TRUE; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2515 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2516 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2517 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2518 if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2519 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2520 while (*arg == *cmd) // allow any number of '>' or '<' |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2521 ++arg; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2522 arg = skipwhite(arg); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2523 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2524 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2525 // Does command allow "+command"? |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2526 if ((ea.argt & EX_CMDARG) && !usefilter && *arg == '+') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2527 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2528 // Check if we're in the +command |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2529 p = arg + 1; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2530 arg = skip_cmd_arg(arg, FALSE); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2531 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2532 // Still touching the command after '+'? |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2533 if (*arg == NUL) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2534 return p; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2535 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2536 // Skip space(s) after +command to get to the real argument |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2537 arg = skipwhite(arg); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2538 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2539 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2540 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2541 // Check for '|' to separate commands and '"' to start comments. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2542 // Don't do this for ":read !cmd" and ":write !cmd". |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2543 if ((ea.argt & EX_TRLBAR) && !usefilter) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2544 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2545 p = arg; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2546 // ":redir @" is not the start of a comment |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2547 if (ea.cmdidx == CMD_redir && p[0] == '@' && p[1] == '"') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2548 p += 2; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2549 while (*p) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2550 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2551 if (*p == Ctrl_V) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2552 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2553 if (p[1] != NUL) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2554 ++p; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2555 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2556 else if ( (*p == '"' && !(ea.argt & EX_NOTRLCOM)) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2557 || *p == '|' || *p == '\n') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2558 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2559 if (*(p - 1) != '\\') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2560 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2561 if (*p == '|' || *p == '\n') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2562 return p + 1; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2563 return NULL; // It's a comment |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2564 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2565 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2566 MB_PTR_ADV(p); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2567 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2568 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2569 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2570 if (!(ea.argt & EX_EXTRA) && *arg != NUL |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2571 && vim_strchr((char_u *)"|\"", *arg) == NULL) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2572 // no arguments allowed but there is something |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2573 return NULL; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2574 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2575 // Find start of last argument (argument just before cursor): |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2576 p = buff; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2577 xp->xp_pattern = p; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2578 len = (int)STRLEN(buff); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2579 while (*p && p < buff + len) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2580 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2581 if (*p == ' ' || *p == TAB) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2582 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2583 // argument starts after a space |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2584 xp->xp_pattern = ++p; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2585 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2586 else |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2587 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2588 if (*p == '\\' && *(p + 1) != NUL) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2589 ++p; // skip over escaped character |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2590 MB_PTR_ADV(p); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2591 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2592 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2593 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2594 if (ea.argt & EX_XFILE) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2595 set_context_for_wildcard_arg(&ea, arg, usefilter, xp, &compl); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2596 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2597 // 6. Switch on command name. |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2598 return set_context_by_cmdname(cmd, ea.cmdidx, xp, arg, ea.argt, compl, |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2599 forceit); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2600 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2601 |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2602 /* |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2603 * Set the completion context in 'xp' for command 'str' |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2604 */ |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2605 void |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2606 set_cmd_context( |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2607 expand_T *xp, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2608 char_u *str, // start of command line |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2609 int len, // length of command line (excl. NUL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2610 int col, // position of cursor |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2611 int use_ccline UNUSED) // use ccline for info |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2612 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2613 #ifdef FEAT_EVAL |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2614 cmdline_info_T *ccline = get_cmdline_info(); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2615 #endif |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2616 int old_char = NUL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2617 char_u *nextcomm; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2618 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2619 // Avoid a UMR warning from Purify, only save the character if it has been |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2620 // written before. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2621 if (col < len) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2622 old_char = str[col]; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2623 str[col] = NUL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2624 nextcomm = str; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2625 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2626 #ifdef FEAT_EVAL |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2627 if (use_ccline && ccline->cmdfirstc == '=') |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2628 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2629 // pass CMD_SIZE because there is no real command |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2630 set_context_for_expression(xp, str, CMD_SIZE); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2631 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2632 else if (use_ccline && ccline->input_fn) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2633 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2634 xp->xp_context = ccline->xp_context; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2635 xp->xp_pattern = ccline->cmdbuff; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2636 xp->xp_arg = ccline->xp_arg; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2637 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2638 else |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2639 #endif |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2640 while (nextcomm != NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2641 nextcomm = set_one_cmd_context(xp, nextcomm); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2642 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2643 // Store the string here so that call_user_expand_func() can get to them |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2644 // easily. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2645 xp->xp_line = str; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2646 xp->xp_col = col; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2647 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2648 str[col] = old_char; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2649 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2650 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2651 /* |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2652 * Expand the command line "str" from context "xp". |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2653 * "xp" must have been set by set_cmd_context(). |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2654 * xp->xp_pattern points into "str", to where the text that is to be expanded |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2655 * starts. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2656 * Returns EXPAND_UNSUCCESSFUL when there is something illegal before the |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2657 * cursor. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2658 * Returns EXPAND_NOTHING when there is nothing to expand, might insert the |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2659 * key that triggered expansion literally. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2660 * Returns EXPAND_OK otherwise. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2661 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2662 int |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2663 expand_cmdline( |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2664 expand_T *xp, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2665 char_u *str, // start of command line |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2666 int col, // position of cursor |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2667 int *matchcount, // return: nr of matches |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2668 char_u ***matches) // return: array of pointers to matches |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2669 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2670 char_u *file_str = NULL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2671 int options = WILD_ADD_SLASH|WILD_SILENT; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2672 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2673 if (xp->xp_context == EXPAND_UNSUCCESSFUL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2674 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2675 beep_flush(); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2676 return EXPAND_UNSUCCESSFUL; // Something illegal on command line |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2677 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2678 if (xp->xp_context == EXPAND_NOTHING) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2679 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2680 // Caller can use the character as a normal char instead |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2681 return EXPAND_NOTHING; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2682 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2683 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2684 // add star to file name, or convert to regexp if not exp. files. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2685 xp->xp_pattern_len = (int)(str + col - xp->xp_pattern); |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
2686 if (cmdline_fuzzy_completion_supported(xp)) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
2687 // If fuzzy matching, don't modify the search string |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
2688 file_str = vim_strsave(xp->xp_pattern); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
2689 else |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
2690 { |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
2691 file_str = addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context); |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
2692 if (file_str == NULL) |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
2693 return EXPAND_UNSUCCESSFUL; |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
2694 } |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2695 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2696 if (p_wic) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2697 options += WILD_ICASE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2698 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2699 // find all files that match the description |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2700 if (ExpandFromContext(xp, file_str, matches, matchcount, options) == FAIL) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2701 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2702 *matchcount = 0; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2703 *matches = NULL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2704 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2705 vim_free(file_str); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2706 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2707 return EXPAND_OK; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2708 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2709 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2710 /* |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2711 * Expand file or directory names. |
30325
58fb880f3607
patch 9.0.0498: various small issues
Bram Moolenaar <Bram@vim.org>
parents:
30043
diff
changeset
|
2712 * Returns OK or FAIL. |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2713 */ |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2714 static int |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2715 expand_files_and_dirs( |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2716 expand_T *xp, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2717 char_u *pat, |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2718 char_u ***matches, |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2719 int *numMatches, |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2720 int flags, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2721 int options) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2722 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2723 int free_pat = FALSE; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2724 int i; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2725 int ret; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2726 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2727 // for ":set path=" and ":set tags=" halve backslashes for escaped |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2728 // space |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2729 if (xp->xp_backslash != XP_BS_NONE) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2730 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2731 free_pat = TRUE; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2732 pat = vim_strsave(pat); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2733 for (i = 0; pat[i]; ++i) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2734 if (pat[i] == '\\') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2735 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2736 if (xp->xp_backslash == XP_BS_THREE |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2737 && pat[i + 1] == '\\' |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2738 && pat[i + 2] == '\\' |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2739 && pat[i + 3] == ' ') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2740 STRMOVE(pat + i, pat + i + 3); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2741 if (xp->xp_backslash == XP_BS_ONE |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2742 && pat[i + 1] == ' ') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2743 STRMOVE(pat + i, pat + i + 1); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2744 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2745 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2746 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2747 if (xp->xp_context == EXPAND_FILES) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2748 flags |= EW_FILE; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2749 else if (xp->xp_context == EXPAND_FILES_IN_PATH) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2750 flags |= (EW_FILE | EW_PATH); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2751 else |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2752 flags = (flags | EW_DIR) & ~EW_FILE; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2753 if (options & WILD_ICASE) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2754 flags |= EW_ICASE; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2755 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2756 // Expand wildcards, supporting %:h and the like. |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2757 ret = expand_wildcards_eval(&pat, numMatches, matches, flags); |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2758 if (free_pat) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2759 vim_free(pat); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2760 #ifdef BACKSLASH_IN_FILENAME |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2761 if (p_csl[0] != NUL && (options & WILD_IGNORE_COMPLETESLASH) == 0) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2762 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2763 int j; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2764 |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2765 for (j = 0; j < *numMatches; ++j) |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2766 { |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2767 char_u *ptr = (*matches)[j]; |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2768 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2769 while (*ptr != NUL) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2770 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2771 if (p_csl[0] == 's' && *ptr == '\\') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2772 *ptr = '/'; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2773 else if (p_csl[0] == 'b' && *ptr == '/') |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2774 *ptr = '\\'; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2775 ptr += (*mb_ptr2len)(ptr); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2776 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2777 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2778 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2779 #endif |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2780 return ret; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2781 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2782 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2783 /* |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2784 * Function given to ExpandGeneric() to obtain the possible arguments of the |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2785 * ":behave {mswin,xterm}" command. |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2786 */ |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2787 static char_u * |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2788 get_behave_arg(expand_T *xp UNUSED, int idx) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2789 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2790 if (idx == 0) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2791 return (char_u *)"mswin"; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2792 if (idx == 1) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2793 return (char_u *)"xterm"; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2794 return NULL; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2795 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2796 |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
2797 #ifdef FEAT_EVAL |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2798 /* |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2799 * Function given to ExpandGeneric() to obtain the possible arguments of the |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2800 * ":breakadd {expr, file, func, here}" command. |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2801 * ":breakdel {func, file, here}" command. |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2802 */ |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2803 static char_u * |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2804 get_breakadd_arg(expand_T *xp UNUSED, int idx) |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2805 { |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2806 char *opts[] = {"expr", "file", "func", "here"}; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2807 |
31667
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31420
diff
changeset
|
2808 if (idx >= 0 && idx <= 3) |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2809 { |
28091
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
2810 // breakadd {expr, file, func, here} |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2811 if (breakpt_expand_what == EXP_BREAKPT_ADD) |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2812 return (char_u *)opts[idx]; |
28091
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
2813 else if (breakpt_expand_what == EXP_BREAKPT_DEL) |
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
2814 { |
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
2815 // breakdel {func, file, here} |
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
2816 if (idx <= 2) |
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
2817 return (char_u *)opts[idx + 1]; |
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
2818 } |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2819 else |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2820 { |
28091
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
2821 // profdel {func, file} |
554f493902ea
patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
2822 if (idx <= 1) |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2823 return (char_u *)opts[idx + 1]; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2824 } |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2825 } |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2826 return NULL; |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2827 } |
28183
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2828 |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2829 /* |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2830 * Function given to ExpandGeneric() to obtain the possible arguments for the |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2831 * ":scriptnames" command. |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2832 */ |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2833 static char_u * |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2834 get_scriptnames_arg(expand_T *xp UNUSED, int idx) |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2835 { |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2836 scriptitem_T *si; |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2837 |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2838 if (!SCRIPT_ID_VALID(idx + 1)) |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2839 return NULL; |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2840 |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2841 si = SCRIPT_ITEM(idx + 1); |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2842 home_replace(NULL, si->sn_name, NameBuff, MAXPATHL, TRUE); |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2843 return NameBuff; |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2844 } |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2845 #endif |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2846 |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2847 /* |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2848 * Function given to ExpandGeneric() to obtain the possible arguments of the |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2849 * ":messages {clear}" command. |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2850 */ |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2851 static char_u * |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2852 get_messages_arg(expand_T *xp UNUSED, int idx) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2853 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2854 if (idx == 0) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2855 return (char_u *)"clear"; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2856 return NULL; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2857 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2858 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2859 static char_u * |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2860 get_mapclear_arg(expand_T *xp UNUSED, int idx) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2861 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2862 if (idx == 0) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2863 return (char_u *)"<buffer>"; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2864 return NULL; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2865 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2866 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17801
diff
changeset
|
2867 /* |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2868 * Do the expansion based on xp->xp_context and 'rmp'. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2869 */ |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2870 static int |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2871 ExpandOther( |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
2872 char_u *pat, |
27904
7422add1afd1
patch 8.2.4477: crash when using fuzzy completion
Bram Moolenaar <Bram@vim.org>
parents:
27899
diff
changeset
|
2873 expand_T *xp, |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2874 regmatch_T *rmp, |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2875 char_u ***matches, |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2876 int *numMatches) |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2877 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2878 static struct expgen |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2879 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2880 int context; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2881 char_u *((*func)(expand_T *, int)); |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2882 int ic; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2883 int escaped; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2884 } tab[] = |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2885 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2886 {EXPAND_COMMANDS, get_command_name, FALSE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2887 {EXPAND_BEHAVE, get_behave_arg, TRUE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2888 {EXPAND_MAPCLEAR, get_mapclear_arg, TRUE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2889 {EXPAND_MESSAGES, get_messages_arg, TRUE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2890 {EXPAND_HISTORY, get_history_arg, TRUE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2891 {EXPAND_USER_COMMANDS, get_user_commands, FALSE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2892 {EXPAND_USER_ADDR_TYPE, get_user_cmd_addr_type, FALSE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2893 {EXPAND_USER_CMD_FLAGS, get_user_cmd_flags, FALSE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2894 {EXPAND_USER_NARGS, get_user_cmd_nargs, FALSE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2895 {EXPAND_USER_COMPLETE, get_user_cmd_complete, FALSE, TRUE}, |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2896 #ifdef FEAT_EVAL |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2897 {EXPAND_USER_VARS, get_user_var_name, FALSE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2898 {EXPAND_FUNCTIONS, get_function_name, FALSE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2899 {EXPAND_USER_FUNC, get_user_func_name, FALSE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2900 {EXPAND_DISASSEMBLE, get_disassemble_argument, FALSE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2901 {EXPAND_EXPRESSION, get_expr_name, FALSE, TRUE}, |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2902 #endif |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2903 #ifdef FEAT_MENU |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2904 {EXPAND_MENUS, get_menu_name, FALSE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2905 {EXPAND_MENUNAMES, get_menu_names, FALSE, TRUE}, |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2906 #endif |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2907 #ifdef FEAT_SYN_HL |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2908 {EXPAND_SYNTAX, get_syntax_name, TRUE, TRUE}, |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2909 #endif |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2910 #ifdef FEAT_PROFILE |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2911 {EXPAND_SYNTIME, get_syntime_arg, TRUE, TRUE}, |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2912 #endif |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2913 {EXPAND_HIGHLIGHT, get_highlight_name, TRUE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2914 {EXPAND_EVENTS, get_event_name, TRUE, FALSE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2915 {EXPAND_AUGROUP, get_augroup_name, TRUE, FALSE}, |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2916 #ifdef FEAT_CSCOPE |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2917 {EXPAND_CSCOPE, get_cscope_name, TRUE, TRUE}, |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2918 #endif |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2919 #ifdef FEAT_SIGNS |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2920 {EXPAND_SIGN, get_sign_name, TRUE, TRUE}, |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2921 #endif |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2922 #ifdef FEAT_PROFILE |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2923 {EXPAND_PROFILE, get_profile_name, TRUE, TRUE}, |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2924 #endif |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2925 #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2926 {EXPAND_LANGUAGE, get_lang_arg, TRUE, FALSE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2927 {EXPAND_LOCALES, get_locales, TRUE, FALSE}, |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2928 #endif |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2929 {EXPAND_ENV_VARS, get_env_name, TRUE, TRUE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2930 {EXPAND_USER, get_users, TRUE, FALSE}, |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2931 {EXPAND_ARGLIST, get_arglist_name, TRUE, FALSE}, |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2932 #ifdef FEAT_EVAL |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2933 {EXPAND_BREAKPOINT, get_breakadd_arg, TRUE, TRUE}, |
28183
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
2934 {EXPAND_SCRIPTNAMES, get_scriptnames_arg, TRUE, FALSE}, |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
27920
diff
changeset
|
2935 #endif |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2936 }; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2937 int i; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2938 int ret = FAIL; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2939 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2940 // Find a context in the table and call the ExpandGeneric() with the |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2941 // right function to do the expansion. |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2942 for (i = 0; i < (int)ARRAY_LENGTH(tab); ++i) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2943 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2944 if (xp->xp_context == tab[i].context) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2945 { |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2946 if (tab[i].ic) |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2947 rmp->rm_ic = TRUE; |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
2948 ret = ExpandGeneric(pat, xp, rmp, matches, numMatches, |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
2949 tab[i].func, tab[i].escaped); |
27661
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2950 break; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2951 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2952 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2953 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2954 return ret; |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2955 } |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2956 |
2062de7c0edd
patch 8.2.4356: command line completion functions are very long
Bram Moolenaar <Bram@vim.org>
parents:
27630
diff
changeset
|
2957 /* |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2958 * Map wild expand options to flags for expand_wildcards() |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2959 */ |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2960 static int |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2961 map_wildopts_to_ewflags(int options) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2962 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2963 int flags; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2964 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2965 flags = EW_DIR; // include directories |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2966 if (options & WILD_LIST_NOTFOUND) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2967 flags |= EW_NOTFOUND; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2968 if (options & WILD_ADD_SLASH) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2969 flags |= EW_ADDSLASH; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2970 if (options & WILD_KEEP_ALL) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2971 flags |= EW_KEEPALL; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2972 if (options & WILD_SILENT) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2973 flags |= EW_SILENT; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2974 if (options & WILD_NOERROR) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2975 flags |= EW_NOERROR; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2976 if (options & WILD_ALLLINKS) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2977 flags |= EW_ALLLINKS; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2978 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2979 return flags; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2980 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2981 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
2982 /* |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2983 * Do the expansion based on xp->xp_context and "pat". |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2984 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2985 static int |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2986 ExpandFromContext( |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2987 expand_T *xp, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2988 char_u *pat, |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2989 char_u ***matches, |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
2990 int *numMatches, |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2991 int options) // WILD_ flags |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2992 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2993 regmatch_T regmatch; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2994 int ret; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2995 int flags; |
19556
ff5048b0ccfe
patch 8.2.0335: no completion for :disassemble
Bram Moolenaar <Bram@vim.org>
parents:
19077
diff
changeset
|
2996 char_u *tofree = NULL; |
27906
11141b2ec0e1
patch 8.2.4478: crash when using fuzzy completion
Bram Moolenaar <Bram@vim.org>
parents:
27904
diff
changeset
|
2997 int fuzzy = cmdline_fuzzy_complete(pat) |
11141b2ec0e1
patch 8.2.4478: crash when using fuzzy completion
Bram Moolenaar <Bram@vim.org>
parents:
27904
diff
changeset
|
2998 && cmdline_fuzzy_completion_supported(xp); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2999 |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3000 flags = map_wildopts_to_ewflags(options); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3001 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3002 if (xp->xp_context == EXPAND_FILES |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3003 || xp->xp_context == EXPAND_DIRECTORIES |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3004 || xp->xp_context == EXPAND_FILES_IN_PATH) |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3005 return expand_files_and_dirs(xp, pat, matches, numMatches, flags, |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3006 options); |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3007 |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3008 *matches = (char_u **)""; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3009 *numMatches = 0; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3010 if (xp->xp_context == EXPAND_HELP) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3011 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3012 // With an empty argument we would get all the help tags, which is |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3013 // very slow. Get matches for "help" instead. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3014 if (find_help_tags(*pat == NUL ? (char_u *)"help" : pat, |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3015 numMatches, matches, FALSE) == OK) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3016 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3017 #ifdef FEAT_MULTI_LANG |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3018 cleanup_help_tags(*numMatches, *matches); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3019 #endif |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3020 return OK; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3021 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3022 return FAIL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3023 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3024 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3025 if (xp->xp_context == EXPAND_SHELLCMD) |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3026 return expand_shellcmd(pat, matches, numMatches, flags); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3027 if (xp->xp_context == EXPAND_OLD_SETTING) |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3028 return ExpandOldSetting(numMatches, matches); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3029 if (xp->xp_context == EXPAND_BUFFERS) |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3030 return ExpandBufnames(pat, numMatches, matches, options); |
18987
e378907d79bf
patch 8.2.0054: :diffget and :diffput don't have good completion
Bram Moolenaar <Bram@vim.org>
parents:
18713
diff
changeset
|
3031 #ifdef FEAT_DIFF |
e378907d79bf
patch 8.2.0054: :diffget and :diffput don't have good completion
Bram Moolenaar <Bram@vim.org>
parents:
18713
diff
changeset
|
3032 if (xp->xp_context == EXPAND_DIFF_BUFFERS) |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3033 return ExpandBufnames(pat, numMatches, matches, |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3034 options | BUF_DIFF_FILTER); |
18987
e378907d79bf
patch 8.2.0054: :diffget and :diffput don't have good completion
Bram Moolenaar <Bram@vim.org>
parents:
18713
diff
changeset
|
3035 #endif |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3036 if (xp->xp_context == EXPAND_TAGS |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3037 || xp->xp_context == EXPAND_TAGS_LISTFILES) |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3038 return expand_tags(xp->xp_context == EXPAND_TAGS, pat, numMatches, |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3039 matches); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3040 if (xp->xp_context == EXPAND_COLORS) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3041 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3042 char *directories[] = {"colors", NULL}; |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3043 return ExpandRTDir(pat, DIP_START + DIP_OPT, numMatches, matches, |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3044 directories); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3045 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3046 if (xp->xp_context == EXPAND_COMPILER) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3047 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3048 char *directories[] = {"compiler", NULL}; |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3049 return ExpandRTDir(pat, 0, numMatches, matches, directories); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3050 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3051 if (xp->xp_context == EXPAND_OWNSYNTAX) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3052 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3053 char *directories[] = {"syntax", NULL}; |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3054 return ExpandRTDir(pat, 0, numMatches, matches, directories); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3055 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3056 if (xp->xp_context == EXPAND_FILETYPE) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3057 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3058 char *directories[] = {"syntax", "indent", "ftplugin", NULL}; |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3059 return ExpandRTDir(pat, 0, numMatches, matches, directories); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3060 } |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3061 #if defined(FEAT_EVAL) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3062 if (xp->xp_context == EXPAND_USER_LIST) |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3063 return ExpandUserList(xp, matches, numMatches); |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3064 #endif |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3065 if (xp->xp_context == EXPAND_PACKADD) |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3066 return ExpandPackAddDir(pat, numMatches, matches); |
31811
c5ff7d053fa1
patch 9.0.1238: :runtime completion can be further improved
Bram Moolenaar <Bram@vim.org>
parents:
31798
diff
changeset
|
3067 if (xp->xp_context == EXPAND_RUNTIME) |
c5ff7d053fa1
patch 9.0.1238: :runtime completion can be further improved
Bram Moolenaar <Bram@vim.org>
parents:
31798
diff
changeset
|
3068 return expand_runtime_cmd(pat, numMatches, matches); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3069 |
19556
ff5048b0ccfe
patch 8.2.0335: no completion for :disassemble
Bram Moolenaar <Bram@vim.org>
parents:
19077
diff
changeset
|
3070 // When expanding a function name starting with s:, match the <SNR>nr_ |
ff5048b0ccfe
patch 8.2.0335: no completion for :disassemble
Bram Moolenaar <Bram@vim.org>
parents:
19077
diff
changeset
|
3071 // prefix. |
25682
17ba70005a2e
patch 8.2.3377: Vim9: :disass completion does not understand "s:"
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
3072 if ((xp->xp_context == EXPAND_USER_FUNC |
17ba70005a2e
patch 8.2.3377: Vim9: :disass completion does not understand "s:"
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
3073 || xp->xp_context == EXPAND_DISASSEMBLE) |
17ba70005a2e
patch 8.2.3377: Vim9: :disass completion does not understand "s:"
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
3074 && STRNCMP(pat, "^s:", 3) == 0) |
19556
ff5048b0ccfe
patch 8.2.0335: no completion for :disassemble
Bram Moolenaar <Bram@vim.org>
parents:
19077
diff
changeset
|
3075 { |
ff5048b0ccfe
patch 8.2.0335: no completion for :disassemble
Bram Moolenaar <Bram@vim.org>
parents:
19077
diff
changeset
|
3076 int len = (int)STRLEN(pat) + 20; |
ff5048b0ccfe
patch 8.2.0335: no completion for :disassemble
Bram Moolenaar <Bram@vim.org>
parents:
19077
diff
changeset
|
3077 |
ff5048b0ccfe
patch 8.2.0335: no completion for :disassemble
Bram Moolenaar <Bram@vim.org>
parents:
19077
diff
changeset
|
3078 tofree = alloc(len); |
27722
637ccebaf328
patch 8.2.4387: command line completion doesn't always work properly
Bram Moolenaar <Bram@vim.org>
parents:
27680
diff
changeset
|
3079 if (tofree == NULL) |
637ccebaf328
patch 8.2.4387: command line completion doesn't always work properly
Bram Moolenaar <Bram@vim.org>
parents:
27680
diff
changeset
|
3080 return FAIL; |
19560
df0a6cba5c3d
patch 8.2.0337: build fails on a few systems
Bram Moolenaar <Bram@vim.org>
parents:
19556
diff
changeset
|
3081 vim_snprintf((char *)tofree, len, "^<SNR>\\d\\+_%s", pat + 3); |
19556
ff5048b0ccfe
patch 8.2.0335: no completion for :disassemble
Bram Moolenaar <Bram@vim.org>
parents:
19077
diff
changeset
|
3082 pat = tofree; |
ff5048b0ccfe
patch 8.2.0335: no completion for :disassemble
Bram Moolenaar <Bram@vim.org>
parents:
19077
diff
changeset
|
3083 } |
ff5048b0ccfe
patch 8.2.0335: no completion for :disassemble
Bram Moolenaar <Bram@vim.org>
parents:
19077
diff
changeset
|
3084 |
27906
11141b2ec0e1
patch 8.2.4478: crash when using fuzzy completion
Bram Moolenaar <Bram@vim.org>
parents:
27904
diff
changeset
|
3085 if (!fuzzy) |
11141b2ec0e1
patch 8.2.4478: crash when using fuzzy completion
Bram Moolenaar <Bram@vim.org>
parents:
27904
diff
changeset
|
3086 { |
11141b2ec0e1
patch 8.2.4478: crash when using fuzzy completion
Bram Moolenaar <Bram@vim.org>
parents:
27904
diff
changeset
|
3087 regmatch.regprog = vim_regcomp(pat, magic_isset() ? RE_MAGIC : 0); |
11141b2ec0e1
patch 8.2.4478: crash when using fuzzy completion
Bram Moolenaar <Bram@vim.org>
parents:
27904
diff
changeset
|
3088 if (regmatch.regprog == NULL) |
11141b2ec0e1
patch 8.2.4478: crash when using fuzzy completion
Bram Moolenaar <Bram@vim.org>
parents:
27904
diff
changeset
|
3089 return FAIL; |
11141b2ec0e1
patch 8.2.4478: crash when using fuzzy completion
Bram Moolenaar <Bram@vim.org>
parents:
27904
diff
changeset
|
3090 |
11141b2ec0e1
patch 8.2.4478: crash when using fuzzy completion
Bram Moolenaar <Bram@vim.org>
parents:
27904
diff
changeset
|
3091 // set ignore-case according to p_ic, p_scs and pat |
11141b2ec0e1
patch 8.2.4478: crash when using fuzzy completion
Bram Moolenaar <Bram@vim.org>
parents:
27904
diff
changeset
|
3092 regmatch.rm_ic = ignorecase(pat); |
11141b2ec0e1
patch 8.2.4478: crash when using fuzzy completion
Bram Moolenaar <Bram@vim.org>
parents:
27904
diff
changeset
|
3093 } |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3094 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3095 if (xp->xp_context == EXPAND_SETTINGS |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3096 || xp->xp_context == EXPAND_BOOL_SETTINGS) |
28786
fd5942a62312
patch 8.2.4917: fuzzy expansion of option names is not right
Bram Moolenaar <Bram@vim.org>
parents:
28757
diff
changeset
|
3097 ret = ExpandSettings(xp, ®match, pat, numMatches, matches, fuzzy); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3098 else if (xp->xp_context == EXPAND_MAPPINGS) |
27908
099c2e612827
patch 8.2.4479: no fuzzy completieon for maps and abbreviations
Bram Moolenaar <Bram@vim.org>
parents:
27906
diff
changeset
|
3099 ret = ExpandMappings(pat, ®match, numMatches, matches); |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3100 #if defined(FEAT_EVAL) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3101 else if (xp->xp_context == EXPAND_USER_DEFINED) |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3102 ret = ExpandUserDefined(pat, xp, ®match, matches, numMatches); |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3103 #endif |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3104 else |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
3105 ret = ExpandOther(pat, xp, ®match, matches, numMatches); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3106 |
27906
11141b2ec0e1
patch 8.2.4478: crash when using fuzzy completion
Bram Moolenaar <Bram@vim.org>
parents:
27904
diff
changeset
|
3107 if (!fuzzy) |
11141b2ec0e1
patch 8.2.4478: crash when using fuzzy completion
Bram Moolenaar <Bram@vim.org>
parents:
27904
diff
changeset
|
3108 vim_regfree(regmatch.regprog); |
19556
ff5048b0ccfe
patch 8.2.0335: no completion for :disassemble
Bram Moolenaar <Bram@vim.org>
parents:
19077
diff
changeset
|
3109 vim_free(tofree); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3110 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3111 return ret; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3112 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3113 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3114 /* |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3115 * Expand a list of names. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3116 * |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3117 * Generic function for command line completion. It calls a function to |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3118 * obtain strings, one by one. The strings are matched against a regexp |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3119 * program. Matching strings are copied into an array, which is returned. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3120 * |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
3121 * If 'fuzzy' is TRUE, then fuzzy matching is used. Otherwise, regex matching |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
3122 * is used. |
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
3123 * |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3124 * Returns OK when no problems encountered, FAIL for error (out of memory). |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3125 */ |
19053
cec4da73951a
patch 8.2.0087: crash in command line expansion when out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18987
diff
changeset
|
3126 static int |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3127 ExpandGeneric( |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3128 char_u *pat, |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3129 expand_T *xp, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3130 regmatch_T *regmatch, |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3131 char_u ***matches, |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3132 int *numMatches, |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3133 char_u *((*func)(expand_T *, int)), |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3134 // returns a string from the list |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3135 int escaped) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3136 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3137 int i; |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3138 garray_T ga; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3139 char_u *str; |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
3140 fuzmatch_str_T *fuzmatch = NULL; |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3141 int score = 0; |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3142 int fuzzy; |
27879
76e2115dddb8
patch 8.2.4465: fuzzy completion does not order matches properly
Bram Moolenaar <Bram@vim.org>
parents:
27875
diff
changeset
|
3143 int match; |
28183
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3144 int sort_matches = FALSE; |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3145 int funcsort = FALSE; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3146 |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3147 fuzzy = cmdline_fuzzy_complete(pat); |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3148 *matches = NULL; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3149 *numMatches = 0; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3150 |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3151 if (!fuzzy) |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3152 ga_init2(&ga, sizeof(char *), 30); |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3153 else |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3154 ga_init2(&ga, sizeof(fuzmatch_str_T), 30); |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3155 |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3156 for (i = 0; ; ++i) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3157 { |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3158 str = (*func)(xp, i); |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3159 if (str == NULL) // end of list |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3160 break; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3161 if (*str == NUL) // skip empty strings |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3162 continue; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3163 |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3164 if (xp->xp_pattern[0] != NUL) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3165 { |
27879
76e2115dddb8
patch 8.2.4465: fuzzy completion does not order matches properly
Bram Moolenaar <Bram@vim.org>
parents:
27875
diff
changeset
|
3166 if (!fuzzy) |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3167 match = vim_regexec(regmatch, str, (colnr_T)0); |
27879
76e2115dddb8
patch 8.2.4465: fuzzy completion does not order matches properly
Bram Moolenaar <Bram@vim.org>
parents:
27875
diff
changeset
|
3168 else |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3169 { |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3170 score = fuzzy_match_str(str, pat); |
27879
76e2115dddb8
patch 8.2.4465: fuzzy completion does not order matches properly
Bram Moolenaar <Bram@vim.org>
parents:
27875
diff
changeset
|
3171 match = (score != 0); |
76e2115dddb8
patch 8.2.4465: fuzzy completion does not order matches properly
Bram Moolenaar <Bram@vim.org>
parents:
27875
diff
changeset
|
3172 } |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3173 } |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3174 else |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3175 match = TRUE; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3176 |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3177 if (!match) |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3178 continue; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3179 |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3180 if (escaped) |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3181 str = vim_strsave_escaped(str, (char_u *)" \t\\."); |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3182 else |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3183 str = vim_strsave(str); |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3184 if (str == NULL) |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3185 { |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3186 if (!fuzzy) |
27879
76e2115dddb8
patch 8.2.4465: fuzzy completion does not order matches properly
Bram Moolenaar <Bram@vim.org>
parents:
27875
diff
changeset
|
3187 { |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3188 ga_clear_strings(&ga); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3189 return FAIL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3190 } |
28415
813660733869
patch 8.2.4732: duplicate code to free fuzzy matches
Bram Moolenaar <Bram@vim.org>
parents:
28183
diff
changeset
|
3191 fuzmatch_str_free(ga.ga_data, ga.ga_len); |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3192 return FAIL; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3193 } |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3194 |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3195 if (ga_grow(&ga, 1) == FAIL) |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3196 { |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3197 vim_free(str); |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3198 break; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3199 } |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3200 |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3201 if (fuzzy) |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3202 { |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3203 fuzmatch = &((fuzmatch_str_T *)ga.ga_data)[ga.ga_len]; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3204 fuzmatch->idx = ga.ga_len; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3205 fuzmatch->str = str; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3206 fuzmatch->score = score; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3207 } |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3208 else |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3209 ((char_u **)ga.ga_data)[ga.ga_len] = str; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3210 |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3211 #ifdef FEAT_MENU |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3212 if (func == get_menu_names) |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3213 { |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3214 // test for separator added by get_menu_names() |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3215 str += STRLEN(str) - 1; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3216 if (*str == '\001') |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3217 *str = '.'; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3218 } |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3219 #endif |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3220 |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3221 ++ga.ga_len; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3222 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3223 |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3224 if (ga.ga_len == 0) |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3225 return OK; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3226 |
28183
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3227 // sort the matches when using regular expression matching and sorting |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3228 // applies to the completion context. Menus and scriptnames should be kept |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3229 // in the specified order. |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3230 if (!fuzzy && xp->xp_context != EXPAND_MENUNAMES |
28183
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3231 && xp->xp_context != EXPAND_MENUS |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3232 && xp->xp_context != EXPAND_SCRIPTNAMES) |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3233 sort_matches = TRUE; |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3234 |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3235 // <SNR> functions should be sorted to the end. |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3236 if (xp->xp_context == EXPAND_EXPRESSION |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3237 || xp->xp_context == EXPAND_FUNCTIONS |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3238 || xp->xp_context == EXPAND_USER_FUNC |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3239 || xp->xp_context == EXPAND_DISASSEMBLE) |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3240 funcsort = TRUE; |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3241 |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3242 // Sort the matches. |
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3243 if (sort_matches) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3244 { |
28183
2b595cee4c85
patch 8.2.4617: no completion for :scriptnames
Bram Moolenaar <Bram@vim.org>
parents:
28166
diff
changeset
|
3245 if (funcsort) |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3246 // <SNR> functions should be sorted to the end. |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3247 qsort((void *)ga.ga_data, (size_t)ga.ga_len, sizeof(char_u *), |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3248 sort_func_compare); |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3249 else |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3250 sort_strings((char_u **)ga.ga_data, ga.ga_len); |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3251 } |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3252 |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3253 if (!fuzzy) |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3254 { |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3255 *matches = ga.ga_data; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3256 *numMatches = ga.ga_len; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3257 } |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3258 else |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3259 { |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3260 if (fuzzymatches_to_strmatches(ga.ga_data, matches, ga.ga_len, |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3261 funcsort) == FAIL) |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3262 return FAIL; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3263 *numMatches = ga.ga_len; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3264 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3265 |
17781
04245f071792
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17779
diff
changeset
|
3266 #if defined(FEAT_SYN_HL) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3267 // Reset the variables used for special highlight names expansion, so that |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3268 // they don't show up when getting normal highlight names by ID. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3269 reset_expand_highlight(); |
17781
04245f071792
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17779
diff
changeset
|
3270 #endif |
27875
ae38d2e81fca
patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents:
27760
diff
changeset
|
3271 |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3272 return OK; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3273 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3274 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3275 /* |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3276 * Expand shell command matches in one directory of $PATH. |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3277 */ |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3278 static void |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3279 expand_shellcmd_onedir( |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3280 char_u *buf, |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3281 char_u *s, |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3282 size_t l, |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3283 char_u *pat, |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3284 char_u ***matches, |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3285 int *numMatches, |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3286 int flags, |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3287 hashtab_T *ht, |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3288 garray_T *gap) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3289 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3290 int ret; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3291 hash_T hash; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3292 hashitem_T *hi; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3293 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3294 vim_strncpy(buf, s, l); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3295 add_pathsep(buf); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3296 l = STRLEN(buf); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3297 vim_strncpy(buf + l, pat, MAXPATHL - 1 - l); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3298 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3299 // Expand matches in one directory of $PATH. |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3300 ret = expand_wildcards(1, &buf, numMatches, matches, flags); |
31083
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3301 if (ret != OK) |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3302 return; |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3303 |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3304 if (ga_grow(gap, *numMatches) == FAIL) |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3305 { |
31083
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3306 FreeWild(*numMatches, *matches); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3307 return; |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3308 } |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3309 |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3310 for (int i = 0; i < *numMatches; ++i) |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3311 { |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3312 char_u *name = (*matches)[i]; |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3313 |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3314 if (STRLEN(name) > l) |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3315 { |
31083
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3316 // Check if this name was already found. |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3317 hash = hash_hash(name + l); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3318 hi = hash_lookup(ht, name + l, hash); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3319 if (HASHITEM_EMPTY(hi)) |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3320 { |
31083
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3321 // Remove the path that was prepended. |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3322 STRMOVE(name, name + l); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3323 ((char_u **)gap->ga_data)[gap->ga_len++] = name; |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3324 hash_add_item(ht, hi, name, hash); |
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3325 name = NULL; |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3326 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3327 } |
31083
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3328 vim_free(name); |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3329 } |
31083
20390549ce2f
patch 9.0.0876: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31065
diff
changeset
|
3330 vim_free(*matches); |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3331 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3332 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3333 /* |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3334 * Complete a shell command. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3335 * Returns FAIL or OK; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3336 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3337 static int |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3338 expand_shellcmd( |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3339 char_u *filepat, // pattern to match with command names |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3340 char_u ***matches, // return: array with matches |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3341 int *numMatches, // return: number of matches |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3342 int flagsarg) // EW_ flags |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3343 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3344 char_u *pat; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3345 int i; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3346 char_u *path = NULL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3347 int mustfree = FALSE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3348 garray_T ga; |
19077
568cce19fd2b
patch 8.2.0099: use of NULL pointer when out of memory
Bram Moolenaar <Bram@vim.org>
parents:
19057
diff
changeset
|
3349 char_u *buf; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3350 size_t l; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3351 char_u *s, *e; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3352 int flags = flagsarg; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3353 int did_curdir = FALSE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3354 hashtab_T found_ht; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3355 |
19077
568cce19fd2b
patch 8.2.0099: use of NULL pointer when out of memory
Bram Moolenaar <Bram@vim.org>
parents:
19057
diff
changeset
|
3356 buf = alloc(MAXPATHL); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3357 if (buf == NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3358 return FAIL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3359 |
19077
568cce19fd2b
patch 8.2.0099: use of NULL pointer when out of memory
Bram Moolenaar <Bram@vim.org>
parents:
19057
diff
changeset
|
3360 // for ":set path=" and ":set tags=" halve backslashes for escaped space |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3361 pat = vim_strsave(filepat); |
19077
568cce19fd2b
patch 8.2.0099: use of NULL pointer when out of memory
Bram Moolenaar <Bram@vim.org>
parents:
19057
diff
changeset
|
3362 if (pat == NULL) |
568cce19fd2b
patch 8.2.0099: use of NULL pointer when out of memory
Bram Moolenaar <Bram@vim.org>
parents:
19057
diff
changeset
|
3363 { |
568cce19fd2b
patch 8.2.0099: use of NULL pointer when out of memory
Bram Moolenaar <Bram@vim.org>
parents:
19057
diff
changeset
|
3364 vim_free(buf); |
568cce19fd2b
patch 8.2.0099: use of NULL pointer when out of memory
Bram Moolenaar <Bram@vim.org>
parents:
19057
diff
changeset
|
3365 return FAIL; |
568cce19fd2b
patch 8.2.0099: use of NULL pointer when out of memory
Bram Moolenaar <Bram@vim.org>
parents:
19057
diff
changeset
|
3366 } |
568cce19fd2b
patch 8.2.0099: use of NULL pointer when out of memory
Bram Moolenaar <Bram@vim.org>
parents:
19057
diff
changeset
|
3367 |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3368 for (i = 0; pat[i]; ++i) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3369 if (pat[i] == '\\' && pat[i + 1] == ' ') |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3370 STRMOVE(pat + i, pat + i + 1); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3371 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3372 flags |= EW_FILE | EW_EXEC | EW_SHELLCMD; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3373 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3374 if (pat[0] == '.' && (vim_ispathsep(pat[1]) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3375 || (pat[1] == '.' && vim_ispathsep(pat[2])))) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3376 path = (char_u *)"."; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3377 else |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3378 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3379 // For an absolute name we don't use $PATH. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3380 if (!mch_isFullName(pat)) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3381 path = vim_getenv((char_u *)"PATH", &mustfree); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3382 if (path == NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3383 path = (char_u *)""; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3384 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3385 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3386 // Go over all directories in $PATH. Expand matches in that directory and |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3387 // collect them in "ga". When "." is not in $PATH also expand for the |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3388 // current directory, to find "subdir/cmd". |
27028
c9474ae175f4
patch 8.2.4043: using int for second argument of ga_init2()
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3389 ga_init2(&ga, sizeof(char *), 10); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3390 hash_init(&found_ht); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3391 for (s = path; ; s = e) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3392 { |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3393 #if defined(MSWIN) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3394 e = vim_strchr(s, ';'); |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3395 #else |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3396 e = vim_strchr(s, ':'); |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3397 #endif |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3398 if (e == NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3399 e = s + STRLEN(s); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3400 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3401 if (*s == NUL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3402 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3403 if (did_curdir) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3404 break; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3405 // Find directories in the current directory, path is empty. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3406 did_curdir = TRUE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3407 flags |= EW_DIR; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3408 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3409 else if (STRNCMP(s, ".", (int)(e - s)) == 0) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3410 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3411 did_curdir = TRUE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3412 flags |= EW_DIR; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3413 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3414 else |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3415 // Do not match directories inside a $PATH item. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3416 flags &= ~EW_DIR; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3417 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3418 l = e - s; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3419 if (l > MAXPATHL - 5) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3420 break; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3421 |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3422 expand_shellcmd_onedir(buf, s, l, pat, matches, numMatches, flags, |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3423 &found_ht, &ga); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3424 |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3425 if (*e != NUL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3426 ++e; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3427 } |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3428 *matches = ga.ga_data; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3429 *numMatches = ga.ga_len; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3430 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3431 vim_free(buf); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3432 vim_free(pat); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3433 if (mustfree) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3434 vim_free(path); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3435 hash_clear(&found_ht); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3436 return OK; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3437 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3438 |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3439 #if defined(FEAT_EVAL) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3440 /* |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3441 * Call "user_expand_func()" to invoke a user defined Vim script function and |
21477
8a0362947c3a
patch 8.2.1289: crash when using a custom completion function
Bram Moolenaar <Bram@vim.org>
parents:
21423
diff
changeset
|
3442 * return the result (either a string, a List or NULL). |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3443 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3444 static void * |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3445 call_user_expand_func( |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3446 void *(*user_expand_func)(char_u *, int, typval_T *), |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3447 expand_T *xp) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3448 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3449 cmdline_info_T *ccline = get_cmdline_info(); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3450 int keep = 0; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3451 typval_T args[4]; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3452 sctx_T save_current_sctx = current_sctx; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3453 char_u *pat = NULL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3454 void *ret; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3455 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3456 if (xp->xp_arg == NULL || xp->xp_arg[0] == '\0' || xp->xp_line == NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3457 return NULL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3458 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3459 if (ccline->cmdbuff != NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3460 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3461 keep = ccline->cmdbuff[ccline->cmdlen]; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3462 ccline->cmdbuff[ccline->cmdlen] = 0; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3463 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3464 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3465 pat = vim_strnsave(xp->xp_pattern, xp->xp_pattern_len); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3466 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3467 args[0].v_type = VAR_STRING; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3468 args[0].vval.v_string = pat; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3469 args[1].v_type = VAR_STRING; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3470 args[1].vval.v_string = xp->xp_line; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3471 args[2].v_type = VAR_NUMBER; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3472 args[2].vval.v_number = xp->xp_col; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3473 args[3].v_type = VAR_UNKNOWN; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3474 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3475 current_sctx = xp->xp_script_ctx; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3476 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3477 ret = user_expand_func(xp->xp_arg, 3, args); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3478 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3479 current_sctx = save_current_sctx; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3480 if (ccline->cmdbuff != NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3481 ccline->cmdbuff[ccline->cmdlen] = keep; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3482 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3483 vim_free(pat); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3484 return ret; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3485 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3486 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3487 /* |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3488 * Expand names with a function defined by the user (EXPAND_USER_DEFINED and |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3489 * EXPAND_USER_LIST). |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3490 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3491 static int |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3492 ExpandUserDefined( |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3493 char_u *pat, |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3494 expand_T *xp, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3495 regmatch_T *regmatch, |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3496 char_u ***matches, |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3497 int *numMatches) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3498 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3499 char_u *retstr; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3500 char_u *s; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3501 char_u *e; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3502 int keep; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3503 garray_T ga; |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3504 int fuzzy; |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3505 int match; |
27920
8543d5a1103e
patch 8.2.4485: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
27916
diff
changeset
|
3506 int score = 0; |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3507 |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3508 fuzzy = cmdline_fuzzy_complete(pat); |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3509 *matches = NULL; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3510 *numMatches = 0; |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3511 |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3512 retstr = call_user_expand_func(call_func_retstr, xp); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3513 if (retstr == NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3514 return FAIL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3515 |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3516 if (!fuzzy) |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3517 ga_init2(&ga, sizeof(char *), 3); |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3518 else |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3519 ga_init2(&ga, sizeof(fuzmatch_str_T), 3); |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3520 |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3521 for (s = retstr; *s != NUL; s = e) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3522 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3523 e = vim_strchr(s, '\n'); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3524 if (e == NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3525 e = s + STRLEN(s); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3526 keep = *e; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3527 *e = NUL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3528 |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3529 if (xp->xp_pattern[0] != NUL) |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3530 { |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3531 if (!fuzzy) |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3532 match = vim_regexec(regmatch, s, (colnr_T)0); |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3533 else |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3534 { |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3535 score = fuzzy_match_str(s, pat); |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3536 match = (score != 0); |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3537 } |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3538 } |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3539 else |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3540 match = TRUE; // match everything |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3541 |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3542 *e = keep; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3543 |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3544 if (match) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3545 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3546 if (ga_grow(&ga, 1) == FAIL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3547 break; |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3548 if (!fuzzy) |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3549 ((char_u **)ga.ga_data)[ga.ga_len] = vim_strnsave(s, e - s); |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3550 else |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3551 { |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3552 fuzmatch_str_T *fuzmatch = |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3553 &((fuzmatch_str_T *)ga.ga_data)[ga.ga_len]; |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3554 fuzmatch->idx = ga.ga_len; |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3555 fuzmatch->str = vim_strnsave(s, e - s); |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3556 fuzmatch->score = score; |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3557 } |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3558 ++ga.ga_len; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3559 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3560 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3561 if (*e != NUL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3562 ++e; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3563 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3564 vim_free(retstr); |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3565 |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3566 if (ga.ga_len == 0) |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3567 return OK; |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3568 |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3569 if (!fuzzy) |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3570 { |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3571 *matches = ga.ga_data; |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3572 *numMatches = ga.ga_len; |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3573 } |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3574 else |
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3575 { |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3576 if (fuzzymatches_to_strmatches(ga.ga_data, matches, ga.ga_len, |
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3577 FALSE) == FAIL) |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3578 return FAIL; |
27916
6efa2f193c94
patch 8.2.4483: command completion makes two rounds to collect matches
Bram Moolenaar <Bram@vim.org>
parents:
27914
diff
changeset
|
3579 *numMatches = ga.ga_len; |
27914
9a997de62da2
patch 8.2.4482: no fuzzy cmdline completion for user defined completion
Bram Moolenaar <Bram@vim.org>
parents:
27912
diff
changeset
|
3580 } |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3581 return OK; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3582 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3583 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3584 /* |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3585 * Expand names with a list returned by a function defined by the user. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3586 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3587 static int |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3588 ExpandUserList( |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3589 expand_T *xp, |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3590 char_u ***matches, |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3591 int *numMatches) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3592 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3593 list_T *retlist; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3594 listitem_T *li; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3595 garray_T ga; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3596 |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3597 *matches = NULL; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3598 *numMatches = 0; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3599 retlist = call_user_expand_func(call_func_retlist, xp); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3600 if (retlist == NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3601 return FAIL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3602 |
27028
c9474ae175f4
patch 8.2.4043: using int for second argument of ga_init2()
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3603 ga_init2(&ga, sizeof(char *), 3); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3604 // Loop over the items in the list. |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19560
diff
changeset
|
3605 FOR_ALL_LIST_ITEMS(retlist, li) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3606 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3607 if (li->li_tv.v_type != VAR_STRING || li->li_tv.vval.v_string == NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3608 continue; // Skip non-string items and empty strings |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3609 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3610 if (ga_grow(&ga, 1) == FAIL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3611 break; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3612 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3613 ((char_u **)ga.ga_data)[ga.ga_len] = |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3614 vim_strsave(li->li_tv.vval.v_string); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3615 ++ga.ga_len; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3616 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3617 list_unref(retlist); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3618 |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3619 *matches = ga.ga_data; |
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3620 *numMatches = ga.ga_len; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3621 return OK; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3622 } |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3623 #endif |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3624 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3625 /* |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3626 * Expand "file" for all comma-separated directories in "path". |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3627 * Adds the matches to "ga". Caller must init "ga". |
31798
5948cc887603
patch 9.0.1231: completion of :runtime does not handle {where} argument
Bram Moolenaar <Bram@vim.org>
parents:
31790
diff
changeset
|
3628 * If "dirs" is TRUE only expand directory names. |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3629 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3630 void |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3631 globpath( |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3632 char_u *path, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3633 char_u *file, |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3634 garray_T *ga, |
31798
5948cc887603
patch 9.0.1231: completion of :runtime does not handle {where} argument
Bram Moolenaar <Bram@vim.org>
parents:
31790
diff
changeset
|
3635 int expand_options, |
5948cc887603
patch 9.0.1231: completion of :runtime does not handle {where} argument
Bram Moolenaar <Bram@vim.org>
parents:
31790
diff
changeset
|
3636 int dirs) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3637 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3638 expand_T xpc; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3639 char_u *buf; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3640 int i; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3641 int num_p; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3642 char_u **p; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3643 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3644 buf = alloc(MAXPATHL); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3645 if (buf == NULL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3646 return; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3647 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3648 ExpandInit(&xpc); |
31798
5948cc887603
patch 9.0.1231: completion of :runtime does not handle {where} argument
Bram Moolenaar <Bram@vim.org>
parents:
31790
diff
changeset
|
3649 xpc.xp_context = dirs ? EXPAND_DIRECTORIES : EXPAND_FILES; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3650 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3651 // Loop over all entries in {path}. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3652 while (*path != NUL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3653 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3654 // Copy one item of the path to buf[] and concatenate the file name. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3655 copy_option_part(&path, buf, MAXPATHL, ","); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3656 if (STRLEN(buf) + STRLEN(file) + 2 < MAXPATHL) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3657 { |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3658 #if defined(MSWIN) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3659 // Using the platform's path separator (\) makes vim incorrectly |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3660 // treat it as an escape character, use '/' instead. |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3661 if (*buf != NUL && !after_pathsep(buf, buf + STRLEN(buf))) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3662 STRCAT(buf, "/"); |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3663 #else |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3664 add_pathsep(buf); |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3665 #endif |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3666 STRCAT(buf, file); |
27760
010fa62d6fe2
patch 8.2.4406: expand functions use confusing argument names
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
3667 if (ExpandFromContext(&xpc, buf, &p, &num_p, |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3668 WILD_SILENT|expand_options) != FAIL && num_p > 0) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3669 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3670 ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT|expand_options); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3671 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3672 if (ga_grow(ga, num_p) == OK) |
19057
463b6fad54e9
patch 8.2.0089: crash when running out of memory in :setfiletype completion
Bram Moolenaar <Bram@vim.org>
parents:
19053
diff
changeset
|
3673 // take over the pointers and put them in "ga" |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3674 for (i = 0; i < num_p; ++i) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3675 { |
19057
463b6fad54e9
patch 8.2.0089: crash when running out of memory in :setfiletype completion
Bram Moolenaar <Bram@vim.org>
parents:
19053
diff
changeset
|
3676 ((char_u **)ga->ga_data)[ga->ga_len] = p[i]; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3677 ++ga->ga_len; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3678 } |
19057
463b6fad54e9
patch 8.2.0089: crash when running out of memory in :setfiletype completion
Bram Moolenaar <Bram@vim.org>
parents:
19053
diff
changeset
|
3679 vim_free(p); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3680 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3681 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3682 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3683 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3684 vim_free(buf); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3685 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3686 |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3687 /* |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3688 * Translate some keys pressed when 'wildmenu' is used. |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3689 */ |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3690 int |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3691 wildmenu_translate_key( |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3692 cmdline_info_T *cclp, |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3693 int key, |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3694 expand_T *xp, |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3695 int did_wild_list) |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3696 { |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3697 int c = key; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3698 |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
3699 if (cmdline_pum_active()) |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
3700 { |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
3701 // When the popup menu is used for cmdline completion: |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
3702 // Up : go to the previous item in the menu |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
3703 // Down : go to the next item in the menu |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
3704 // Left : go to the parent directory |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
3705 // Right: list the files in the selected directory |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
3706 switch (c) |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
3707 { |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
3708 case K_UP: c = K_LEFT; break; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
3709 case K_DOWN: c = K_RIGHT; break; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
3710 case K_LEFT: c = K_UP; break; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
3711 case K_RIGHT: c = K_DOWN; break; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
3712 default: break; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27615
diff
changeset
|
3713 } |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
3714 } |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
3715 |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3716 if (did_wild_list) |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3717 { |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3718 if (c == K_LEFT) |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3719 c = Ctrl_P; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3720 else if (c == K_RIGHT) |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3721 c = Ctrl_N; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3722 } |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27523
diff
changeset
|
3723 |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3724 // Hitting CR after "emenu Name.": complete submenu |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3725 if (xp->xp_context == EXPAND_MENUNAMES |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3726 && cclp->cmdpos > 1 |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3727 && cclp->cmdbuff[cclp->cmdpos - 1] == '.' |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3728 && cclp->cmdbuff[cclp->cmdpos - 2] != '\\' |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3729 && (c == '\n' || c == '\r' || c == K_KENTER)) |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3730 c = K_DOWN; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3731 |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3732 return c; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3733 } |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3734 |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3735 /* |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3736 * Delete characters on the command line, from "from" to the current |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3737 * position. |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3738 */ |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3739 static void |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3740 cmdline_del(cmdline_info_T *cclp, int from) |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3741 { |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3742 mch_memmove(cclp->cmdbuff + from, cclp->cmdbuff + cclp->cmdpos, |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3743 (size_t)(cclp->cmdlen - cclp->cmdpos + 1)); |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3744 cclp->cmdlen -= cclp->cmdpos - from; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3745 cclp->cmdpos = from; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3746 } |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3747 |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3748 /* |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3749 * Handle a key pressed when the wild menu for the menu names |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3750 * (EXPAND_MENUNAMES) is displayed. |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3751 */ |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3752 static int |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3753 wildmenu_process_key_menunames(cmdline_info_T *cclp, int key, expand_T *xp) |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3754 { |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3755 int i; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3756 int j; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3757 |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3758 // Hitting <Down> after "emenu Name.": complete submenu |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3759 if (key == K_DOWN && cclp->cmdpos > 0 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3760 && cclp->cmdbuff[cclp->cmdpos - 1] == '.') |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3761 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3762 key = p_wc; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3763 KeyTyped = TRUE; // in case the key was mapped |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3764 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3765 else if (key == K_UP) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3766 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3767 // Hitting <Up>: Remove one submenu name in front of the |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3768 // cursor |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3769 int found = FALSE; |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3770 |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3771 j = (int)(xp->xp_pattern - cclp->cmdbuff); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3772 i = 0; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3773 while (--j > 0) |
23356
32a9d01c2a49
patch 8.2.2221: if <Down> is mapped on the command line 'wildchar' is inserted
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3774 { |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3775 // check for start of menu name |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3776 if (cclp->cmdbuff[j] == ' ' |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3777 && cclp->cmdbuff[j - 1] != '\\') |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3778 { |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3779 i = j + 1; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3780 break; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3781 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3782 // check for start of submenu name |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3783 if (cclp->cmdbuff[j] == '.' |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3784 && cclp->cmdbuff[j - 1] != '\\') |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3785 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3786 if (found) |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3787 { |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3788 i = j + 1; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3789 break; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3790 } |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3791 else |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3792 found = TRUE; |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3793 } |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3794 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3795 if (i > 0) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3796 cmdline_del(cclp, i); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3797 key = p_wc; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3798 KeyTyped = TRUE; // in case the key was mapped |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3799 xp->xp_context = EXPAND_NOTHING; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3800 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3801 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3802 return key; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3803 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3804 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3805 /* |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3806 * Handle a key pressed when the wild menu for file names (EXPAND_FILES) or |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3807 * directory names (EXPAND_DIRECTORIES) or shell command names |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3808 * (EXPAND_SHELLCMD) is displayed. |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3809 */ |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3810 static int |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3811 wildmenu_process_key_filenames(cmdline_info_T *cclp, int key, expand_T *xp) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3812 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3813 int i; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3814 int j; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3815 char_u upseg[5]; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3816 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3817 upseg[0] = PATHSEP; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3818 upseg[1] = '.'; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3819 upseg[2] = '.'; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3820 upseg[3] = PATHSEP; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3821 upseg[4] = NUL; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3822 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3823 if (key == K_DOWN |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3824 && cclp->cmdpos > 0 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3825 && cclp->cmdbuff[cclp->cmdpos - 1] == PATHSEP |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3826 && (cclp->cmdpos < 3 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3827 || cclp->cmdbuff[cclp->cmdpos - 2] != '.' |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3828 || cclp->cmdbuff[cclp->cmdpos - 3] != '.')) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3829 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3830 // go down a directory |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3831 key = p_wc; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3832 KeyTyped = TRUE; // in case the key was mapped |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3833 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3834 else if (STRNCMP(xp->xp_pattern, upseg + 1, 3) == 0 && key == K_DOWN) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3835 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3836 // If in a direct ancestor, strip off one ../ to go down |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3837 int found = FALSE; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3838 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3839 j = cclp->cmdpos; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3840 i = (int)(xp->xp_pattern - cclp->cmdbuff); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3841 while (--j > i) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3842 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3843 if (has_mbyte) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3844 j -= (*mb_head_off)(cclp->cmdbuff, cclp->cmdbuff + j); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3845 if (vim_ispathsep(cclp->cmdbuff[j])) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3846 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3847 found = TRUE; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3848 break; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3849 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3850 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3851 if (found |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3852 && cclp->cmdbuff[j - 1] == '.' |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3853 && cclp->cmdbuff[j - 2] == '.' |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3854 && (vim_ispathsep(cclp->cmdbuff[j - 3]) || j == i + 2)) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3855 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3856 cmdline_del(cclp, j - 2); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3857 key = p_wc; |
23356
32a9d01c2a49
patch 8.2.2221: if <Down> is mapped on the command line 'wildchar' is inserted
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3858 KeyTyped = TRUE; // in case the key was mapped |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3859 } |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3860 } |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3861 else if (key == K_UP) |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3862 { |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3863 // go up a directory |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3864 int found = FALSE; |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3865 |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3866 j = cclp->cmdpos - 1; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3867 i = (int)(xp->xp_pattern - cclp->cmdbuff); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3868 while (--j > i) |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3869 { |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3870 if (has_mbyte) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3871 j -= (*mb_head_off)(cclp->cmdbuff, cclp->cmdbuff + j); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3872 if (vim_ispathsep(cclp->cmdbuff[j]) |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3873 #ifdef BACKSLASH_IN_FILENAME |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3874 && vim_strchr((char_u *)" *?[{`$%#", |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3875 cclp->cmdbuff[j + 1]) == NULL |
31091
551ce1a137da
patch 9.0.0880: preprocessor indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
31083
diff
changeset
|
3876 #endif |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3877 ) |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3878 { |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3879 if (found) |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3880 { |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3881 i = j + 1; |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3882 break; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3883 } |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3884 else |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3885 found = TRUE; |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3886 } |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3887 } |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3888 |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3889 if (!found) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3890 j = i; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3891 else if (STRNCMP(cclp->cmdbuff + j, upseg, 4) == 0) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3892 j += 4; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3893 else if (STRNCMP(cclp->cmdbuff + j, upseg + 1, 3) == 0 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3894 && j == i) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3895 j += 3; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3896 else |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3897 j = 0; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3898 if (j > 0) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3899 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3900 // TODO this is only for DOS/UNIX systems - need to put in |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3901 // machine-specific stuff here and in upseg init |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3902 cmdline_del(cclp, j); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3903 put_on_cmdline(upseg + 1, 3, FALSE); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3904 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3905 else if (cclp->cmdpos > i) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3906 cmdline_del(cclp, i); |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3907 |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3908 // Now complete in the new directory. Set KeyTyped in case the |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3909 // Up key came from a mapping. |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3910 key = p_wc; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3911 KeyTyped = TRUE; |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3912 } |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3913 |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3914 return key; |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3915 } |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3916 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3917 /* |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3918 * Handle a key pressed when the wild menu is displayed |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3919 */ |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3920 int |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3921 wildmenu_process_key(cmdline_info_T *cclp, int key, expand_T *xp) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3922 { |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3923 if (xp->xp_context == EXPAND_MENUNAMES) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3924 return wildmenu_process_key_menunames(cclp, key, xp); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3925 else if ((xp->xp_context == EXPAND_FILES |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3926 || xp->xp_context == EXPAND_DIRECTORIES |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3927 || xp->xp_context == EXPAND_SHELLCMD)) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3928 return wildmenu_process_key_filenames(cclp, key, xp); |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3929 |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27722
diff
changeset
|
3930 return key; |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3931 } |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3932 |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3933 /* |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3934 * Free expanded names when finished walking through the matches |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3935 */ |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3936 void |
29886
3ef1fe06690d
patch 9.0.0281: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
3937 wildmenu_cleanup(cmdline_info_T *cclp UNUSED) |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3938 { |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3939 int skt = KeyTyped; |
29886
3ef1fe06690d
patch 9.0.0281: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
3940 #ifdef FEAT_EVAL |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3941 int old_RedrawingDisabled = RedrawingDisabled; |
29886
3ef1fe06690d
patch 9.0.0281: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
3942 #endif |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3943 |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3944 if (!p_wmnu || wild_menu_showing == 0) |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3945 return; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3946 |
29886
3ef1fe06690d
patch 9.0.0281: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
3947 #ifdef FEAT_EVAL |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3948 if (cclp->input_fn) |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3949 RedrawingDisabled = 0; |
29886
3ef1fe06690d
patch 9.0.0281: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
3950 #endif |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3951 |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3952 if (wild_menu_showing == WM_SCROLLED) |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3953 { |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3954 // Entered command line, move it up |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3955 cmdline_row--; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3956 redrawcmd(); |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3957 } |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3958 else if (save_p_ls != -1) |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3959 { |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3960 // restore 'laststatus' and 'winminheight' |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3961 p_ls = save_p_ls; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3962 p_wmh = save_p_wmh; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3963 last_status(FALSE); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29495
diff
changeset
|
3964 update_screen(UPD_VALID); // redraw the screen NOW |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3965 redrawcmd(); |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3966 save_p_ls = -1; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3967 } |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3968 else |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3969 { |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3970 win_redraw_last_status(topframe); |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3971 redraw_statuslines(); |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3972 } |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3973 KeyTyped = skt; |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3974 wild_menu_showing = 0; |
29886
3ef1fe06690d
patch 9.0.0281: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
3975 #ifdef FEAT_EVAL |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3976 if (cclp->input_fn) |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3977 RedrawingDisabled = old_RedrawingDisabled; |
29886
3ef1fe06690d
patch 9.0.0281: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
3978 #endif |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3979 } |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
21477
diff
changeset
|
3980 |
17781
04245f071792
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17779
diff
changeset
|
3981 #if defined(FEAT_EVAL) || defined(PROTO) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3982 /* |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3983 * "getcompletion()" function |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3984 */ |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3985 void |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3986 f_getcompletion(typval_T *argvars, typval_T *rettv) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3987 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3988 char_u *pat; |
20745
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
3989 char_u *type; |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3990 expand_T xpc; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3991 int filtered = FALSE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3992 int options = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH |
26032
162ef12a3b5f
patch 8.2.3550: completion() does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
3993 | WILD_NO_BEEP | WILD_HOME_REPLACE; |
20745
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
3994 |
25302
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
3995 if (in_vim9script() |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
3996 && (check_for_string_arg(argvars, 0) == FAIL |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
3997 || check_for_string_arg(argvars, 1) == FAIL |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
3998 || check_for_opt_bool_arg(argvars, 2) == FAIL)) |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
3999 return; |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24909
diff
changeset
|
4000 |
26213
ee1c116b91ea
patch 8.2.3638: getcompletion() always passes zero as position
Bram Moolenaar <Bram@vim.org>
parents:
26032
diff
changeset
|
4001 pat = tv_get_string(&argvars[0]); |
30043
fd855ad74887
patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents:
30017
diff
changeset
|
4002 if (check_for_string_arg(argvars, 1) == FAIL) |
20745
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4003 return; |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4004 type = tv_get_string(&argvars[1]); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4005 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4006 if (argvars[2].v_type != VAR_UNKNOWN) |
22109
3785043f8768
patch 8.2.1604: Vim9: cannot use "true" with getcompletion()
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
4007 filtered = tv_get_bool_chk(&argvars[2], NULL); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4008 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4009 if (p_wic) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4010 options |= WILD_ICASE; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4011 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4012 // For filtered results, 'wildignore' is used |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4013 if (!filtered) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4014 options |= WILD_KEEP_ALL; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4015 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4016 ExpandInit(&xpc); |
20745
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4017 if (STRCMP(type, "cmdline") == 0) |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4018 { |
26213
ee1c116b91ea
patch 8.2.3638: getcompletion() always passes zero as position
Bram Moolenaar <Bram@vim.org>
parents:
26032
diff
changeset
|
4019 set_one_cmd_context(&xpc, pat); |
20745
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4020 xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern); |
26213
ee1c116b91ea
patch 8.2.3638: getcompletion() always passes zero as position
Bram Moolenaar <Bram@vim.org>
parents:
26032
diff
changeset
|
4021 xpc.xp_col = (int)STRLEN(pat); |
20745
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4022 } |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4023 else |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4024 { |
26213
ee1c116b91ea
patch 8.2.3638: getcompletion() always passes zero as position
Bram Moolenaar <Bram@vim.org>
parents:
26032
diff
changeset
|
4025 xpc.xp_pattern = pat; |
20745
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4026 xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern); |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4027 |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4028 xpc.xp_context = cmdcomplete_str_to_type(type); |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4029 if (xpc.xp_context == EXPAND_NOTHING) |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4030 { |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26436
diff
changeset
|
4031 semsg(_(e_invalid_argument_str), type); |
20745
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4032 return; |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4033 } |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4034 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4035 # if defined(FEAT_MENU) |
20745
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4036 if (xpc.xp_context == EXPAND_MENUS) |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4037 { |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4038 set_context_in_menu_cmd(&xpc, (char_u *)"menu", xpc.xp_pattern, FALSE); |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4039 xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern); |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4040 } |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4041 # endif |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4042 # ifdef FEAT_CSCOPE |
20745
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4043 if (xpc.xp_context == EXPAND_CSCOPE) |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4044 { |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4045 set_context_in_cscope_cmd(&xpc, xpc.xp_pattern, CMD_cscope); |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4046 xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern); |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4047 } |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4048 # endif |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4049 # ifdef FEAT_SIGNS |
20745
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4050 if (xpc.xp_context == EXPAND_SIGN) |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4051 { |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4052 set_context_in_sign_cmd(&xpc, xpc.xp_pattern); |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4053 xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern); |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4054 } |
49673325ca13
patch 8.2.0925: getcompletion() does not return command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4055 # endif |
31798
5948cc887603
patch 9.0.1231: completion of :runtime does not handle {where} argument
Bram Moolenaar <Bram@vim.org>
parents:
31790
diff
changeset
|
4056 if (xpc.xp_context == EXPAND_RUNTIME) |
5948cc887603
patch 9.0.1231: completion of :runtime does not handle {where} argument
Bram Moolenaar <Bram@vim.org>
parents:
31790
diff
changeset
|
4057 { |
5948cc887603
patch 9.0.1231: completion of :runtime does not handle {where} argument
Bram Moolenaar <Bram@vim.org>
parents:
31790
diff
changeset
|
4058 set_context_in_runtime_cmd(&xpc, xpc.xp_pattern); |
5948cc887603
patch 9.0.1231: completion of :runtime does not handle {where} argument
Bram Moolenaar <Bram@vim.org>
parents:
31790
diff
changeset
|
4059 xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern); |
5948cc887603
patch 9.0.1231: completion of :runtime does not handle {where} argument
Bram Moolenaar <Bram@vim.org>
parents:
31790
diff
changeset
|
4060 } |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4061 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4062 |
28166
130f4082a13d
patch 8.2.4608: getcompletion() does not work when 'wildoptions' has "fuzzy"
Bram Moolenaar <Bram@vim.org>
parents:
28109
diff
changeset
|
4063 if (cmdline_fuzzy_completion_supported(&xpc)) |
130f4082a13d
patch 8.2.4608: getcompletion() does not work when 'wildoptions' has "fuzzy"
Bram Moolenaar <Bram@vim.org>
parents:
28109
diff
changeset
|
4064 // when fuzzy matching, don't modify the search string |
130f4082a13d
patch 8.2.4608: getcompletion() does not work when 'wildoptions' has "fuzzy"
Bram Moolenaar <Bram@vim.org>
parents:
28109
diff
changeset
|
4065 pat = vim_strsave(xpc.xp_pattern); |
130f4082a13d
patch 8.2.4608: getcompletion() does not work when 'wildoptions' has "fuzzy"
Bram Moolenaar <Bram@vim.org>
parents:
28109
diff
changeset
|
4066 else |
130f4082a13d
patch 8.2.4608: getcompletion() does not work when 'wildoptions' has "fuzzy"
Bram Moolenaar <Bram@vim.org>
parents:
28109
diff
changeset
|
4067 pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context); |
130f4082a13d
patch 8.2.4608: getcompletion() does not work when 'wildoptions' has "fuzzy"
Bram Moolenaar <Bram@vim.org>
parents:
28109
diff
changeset
|
4068 |
29175
755ab148288b
patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents:
28786
diff
changeset
|
4069 if (rettv_list_alloc(rettv) == OK && pat != NULL) |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4070 { |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4071 int i; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4072 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4073 ExpandOne(&xpc, pat, NULL, options, WILD_ALL_KEEP); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4074 |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4075 for (i = 0; i < xpc.xp_numfiles; i++) |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4076 list_append_string(rettv->vval.v_list, xpc.xp_files[i], -1); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4077 } |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4078 vim_free(pat); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4079 ExpandCleanup(&xpc); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4080 } |
17781
04245f071792
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17779
diff
changeset
|
4081 #endif // FEAT_EVAL |