general question: ncurses library

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Guest

general question: ncurses library

Post by Guest »

Okay, I'm wokring a bit with the ncurses library, in this case on linux, and I was having a little bit of a problem.

I have this loop:

Code: Select all

	int c = 0;
	while((c = getch()) != KEY_F(1))
	{
		switch(c){
			case KEY_DOWN:
				menu_driver(menuObj, REQ_DOWN_ITEM);
				break;
			case KEY_UP:
				menu_driver(menuObj, REQ_UP_ITEM);
				break;
			case '\n': /* enter */
				menu_driver(menuObj, REQ_TOGGLE_ITEM);
				// Cycle through the items and find which was
				// toggled
				ITEM** items = menu_items(menuObj);
				for(i=0; i < item_count(menuObj); i++){
					if( item_value( items[i] ) == TRUE ){
						// Get rid of menu, so normal output
						const char* item = item_description(items[i]);
					
						// Get rid of menu
						unpost_menu(menuObj);
						refresh();
						endwin();
						// Keyboard mapping
						keypad(stdscr, FALSE);
						
						// Call function
						callFunction( item );
						set_item_value(items[i], FALSE);
						
						// Keyboard mapping
						keypad(stdscr, FALSE);
						// Bring menu back
						initscr();
						post_menu(menuObj);
						refresh();
					
					}
				}
		}
		// refresh the menu (draw the menu again)
		refresh();
	}	
and this function:

Code: Select all

void callFunction(const char* s)
{
	printf("\n Function called is: %s\n Press any key to continue.\n", s);
	getchar();
}
When I run this, the menu comes up all fine and I can move and everything, but when I select an item, I need a way to turn the menu off since the rest of the program will be using the standard output and input.

Right now when I select an item, the function is call and nothing appears. Then when I select another one, the function comes up and prints the FIRST menu item. Then for the third, it prints the second, and etc, so its always one behind.

Any ideas??
Endar
Posts: 145
Joined: Mon Jun 14, 2004 7:59 am

Post by Endar »

The above post was me.

I would have been logged in but........damn knoppix!
"The reputation of a thousand years may be determined by the conduct of one hour."
-Japanese Proverb
Endar
Posts: 145
Joined: Mon Jun 14, 2004 7:59 am

Post by Endar »

Okay, well I have refined my problem.

I changed the second 'keypad' call to TRUE instead of FALSE, which was as it should be, and now I've found that the printing from the function 'callFunction()' is actually done after the second call to 'keypad'.

Any ideas?
"The reputation of a thousand years may be determined by the conduct of one hour."
-Japanese Proverb
Post Reply