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)