CHAR_T delbuf[DELBUFSIZ]; /* a place to store deleted characters */
#endif
#if ENABLE_FEATURE_EDITING_ASK_TERMINAL
+ smallint unknown_width;
smallint sent_ESC_br6n;
#endif
* 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
*/
- struct pollfd pfd;
-
- pfd.fd = STDIN_FILENO;
- pfd.events = POLLIN;
- if (safe_poll(&pfd, 1, 0) == 0) {
- S.sent_ESC_br6n = 1;
- fputs("\033" "[6n", stdout);
- fflush_all(); /* make terminal see it ASAP! */
+ if (S.unknown_width) { /* only if window size is not known */
+ struct pollfd pfd;
+
+ pfd.fd = STDIN_FILENO;
+ pfd.events = POLLIN;
+ if (safe_poll(&pfd, 1, 0) == 0) {
+ S.sent_ESC_br6n = 1;
+ fputs("\033" "[6n", stdout);
+ fflush_all(); /* make terminal see it ASAP! */
+ }
}
}
#else
static void win_changed(int nsig)
{
+ int sv_errno = errno;
unsigned width;
- get_terminal_width_height(0, &width, NULL);
+ IF_FEATURE_EDITING_ASK_TERMINAL(S.unknown_width =) get_terminal_width_height(0, &width, NULL);
cmdedit_setwidth(width, nsig /* - just a yes/no flag */);
if (nsig == SIGWINCH)
signal(SIGWINCH, win_changed); /* rearm ourself */
+ errno = sv_errno;
}
static int lineedit_read_key(char *read_key_buffer)