Subject: Re: Curses and function-keys
To: Mikael Nystr?m <miny3945@comhem.se>
From: Julian Coleman <jdc@coris.org.uk>
List: netbsd-users
Date: 01/03/2006 10:38:52
> According to the manual page, one has to activate keypad(WINDOW *, TRUE) 
> to be able to map function keys. It seems like the curses libraries 
> depends on /usr/share/misc/termcap, and that not all function keys are 
> defined(?). I'm using keypad() but still have to use define_key() to 
> be able to detect for example KEY_F(*) and arrow keys. I'm 
> using NetBSD 3.0/XFree86 4.5.0 and have tested xterm, mrxvt and vt220.

That's correct.  In the curses key input initialisation [*], the key entries
from the termcap database are read in.  If the key definition for a key
isn't present in the termcap entry for a terminal type, then the code won't
recognise the key.

> How do I detect function keys correctly, and how should I do to make my 
> code work with different terminals? It's my first curses-based 
> application and I'm no terminal guru, so I believe that I'm missing 
> something vital... :-)

Using keypad(win, TRUE) and getch() is the correct way.  If some of the key
definitions are missing, then they can be added to the termcap database.

J

[*] See src/lib/libcurses/getch.c:__init_getch()

-- 
  My other computer also runs NetBSD    /        Sailing at Newbiggin
        http://www.netbsd.org/        /   http://www.newbigginsailingclub.org/