Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!VAX1.CC.UAKRON.EDU!mcs.kent.edu!usenet.ins.cwru.edu!ncoast!allbery From: allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) Newsgroups: comp.unix.programmer Subject: Re: How do you read the arrow keys? Message-ID: <1991Jan5.025602.21068@NCoast.ORG> Date: 5 Jan 91 02:56:02 GMT References: <4927:Dec2920:17:4790@kramden.acf.nyu.edu> <1991Jan1.035656.27394@NCoast.ORG> <1991Jan3.191845.4767@jwt.UUCP> Reply-To: allbery@ncoast.ORG (Brandon S. Allbery KB8JRR) Followup-To: comp.unix.programmer Organization: North Coast Computer Resources (ncoast) Lines: 47 As quoted from <1991Jan3.191845.4767@jwt.UUCP> by john@jwt.UUCP (John Temples): +--------------- | In article <1991Jan1.035656.27394@NCoast.ORG> allbery@ncoast.ORG (Brandon S. Allbery KB8JRR) writes: | >Termio(s) doesn't really have a "raw" mode; it has a "packet" mode. The most | >common use is with a packet size of 1 and a timeout of 1 (which is treated as | >"no timeout"). | | Did you mean "timeout of 0" here? Timeout of 1 activates a .1 second | timeout on systems I've used -- although VTIME seems to have no effect when | VMIN == 1. My playing with termio shows that VTIME only takes effect +--------------- Correct as to VMIN=1 disabling timeout: the packet timer starts *after the first character is received*, so it can block waiting for a packet. That's why I specified that it is a packet driver, not a general read with a timeout. I have seen and used a number of implementations; at least two use VTIME=0 to cause the driver to essentially become non-blocking, at least if VMIN=1. Weird, no? +--------------- | between characters of multi-character reads. So how does curses | halfdelay() mode work? This lets a single-character read time out in | as little as .1 second. Does the fact that halfdelay() seems to be | broken on many systems imply that there's something more to it than | just a termio call? +--------------- I strongly suspect that halfdelay breaks because of the common misconception that VTIME makes the tty driver do general reads with timeouts, when in fact it merely times out reads of packets after the first character is received. The proper way to do halfdelay() is to make the tty driver select()able or poll()able and use that with a timeout. (Most 386/486 SVR3.2's treat select() as poll() with a different calling sequence, so there's no difference in the way they work.) ++Brandon (P.S. I also suspect that the packet driver mode of the termio driver was intended as a more general alternative to the UUCP packet device driver in some V7's --- mainly because I once checked the stty settings on a port under System III when there was a uucico talking on it, and VMIN was set to the size of a UUCP G protocol packet....) -- Me: Brandon S. Allbery VHF/UHF: KB8JRR on 220, 2m, 440 Internet: allbery@NCoast.ORG Packet: KB8JRR @ WA8BXN America OnLine: KB8JRR AMPR: KB8JRR.AmPR.ORG [44.70.4.88] uunet!usenet.ins.cwru.edu!ncoast!allbery Delphi: ALLBERY