/* GCC -lncurses * * $Log: tbuffer.c,v $ * Revision 1.2 2002/02/04 15:04:52 host8 * Added '$Id/Log: $' keyword substitution for simple identification version of file. * */ #include #include #include #include #include #include #include int main(int argc, char *argv[]) { int press_enter, c; fd_set fds; struct timeval tv; tv.tv_sec = 1; tv.tv_usec = 1000; initscr(); cbreak(); scrollok(stdscr, TRUE); while (1) { usleep(500); FD_ZERO(&fds); FD_SET(0, &fds); switch (select(1, &fds, NULL, NULL, &tv)) { case -1: exit(errno); break; case 0: // timeout printf("\n"); press_enter = 1; break; default: if (FD_ISSET(0, &fds)) { c=getch(); if (c == '\n' || c == '\r') { press_enter = 0; } else { press_enter = 1; } } break; } } return 0; }