6 /* Use this variable to remember original terminal attributes. */
8 struct termios saved_attributes
;
11 reset_input_mode (void)
13 tcsetattr (STDIN_FILENO
, TCSANOW
, &saved_attributes
);
22 /* Make sure stdin is a terminal. */
23 if (!isatty (STDIN_FILENO
))
25 fprintf (stderr
, "Not a terminal.\n");
29 /* Save the terminal attributes so we can restore them later. */
30 tcgetattr (STDIN_FILENO
, &saved_attributes
);
31 atexit (reset_input_mode
);
34 /* Set the funny terminal modes. */
35 tcgetattr (STDIN_FILENO
, &tattr
);
36 tattr
.c_lflag
&= ~(ICANON
|ECHO
); /* Clear ICANON and ECHO. */
38 tattr
.c_cc
[VTIME
] = 0;
39 tcsetattr (STDIN_FILENO
, TCSAFLUSH
, &tattr
);
52 read (STDIN_FILENO
, &c
, 1);
53 if (c
== '\004') /* @kbd{C-d} */