🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #1317

Re: curses fcn. key problem...

#1317
From: Tony Rems
Date: Mon, 03 Dec 1990 12:02
69 lines
2061 bytes
Sender: 
Reply-To: rembo@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@unisoft.com.

-Tony
Technical Details
Message-ID: <3266@unisoft.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!unisoft!rembo

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!unisoft!rembo
From: rembo@unisoft.UUCP (Tony Rems)
Newsgroups: comp.unix.programmer
Subject: Re: curses fcn. key problem...
Message-ID: <3266@unisoft.UUCP>
Date: 3 Dec 90 12:02:42 GMT
Organization: UniSoft Corporation -- UNIX R Us.
Lines: 69