diff options
-rw-r--r-- | src/termios_wrapper.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/termios_wrapper.c b/src/termios_wrapper.c index 1c6dd70..b23ae2d 100644 --- a/src/termios_wrapper.c +++ b/src/termios_wrapper.c @@ -1,15 +1,49 @@ #include <termios.h> +/* very simplistic, ignores a lot of the settings that i don't understand, + * patches welcome */ + int cooked() { + struct termios t; + + if (tcgetattr(0, &t) == -1) { + return 0; + } + + t.c_lflag |= (ICANON | ISIG | IEXTEN); + t.c_iflag |= (IXON | BRKINT); + + return tcsetattr(0, TCSANOW, &t) == 0; } int cbreak() { + struct termios t; + + if (tcgetattr(0, &t) == -1) { + return 0; + } + + t.c_lflag |= ISIG; + t.c_lflag &= ~(ICANON | IEXTEN); + t.c_iflag |= (IXON | BRKINT); + + return tcsetattr(0, TCSANOW, &t) == 0; } int raw() { + struct termios t; + + if (tcgetattr(0, &t) == -1) { + return 0; + } + + t.c_lflag &= ~(ICANON | ISIG | IEXTEN); + t.c_iflag &= ~(IXON | BRKINT); + + return tcsetattr(0, TCSANOW, &t) == 0; } int echo(int enabled) |