Cursor key input in curses ?

Ken Wellsch kcwellsch at watdragon.waterloo.edu
Sun Apr 21 11:52:51 AEST 1991


> Problem: 
> How do you input cursor keys in curses ? 
>
> Please: 
> I would be grateful if someone in netland could explain me what goes wrong
> on the vt100 emulation side or even get me a piece of code which reads
> in a cursor key correctly.

I'll put my two-bits in on this one.  Unlike VMS which I believe has a
strong dislike for any terminal that is not DEC (e.g. VT100 etc.), a
package like curses has the horrid task of trying to understand numerous
terminal types (thousands of old and new terminals - actually "termcap"
describes them, while curses tries to provide a windowing environment
for a regular tty).

Now if you receive the three characters that a VT100 arrow key sends, or
if your application (say "emacs") understands that set of key strokes to
mean something else (unlikely but possible), how do you decide which it
is?  The three characters or "an arrow key was hit?"

The few screen oriented programs that I have studied that attempt to handle
this use the "select" system call as I recall to do very short waits on
input (say 50-100 mSec) and if another character is received that continues
an arrow key-stroke then we continue to guess it is an arrow key and
not separate key strokes.  If there is sufficent lag, I think one tended
to assume it was not an arrow key.

I took a very quick look at 4.3BSD's curses source and didn't see anything
attempting this sort of (admittedly painful) approach.



More information about the Comp.unix.ultrix mailing list