diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-26 13:24:28 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-26 13:24:28 +0200 |
commit | ad4824748f3b8757b0c82d6bfffb5c6033136a91 (patch) | |
tree | 6a410dabb1d67f242cf10bb1fffea8fa3a9c6323 | |
parent | e19c5dae8dd0781045163ea6e09bd6826b2fd674 (diff) |
Add Win32 implementation for console width detection
-rw-r--r-- | bpkg/help.cxx | 8 |
1 files changed, 8 insertions, 0 deletions
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 <unistd.h> // close(), STDOUT_FILENO # include <sys/ioctl.h> // ioctl() #else +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include <windows.h> // GetConsoleScreenBufferInfo(), GetStdHandle() # include <io.h> // _close() #endif @@ -49,6 +53,10 @@ namespace bpkg col = static_cast<size_t> (w.ws_col); # endif #else +#error TODO: needs testing + CONSOLE_SCREEN_BUFFER_INFO w; + if (GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &w)) + col = static_cast<size_t> (w.srWindow.Right - w.srWindow.Left + 1); #endif if (col > 80) indent_.assign ((col - 80) / 2, ' '); |