--- a/queue.c +++ b/queue.c @@ -19,6 +19,7 @@ #include #ifdef HAVE_SYS_SELECT_H #include +#include CURSES_HEADER #endif #include #include @@ -78,30 +79,13 @@ static int my_select (struct timeval *timeout) -/* Wait until input is ready on stdin or a timeout is reached. - * TIMEOUT has the same meaning, as is has for the `select' system - * call. The return value is 0 if we return because of a timeout, - * positive if input is ready, and negative if a signal occured. In - * the latter case we must calculate a new TIMEOUT value and call - * `my_select' again. */ +/* fredygames.com: wait for a key typed on the page, or for the timeout (curses-web/curses.c). + * Returns 1 if a key is waiting and 0 on timeout. */ { - fd_set rfds; - int res; + int ms = -1; - /* Watch stdin (fd 0) to see when it has input. */ - FD_ZERO (&rfds); - FD_SET (0, &rfds); - - if (handle_signals ()) return -1; - res = select (FD_SETSIZE, &rfds, NULL, NULL, timeout); - if (res < 0) { - if (errno == EINTR) { - handle_signals (); - } else { - fatal ("Select failed: %s", strerror (errno)); - } - } - return res; + if (timeout) ms = timeout->tv_sec*1000 + (timeout->tv_usec+999)/1000; + return cw_wait_input (ms); } static int @@ -164,19 +148,9 @@ drain_input (void) /* Discard all data from the input queue. */ { - char buffer [16]; - int oldflags; - - oldflags = fcntl (0, F_GETFL, 0); - if (oldflags < 0) { - fatal ("Cannot get file status flags (%s)", strerror (errno)); - } - fcntl (0, F_SETFL, oldflags|O_NONBLOCK); - while (read (0, buffer, 16) == 16) - ; - fcntl (0, F_SETFL, oldflags); + flushinp (); } - + void clock_reset (void) /* Adjust the clock to make 0 the current time. */ --- a/terminal.c +++ b/terminal.c @@ -46,6 +46,7 @@ int res; assert (! term_mode_valid); + return; /* fredygames.com: no tty */ if ( ! isatty (0) ) return; if (mesg_n_flag) { @@ -86,6 +87,7 @@ #endif int res; + return; /* fredygames.com: no tty */ #if HAVE_TERMIOS_H if (attributes_changed) { res = tcgetattr (0, &settings);