I started using ncurses by creating a test program so I could map what input I could expect from the function and implement a control using function pointers. However, after having the data I needed, the program having the before mentioned control structure was not responding as expected. The first issue I noticed was that when using the arrow keys, the program displays text after each press. The second problem I noticed was that the values being shown in my own debug printouts indicate that the values for getch are different in the second program than the first.
Both programs have the same init functions with the same args in the same order, and are on the same machine, so there should be no reason why the output and behaviour should be different.
Does anyone know why this might be happening?
EDIT: This system is running on Linux Mint 16 x86_64 architecture. I compile with gcc using eclipse. libncurses is the only library included in the projects.
This is the code for the test:
int main()
{
int i = 0;
initscr();
raw();
keypad( stdscr, TRUE );
noecho();
while( 1 ) // need to catch all available keys
{
i = getch();
mvprintw( 0, 0, "%d ", i );
}
getch();
endwin();
return 0;
}
The output from this, when pressing the up key is: "259"
The other program which has the same code split among different files gives this output: "got 27 OA" and adds "^[OA" every time the up key is pressed again as if its echoing when it was configured to not.
I created another test program, but my simplifications have yet to reproduce the behaviour.
I removed portions of the code that the inclusion of this function which is planned on being called when pressing enter is causing/uncovering the change. Right now, the function is not associated with input, but still seems to be affecting the program's interpretation of the input.
void select( int n, Point *p )
{
if( 16 == p->Y )
phase = SETUP;
else if( 18 == p->Y )
;
else
phase = QUIT;
}