From e16e55d4a02105b03434e1434e1a13562503d0f2 Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Mon, 2 May 2011 05:57:02 +0200 Subject: [PATCH] src/sysdep.c (get_tty_size) [WINDOWSNT]: Implement. Fixes: debbugs:8596 --- src/ChangeLog | 4 ++++ src/sysdep.c | 26 ++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 2137c133f54..1231099fff3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2011-05-02 Juanma Barranquero + + * sysdep.c (get_tty_size) [WINDOWSNT]: Implement. (Bug#8596) + 2011-05-02 Juanma Barranquero * gnutls.c (Qgnutls_log_level, Qgnutls_code, Qgnutls_anon) diff --git a/src/sysdep.c b/src/sysdep.c index ea9a25cc6e7..462e03879c6 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -1125,8 +1125,7 @@ tabs_safe_p (int fd) void get_tty_size (int fd, int *widthp, int *heightp) { - -#ifdef TIOCGWINSZ +#if defined TIOCGWINSZ /* BSD-style. */ struct winsize size; @@ -1139,8 +1138,7 @@ get_tty_size (int fd, int *widthp, int *heightp) *heightp = size.ws_row; } -#else -#ifdef TIOCGSIZE +#elif defined TIOCGSIZE /* SunOS - style. */ struct ttysize size; @@ -1153,16 +1151,28 @@ get_tty_size (int fd, int *widthp, int *heightp) *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 -- 2.39.2