Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!mordor!sri-spam!ames!nrl-cmf!cmcl2!brl-adm!adm!rbj@icst-cmr.arpa From: rbj@icst-cmr.arpa (Root Boy Jim) Newsgroups: comp.unix.questions Subject: a question about using curses lib Message-ID: <12009@brl-adm.ARPA> Date: 26 Feb 88 22:40:51 GMT Sender: news@brl-adm.ARPA Lines: 41 From: Xinhua Wu 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@cse.usc.edu (Root Boy) Jim Cottrell National Bureau of Standards Flamer's Hotline: (301) 975-5688 Eisenhower!! Your mimeograph machine upsets my stomach!!