]>
diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/miscellany/less-177/ttyin.c
2 * Routines dealing with getting input from the keyboard (i.e. from the user).
16 * Open keyboard for input.
23 * Open a new handle to CON: in binary mode
24 * for unbuffered keyboard read.
26 tty
= open("CON", O_RDONLY
|O_BINARY
);
30 * If that doesn't work, use file descriptor 2,
31 * which in Unix is usually attached to the screen,
32 * but also usually lets you read from the keyboard.
34 tty
= open("/dev/tty", 0);
41 * Get a character from the keyboard.
51 result
= iread(tty
, &c
, sizeof(char));
52 if (result
== READ_INTR
)
57 * Don't call error() here,
58 * because error calls getchr!
64 * In raw read, we don't see ^C so look here for it.
70 * Various parts of the program cannot handle
71 * an input character of '\0'.
72 * If a '\0' was actually typed, convert it to '\200' here.
76 } while (result
!= 1);