Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!boutell From: boutell@freezer.it.udel.edu (Tom Boutell) Newsgroups: comp.unix.programmer Subject: Re: How can I detect waiting characters in a curses application ? Keywords: curses typeahead Message-ID: <38385@nigel.ee.udel.edu> Date: 7 Dec 90 01:18:10 GMT References: <677@ntpdvp1.UUCP> <1990Dec6.234823.2763@ux1.cso.uiuc.edu> Sender: usenet@ee.udel.edu Organization: University of Delaware -- ACIT Sun Lab Lines: 36 Nntp-Posting-Host: maplenut.it.udel.edu In article <1990Dec6.234823.2763@ux1.cso.uiuc.edu> carroll@cs.uiuc.edu (Alan M. Carroll) writes: >Try this. (test by compiling and running. Type and hit return. Works >for me on ISC 2.0.2). > >#include >#include > >int istypeahead(fd) int fd; /* file descriptor */ ... Lots of good code ... >} > >main() >{ > while (1) > { > if (istypeahead(0)) printf("Input waiting\n"); Not so good. Or rather, not so portable. I strongly suggets you do this instead: if (istypeahead(fileno(stdin))) printf("Input waiting\n"); This is very widely compatible; I've just been through this particular mill. Trust me- I know. (-: Of course, it's most sensible to save fileno(stdin) to an int and just use istypeahead(stdinfd) where stdinfd is the int in question. > else printf("No input\n"); > sleep(1); > } >} Otherwise very good stuff. -- THE TECHNOLOGY HOUSE: An idea whose time has come! My girlfriend is a pseudo- aardvark. She is quite insistent on this point. And remember- when all else fails- and no one else can help- boutell@freezer.it.udel.edu