1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-23 08:38:49 -05:00

progress-bar: get screen width on windows

This commit is contained in:
Gisle Vanem 2018-01-23 22:41:50 +01:00 committed by Daniel Stenberg
parent 65ceb20dfd
commit a0b5e89445
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -202,6 +202,21 @@ void progressbarinit(struct ProgressData *bar,
struct winsize ts;
if(!ioctl(STDIN_FILENO, TIOCGWINSZ, &ts))
cols = ts.ws_col;
#elif defined(_WIN32)
{
HANDLE stderr_hnd = GetStdHandle(STD_ERROR_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO console_info;
if((stderr_hnd != INVALID_HANDLE_VALUE) &&
GetConsoleScreenBufferInfo(stderr_hnd, &console_info)) {
/*
* Do not use +1 to get the true screen-width since writing a
* character at the right edge will cause a line wrap.
*/
cols = (int)
(console_info.srWindow.Right - console_info.srWindow.Left);
}
}
#endif /* TIOCGSIZE */
bar->width = cols;
}