* Disable line buffer and input echo of stdin
*/
static int __getch()
{
char ch;
struct termios old, new;
(void) tcgetattr(STDIN_FILENO, &old);
memcpy(&new, &old, sizeof(struct termios));
new.c_lflag &= ~(ICANON | ECHO);
(void) tcsetattr(STDIN_FILENO, TCSANOW, &new);
ch = getchar();
(void) tcsetattr(STDIN_FILENO, TCSANOW, &old);
return ch;
}
时间: 2024-11-08 04:54:55