]> sjero.net Git - wget/commitdiff
[svn] Correctly determine screen size under Windows.
authorhniksic <devnull@localhost>
Wed, 28 Jan 2004 13:42:52 +0000 (05:42 -0800)
committerhniksic <devnull@localhost>
Wed, 28 Jan 2004 13:42:52 +0000 (05:42 -0800)
src/ChangeLog
src/utils.c

index b44e5c416ce6f3b0441fa03a7d80a282ad2dd99c..934be2354f8ecd2fd22cd7690c33a88cb85acae3 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-28  David Fritz  <zeroxdf@att.net>
+
+       * utils.c (determine_screen_width): Correctly determine console
+       width under Windows.
+
 2004-01-28  Christian Biere  <christianbiere@gmx.de>
 
        * progress.c (bar_set_params): Fixed syntax error when HAVE_ISATTY
index c9de2ea2480b6c8f96c83cb5e8df8077ae8c6462..c096b3e7e781dc0478658170b124a9da4544061b 100644 (file)
@@ -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.