| 282 | } |
| 283 | |
| 284 | int wmenuSelect_ext(WINDOW *window, const int yinfo, const int y, const int x, const struct MenuItem *menuItems, const unsigned int itemLength, const char *available, const int menuType, unsigned int *current, int *real_key) |
| 285 | { |
| 286 | unsigned int i; |
| 287 | unsigned int ylast = y; |
| 288 | int key = 0; |
| 289 | |
| 290 | /* |
| 291 | if( ( menuType & ( MENU_HORIZ | MENU_VERT ) )==0 ) |
| 292 | { |
| 293 | wprintw(window,"Menu without direction. Defaulting horizontal."); |
| 294 | menuType |= MENU_HORIZ; |
| 295 | } |
| 296 | */ |
| 297 | /* Warning: current may be out of bound, not checked */ |
| 298 | /* Make sure that the current is one of the available items */ |
| 299 | while(strchr(available, menuItems[*current].key)==NULL) |
| 300 | { |
| 301 | (*current)++ ; |
| 302 | if( menuItems[*current].key==0 ) |
| 303 | { |
| 304 | *current = 0; |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | /* Repeat until allowable choice has been made */ |
| 309 | while( key==0 ) |
| 310 | { |
| 311 | /* Display the menu */ |
| 312 | ylast = wmenuUpdate( window, yinfo, y, x, menuItems, itemLength, available, |
| 313 | menuType, *current ); |
| 314 | wrefresh(window); |
| 315 | /* Don't put wgetch after the following wclrtoeol */ |
| 316 | key = wgetch(window); |
| 317 | if(real_key!=NULL) |
| 318 | *real_key=key; |
| 319 | |
| 320 | /* Clear out all prompts and such */ |
| 321 | for( i = y; i < ylast; i ++ ) |
| 322 | { |
| 323 | wmove(window, i, x ); |
| 324 | wclrtoeol(window); |
| 325 | } |
| 326 | wmove(window, yinfo, 0 ); |
| 327 | wclrtoeol(window); |
| 328 | if(strchr(available, key)==NULL) |
| 329 | { |
| 330 | if(key=='2') |
| 331 | key=KEY_DOWN; |
| 332 | else if(key=='4') |
| 333 | key=KEY_LEFT; |
| 334 | else if(key=='5') |
| 335 | key=KEY_ENTER; |
| 336 | else if(key=='6') |
| 337 | key=KEY_RIGHT; |
| 338 | else if(key=='8') |
| 339 | key=KEY_UP; |
| 340 | } |
| 341 | /* Cursor keys */ |
no test coverage detected