-void Console::set_line_buffer(bool l)
-{
- check_access(M_READ);
-
-#ifdef WIN32
- DWORD m;
- if(!GetConsoleMode(*handle, &m))
- throw system_error("GetConsoleMode");
- if(!SetConsoleMode(*handle, (m&~ENABLE_LINE_INPUT) | (l?ENABLE_LINE_INPUT:0)))
- throw system_error("SetConsoleMode");
-#else
- termios t;
- if(tcgetattr(*handle, &t)==-1)
- throw system_error("tcgetattr");
- t.c_lflag = (t.c_lflag&~ICANON) | (l?ICANON:0);
- // man termios warns that VMIN and VTIME may share indices with VEOF and VEOL
- if(l)
- {
- t.c_cc[VEOF] = orig_attr.c_cc[VEOF];
- t.c_cc[VEOL] = orig_attr.c_cc[VEOL];
- }
- else
- {
- t.c_cc[VMIN] = 1;
- t.c_cc[VTIME] = 0;
- }
- if(tcsetattr(*handle, TCSADRAIN, &t)==-1)
- throw system_error("tcsetattr");
-#endif
-}
-
-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;
-#else
- struct winsize wsz;
- if(ioctl(*handle, TIOCGWINSZ, &wsz)==-1)
- throw system_error("ioctl TIOCGWINSZ");
- rows = wsz.ws_row;
- cols = wsz.ws_col;
-#endif
-}
-
-void Console::redirect(Base &other)
-{
- Handle other_handle = other.get_handle(mode&M_RDWR);
-#ifdef WIN32
- SetStdHandle(stream_to_sys(stream), *other_handle);
-#else
- dup2(*other_handle, *handle);
-#endif
-}
-
-unsigned Console::do_write(const char *buf, unsigned len)