mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 10:01:11 +02:00
zsh-workers/9799
This commit is contained in:
parent
9063cd0d55
commit
245847e9e4
1 changed files with 30 additions and 18 deletions
48
Src/utils.c
48
Src/utils.c
|
@ -1311,6 +1311,23 @@ read1char(void)
|
|||
return STOUC(c);
|
||||
}
|
||||
|
||||
/**/
|
||||
int
|
||||
noquery(int purge)
|
||||
{
|
||||
int c, val = 0;
|
||||
|
||||
#ifdef FIONREAD
|
||||
ioctl(SHTTY, FIONREAD, (char *)&val);
|
||||
if (purge) {
|
||||
while(val--)
|
||||
read(SHTTY, &c, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/**/
|
||||
int
|
||||
getquery(char *valid_chars, int purge)
|
||||
|
@ -1318,26 +1335,17 @@ getquery(char *valid_chars, int purge)
|
|||
int c, d;
|
||||
int isem = !strcmp(term, "emacs");
|
||||
|
||||
#ifdef FIONREAD
|
||||
int val = 0;
|
||||
#endif
|
||||
|
||||
attachtty(mypgrp);
|
||||
if (!isem)
|
||||
setcbreak();
|
||||
|
||||
#ifdef FIONREAD
|
||||
ioctl(SHTTY, FIONREAD, (char *)&val);
|
||||
if(purge) {
|
||||
while(val--)
|
||||
read(SHTTY, &c, 1);
|
||||
} else if (val) {
|
||||
if (noquery(purge)) {
|
||||
if (!isem)
|
||||
settyinfo(&shttyinfo);
|
||||
write(SHTTY, "n\n", 2);
|
||||
return 'n';
|
||||
}
|
||||
#endif
|
||||
|
||||
while ((c = read1char()) >= 0) {
|
||||
if (c == 'Y' || c == '\t')
|
||||
c = 'y';
|
||||
|
@ -1494,13 +1502,17 @@ spckword(char **s, int hist, int cmd, int ask)
|
|||
*guess = *best = ztokens[ic - Pound];
|
||||
}
|
||||
if (ask) {
|
||||
char *pptbuf;
|
||||
pptbuf = promptexpand(sprompt, 0, best, guess);
|
||||
zputs(pptbuf, shout);
|
||||
free(pptbuf);
|
||||
fflush(shout);
|
||||
zbeep();
|
||||
x = getquery("nyae ", 0);
|
||||
if (noquery(0)) {
|
||||
x = 'n';
|
||||
} else {
|
||||
char *pptbuf;
|
||||
pptbuf = promptexpand(sprompt, 0, best, guess);
|
||||
zputs(pptbuf, shout);
|
||||
free(pptbuf);
|
||||
fflush(shout);
|
||||
zbeep();
|
||||
x = getquery("nyae ", 0);
|
||||
}
|
||||
} else
|
||||
x = 'y';
|
||||
if (x == 'y' || x == ' ') {
|
||||
|
|
Loading…
Reference in a new issue