home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 1
/
GoldFishApril1994_CD1.img
/
d1xx
/
d149
/
less
/
src
/
ttyin.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-06-15
|
902b
|
59 lines
/*
* Routines dealing with getting input from the keyboard (i.e. from the user).
*/
#include "less.h"
/*
* The boolean "reading" is set true or false according to whether
* we are currently reading from the keyboard.
* This information is used by the signal handling stuff in signal.c.
* {{ There are probably some race conditions here
* involving the variable "reading". }}
*/
public int reading;
#ifdef AMIGA
extern struct FileHandle *tty;
#else
static int tty;
#endif
/*
* Open keyboard for input.
* (Just use file descriptor 2.)
*/
public void
open_getchr()
{
#ifdef AMIGA
ttopen();
#else
tty = 2;
#endif
}
/*
* Get a character from the keyboard.
*/
public int
getchr()
{
char c;
int result;
reading = 1;
do
{
flush();
#ifdef AMIGA
result = Read(tty, &c, 1L);
#else
result = read(tty, &c, 1);
#endif
} while (result != 1);
reading = 0;
return (c & 0177);
}