Path: utzoo!mnetor!tmsoft!torsqnt!hybrid!scifi!bywater!uunet!bria!mike Newsgroups: comp.unix.programmer Subject: Re: raw mode vs cooked mode Message-ID: <482@bria> Date: 24 Feb 91 19:25:28 GMT References: <505sis-c@massey.ac.nz> Reply-To: uunet!bria!mike Organization: MGI Group International, Los Angeles, CA Lines: 35 Followup-To: Keywords: In an article, A.J.Rasiah@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? Brought to you by Super Global Mega Corp .com