🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.programmer
1 messages
1 total messages Started by afsidbb Wed, 28 Nov 1990 17:02
Curses --- Key_f(n)
#1293
Author: afsidbb
Date: Wed, 28 Nov 1990 17:02
61 lines
1822 bytes
   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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads