curses fcn. key problem...

Tony Rems rembo at unisoft.UUCP
Mon Dec 3 23:02:42 AEST 1990


Sender: 
Reply-To: rembo at unisoft.UUCP (Tony Rems)
Followup-To: 
Distribution: 
Organization: UniSoft Corporation -- UNIX R Us.
Keywords: 

I saved this off and couldn't get the e-mail address path to go
through.  So, this is in response to Doug Bender's curses question:

>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()
>   {

Well, first of all the slk_init() routine takes an argument, so
your fcn. keys may not be getting initialized correctly.  The 
argument is the format (an int) that you are going to use for
your fcn. keys.
>	  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:

Second:
	You have the arguments here wrong.  You don't want the
	stdscr in here.  This should just be: mvaddstr(1,1,"Key unrecognized");
>		  mvaddstr(stdscr,1,1," Key unrecognized");
>		  break;
>	  }
>	  wrefresh(stdscr);
>  }
>

Besides that, you're on the right track.  I made the corrections and
compiled your program (I had to stub the missing routines), and it
ran fine (I love when that happens :-) ).  

If this doesn't fix your problem send me some mail with the problems
to rembo at unisoft.com.

-Tony



More information about the Comp.unix.programmer mailing list