Problems w/curses and the arrow keys...

randy frank randy at tessa.iaf.uiowa.edu
Thu Feb 21 09:40:47 AEST 1991


	I'm running A/UX 2.0, trying to port some curses code which runs
fine on Silicon Graphics boxes.  I've got some input problems...
	I'm using curses in raw mode with nodelay while trying to read the
arrow keys.  The arrow keys are handled but are not returned by getch()
until the next character is pressed (I'm guessing that curses is checking
for some other multi-character code which starts with the KEY_XXX codes? or
just making sure the sequence is correct.).  Anyway this is not the same
as several other curses libs do it.  Normally this code frag would display
the hex equiv of the arrow keys when pressed.  Instead, under A/UX 2.0, it
will not return KEY_XXX until another keystroke is obtained at which time
it returns the KEY_XXX followed immediately by the other keystroke.  My 
question: Is this a bug? or am I calling it wrong? or did I miss some 
initialization?  
	A further question relates to the function keys on the extended
keyboard.  How can these be intercepted?  

Here's the test program I was using:    
#include <stdio.h>
#include <curses.h>

main()
{
	int time;
	int mych;

	initscr();
	noecho();
	nonl();
	nodelay(stdscr,TRUE);
	raw();
	keypad(stdscr,TRUE);

	move(0,0);
	printw("Working...\n");
	refresh();
	time = 0;

top:
	mych = getch();
	if (mych == ERR)  {
		time = time + 1;
		goto top;
	}
	move(10,10);
	printw("Char: %.4X at %d\n",mych,time);
	refresh();
	time = 0;
	if (mych == KEY_UP) beep();
	if (mych != KEY_DOWN) goto top;

	noraw();
	nodelay(stdscr,FALSE);
	endwin();
	exit(0);
}

Any help at all would be appreciated...

Thanks,
--
rjf.
Randy Frank, Engineer                       |  (319) 335-6712       
University of Iowa, Image Analysis Facility |  73 EMRB              
randy at tessa.iaf.uiowa.edu                   |  Iowa City, IA 52242  



More information about the Comp.unix.aux mailing list