From: hniksic Date: Wed, 28 Jan 2004 13:42:52 +0000 (-0800) Subject: [svn] Correctly determine screen size under Windows. X-Git-Tag: v1.13~1323 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=4d626daf5aab52a22df4dd56144735679869d095 [svn] Correctly determine screen size under Windows. --- diff --git a/src/ChangeLog b/src/ChangeLog index b44e5c41..934be235 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-01-28 David Fritz + + * utils.c (determine_screen_width): Correctly determine console + width under Windows. + 2004-01-28 Christian Biere * progress.c (bar_set_params): Fixed syntax error when HAVE_ISATTY diff --git a/src/utils.c b/src/utils.c index c9de2ea2..c096b3e7 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1659,9 +1659,7 @@ determine_screen_width (void) { /* If there's a way to get the terminal size using POSIX tcgetattr(), somebody please tell me. */ -#ifndef TIOCGWINSZ - return 0; -#else /* TIOCGWINSZ */ +#ifdef TIOCGWINSZ int fd; struct winsize wsz; @@ -1673,7 +1671,14 @@ determine_screen_width (void) return 0; /* most likely ENOTTY */ return wsz.ws_col; -#endif /* TIOCGWINSZ */ +#else /* not TIOCGWINSZ */ +# ifdef WINDOWS + CONSOLE_SCREEN_BUFFER_INFO csbi; + if (!GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &csbi)) + return 0; + return csbi.dwSize.X; +# endif /* WINDOWS */ +#endif /* not TIOCGWINSZ */ } /* Return a random number between 0 and MAX-1, inclusive.