lineedit: mostly revert recent wrong logic in "ask terminal" code

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2010-07-25 00:06:41 +02:00
parent 2e9b5510d6
commit 451add4f23

View File

@ -149,7 +149,6 @@ struct lineedit_statics {
CHAR_T delbuf[DELBUFSIZ]; /* a place to store deleted characters */ CHAR_T delbuf[DELBUFSIZ]; /* a place to store deleted characters */
#endif #endif
#if ENABLE_FEATURE_EDITING_ASK_TERMINAL #if ENABLE_FEATURE_EDITING_ASK_TERMINAL
smallint unknown_width;
smallint sent_ESC_br6n; smallint sent_ESC_br6n;
#endif #endif
@ -1611,16 +1610,14 @@ static void ask_terminal(void)
* poll([{fd=0, events=POLLIN}], 1, 4294967295) = 1 ([{fd=0, revents=POLLIN}]) * poll([{fd=0, events=POLLIN}], 1, 4294967295) = 1 ([{fd=0, revents=POLLIN}])
* read(0, "\n", 1) = 1 <-- oh crap, user's input got in first * read(0, "\n", 1) = 1 <-- oh crap, user's input got in first
*/ */
if (S.unknown_width) { /* only if window size is not known */ struct pollfd pfd;
struct pollfd pfd;
pfd.fd = STDIN_FILENO; pfd.fd = STDIN_FILENO;
pfd.events = POLLIN; pfd.events = POLLIN;
if (safe_poll(&pfd, 1, 0) == 0) { if (safe_poll(&pfd, 1, 0) == 0) {
S.sent_ESC_br6n = 1; S.sent_ESC_br6n = 1;
fputs("\033" "[6n", stdout); fputs("\033" "[6n", stdout);
fflush_all(); /* make terminal see it ASAP! */ fflush_all(); /* make terminal see it ASAP! */
}
} }
} }
#else #else
@ -1768,7 +1765,7 @@ static void win_changed(int nsig)
{ {
int sv_errno = errno; int sv_errno = errno;
unsigned width; unsigned width;
IF_FEATURE_EDITING_ASK_TERMINAL(S.unknown_width =) get_terminal_width_height(0, &width, NULL); get_terminal_width_height(0, &width, NULL);
cmdedit_setwidth(width, nsig /* - just a yes/no flag */); cmdedit_setwidth(width, nsig /* - just a yes/no flag */);
if (nsig == SIGWINCH) if (nsig == SIGWINCH)
signal(SIGWINCH, win_changed); /* rearm ourself */ signal(SIGWINCH, win_changed); /* rearm ourself */