5 #include <msp/core/systemerror.h>
7 #include "handle_private.h"
19 void Console::platform_init()
24 tcgetattr(*handle, &orig_attr);
30 tcsetattr(*handle, TCSADRAIN, &orig_attr);
33 void Console::set_local_echo(bool e)
38 tcgetattr(*handle, &t);
39 t.c_lflag = (t.c_lflag&~ECHO) | (e?ECHO:0);
40 tcsetattr(*handle, TCSADRAIN, &t);
43 void Console::set_line_buffer(bool l)
48 if(tcgetattr(*handle, &t)==-1)
49 throw system_error("tcgetattr");
50 t.c_lflag = (t.c_lflag&~ICANON) | (l?ICANON:0);
51 // man termios warns that VMIN and VTIME may share indices with VEOF and VEOL
54 t.c_cc[VEOF] = orig_attr.c_cc[VEOF];
55 t.c_cc[VEOL] = orig_attr.c_cc[VEOL];
62 if(tcsetattr(*handle, TCSADRAIN, &t)==-1)
63 throw system_error("tcsetattr");
66 void Console::get_size(unsigned &rows, unsigned &cols)
68 check_access(M_WRITE);
71 if(ioctl(*handle, TIOCGWINSZ, &wsz)==-1)
72 throw system_error("ioctl TIOCGWINSZ");
77 void Console::redirect(Base &other)
79 dup2(*other.get_handle(mode), *handle);