termcap or curses help. HPux and solaris function keys

termcap or curses help. HPux and solaris function keys

Post by Klaus Schillin » Sat, 05 Sep 1998 04:00:00

> I need a quick test for reading the function keys of an emulator running on a
> PC TERM is either vt340 or wyse60 or some other vt or wyse variant. I need
> see if the function key is being passed in F1-F20 at least F1-F24 ideally.
> Can someone point me to some code examples of reading function keys in C,
> Perl, or anything so that I can test if the problem lies in the operating
> system a third party software. Thanks in advance. Ray Kinney

#include <curses.h>

int key;

int main (void)
initscr ();
atexit (endwin);
cbreak ();
noecho ();
keypad (stdscr, TRUE);

while (1)
clear ();
key = getch ();
if (key == 4) exit (EXIT_SUCCESS);
mvaddstr (0, 0, keyname (key));
refresh ();


The endless loop will wait for a key to be hit, and then display the keyname
on the screen top. ctrl-d will terminate the endless loop (and the whole

Klaus Schilling


1. Function Keys and CURSES/TERMCAP ?

Subj.:  Use Function Keys in Curses Program

Hello World!

At first the hard/software platform I use:

Apollo Domain DN4500
Domain/OS kernel(7), revision 10.3, or
UNIX SYS5.3, or

Now the problem:

I want to write a simple user interface prg for getting some data. It should
use full screen mode and be controlled by function keys. If I use CURSES
function 'getch()' to read Function Key codes I do not get the right values
(that are defined in "curses.h") for some of them. Although my terminfo file
defines all function key codes for my terminal emulation (vt132) the program
does not get the correct key codes.

It seems to me as if the display manager defined key commands are still in
effect and not replaced by the terminals key capabilities.

How can I reprogram the terminfo database? How can I force CURSES/TERMCAP to
return the correct values? How can I program the function keys from a CURSES
program at all? What TERMCAP function must I use to redefine other keys? Have I
to use a terminal emulator at all? Should'nt CURSES emulate a terminal by itself
(defined in ENV) or if I use 'setupterm' that terminal that I want?

What, How ... ?

The documentation is not very helpful, so I have to ask the world.

Any help is appreciated.



Armin Montigny,   Motorola Taunusstein,  Germany


2. updatedb, periodic HD access

3. *NEED* VT520 Emulation Software BAD!

4. Olwm - need cmdtool termcap and function key mappings

5. BETA-RedHat 5.9/Starbuck: Install Hints

6. Function Keys on HPUX 10.2

7. Is a disk quota possible?

8. Function keys in (n)curses

9. Can't reliably read function keys with curses

10. Get Function Keys w/o using curses?

11. function keys in curses

12. Function keys / curses / xterm