From: Mikko Rasa Date: Thu, 26 Jul 2012 19:30:06 +0000 (+0300) Subject: Implement Console::get_size on windows X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=bdea0d5d312658f8ca4a52b2c645ed7c6d78c983;p=libs%2Fcore.git Implement Console::get_size on windows --- 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)