192 inputField_t *inputLine = &prompt->inputLine;
193 char *text, *partial, *s;
194 int i, argc, currentArg, argnum;
195 size_t size, len, pos;
198 char *matches[MAX_MATCHES], *sortedMatches[MAX_MATCHES];
199 int numCommands, numCvars, numAliases;
201 text = inputLine->text;
202 size = inputLine->maxChars + 1;
203 pos = inputLine->cursorPos;
207 if (inputLine->text[0] !=
'\\' && inputLine->text[0] !=
'/') {
208 memmove(inputLine->text + 1, inputLine->text, size - 1);
209 inputLine->text[0] =
'\\';
230 for (i = 0; i < currentArg; i++) {
241 if (*partial ==
';') {
249 memset(&ctx, 0,
sizeof(ctx));
250 ctx.partial = partial;
251 ctx.length = strlen(partial);
252 ctx.argnum = currentArg;
253 ctx.matches = matches;
254 ctx.size = MAX_MATCHES;
259 numCommands = numCvars = numAliases = 0;
263 numCommands = ctx.count;
266 numCvars = ctx.count - numCommands;
269 numAliases = ctx.count - numCvars - numCommands;
273 pos = strlen(inputLine->text);
274 prompt->tooMany = qfalse;
289 if (ctx.count == 1) {
293 pos +=
Q_concat(text, size,
"\"", matches[0],
"\" ", s, NULL);
295 pos +=
Q_concat(text, size, matches[0],
" ", s, NULL);
298 prompt->tooMany = qfalse;
303 prompt->printf(
"Press TAB again to display all %d possibilities.\n", ctx.count);
304 pos = strlen(inputLine->text);
305 prompt->tooMany = qtrue;
309 prompt->tooMany = qfalse;
312 for (i = 0; i < ctx.count; i++) {
313 sortedMatches[i] = matches[i];
315 qsort(sortedMatches, ctx.count,
sizeof(sortedMatches[0]),
319 first = sortedMatches[0];
320 last = sortedMatches[ctx.count - 1];
323 if (*first != *last) {
324 if (!ctx.ignorecase || Q_tolower(*first) != Q_tolower(*last)) {
328 text[len++] = *first;
329 if (len == size - 1) {
342 if (currentArg + 1 < argc) {
344 pos +=
Q_concat(text + len, size,
" ", s, NULL);
357 for (i = 0; i < ctx.count; i++) {
358 prompt->printf(
"%s\n", sortedMatches[i]);
375 for (i = 0; i < ctx.count; i++) {
381 if (pos >= inputLine->maxChars) {
382 pos = inputLine->maxChars - 1;
384 inputLine->cursorPos = pos;