#include #include void func_item_40() { printw( "test\n" ); refresh(); getch(); } item_str_t items_menu[] = { { "Item 1", NULL , NULL }, { "Item 2", "2" , NULL }, { "Item 3", "3" , NULL }, { "Item 4", "4" , NULL }, { "Item 5", "5" , NULL }, { "Item 6", "6" , NULL }, { "Item 7", "7" , NULL }, { "Item 8", "8" , NULL }, { "Item 9", "9" , NULL }, { "Item 10", "10" , NULL }, { "Item 11", "11" , NULL }, { "Item 12", "12" , NULL }, { "Item 13", "13" , NULL }, { "Item 14", "14" , NULL }, { "Item 15", "15" , NULL }, { "Item 16", "16" , NULL }, { "Item 17", "17" , NULL }, { "Item 18", "18" , NULL }, { "Item 19", "19" , NULL }, { "Item 20", "20" , NULL }, { "Item 21", "21" , NULL }, { "Item 22", "22" , NULL }, { "Item 23", "23" , NULL }, { "Item 24", "24" , NULL }, { "Item 25", "25" , NULL }, { "Item 26", "26" , NULL }, { "Item 27", "27" , NULL }, { "Item 28", "28" , NULL }, { "Item 29", "29" , NULL }, { "Item 30", "30" , NULL }, { "Item 31", "31" , NULL }, { "Item 32", "32" , NULL }, { "Item 33", "33" , NULL }, { "Item 34", "34" , NULL }, { "Item 35", "35" , NULL }, { "Item 36", "36" , NULL }, { "Item 37", "37" , NULL }, { "Item 38", NULL , NULL }, { "Item 39", NULL , NULL }, { "Item 40", NULL , func_item_40 }, { NULL, NULL, NULL } }; int main( int argc, char *argv[] ) { int c, menu_size, stop=0; menu_t *menu; ITEM *ci; WINDOW *w_menu; void (*f)(void); init_curses(); init_pair( 1, COLOR_RED, COLOR_BLACK ); init_pair( 2, COLOR_BLUE, COLOR_WHITE ); init_pair( 3, COLOR_GREEN, COLOR_WHITE ); menu = create_menu( items_menu, 5, 5, 20, 5, 1, 2, 3 ); item_opts_off( menu_items( menu->menu )[ 2 ], O_SELECTABLE ); post_menu( menu->menu ); wrefresh( menu->win ); menu_size = item_count( menu->menu ); while ( ! stop ) { c = wgetch( menu->win ); ci = current_item( menu->menu ); switch ( c ) { case 13: f = item_userptr( ci ); stop = 1; break; case 'q': stop = 1; break; case KEY_DOWN: if ( item_index( ci ) == menu_size - 1 ) c = REQ_FIRST_ITEM; else c = REQ_DOWN_ITEM; break; case KEY_UP: if ( item_index( ci ) == 0 ) c = REQ_LAST_ITEM; else c = REQ_UP_ITEM; break; case KEY_LEFT: c = -1; touchwin( stdscr ); refresh(); mvwin( menu->win, menu->y, menu->x-- ); break; case KEY_RIGHT: c = -1; touchwin( stdscr ); refresh(); mvwin( menu->win, menu->y, menu->x++ ); break; case KEY_HOME: c = REQ_FIRST_ITEM; break; case KEY_END: c = REQ_LAST_ITEM; break; case KEY_NPAGE: c = REQ_SCR_DPAGE; break; case KEY_PPAGE: c = REQ_SCR_UPAGE; break; } if ( c > 0 ) menu_driver( menu->menu, c ); wrefresh( menu->win ); } unpost_menu( menu->menu ); destroy_menu( menu ); refresh(); if ( f ) f(); quit_curses(); return 0; } /* author: Gustavo Sverzut Barbieri (http://www.gustavobarbieri.com.br) */