Súbor: [Platon] / scripts / ep / tbuffer-rajo / tbuffer.c (stiahnutie)
Revízia 1.2, Mon Feb 4 15:04:52 2002 UTC (22 years, 2 months ago) by host8
Zmeny od 1.1: +4 -1
[lines]
Added '$Id/Log: $' keyword substitution for simple identification version of file.
|
/*
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 <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <curses.h>
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("<timeout>\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;
}
Platon Group <platon@platon.sk> http://platon.sk/
|