Curses --- Key_f(n)

afsidbb at cidsv01.cid.aes.doe.CA afsidbb at cidsv01.cid.aes.doe.CA
Thu Nov 29 04:02:30 AEST 1990


   I'm writing a curses program and I want to make use of function keys
   for opening sub_windows etc. I've read our manuals on curses, and
   they explain everything but interpreting function keys. Here is a
   rough example of my program;

   main()
   {
	  slk_init();
	  initscr();
	  slk_set(1,"Menu",1);
	  slk_set(2,"Help",1);
	  keypad(stdscr,TRUE);
	  help=subwin(stdscr,15,60,5,10);
	  menu=subwin(stdscr,20,20,2,30);

	  cbreak();
	  draw_screen();
	  check_fkey();
	  .
	  .
	  .
	  endwin();
  }
  int check_fkey()
  {
	  int fkey;
	  fkey=mvwgetch(stdscr,1,1);
	  switch(fkey)
	  {
	  case KEY_F(1):
		  menu_screen();
		  break;
	  case KEY_F(2):
		  help_screen();
		  break;
	  default:
		  mvaddstr(stdscr,1,1," Key unrecognized");
		  break;
	  }
	  wrefresh(stdscr);
  }


  I always get 'Key unrecognized' when I run this.
  Questions:
	- Do I have to check every character I read to see if it's a
      function key, or can it trap it as a signal ?
	- Why doesn't it work ??

	I'd appreciate any suggestions/examples you can send my way.

	Thanks
		   Doug

	 
-- 
---------------------------------------------------------------------------
     " You're never alone with a schizophrenic ! " - Ian Hunter

Douglas Bender                      Canadian Meteorological Center



More information about the Comp.unix.programmer mailing list