+2011-05-02 Juanma Barranquero <lekktu@gmail.com>
+
+ * sysdep.c (get_tty_size) [WINDOWSNT]: Implement. (Bug#8596)
+
2011-05-02 Juanma Barranquero <lekktu@gmail.com>
* gnutls.c (Qgnutls_log_level, Qgnutls_code, Qgnutls_anon)
void
get_tty_size (int fd, int *widthp, int *heightp)
{
-
-#ifdef TIOCGWINSZ
+#if defined TIOCGWINSZ
/* BSD-style. */
struct winsize size;
*heightp = size.ws_row;
}
-#else
-#ifdef TIOCGSIZE
+#elif defined TIOCGSIZE
/* SunOS - style. */
struct ttysize size;
*heightp = size.ts_lines;
}
-#else
-#ifdef MSDOS
+#elif defined WINDOWSNT
+
+ CONSOLE_SCREEN_BUFFER_INFO info;
+ if (GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &info))
+ {
+ *widthp = info.srWindow.Right - info.srWindow.Left + 1;
+ *heightp = info.srWindow.Bottom - info.srWindow.Top + 1;
+ }
+ else
+ *widthp = *heightp = 0;
+
+#elif defined MSDOS
+
*widthp = ScreenCols ();
*heightp = ScreenRows ();
+
#else /* system doesn't know size */
+
*widthp = 0;
*heightp = 0;
+
#endif
-#endif /* not SunOS-style */
-#endif /* not BSD-style */
}
/* Set the logical window size associated with descriptor FD