How do you read the arrow keys?

Brandon S. Allbery KB8JRR allbery at NCoast.ORG
Sat Jan 5 13:56:02 AEST 1991


As quoted from <1991Jan3.191845.4767 at jwt.UUCP> by john at jwt.UUCP (John Temples):
+---------------
| In article <1991Jan1.035656.27394 at NCoast.ORG> allbery at 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 at 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



More information about the Comp.unix.programmer mailing list