raw mode vs cooked mode
uunet!bria!mike
uunet!bria!mike
Mon Feb 25 06:25:28 AEST 1991
In an article, A.J.Rasiah at massey.ac.nz writes:
>I would like to write a program which will get characters from the terminal
>in "raw" mode. The default is "cooked" mode. Can someone point me in the
>right direction? I am using a Sun Workstation running UNIX 4.2 BSD.
This should be in a FAQ somewhere. If your system groks termio, then
here is what you could have:
struct termio old, new;
ioctl(0,TCGETA,&old); /* save current state */
ioctl(0,TCGETA,&new); /* save current state */
new.c_lflag &= ~ICANON; /* no canonical input */
new.c_lflag &= ~ISIG; /* no signals */
new.c_cc[VMIN] = 1; /* return one character */
new.c_cc[VTIME] = 0; /* no timeout */
ioctl(0,TCSETA,&new); /* change current state */
.
.
.
ioctl(0,TCSETA,&old); /* restore previous state */
If you want to grab cursor keys, function keys, etc. then you're better
off using curses (although if you are *really* interested, I can give you
the algorithm for snagging ``special'' keys as well).
--
Michael Stefanik, MGI Inc., Los Angeles| Opinions stated are not even my own.
Title of the week: Systems Engineer | UUCP: ...!uunet!bria!mike
-------------------------------------------------------------------------------
Remember folks: If you can't flame MS-DOS, then what _can_ you flame?
More information about the Comp.unix.programmer
mailing list