diff options
author | Pixel <> | 2001-04-16 20:40:13 +0000 |
---|---|---|
committer | Pixel <> | 2001-04-16 20:40:13 +0000 |
commit | 85155ff54ba94f8ac40e267f83435284e88b866c (patch) | |
tree | 26e8ba119f6e5af7cbdf40cf8382becbc1affefd /lib/terminal.c | |
parent | 4b6921b966481ff28c919ca0e0fb345e601a9a74 (diff) |
Prout
Diffstat (limited to 'lib/terminal.c')
-rw-r--r-- | lib/terminal.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/terminal.c b/lib/terminal.c new file mode 100644 index 0000000..df3e61d --- /dev/null +++ b/lib/terminal.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <termios.h> +#include <string.h> +#include "config.h" + +FILE *input; +struct termios initial_settings, new_settings; + +void initterm() { + tcgetattr(fileno(input), &initial_settings); + new_settings = initial_settings; + new_settings.c_lflag &= ~ICANON; + new_settings.c_lflag &= ~ECHO; + new_settings.c_cc[VMIN] = 1; + new_settings.c_cc[VTIME] = 0; + new_settings.c_lflag &= ~ISIG; + + if (tcsetattr(fileno(input), TCSANOW, &new_settings) != 0) { + exception(1, _("could not set terminal attributes")); + } + +} + +void clearterm() { + tcsetattr(fileno(input), TCSANOW, &initial_settings); +} + +void openterm() { + if (!(input = fopen("/dev/tty", "r"))) { + exception(1, _("could not open terminal")); + } +} |