#include #include #include #include /* * Sets terminal into raw mode. * This causes having the characters available * immediately instead of waiting for a newline. * Also there is no automatic echo. */ void tty_raw_mode(void) { struct termios tty_attr; tcgetattr(0,&tty_attr); /* Set raw mode. */ tty_attr.c_lflag &= (~(ICANON|ECHO)); tty_attr.c_cc[VTIME] = 0; tty_attr.c_cc[VMIN] = 1; tcsetattr(0,TCSANOW,&tty_attr); }