/** * Fill in menu with CDROM links based on real windows drives */ static void initmenu(void) { int c; HMENU m; char s[32]; int item; /* Locate the Settings menu */ item = menu_search(menu, "&Settings"); if (item == -1) { fprintf(stderr, "Settings menu not found\n"); exit(EXIT_FAILURE); } m = GetSubMenu(menu, item); /* Locate the CD-ROM menu */ item = menu_search(m, "&CD-ROM"); if (item == -1) { fprintf(stderr, "CD-ROM menu not found\n"); exit(EXIT_FAILURE); } m = GetSubMenu(m, item); /* Loop through each Windows drive letter and test to see if it's a CDROM */ for (c='A';c<='Z';c++) { sprintf(s,"%c:\\",c); if (GetDriveType(s)==DRIVE_CDROM) { sprintf(s, "Host CD/DVD Drive (%c:)", c); AppendMenu(m,MF_STRING,IDM_CDROM_REAL+c,s); } } }
void search() /* This function will search a record by code, name or price */ { unsigned int code; char name[50]; unsigned long long price; int index=0; clrscr(); puts("\t\t\t Product Search \n\n\n"); switch(menu_search()) { case 1: // Search by code clrscr(); puts("Enter Code to search: "); scanf("%u",&code); puts("Code \t\t Name \t\t Price \n"); index=getIndexByCode(code); if(index!=false) printf("%u \t\t %s \t\t %llu \n",arrMain[index].code,arrMain[index].name,arrMain[index].price); else puts("Any products with this code not found..."); break; case 2: // Search by name clrscr(); puts("Enter Name to search: "); scanf("%s",name); puts("Code \t\t Name \t\t Price \n"); index=getIndexByName(name); if(index!=false) printf("%u \t\t %s \t\t %llu \n",arrMain[index].code,arrMain[index].name,arrMain[index].price); else puts("Any products with this name not found..."); break; case 3:// Search by price clrscr(); puts("Enter Price to search: "); scanf("%llu",&price); puts("Code \t\t Name \t\t Price \n"); index=getIndexByPrice(price); if(index!=false) printf("%u \t\t %s \t\t %llu \n",arrMain[index].code,arrMain[index].name,arrMain[index].price); else puts("Any products with this price not found..."); break; case 4: default: break; } getch(); }
char user_input(char menu[4]) { int in,y = menu_search(menu); in = getch(); if( in == 87 || in == 119 ) { if( y > 0 ) { menu[y] = 'x'; menu[y - 1] = '+'; } } else if( in == 83 || in == 115 ) { if(y < 3) { menu[y] = 'x'; menu[y + 1] = '+'; } } else if( in == 81 || in == 113) { exit(-1); } else if( in == 13 ) { if( y == 0 ) { /*start game*/ } else if ( y == 1 ) { option(); } else if ( y == 2 ) { about(); } else if ( y == 3 ) { exit(-1); } } }
char print_menu(char menu[4]) { int y; y = menu_search(menu); printf("\n\n"); Welcome(); printf("\n\n"); if(y == 0) { printf("\t%c[ START GAME ]\n\n",16); } else { printf("\tStart Game\n\n"); } if( y == 1) { printf("\t%c[ OPTION ]\n\n",16); } else { printf("\tOption\n\n"); } if( y == 2) { printf("\t%c[ ABOUT ]\n\n",16); } else { printf("\tAbout\n\n"); } if( y == 3) { printf("\t%c[ EXIT ]\n\n",16); } else { printf("\tExit\n\n"); } printf("\n\t\t\t\t\t\tPress W and S to navigate.\n\n\t\t\t\t\t\tPress Enter to Select.\n"); }
int mutt_menuLoop (MUTTMENU * menu) { int i = OP_NULL; FOREVER { if (option (OPTMENUCALLER)) { unset_option (OPTMENUCALLER); return OP_NULL; } mutt_curs_set (0); #ifdef USE_IMAP imap_keepalive (); #endif if (menu_redraw (menu) == OP_REDRAW) return OP_REDRAW; menu->oldcurrent = menu->current; if (option (OPTARROWCURSOR)) move (menu->current - menu->top + menu->offset, SW + 2); else if (option (OPTBRAILLEFRIENDLY)) move (menu->current - menu->top + menu->offset, SW); else move (menu->current - menu->top + menu->offset, COLS - 1); mutt_refresh (); /* try to catch dialog keys before ops */ if (menu->dialog && menu_dialog_dokey (menu, &i) == 0) return i; i = km_dokey (menu->menu); if (i == OP_TAG_PREFIX || i == OP_TAG_PREFIX_COND) { if (menu->tagged) { mvaddstr (LINES - 1, 0, "Tag-"); clrtoeol (); i = km_dokey (menu->menu); menu->tagprefix = 1; CLEARLINE (LINES - 1); } else if (i == OP_TAG_PREFIX) { mutt_error _("No tagged entries."); i = -1; } else { /* None tagged, OP_TAG_PREFIX_COND */ event_t tmp; while (UngetCount > 0) { tmp = mutt_getch (); if (tmp.op == OP_END_COND) break; } mutt_message _("Nothing to do."); i = -1; } } else if (menu->tagged && option (OPTAUTOTAG)) menu->tagprefix = 1; else menu->tagprefix = 0; mutt_curs_set (1); #if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM) if (SigWinch) { mutt_resize_screen (); menu->redraw = REDRAW_FULL; SigWinch = 0; clearok (stdscr, TRUE); /*force complete redraw */ } #endif if (i == -1) continue; if (!menu->dialog) mutt_clear_error (); /* Convert menubar movement to scrolling */ if (menu->dialog) i = menu_dialog_translate_op (i); switch (i) { case OP_NEXT_ENTRY: menu_next_entry (menu); break; case OP_PREV_ENTRY: menu_prev_entry (menu); break; case OP_HALF_DOWN: menu_half_down (menu); break; case OP_HALF_UP: menu_half_up (menu); break; case OP_NEXT_PAGE: menu_next_page (menu); break; case OP_PREV_PAGE: menu_prev_page (menu); break; case OP_NEXT_LINE: menu_next_line (menu); break; case OP_PREV_LINE: menu_prev_line (menu); break; case OP_FIRST_ENTRY: menu_first_entry (menu); break; case OP_LAST_ENTRY: menu_last_entry (menu); break; case OP_TOP_PAGE: menu_top_page (menu); break; case OP_MIDDLE_PAGE: menu_middle_page (menu); break; case OP_BOTTOM_PAGE: menu_bottom_page (menu); break; case OP_CURRENT_TOP: menu_current_top (menu); break; case OP_CURRENT_MIDDLE: menu_current_middle (menu); break; case OP_CURRENT_BOTTOM: menu_current_bottom (menu); break; case OP_SEARCH: case OP_SEARCH_REVERSE: case OP_SEARCH_NEXT: case OP_SEARCH_OPPOSITE: if (menu->search && !menu->dialog) { /* Searching dialogs won't work */ menu->oldcurrent = menu->current; if ((menu->current = menu_search (menu, i)) != -1) menu->redraw = REDRAW_MOTION; else menu->current = menu->oldcurrent; } else mutt_error _("Search is not implemented for this menu."); break; case OP_JUMP: if (menu->dialog) mutt_error (_("Jumping is not implemented for dialogs.")); else menu_jump (menu); break; case OP_ENTER_COMMAND: CurrentMenu = menu->menu; mutt_enter_command (); if (option (OPTFORCEREDRAWINDEX)) { menu->redraw = REDRAW_FULL; unset_option (OPTFORCEREDRAWINDEX); unset_option (OPTFORCEREDRAWPAGER); } break; case OP_TAG: if (menu->tag && !menu->dialog) { if (menu->tagprefix && !option (OPTAUTOTAG)) { for (i = 0; i < menu->max; i++) menu->tagged += menu->tag (menu, i, 0); menu->redraw = REDRAW_INDEX; } else if (menu->max) { int i = menu->tag (menu, menu->current, -1); menu->tagged += i; if (i && option (OPTRESOLVE) && menu->current < menu->max - 1) { menu->current++; menu->redraw = REDRAW_MOTION_RESYNCH; } else menu->redraw = REDRAW_CURRENT; } else mutt_error _("No entries."); } else mutt_error _("Tagging is not supported."); break; case OP_SHELL_ESCAPE: mutt_shell_escape (); MAYBE_REDRAW (menu->redraw); break; case OP_WHAT_KEY: mutt_what_key (); break; case OP_REBUILD_CACHE: mx_rebuild_cache (); break; case OP_REDRAW: clearok (stdscr, TRUE); menu->redraw = REDRAW_FULL; break; case OP_HELP: mutt_help (menu->menu); menu->redraw = REDRAW_FULL; break; case OP_NULL: km_error_key (menu->menu); break; case OP_END_COND: break; default: return (i); } } /* not reached */ }
void initialize_interface() { warehouse *warehouses = NULL; FILE *database = NULL; boolean loop = TRUE; int option; int db_type; database = get_file(DBNAME, "rb"); db_type = identify(database); //db_type = 2; if(db_type == 0) { warehouses = initialize(database); } else if(db_type == 1) { warehouses = initialize_legacy(database); } else if(db_type == 2) { warehouses = initialize_random(); } if(database != NULL) { fclose(database); } printf("Digite o numero da opcao a esquerda para navegar entre menus.\n\n"); while(loop) { show_menu(1); int_input(&option, 3); switch(option) { case 1: { menu_search(warehouses); break; } case 2: { menu_insert(warehouses); break; } case 3: { menu_file(warehouses); break; } case 4: { menu_warehouse(warehouses); break; } case 9: { loop = FALSE; break; } default: { printf("Essa opcao nao existe.\n\n"); break; } } } show_sold_products(warehouses, TRUE); shutdown(get_file(DBNAME, "wb"), warehouses, TRUE); }