Xref: utzoo comp.os.vms:38204 comp.sys.dec:5577 comp.unix.ultrix:6933 Newsgroups: comp.os.vms,comp.sys.dec,comp.unix.ultrix Path: utzoo!utgpu!watserv1!watdragon!kcwellsch From: kcwellsch@watdragon.waterloo.edu (Ken Wellsch) Subject: Re: Cursor key input in curses ? Message-ID: <1991Apr21.015251.6148@watdragon.waterloo.edu> Organization: University of Waterloo References: <1991Apr20.160134.1514@urz.unibas.ch> Date: Sun, 21 Apr 1991 01:52:51 GMT Lines: 29 > 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.