Function keys and rxvt term with ncurses/curses

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
wibble
Posts: 76
Joined: Thu 11 Jul 2013, 03:48

Function keys and rxvt term with ncurses/curses

#1 Post by wibble »

So I am trying to cobble togeather my menu system and I figured - ncurses/curses can do everything I want (and more).

But I cannot get the function keys to respond.

Code: Select all

#include <ncurses.h>

int main()
{	int ch;

	initscr();			/* Start curses mode 		*/
	raw();				/* Line buffering disabled	*/
	keypad(stdscr, TRUE);		/* We get F1, F2 etc..		*/
	noecho();			/* Don't echo() while we do getch */

    	printw("Type any character to see it in bold\n");
	ch = getch();			/* If raw() hadn't been called
					 * we have to press enter before it
					 * gets to the program 		*/
	if(ch == KEY_F(1))		/* Without keypad enabled this will */
		printw("F1 Key pressed");/*  not get to us either	*/
					/* Without noecho() some ugly escape
					 * charachters might have been printed
					 * on screen			*/
	else
	{	printw("The pressed key is ");
		attron(A_BOLD);
		printw("%c", ch);
		attroff(A_BOLD);
	}
	refresh();			/* Print it on to the real screen */
    	getch();			/* Wait for user input */
	endwin();			/* End curses mode		  */

	return 0;
}
What I don't understand is

keypad(stdscr, TRUE);

should enable the reading of function keys but its not working...

any ideas? :?

Post Reply