tty autocomplete

Change tty extended command autocomplete, based loosely on <Someone>'s
patch, to allow you to type autocompleted characters.  That is, you can type
characters the autocompleter inserted without invalidating the command.
I haven't looked closely, but at least some other windowport extended
command readers seem to already behave similarly.
This commit is contained in:
cohrs
2002-12-12 06:16:39 +00:00
parent d013f95679
commit ed39497b21
2 changed files with 20 additions and 8 deletions

View File

@@ -371,6 +371,7 @@ tty: support terms where turning off inverse video turns off color too
tty: object selection at --More-- prompt after '?' didn't work anymore
unix: install recover command into GAMEDIR by default
vms: prevent error() from indirectly triggering hangup save during forced exit
tty: ext command autocomplete now lets you enter auto-completed characters
General New Features

View File

@@ -59,7 +59,6 @@ getlin_hook_proc hook;
Sprintf(toplines, "%s ", query);
Strcat(toplines, obufp);
if((c = Getchar()) == EOF) {
*bufp = 0;
break;
}
if(c == '\033') {
@@ -101,34 +100,46 @@ getlin_hook_proc hook;
}
if(c == erase_char || c == '\b') {
if(bufp != obufp) {
char *i;
bufp--;
putsyms("\b \b");/* putsym converts \b */
putsyms("\b");
for (i = bufp; *i; ++i) putsyms(" ");
for (; i > bufp; --i) putsyms("\b");
*bufp = 0;
} else tty_nhbell();
#if defined(apollo)
} else if(c == '\n' || c == '\r') {
#else
} else if(c == '\n') {
#endif
*bufp = 0;
break;
} else if(' ' <= (unsigned char) c && c != '\177' &&
(bufp-obufp < BUFSZ-1 && bufp-obufp < COLNO)) {
/* avoid isprint() - some people don't have it
' ' is not always a printing char */
char *i = eos(bufp);
*bufp = c;
bufp[1] = 0;
putsyms(bufp);
bufp++;
if (hook && (*hook)(obufp)) {
putsyms(bufp);
bufp = eos(bufp);
/* pointer and cursor left where they were */
for (i = bufp; *i; ++i) putsyms("\b");
} else if (i > bufp) {
char *s = i;
/* erase rest of prior guess */
for (; i > bufp; --i) putsyms(" ");
for (; s > bufp; --s) putsyms("\b");
}
} else if(c == kill_char || c == '\177') { /* Robert Viduya */
/* this test last - @ might be the kill_char */
while(bufp != obufp) {
bufp--;
putsyms("\b \b");
}
for (; *bufp; ++bufp) putsyms(" ");
for (; bufp != obufp; --bufp) putsyms("\b \b");
*bufp = 0;
} else
tty_nhbell();
}