From bdea0d5d312658f8ca4a52b2c645ed7c6d78c983 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 26 Jul 2012 22:30:06 +0300 Subject: [PATCH] Implement Console::get_size on windows --- source/io/console.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/io/console.cpp b/source/io/console.cpp index 6ae9699..a03ad20 100644 --- a/source/io/console.cpp +++ b/source/io/console.cpp @@ -124,9 +124,12 @@ void Console::get_size(unsigned &rows, unsigned &cols) check_access(M_WRITE); #ifdef WIN32 - // XXX Figure out how to do this - rows = 24; - cols = 80; + CONSOLE_SCREEN_BUFFER_INFO sbi; + if(!GetConsoleScreenBufferInfo(*handle, &sbi)) + throw system_error("GetConsoleScreenBufferInfo"); + // Right/bottom coords are inclusive + rows = sbi.srWindow.Bottom+1-sbi.srWindow.Top; + cols = sbi.srWindow.Right+1-sbi.srWindow.Left; #else struct winsize wsz; if(ioctl(*handle, TIOCGWINSZ, &wsz)==-1) -- 2.43.0