a question about using curses lib

Root Boy Jim rbj at icst-cmr.arpa
Sat Feb 27 08:40:51 AEST 1988


   From: Xinhua Wu <xwu at pollux.usc.EDU>

   I'm writing a program using curses lib.  I want to use function
   keys (eg, use arrow keys to choose from a menu).  The program
   should work for different terminal types (vt100, xterm, ibmaed,
   h19, etc).

   My general question is: how can I make the program recognize a function key
   immediately after the user hits it?

Several people have mentioned that you need to use CBREAK mode, or
whatever TPC calls their version of it. I will assume you use BSD.

   I'm now using wgetch(win) to read the input (wgetstr(win, str)
   needs a newline or EOF).  The problem is that in this case the
   program needs to know in advance the code for a function key and
   how long the code is.  Since the code and the length vary for
   different terminal types (eg, the code for uparrow is \033A for
   ibmaed, \033[A for xterm and vt100 under X), the program may not
   work for new terminal types.

Curses is a great package for output, but I have heard it is somewhat
broken for input. Even if not, I don't see it handling input very well
anyway. It doesn't seem to recognize function keys either, so you'll
have to pick them out of the term{cap,info} entry anyway.

Which brings me to another point. Why bother using function keys?
Not all terminals have the same ones; some have none, altho arrow
keys do seem to be the first to appear. Try using control characters
instead. If you do decide to use function keys, the length should be
no problem. There will only be one set of `keymaps' active at a time,
the one for the current terminal type, so there should be no confusion.

   Thanks in advance for any help.

   Xinhua Wu   xwu at cse.usc.edu

	(Root Boy) Jim Cottrell	<rbj at icst-cmr.arpa>
	National Bureau of Standards
	Flamer's Hotline: (301) 975-5688
	Eisenhower!!  Your mimeograph machine upsets my stomach!!



More information about the Comp.unix.questions mailing list