]> git.tdb.fi Git - libs/core.git/commitdiff
Implement Console::get_size on windows
authorMikko Rasa <tdb@tdb.fi>
Thu, 26 Jul 2012 19:30:06 +0000 (22:30 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 26 Jul 2012 19:41:57 +0000 (22:41 +0300)
source/io/console.cpp

index 6ae969914b732319ed78609a30d294e3b670c609..a03ad20747bf251c40c57f682e027f760756cb7e 100644 (file)
@@ -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)