Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!ames!pasteur!ucbvax!ulysses!kpv From: kpv@ulysses.homer.nj.att.com (Phong Vo[eww]) Newsgroups: comp.unix.wizards Subject: Re: How can I read keyboard without stopping Summary: latest curses Keywords: curses keyboard Message-ID: <10510@ulysses.homer.nj.att.com> Date: 15 Aug 88 13:20:11 GMT References: <813@ms3.UUCP> <1246@mcgill-vision.UUCP> Organization: AT&T Bell Laboratories, Murray Hill Lines: 21 In article <1246@mcgill-vision.UUCP>, mouse@mcgill-vision.UUCP (der Mouse) writes: > In article <813@ms3.UUCP>, isns02@ms3.UUCP (Harris Reavin) writes: > > I would like to know if it is possible to get input data from the > > keyboard while my program is constantly looping and displaying output > > to the screen. The input comes from a call to "popen()". > > > I know of at least four ways to do this (read without jamming the whole > process), of varying degrees of portability and functionality. ...four different ways described ... Functionality such as this is required frequently enough and its implementation is reasonably hard for ensuring portability across different UNIX flavors that I think it ought to be a part of a standard package such as curses. In a version of curses that I wrote a number of years back, there is a function wtimeout(WINDOW *win,int delay) which let users define a delay in miniseconds for getting keyboard inputs. Delay < 0 means blocking on reads, delay == 0 means no blocking, and so on. This can be implemented nicely with select(). On systems without select() or an equivalent function, it can be simulated with a hack using fcntl() and times(). This curses is now distributed with a version of system V. Phong Vo, AT&T Bell Labs, ulysses!kpv