Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Saturday, November 14, 2026

File: [Platon] / scripts / ep / tbuffer-rajo / tbuffer.c (download)

Revision 1.2, Mon Feb 4 15:04:52 2002 UTC (24 years, 9 months ago) by host8


Changes since 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.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top