aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbb/xfuncs.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 3738d6bcf..06bba0fe3 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -626,13 +626,23 @@ void selinux_or_die(void)
626/* It is perfectly ok to pass in a NULL for either width or for 626/* It is perfectly ok to pass in a NULL for either width or for
627 * height, in which case that value will not be set. */ 627 * height, in which case that value will not be set. */
628#ifdef __MINGW32__ 628#ifdef __MINGW32__
629#include <windows.h>
629int get_terminal_width_height(const int fd, int *width, int *height) 630int get_terminal_width_height(const int fd, int *width, int *height)
630{ 631{
631 /* FIXME: support for Windows console */ 632 HANDLE console;
633 CONSOLE_SCREEN_BUFFER_INFO sbi;
634
635 console = GetStdHandle(STD_OUTPUT_HANDLE);
636 if (console == INVALID_HANDLE_VALUE || !console)
637 return -1;
638
639 GetConsoleScreenBufferInfo(console, &sbi);
640
632 if (width) 641 if (width)
633 *width = 80; 642 *width = sbi.srWindow.Right - sbi.srWindow.Left;
634 if (height) 643 if (height)
635 *height = 25; 644 *height = sbi.srWindow.Bottom - sbi.srWindow.Top;
645 return 0;
636} 646}
637#else 647#else
638int get_terminal_width_height(const int fd, int *width, int *height) 648int get_terminal_width_height(const int fd, int *width, int *height)