From ad4824748f3b8757b0c82d6bfffb5c6033136a91 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 26 Nov 2015 13:24:28 +0200 Subject: Add Win32 implementation for console width detection --- bpkg/help.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bpkg/help.cxx b/bpkg/help.cxx index 2da6b0a..3c44c52 100644 --- a/bpkg/help.cxx +++ b/bpkg/help.cxx @@ -8,6 +8,10 @@ # include // close(), STDOUT_FILENO # include // ioctl() #else +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include // GetConsoleScreenBufferInfo(), GetStdHandle() # include // _close() #endif @@ -49,6 +53,10 @@ namespace bpkg col = static_cast (w.ws_col); # endif #else +#error TODO: needs testing + CONSOLE_SCREEN_BUFFER_INFO w; + if (GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &w)) + col = static_cast (w.srWindow.Right - w.srWindow.Left + 1); #endif if (col > 80) indent_.assign ((col - 80) / 2, ' '); -- cgit v1.1