aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-04-28 15:14:52 +1000
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-04-28 15:14:52 +1000
commitbf132771ae56b6d5c8e5d3d1c33c3b10c9862548 (patch)
tree8105d200760dbef70273205d815a7b48aa16792d
parentf12c99c0e44be0587faa2371af386c7f2d9e72f7 (diff)
downloadbusybox-w32-bf132771ae56b6d5c8e5d3d1c33c3b10c9862548.tar.gz
busybox-w32-bf132771ae56b6d5c8e5d3d1c33c3b10c9862548.tar.bz2
busybox-w32-bf132771ae56b6d5c8e5d3d1c33c3b10c9862548.zip
libbb/xfuncs.c: reimplement get_terminal_width_height to understand Windows console
-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)