comparison src/if_cscope.c @ 1845:dc81a4fc6318 v7.2.143

updated for version 7.2-143
author vimboss
date Wed, 18 Mar 2009 11:52:53 +0000
parents 730697e82c43
children 44fe912b5a1b
comparison
equal deleted inserted replaced
1844:819d952a0a5c 1845:dc81a4fc6318
91 csid_e x; 91 csid_e x;
92 { 92 {
93 (void)EMSG2(_("E560: Usage: cs[cope] %s"), cs_cmds[(int)x].usage); 93 (void)EMSG2(_("E560: Usage: cs[cope] %s"), cs_cmds[(int)x].usage);
94 } 94 }
95 95
96 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
97
98 static enum
99 {
100 EXP_CSCOPE_SUBCMD, /* expand ":cscope" sub-commands */
101 EXP_CSCOPE_FIND, /* expand ":cscope find" arguments */
102 EXP_CSCOPE_KILL /* expand ":cscope kill" arguments */
103 } expand_what;
104
105 /*
106 * Function given to ExpandGeneric() to obtain the cscope command
107 * expansion.
108 */
109 /*ARGSUSED*/
110 char_u *
111 get_cscope_name(xp, idx)
112 expand_T *xp;
113 int idx;
114 {
115 switch (expand_what)
116 {
117 case EXP_CSCOPE_SUBCMD:
118 /* Complete with sub-commands of ":cscope":
119 * add, find, help, kill, reset, show */
120 return (char_u *)cs_cmds[idx].name;
121 case EXP_CSCOPE_FIND:
122 {
123 const char *query_type[] =
124 {
125 "c", "d", "e", "f", "g", "i", "s", "t", NULL
126 };
127
128 /* Complete with query type of ":cscope find {query_type}".
129 * {query_type} can be letters (c, d, ... t) or numbers (0, 1,
130 * ..., 8) but only complete with letters, since numbers are
131 * redundant. */
132 return (char_u *)query_type[idx];
133 }
134 case EXP_CSCOPE_KILL:
135 {
136 int i;
137 int current_idx = 0;
138 static char_u connection[2];
139
140 /* ":cscope kill" accepts connection numbers or partial names of
141 * the pathname of the cscope database as argument. Only complete
142 * with connection numbers. -1 can also be used to kill all
143 * connections. */
144 for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
145 {
146 if (csinfo[i].fname == NULL)
147 continue;
148 if (current_idx++ == idx)
149 {
150 /* Connection number fits in one character since
151 * CSCOPE_MAX_CONNECTIONS is < 10 */
152 connection[0] = i + '0';
153 connection[1] = NUL;
154 return connection;
155 }
156 }
157 return (current_idx == idx && idx > 0) ? (char_u *)"-1" : NULL;
158 }
159 default:
160 return NULL;
161 }
162 }
163
164 /*
165 * Handle command line completion for :cscope command.
166 */
167 void
168 set_context_in_cscope_cmd(xp, arg)
169 expand_T *xp;
170 char_u *arg;
171 {
172 char_u *p;
173
174 /* Default: expand subcommands */
175 xp->xp_context = EXPAND_CSCOPE;
176 expand_what = EXP_CSCOPE_SUBCMD;
177 xp->xp_pattern = arg;
178
179 /* (part of) subcommand already typed */
180 if (*arg != NUL)
181 {
182 p = skiptowhite(arg);
183 if (*p != NUL) /* past first word */
184 {
185 xp->xp_pattern = skipwhite(p);
186 if (*skiptowhite(xp->xp_pattern) != NUL)
187 xp->xp_context = EXPAND_NOTHING;
188 else if (STRNICMP(arg, "add", p - arg) == 0)
189 xp->xp_context = EXPAND_FILES;
190 else if (STRNICMP(arg, "kill", p - arg) == 0)
191 expand_what = EXP_CSCOPE_KILL;
192 else if (STRNICMP(arg, "find", p - arg) == 0)
193 expand_what = EXP_CSCOPE_FIND;
194 else
195 xp->xp_context = EXPAND_NOTHING;
196 }
197 }
198 }
199
200 #endif /* FEAT_CMDL_COMPL */
201
96 /* 202 /*
97 * PRIVATE: do_cscope_general 203 * PRIVATE: do_cscope_general
98 * 204 *
99 * find the command, print help if invalid, and the then call the 205 * Find the command, print help if invalid, and then call the corresponding
100 * corresponding command function, 206 * command function.
101 * called from do_cscope and do_scscope
102 */ 207 */
103 static void 208 static void
104 do_cscope_general(eap, make_split) 209 do_cscope_general(eap, make_split)
105 exarg_T *eap; 210 exarg_T *eap;
106 int make_split; /* whether to split window */ 211 int make_split; /* whether to split window */