Distinquishing escape key from arrow and function keys
Brain in Neutral
bin at primate.wisc.edu
Thu Apr 11 03:44:24 AEST 1991
I have a program where the escape key is significant, but I also
want to be able to use the arrow and functions keys (which typically also
begin with escape). I would be interested in how any of you solve this
problem.
My solution (if you can call it that): when an escape character is seen,
keep reading until
(i) characters read entirely match some special key. return some
value (I use values >= 0200) to indicate such.
(ii) characters read fail to match any special key character sequence.
return escape to caller and save any other characters read
to a pushback queue.
(iii) timeout after brief wait and neither (i) nor (ii) obtain.
return escape to caller and save any other characters read
to a pushback queue.
On a BSD system, select() does the timeout nicely. I'm not so familiar
with System V. Do you use the MIN and TIME special control character
values in the termio.c_cc[] array? What about under POSIX?
--
Paul DuBois "The 'C' shell usually doesn't
dubois at primate.wisc.edu have job control." -- LAN TIMES
More information about the Comp.unix.programmer
mailing list