]>
Commit | Line | Data |
---|---|---|
478508cd ER |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.2.143 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.2.143 | |
11 | Problem: No command line completion for ":cscope" command. | |
12 | Solution: Add the completion for ":cscope". (Dominique Pelle) | |
13 | Files: src/ex_docmd.c, src/ex_getln.c, src/if_cscope.c, | |
14 | src/proto/if_cscope.pro, src/vim.h | |
15 | ||
16 | ||
17 | *** ../vim-7.2.142/src/ex_docmd.c Wed Mar 11 15:36:01 2009 | |
18 | --- src/ex_docmd.c Wed Mar 11 15:45:04 2009 | |
19 | *************** | |
20 | *** 3683,3688 **** | |
21 | --- 3683,3693 ---- | |
22 | case CMD_highlight: | |
23 | set_context_in_highlight_cmd(xp, arg); | |
24 | break; | |
25 | + #ifdef FEAT_CSCOPE | |
26 | + case CMD_cscope: | |
27 | + set_context_in_cscope_cmd(xp, arg); | |
28 | + break; | |
29 | + #endif | |
30 | #ifdef FEAT_LISTCMDS | |
31 | case CMD_bdelete: | |
32 | case CMD_bwipeout: | |
33 | *************** | |
34 | *** 5187,5192 **** | |
35 | --- 5192,5200 ---- | |
36 | {EXPAND_AUGROUP, "augroup"}, | |
37 | {EXPAND_BUFFERS, "buffer"}, | |
38 | {EXPAND_COMMANDS, "command"}, | |
39 | + #if defined(FEAT_CSCOPE) | |
40 | + {EXPAND_CSCOPE, "cscope"}, | |
41 | + #endif | |
42 | #if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL) | |
43 | {EXPAND_USER_DEFINED, "custom"}, | |
44 | {EXPAND_USER_LIST, "customlist"}, | |
45 | *** ../vim-7.2.142/src/ex_getln.c Thu Mar 5 03:13:51 2009 | |
46 | --- src/ex_getln.c Wed Mar 11 15:45:04 2009 | |
47 | *************** | |
48 | *** 4518,4523 **** | |
49 | --- 4518,4526 ---- | |
50 | {EXPAND_EVENTS, get_event_name, TRUE}, | |
51 | {EXPAND_AUGROUP, get_augroup_name, TRUE}, | |
52 | #endif | |
53 | + #ifdef FEAT_CSCOPE | |
54 | + {EXPAND_CSCOPE, get_cscope_name, TRUE}, | |
55 | + #endif | |
56 | #if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ | |
57 | && (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE)) | |
58 | {EXPAND_LANGUAGE, get_lang_arg, TRUE}, | |
59 | *** ../vim-7.2.142/src/if_cscope.c Wed Jan 28 16:03:51 2009 | |
60 | --- src/if_cscope.c Wed Mar 11 15:56:07 2009 | |
61 | *************** | |
62 | *** 93,104 **** | |
63 | (void)EMSG2(_("E560: Usage: cs[cope] %s"), cs_cmds[(int)x].usage); | |
64 | } | |
65 | ||
66 | /* | |
67 | * PRIVATE: do_cscope_general | |
68 | * | |
69 | ! * find the command, print help if invalid, and the then call the | |
70 | ! * corresponding command function, | |
71 | ! * called from do_cscope and do_scscope | |
72 | */ | |
73 | static void | |
74 | do_cscope_general(eap, make_split) | |
75 | --- 93,209 ---- | |
76 | (void)EMSG2(_("E560: Usage: cs[cope] %s"), cs_cmds[(int)x].usage); | |
77 | } | |
78 | ||
79 | + #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | |
80 | + | |
81 | + static enum | |
82 | + { | |
83 | + EXP_CSCOPE_SUBCMD, /* expand ":cscope" sub-commands */ | |
84 | + EXP_CSCOPE_FIND, /* expand ":cscope find" arguments */ | |
85 | + EXP_CSCOPE_KILL /* expand ":cscope kill" arguments */ | |
86 | + } expand_what; | |
87 | + | |
88 | + /* | |
89 | + * Function given to ExpandGeneric() to obtain the cscope command | |
90 | + * expansion. | |
91 | + */ | |
92 | + /*ARGSUSED*/ | |
93 | + char_u * | |
94 | + get_cscope_name(xp, idx) | |
95 | + expand_T *xp; | |
96 | + int idx; | |
97 | + { | |
98 | + switch (expand_what) | |
99 | + { | |
100 | + case EXP_CSCOPE_SUBCMD: | |
101 | + /* Complete with sub-commands of ":cscope": | |
102 | + * add, find, help, kill, reset, show */ | |
103 | + return (char_u *)cs_cmds[idx].name; | |
104 | + case EXP_CSCOPE_FIND: | |
105 | + { | |
106 | + const char *query_type[] = | |
107 | + { | |
108 | + "c", "d", "e", "f", "g", "i", "s", "t", NULL | |
109 | + }; | |
110 | + | |
111 | + /* Complete with query type of ":cscope find {query_type}". | |
112 | + * {query_type} can be letters (c, d, ... t) or numbers (0, 1, | |
113 | + * ..., 8) but only complete with letters, since numbers are | |
114 | + * redundant. */ | |
115 | + return (char_u *)query_type[idx]; | |
116 | + } | |
117 | + case EXP_CSCOPE_KILL: | |
118 | + { | |
119 | + int i; | |
120 | + int current_idx = 0; | |
121 | + static char_u connection[2]; | |
122 | + | |
123 | + /* ":cscope kill" accepts connection numbers or partial names of | |
124 | + * the pathname of the cscope database as argument. Only complete | |
125 | + * with connection numbers. -1 can also be used to kill all | |
126 | + * connections. */ | |
127 | + for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++) | |
128 | + { | |
129 | + if (csinfo[i].fname == NULL) | |
130 | + continue; | |
131 | + if (current_idx++ == idx) | |
132 | + { | |
133 | + /* Connection number fits in one character since | |
134 | + * CSCOPE_MAX_CONNECTIONS is < 10 */ | |
135 | + connection[0] = i + '0'; | |
136 | + connection[1] = NUL; | |
137 | + return connection; | |
138 | + } | |
139 | + } | |
140 | + return (current_idx == idx && idx > 0) ? (char_u *)"-1" : NULL; | |
141 | + } | |
142 | + default: | |
143 | + return NULL; | |
144 | + } | |
145 | + } | |
146 | + | |
147 | + /* | |
148 | + * Handle command line completion for :cscope command. | |
149 | + */ | |
150 | + void | |
151 | + set_context_in_cscope_cmd(xp, arg) | |
152 | + expand_T *xp; | |
153 | + char_u *arg; | |
154 | + { | |
155 | + char_u *p; | |
156 | + | |
157 | + /* Default: expand subcommands */ | |
158 | + xp->xp_context = EXPAND_CSCOPE; | |
159 | + expand_what = EXP_CSCOPE_SUBCMD; | |
160 | + xp->xp_pattern = arg; | |
161 | + | |
162 | + /* (part of) subcommand already typed */ | |
163 | + if (*arg != NUL) | |
164 | + { | |
165 | + p = skiptowhite(arg); | |
166 | + if (*p != NUL) /* past first word */ | |
167 | + { | |
168 | + xp->xp_pattern = skipwhite(p); | |
169 | + if (*skiptowhite(xp->xp_pattern) != NUL) | |
170 | + xp->xp_context = EXPAND_NOTHING; | |
171 | + else if (STRNICMP(arg, "add", p - arg) == 0) | |
172 | + xp->xp_context = EXPAND_FILES; | |
173 | + else if (STRNICMP(arg, "kill", p - arg) == 0) | |
174 | + expand_what = EXP_CSCOPE_KILL; | |
175 | + else if (STRNICMP(arg, "find", p - arg) == 0) | |
176 | + expand_what = EXP_CSCOPE_FIND; | |
177 | + else | |
178 | + xp->xp_context = EXPAND_NOTHING; | |
179 | + } | |
180 | + } | |
181 | + } | |
182 | + | |
183 | + #endif /* FEAT_CMDL_COMPL */ | |
184 | + | |
185 | /* | |
186 | * PRIVATE: do_cscope_general | |
187 | * | |
188 | ! * Find the command, print help if invalid, and then call the corresponding | |
189 | ! * command function. | |
190 | */ | |
191 | static void | |
192 | do_cscope_general(eap, make_split) | |
193 | *** ../vim-7.2.142/src/proto/if_cscope.pro Thu Sep 6 17:38:21 2007 | |
194 | --- src/proto/if_cscope.pro Wed Mar 11 15:57:03 2009 | |
195 | *************** | |
196 | *** 1,4 **** | |
197 | --- 1,6 ---- | |
198 | /* if_cscope.c */ | |
199 | + char_u *get_cscope_name __ARGS((expand_T *xp, int idx)); | |
200 | + void set_context_in_cscope_cmd __ARGS((expand_T *xp, char_u *arg)); | |
201 | void do_cscope __ARGS((exarg_T *eap)); | |
202 | void do_scscope __ARGS((exarg_T *eap)); | |
203 | void do_cstag __ARGS((exarg_T *eap)); | |
204 | *** ../vim-7.2.142/src/vim.h Sun Feb 22 02:36:36 2009 | |
205 | --- src/vim.h Wed Mar 11 15:45:04 2009 | |
206 | *************** | |
207 | *** 708,713 **** | |
208 | --- 708,714 ---- | |
209 | #define EXPAND_USER_DEFINED 30 | |
210 | #define EXPAND_USER_LIST 31 | |
211 | #define EXPAND_SHELLCMD 32 | |
212 | + #define EXPAND_CSCOPE 33 | |
213 | ||
214 | /* Values for exmode_active (0 is no exmode) */ | |
215 | #define EXMODE_NORMAL 1 | |
216 | *** ../vim-7.2.142/src/version.c Wed Mar 18 12:20:35 2009 | |
217 | --- src/version.c Wed Mar 18 12:48:08 2009 | |
218 | *************** | |
219 | *** 678,679 **** | |
220 | --- 678,681 ---- | |
221 | { /* Add new patch number below this line */ | |
222 | + /**/ | |
223 | + 143, | |
224 | /**/ | |
225 | ||
226 | -- | |
227 | hundred-and-one symptoms of being an internet addict: | |
228 | 234. You started college as a chemistry major, and walk out four years | |
229 | later as an Internet provider. | |
230 | ||
231 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
232 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
233 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
234 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |