这篇教程C++ wgetch函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中wgetch函数的典型用法代码示例。如果您正苦于以下问题:C++ wgetch函数的具体用法?C++ wgetch怎么用?C++ wgetch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了wgetch函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ifs_cfg//.........这里部分代码省略......... } break; case 3: wattrset(w, inputbox_attr); wrefresh(w); print_button(w, " OK ", height - 2, (width / 2) - 11, FALSE); if (strlen(d.gateway) < 1) bzero(d.gateway, sizeof(d.gateway)); k = line_edit(w, 10, 19, 23, 23, inputbox_attr, 1, d.gateway, DialogInputAttrs); if (k == KEY_DOWN) { j++; break; } else if (k == 10) { j++; break; } else if (k == 9) { j++; break; } else if (k == KEY_UP) { j--; break; } break; case 4: wattrset(w, title_attr); wrefresh(w); curs_set(0); print_button(w, " OK ", height - 2, (width / 2) - 11, TRUE); print_button(w, "Cancel", height - 2, (width / 2) + 3, FALSE); wrefresh(w); key = wgetch(w); if (key == KEY_UP) { j--; break; } else if (key == 9) { j++; break; } else if (key == KEY_DOWN) { j++; break; } else if (key == 10) { done = 1; set = 1; break; } break; case 5: wattrset(w, title_attr); wrefresh(w); curs_set(0); print_button(w, " OK ", height - 2, (width / 2) - 11, FALSE); print_button(w, "Cancel", height - 2, (width / 2) + 3, TRUE); wrefresh(w); key = wgetch(w); if (key == KEY_UP) { j = 4; break; } else if (key == KEY_DOWN) { j = 4; break; } else if (key == 9) { j = 1;
开发者ID:joshuabergeron,项目名称:ClosedBSD,代码行数:67,
示例2: dialog_confirm//.........这里部分代码省略......... height = 7; // Minimum for header and button lines height += (strlen(text) / width); // Space for the text. // Add one extra line for each newline in the text for (i=0; text[i]; i++) { if (text[i] == '/n') height++; } // Parse each line of payload looking for sdp information tofree = str = strdup((char*)options); i = 0; while ((option = strsep(&str, ",")) != NULL) { strcpy(opts[i++], option); } sng_free(tofree); // Create a new panel and show centered dialog_win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2); keypad(dialog_win, TRUE); curs = curs_set(0); // Set the window title mvwprintw(dialog_win, 1, (width - strlen(title)) / 2, title); // Write border and boxes around the window wattron(dialog_win, COLOR_PAIR(CP_BLUE_ON_DEF)); box(dialog_win, 0, 0); mvwhline(dialog_win, 2, 1, ACS_HLINE, width); mvwaddch(dialog_win, 2, 0, ACS_LTEE); mvwaddch(dialog_win, 2, width - 1, ACS_RTEE); mvwhline(dialog_win, height - 3, 1, ACS_HLINE, width); mvwaddch(dialog_win, height - 3, 0, ACS_LTEE); mvwaddch(dialog_win, height - 3, width - 1, ACS_RTEE); // Exit confirmation message message wattron(dialog_win, COLOR_PAIR(CP_CYAN_ON_DEF)); // Write the message into the screen tofree = str = strdup((char*)text); newl = 0; while ((word = strsep(&str, " ")) != NULL) { if (word[strlen(word)-1] == '/n') { word[strlen(word)-1] = '/0'; newl = 1; } if (col + strlen(word) > width - 2) { line++; col = 2; } mvwprintw(dialog_win, line, col, "%s", word); col += strlen(word) + 1; if (newl) { line++; col = 2; newl = 0; } } sng_free(tofree); wattroff(dialog_win, COLOR_PAIR(CP_CYAN_ON_DEF)); for (;;) { // A list of available keys in this window for (i = 0; i < optioncnt; i++ ) { if (i == selected) wattron(dialog_win, A_REVERSE); mvwprintw(dialog_win, height - 2, 10 + 10 * i, "[ %s ]", opts[i]); wattroff(dialog_win, A_REVERSE); } c = wgetch(dialog_win); switch (c) { case KEY_RIGHT: selected++; break; case KEY_TAB: case KEY_LEFT: selected--; break; case KEY_SPACE: case KEY_ENTER: case KEY_INTRO: goto done; case KEY_ESC: selected = -1; goto done; } // Cycle through ooptions if (selected > optioncnt - 1) selected = 0; if (selected < 0) selected = optioncnt - 1; }done: delwin(dialog_win); curs_set(curs); return selected;}
开发者ID:erhuabushuo,项目名称:sngrep,代码行数:101,
示例3: wmenuSelect_extint 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){ unsigned int i; unsigned int ylast = y; int key = 0; /* if( ( menuType & ( MENU_HORIZ | MENU_VERT ) )==0 ) { wprintw(window,"Menu without direction. Defaulting horizontal."); menuType |= MENU_HORIZ; } */ /* Warning: current may be out of bound, not checked */ /* Make sure that the current is one of the available items */ while(strchr(available, menuItems[*current].key)==NULL) { (*current)++ ; if( menuItems[*current].key==0 ) { *current = 0; } }#if defined(ALL_MOUSE_EVENTS) && defined(ENABLE_MOUSE) if((menuType & MENU_ACCEPT_OTHERS)==0 ) mousemask(ALL_MOUSE_EVENTS, NULL);#endif /* Repeat until allowable choice has been made */ while( key==0 ) { /* Display the menu */ ylast = wmenuUpdate( window, yinfo, y, x, menuItems, itemLength, available, menuType, *current ); wrefresh(window); /* Don't put wgetch after the following wclrtoeol */ key = wgetch(window); if(real_key!=NULL) *real_key=key; /* Clear out all prompts and such */ for( i = y; i < ylast; i ++ ) { wmove(window, i, x ); wclrtoeol(window); } wmove(window, yinfo, 0 ); wclrtoeol(window); if(strchr(available, key)==NULL) { if(key=='2') key=KEY_DOWN; else if(key=='4') key=KEY_LEFT; else if(key=='5') key=KEY_ENTER; else if(key=='6') key=KEY_RIGHT; else if(key=='8') key=KEY_UP; } /* Cursor keys */ switch(key) {#if defined(KEY_MOUSE) && defined(ENABLE_MOUSE) case KEY_MOUSE: if((menuType & MENU_ACCEPT_OTHERS)==0 ) { MEVENT event; if(getmouse(&event) == OK) { /* When the user clicks left mouse button */ if((event.bstate & BUTTON1_CLICKED) || (event.bstate & BUTTON1_DOUBLE_CLICKED)) { key = menu_to_command(yinfo, y_org, x_org, menuItems, itemLength, available, menuType, event.y, event.x); } } } break;#endif case KEY_UP: if( (menuType & MENU_VERT)!=0 ) { do { if( (*current)-- == 0 ) { while( menuItems[(*current)+1].key ) (*current) ++ ; } } while( strchr( available, menuItems[*current].key )==NULL ); key = 0; } break; case KEY_DOWN: if( (menuType & MENU_VERT)!=0 ) { do { (*current) ++ ; if( menuItems[*current].key==0 ) *current = 0 ; } while( strchr( available, menuItems[*current].key )==NULL ); key = 0;//.........这里部分代码省略.........
开发者ID:AndrewSmart,项目名称:testdisk,代码行数:101,
示例4: load_agent_list/* render a list of agents if available */voidload_agent_list (WINDOW * main_win, char *addr){ GMenu *menu; WINDOW *win; char buf[256]; int c, quit = 1, i; int y, x, list_h, list_w, menu_w, menu_h; if (!conf.list_agents) return; getmaxyx (stdscr, y, x); list_h = y / 2; /* list window - height */ list_w = x - 4; /* list window - width */ menu_h = list_h - AGENTS_MENU_Y - 1; /* menu window - height */ menu_w = list_w - AGENTS_MENU_X - AGENTS_MENU_X; /* menu window - width */ win = newwin (list_h, list_w, (y - list_h) / 2, (x - list_w) / 2); keypad (win, TRUE); wborder (win, '|', '|', '-', '-', '+', '+', '+', '+'); /* create a new instance of GMenu and make it selectable */ menu = new_gmenu (win, menu_h, menu_w, AGENTS_MENU_Y, AGENTS_MENU_X); if (set_host_agents (addr, load_host_agents_gmenu, menu) == 1) goto out; post_gmenu (menu); snprintf (buf, sizeof buf, "User Agents for %s", addr); draw_header (win, buf, " %s", 1, 1, list_w - 2, color_panel_header); mvwprintw (win, 2, 2, "[UP/DOWN] to scroll - [q] to close window"); wrefresh (win); while (quit) { c = wgetch (stdscr); switch (c) { case KEY_DOWN: gmenu_driver (menu, REQ_DOWN); break; case KEY_UP: gmenu_driver (menu, REQ_UP); break; case KEY_RESIZE: case 'q': quit = 0; break; } wrefresh (win); } touchwin (main_win); close_win (win); wrefresh (main_win);out: /* clean stuff up */ for (i = 0; i < menu->size; ++i) free (menu->items[i].name); if (menu->items) free (menu->items); free (menu);}
开发者ID:arceduardvincent,项目名称:goaccess,代码行数:65,
示例5: printcmdwinint printcmdwin( cmdWindowtype *cw, Windowtype *awin, Windowtype *pwin ) { int ch; int x = 0; int EXIT = 0; int cc = 1; if( cw->hidden ) { clearcmd( cw ); } else { //collorate wattron( cw->win, COLOR_PAIR(1) ); /*dekorations*/ box( cw->win, 0, 0 ); //topp of border, workdirectory of activ window for( x = 0; cw->wd[x] != '/0' && x+2 < cw->w -2; x++ ) { mvwprintw( cw->win, 0,x+2,"%c", cw->wd[x] ); } //bottom of border, destinationdir, workdirectory of passiv window for( x = 0; cw->ddir[x] != '/0' && x+2 < cw->w -2; x++ ) { mvwprintw( cw->win, 2,x+2,"%c", cw->ddir[x] ); } //print the currentli writen command mvwprintw( cw->win, 1, 1, ":_" ); for( x = 0; x < cw->cruser; x++ ) { mvwprintw( cw->win, 1,x+2,"%c_", cw->currentcmd[0][x] ); } //paint the rest of cw witb background color while( x < cw->w -3 ) { mvwprintw( cw->win, 1,x+2," " ); x++; } } wrefresh( cw->win ); keypad( cw->win, TRUE ); /*get commands*/ while( !EXIT && (ch = wgetch(cw->win)) ) { switch ( ch ) { case 0x7f: if( cw->cruser > 0 ) /*backspace*/ { mvwprintw(cw->win, 1, 1+cw->cruser, "_ "); cw->cruser--; cw->currentcmd[0][cw->cruser] = ' '; if( cc == 1 ) cw->currentcmd[1][cw->cruser] = ' '; } break; case KEY_UP: if( cc < CMDHISTORY ) /*up*/ cc++; clearcmd( cw ); for( x = 0; x < strlen(cw->currentcmd[cc]); x++ ) { mvwprintw( cw->win, 1,x+2,"%c_", cw->currentcmd[cc][x] ); cw->currentcmd[0][x] = cw->currentcmd[cc][x]; } cw->cruser = x; wrefresh( cw->win ); break; case KEY_DOWN: if( cc > 0 ) /*down*/ cc--; clearcmd( cw ); for( x = 0; x < strlen(cw->currentcmd[cc]); x++ ) { mvwprintw( cw->win, 1,x+2,"%c_", cw->currentcmd[cc][x] ); cw->currentcmd[0][x] = cw->currentcmd[cc][x]; } cw->cruser = x; wrefresh( cw->win ); break; case 0xA: trowcmd( cw, awin, pwin ); /*Enter*/ clearcmd( cw ); loadnewdir( awin, awin->wd ); EXIT = 1; break; case 0x1B: EXIT = 1; /*Escape*/ break;//.........这里部分代码省略.........
开发者ID:mrshampoo,项目名称:jeti-filemanager,代码行数:101,
示例6: load_schemes_win/* render schemes dialog */voidload_schemes_win (WINDOW * main_win){ GMenu *menu; WINDOW *win; int c, quit = 1; size_t i, n; int y, x, h = SCHEME_WIN_H, w = SCHEME_WIN_W; int w2 = w - 2; /* ###NOTE: 'Custom Scheme' needs to go at the end */ const char *choices[] = { "Monochrome/Default", "Green/Original", "Custom Scheme" }; n = ARRAY_SIZE (choices); getmaxyx (stdscr, y, x); win = newwin (h, w, (y - h) / 2, (x - w) / 2); keypad (win, TRUE); wborder (win, '|', '|', '-', '-', '+', '+', '+', '+'); /* create a new instance of GMenu and make it selectable */ menu = new_gmenu (win, SCHEME_MENU_H, SCHEME_MENU_W, SCHEME_MENU_Y, SCHEME_MENU_X); /* remove custom color option if no custom scheme used */ menu->size = conf.color_idx == 0 ? n - 1 : n; /* add items to GMenu */ menu->items = (GItem *) xcalloc (n, sizeof (GItem)); for (i = 0; i < n; ++i) { menu->items[i].name = alloc_string (choices[i]); menu->items[i].checked = 0; } post_gmenu (menu); draw_header (win, "Scheme Configuration", " %s", 1, 1, w2, color_panel_header); mvwprintw (win, 2, 2, "[ENTER] to switch scheme"); wrefresh (win); while (quit) { c = wgetch (stdscr); switch (c) { case KEY_DOWN: gmenu_driver (menu, REQ_DOWN); break; case KEY_UP: gmenu_driver (menu, REQ_UP); break; case 32: case 0x0a: case 0x0d: case KEY_ENTER: gmenu_driver (menu, REQ_SEL); for (i = 0; i < n; ++i) { if (menu->items[i].checked != 1) continue; scheme_chosen (choices[i]); break; } quit = 0; break; case KEY_RESIZE: case 'q': quit = 0; break; } wrefresh (win); } /* clean stuff up */ for (i = 0; i < n; ++i) free (menu->items[i].name); free (menu->items); free (menu); touchwin (main_win); close_win (win); wrefresh (main_win);}
开发者ID:arceduardvincent,项目名称:goaccess,代码行数:83,
示例7: load_help_popup/* render help dialog */voidload_help_popup (WINDOW * main_win){ int c, quit = 1; size_t i, n; int y, x, h = HELP_WIN_HEIGHT, w = HELP_WIN_WIDTH; int w2 = w - 2; WINDOW *win; GMenu *menu; n = ARRAY_SIZE (help_main); getmaxyx (stdscr, y, x); win = newwin (h, w, (y - h) / 2, (x - w) / 2); keypad (win, TRUE); wborder (win, '|', '|', '-', '-', '+', '+', '+', '+'); /* create a new instance of GMenu and make it selectable */ menu = new_gmenu (win, HELP_MENU_HEIGHT, HELP_MENU_WIDTH, HELP_MENU_Y, HELP_MENU_X); menu->size = n; /* add items to GMenu */ menu->items = (GItem *) xcalloc (n, sizeof (GItem)); for (i = 0; i < n; ++i) { menu->items[i].name = alloc_string (help_main[i]); menu->items[i].checked = 0; } post_gmenu (menu); draw_header (win, "GoAccess Quick Help", " %s", 1, 1, w2, color_panel_header); mvwprintw (win, 2, 2, "[UP/DOWN] to scroll - [q] to quit"); wrefresh (win); while (quit) { c = wgetch (stdscr); switch (c) { case KEY_DOWN: gmenu_driver (menu, REQ_DOWN); break; case KEY_UP: gmenu_driver (menu, REQ_UP); break; case KEY_RESIZE: case 'q': quit = 0; break; } wrefresh (win); } /* clean stuff up */ for (i = 0; i < n; ++i) free (menu->items[i].name); free (menu->items); free (menu); touchwin (main_win); close_win (win); wrefresh (main_win);}
开发者ID:arceduardvincent,项目名称:goaccess,代码行数:62,
示例8: dump_windowvoiddump_window(WINDOW *w){ wgetch(w); if (dumpfp != 0) { int y, x; int oldy, oldx; int maxy, maxx; int pass; char *cvec = 0; char *avec = 0; char *pvec = 0; int ccnt = 0; int acnt = 0; int pcnt = 0; int endy = -1; int endx = -1; fprintf(dumpfp, "Window %p/n", (void *) w); getyx(w, oldy, oldx); getmaxyx(w, maxy, maxx); fprintf(dumpfp, "size (%dx%d)/n", maxy, maxx); getbegyx(w, y, x); fprintf(dumpfp, "begin (%dx%d)/n", maxy, maxx); getyx(w, y, x); fprintf(dumpfp, "position (%d,%d)/n", y, x); if (maxy > 0 && maxx > 0) { for (pass = 0; pass < 2; ++pass) { for (y = 0; y < maxy; ++y) { if (cvec) memset(cvec, 0, (size_t) maxx + 1); if (avec) memset(avec, 0, (size_t) maxx + 1); if (pvec) memset(pvec, 0, (size_t) maxx + 1); for (x = 0; x < maxx; ++x) { chtype data = mvwinch(w, y, x); chtype temp; char cc = (char) ((data & 0xff) ? (data & 0xff) : ' '); char aa; char pp; temp = ((data & A_ATTRIBUTES) & (~A_COLOR)); if (temp) { if (temp & A_ALTCHARSET) { aa = (temp & A_BOLD) ? 'A' : 'a'; } else if (temp & A_STANDOUT) { aa = (temp & A_BOLD) ? 'S' : 's'; } else if (temp & A_REVERSE) { aa = (temp & A_BOLD) ? 'R' : 'r'; } else if (temp & A_UNDERLINE) { aa = (temp & A_BOLD) ? 'U' : 'u'; } else { aa = (temp & A_BOLD) ? 'b' : '?'; } } else { aa = ' '; } if (data & A_COLOR) { if (PAIR_NUMBER((int) data) < 8) { pp = (char) ('0' + PAIR_NUMBER((int) data)); } else { pp = '*'; } } else { pp = ' '; } if (pass) { if (cvec) cvec[x] = cc; if (avec) avec[x] = aa; if (pvec) pvec[x] = pp; } else { if (cc != ' ' || aa != ' ' || pp != ' ') { if (endx < x) endx = x; if (endy < y) endy = y; } ccnt += (cc != ' '); acnt += (aa != ' '); pcnt += (pp != ' '); } } if (pass) { fprintf(dumpfp, "%3d", y + 1); if (cvec) fprintf(dumpfp, "/tc|%.*s|/n", maxx, cvec); if (avec) fprintf(dumpfp, "/ta|%.*s|/n", maxx, avec); if (pvec) fprintf(dumpfp, "/tp|%.*s|/n", maxx, pvec); }//.........这里部分代码省略.........
开发者ID:ThomasDickey,项目名称:ncurses-snapshots,代码行数:101,
示例9: mainint main(){ ITEM **my_items; int c; MENU *my_menu; int n_choices, i; ITEM *cur_item; WINDOW *local_win; initscr(); cbreak(); noecho(); keypad(stdscr, TRUE); start_color(); init_pair(1, COLOR_BLUE, COLOR_BLACK); attron(COLOR_PAIR(1)); mvprintw((LINES/2)-10,(COLS/3)-25,"%s",title1); mvprintw((LINES/2)-9,(COLS/3)-25,"%s",title2); mvprintw((LINES/2)-8,(COLS/3)-25,"%s",title3); mvprintw((LINES/2)-7,(COLS/3)-25,"%s",title4); mvprintw((LINES/2)-6,(COLS/3)-25,"%s",title5); attroff(COLOR_PAIR(1)); //getch(); mvprintw(((LINES/2)+5), ((COLS/2)-7), "q to Exit"); refresh(); local_win = newwin(5, 15, ((LINES/2)-2), ((COLS/3)+8)); //box(local_win, 0 , 0); wrefresh(local_win); n_choices = ARRAY_SIZE(choices); my_items = (ITEM **)calloc(n_choices + 1, sizeof(ITEM *)); for(i = 0; i < n_choices; ++i) my_items[i] = new_item(choices[i],"");//, choices[i]); my_items[n_choices] = (ITEM *)NULL; my_menu = new_menu((ITEM **)my_items); set_menu_win(my_menu, local_win); keypad(local_win, TRUE); post_menu(my_menu); wrefresh(local_win); while(true) { c = wgetch(local_win); switch(c) { case KEY_DOWN: menu_driver(my_menu, REQ_DOWN_ITEM); break; case KEY_UP: menu_driver(my_menu, REQ_UP_ITEM); break; case 'a': //mvprintw(LINES-3, 0, "Item selected is : %s", item_name(current_item(my_menu))); const char *blargh=item_name(current_item(my_menu)); //mvprintw(LINES-3,0,"Item selected is : %s",blargh); switch(blargh[0]) { case 'S'://tart New Game": mvprintw(LINES-3,0,"Started New Game"); break; case 'L'://oad Game": mvprintw(LINES-3,0,"Loaded Game"); break; case 'O'://ptions": mvprintw(LINES-3,0,"Selected Options"); break; case 'H'://elp": mvprintw(LINES-3,0,"Selected Help"); break; case 'E'://xit": mvprintw(LINES-3,0,"Exiting"); c='q'; } break; } if (c=='q'){ break; } } free_item(my_items[0]); free_item(my_items[1]); free_menu(my_menu); endwin();}
开发者ID:code-11,项目名称:Pandora-Effect,代码行数:90,
示例10: dialog_menu//.........这里部分代码省略......... (scroll+max_choice <= item_no) ) { first_item = scroll; choice = choice - scroll; fclose(f); } else { scroll=0; remove("lxdialog.scrltmp"); fclose(f); f=NULL; } } if ( (choice >= max_choice) || (f==NULL && choice >= max_choice/2) ) { if (choice >= item_no-max_choice/2) scroll = first_item = item_no-max_choice; else scroll = first_item = choice - max_choice/2; choice = choice - scroll; } /* Print the menu */ for (i=0; i < max_choice; i++) { print_item (menu, items[(first_item + i) * 2 + 1], i, i == choice, (items[(first_item + i)*2][0] != ':')); } wnoutrefresh (menu); print_arrows(dialog, item_no, scroll, box_y, box_x+item_x+1, menu_height); print_buttons (dialog, height, width, 0); while (key != ESC) { key = wgetch(dialog); if (key < 256 && isalpha(key)) key = tolower(key); if (strchr("ynm", key)) i = max_choice; else { for (i = choice+1; i < max_choice; i++) { j = first_alpha(items[(scroll+i)*2+1], "YyNnMm"); if (key == tolower(items[(scroll+i)*2+1][j])) break; } if (i == max_choice) for (i = 0; i < max_choice; i++) { j = first_alpha(items[(scroll+i)*2+1], "YyNnMm"); if (key == tolower(items[(scroll+i)*2+1][j])) break; } } if (i < max_choice || key == KEY_UP || key == KEY_DOWN || key == '-' || key == '+' || key == KEY_PPAGE || key == KEY_NPAGE) { print_item (menu, items[(scroll+choice)*2+1], choice, FALSE, (items[(scroll+choice)*2][0] != ':')); if (key == KEY_UP || key == '-') { if (choice < 2 && scroll) { /* Scroll menu down */ scrollok (menu, TRUE); wscrl (menu, -1);
开发者ID:23171580,项目名称:u-boot_wrtnode,代码行数:67,
示例11: timestd::string Terminal::GetCommand(){ std::string output = ""; time_t commandRequestTime; time_t currentTime; time(&commandRequestTime); //Update status message if (status_window) { werase(status_window); print(status_window,statusStr.at(0).c_str()); } while(true){ if(SIGNAL_SEGFAULT){ // segmentation fault (SIGSEGV) Close(); return "_SIGSEGV_"; } if(SIGNAL_INTERRUPT){ // ctrl-c (SIGINT) SIGNAL_INTERRUPT = false; output = "CTRL_C"; text_length = 0; break; } else if(SIGNAL_TERMSTOP){ // ctrl-z (SIGTSTP) SIGNAL_TERMSTOP = false; output = "CTRL_Z"; text_length = 0; break; } flush(); // If there is anything in the stream, dump it to the screen //Time out if there is no command within the set interval (default 0.5 s). if (commandTimeout_ > 0) { time(¤tTime); //If the timeout has passed we simply return the empty output string. if (currentTime > commandRequestTime + commandTimeout_) { break; } } int keypress = wgetch(input_window); // Check for internal commands if(keypress == ERR){ } // No key was pressed in the interval else if(keypress == 10){ // Enter key (10) std::string temp_cmd = cmd.Get(); //Reset the position in the history. commands.Reset(); if(temp_cmd != "" && temp_cmd != commands.PeekPrev()){ // Only save this command if it is different than the previous command commands.Push(temp_cmd); } output = temp_cmd; std::cout << prompt << output << "/n"; flush(); text_length = 0; _scrollPosition = 0; clear_(); tabCount = 0; break; } else if(keypress == '/t' && enableTabComplete) { tabCount++; output = cmd.Get().substr(0,cursX - offset) + "/t"; break; } else if(keypress == 4){ // ctrl-d (EOT) output = "CTRL_D"; text_length = 0; clear_(); tabCount = 0; break; } else if(keypress == 9){ } // Tab key (9) else if(keypress == KEY_UP){ // 259 if(commands.GetIndex() == 0){ commands.Capture(cmd.Get()); } std::string temp_cmd = commands.GetPrev(); if(temp_cmd != "NULL"){ clear_(); cmd.Set(temp_cmd); in_print_(cmd.Get().c_str()); text_length = cmd.GetSize(); } } else if(keypress == KEY_DOWN){ // 258 std::string temp_cmd = commands.GetNext(); if(temp_cmd != "NULL"){ clear_(); cmd.Set(temp_cmd); in_print_(cmd.Get().c_str()); text_length = cmd.GetSize(); } } else if(keypress == KEY_LEFT){ cursX--; } // 260 else if(keypress == KEY_RIGHT){ cursX++; } // 261 else if(keypress == KEY_PPAGE){ //Page up key scroll_(-(_winSizeY-2)); } else if(keypress == KEY_NPAGE){ //Page down key scroll_(_winSizeY-2);//.........这里部分代码省略.........
开发者ID:ksmith0,项目名称:PixieSuite2,代码行数:101,
示例12: mainint main(){ WINDOW *win, *boxing; int c; int x, y; initscr(); signal(SIGINT, die); noecho(); crmode(); win = subwin(stdscr, LINES / 2, COLS / 2, LINES / 4, COLS / 4); scrollok(win, TRUE); boxing = subwin(stdscr, LINES / 2 + 2, COLS / 2 + 2, LINES / 4 - 1, COLS / 4 - 1); box(boxing, '!', '-'); refresh(); wmove(win, 0, 0); wrefresh(win); while ((c = wgetch(win)) != '#') { if (iscntrl(c)) { switch (c) { case CNTRL('E'): werase(win); wrefresh(win); continue; case CNTRL('R'): wrefresh(curscr); continue; case CNTRL('['): getyx(win, y, x); c = wgetch(win); if (c == '[' || c == 'O') c = wgetch(win); switch (c) { case 'H': x = 0; y = 0; goto change; case 'A': y--; goto change; case 'B': y++; goto change; case 'C': x++; goto change; case 'D': x--;change: if (x >= win->_maxx) { x = 0; y++; } if (y >= win->_maxy) y = 0; wmove(win, y, x); wrefresh(win); continue; default: break; } break; default: continue; } } waddch(win, c); wrefresh(win); } die(SIGINT);}
开发者ID:RetroBSD,项目名称:retrobsd,代码行数:87,
示例13: dialog_checklist//.........这里部分代码省略......... /* draw a box around the list items */ draw_box (dialog, box_y, box_x, list_height + 2, list_width + 2, menubox_border_attr, menubox_attr); /* Find length of longest item in order to center checklist */ check_x = 0; for (i = 0; i < item_no; i++) check_x = MAX (check_x, + strlen (items[i * 3 + 1]) + 4); check_x = (list_width - check_x) / 2; item_x = check_x + 4; if (choice >= list_height) { scroll = choice - list_height + 1; choice -= scroll; } /* Print the list */ for (i = 0; i < max_choice; i++) { print_item (list, items[(scroll+i) * 3 + 1], status[i+scroll], i, i == choice); } print_arrows(dialog, choice, item_no, scroll, box_y, box_x + check_x + 5, list_height); print_buttons(dialog, height, width, 0); wnoutrefresh (list); wnoutrefresh (dialog); doupdate (); while (key != ESC) { key = wgetch (dialog); for (i = 0; i < max_choice; i++) if (toupper(key) == toupper(items[(scroll+i)*3+1][0])) break; if ( i < max_choice || key == KEY_UP || key == KEY_DOWN || key == '+' || key == '-' ) { if (key == KEY_UP || key == '-') { if (!choice) { if (!scroll) continue; /* Scroll list down */ if (list_height > 1) { /* De-highlight current first item */ print_item (list, items[scroll * 3 + 1], status[scroll], 0, FALSE); scrollok (list, TRUE); wscrl (list, -1); scrollok (list, FALSE); } scroll--; print_item (list, items[scroll * 3 + 1], status[scroll], 0, TRUE); wnoutrefresh (list); print_arrows(dialog, choice, item_no, scroll, box_y, box_x + check_x + 5, list_height); wrefresh (dialog); continue; /* wait for another key press */
开发者ID:BackupGGCode,项目名称:teebx,代码行数:67,
示例14: setXvoid player::makeUserPlayer(WINDOW*& window){ bool goodInput = false; setX(73); setY(21); //gender while(goodInput != true) { mvwprintw(window, 0, 0, "Are you (M)ale or (F)emale: "); char userGender; wmove(window, 0, 28); userGender = wgetch(window); userGender = toupper(userGender); if(userGender == 'M' || userGender == 'F') { goodInput = true; gender = userGender; } else { goodInput = false; } } goodInput = false; //name while(goodInput != true) { werase(window); mvwprintw(window, 0, 0, "What is your name: "); std::string userName; int x = 19; int y = 0; wmove(window, y, x); int letterCounter = 0; char ch; echo(); while(letterCounter < 12 && ch != '/n') { ch = wgetch(window); if(ch == '/n') { break; } else { userName.push_back(ch); mvwaddch(window, y, x, ch); } letterCounter++; x++; } //userName = string(charName); if(userName.size() > 12) { goodInput = false; } else { goodInput = true; name = userName; name = name.substr(0, letterCounter); } } noecho(); werase(window);}
开发者ID:hashr25,项目名称:TheGameOfLife,代码行数:74,
示例15: getchint getch(void){ return wgetch(mainwin);}
开发者ID:CoZarctan,项目名称:Cataclysm-DDA,代码行数:4,
示例16: interactint interact(WIDGET *widget){ int c; FUNCP f; WINDOW *win = widget->win; void *wid = widget->wid; int desc = widget->desc; box(win, ACS_CKBOARD, ACS_CKBOARD); wrefresh(win); while ((c = wgetch(win)) != '[') { switch (c) { case KEY_LEFT: if (f = widget->direct) f(wid, D_LEFT, desc); break; case KEY_RIGHT: if (f = widget->direct) f(wid, D_RIGHT, desc); break; case KEY_UP: if (f = widget->direct) f(wid, D_UP, desc); break; case KEY_DOWN: if (f = widget->direct) f(wid, D_DOWN, desc); break; case 10: /* Enter */ if (f = widget->enter) /* clear me, waiting for a forward set */ wborder(win, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); wrefresh(win); /* back here */ f(wid); /* back to me, set myself again */ box(win, ACS_CKBOARD, ACS_CKBOARD); wrefresh(win); break; case '-': /* 0x2d */ if (f = widget->backspace) f(wid); break; /* all printable chars */ case 0x20 ... 0x2c: case 0x2e ... 0x7e: if (f = widget->input) f(wid, c); break; default: break; } } /* clear me, waiting for a backward set */ wborder(win, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); wrefresh(win); return 0;}
开发者ID:treblih,项目名称:chafing_dish,代码行数:62,
示例17: mvwgetchint mvwgetch(WINDOW* win, int y, int x){ move(y, x); return wgetch(win);}
开发者ID:CoZarctan,项目名称:Cataclysm-DDA,代码行数:5,
示例18: getinputvoid getinput(struct FIELDLIST *list, struct FIELD *field, int *exitkey){ int ch; int y, x; int endloop = 0; wmove(list->fieldwin, field->ypos, field->xpos); wattrset(list->fieldwin, FIELDATTR); wprintw(list->fieldwin, "%s", field->buf); update_panels(); doupdate(); do { ch = wgetch(list->fieldwin); switch (ch) {#ifndef DISABLEBS case KEY_BACKSPACE:#endif case 7: case 8: case KEY_DC: case KEY_LEFT: if (field->tlen > 0) { getyx(list->fieldwin, y, x); x--; wmove(list->fieldwin, y, x); wprintw(list->fieldwin, " "); wmove(list->fieldwin, y, x); field->tlen--; field->buf[field->tlen] = '/0'; } break; case 9: case 27: case 24: case 13: case 10: case KEY_UP: case KEY_DOWN: endloop = 1; *exitkey = ch; break; case 12: refresh_screen(); break; default: if ((field->tlen < field->len) && ((ch >= 32) && (ch <= 127))) { wprintw(list->fieldwin, "%c", ch); if (ch == ' ') { getyx(list->fieldwin, y, x); wmove(list->fieldwin, y, x); } field->buf[field->tlen + 1] = '/0'; field->buf[field->tlen] = ch; field->tlen++; } break; } doupdate(); } while (!endloop);}
开发者ID:nullren,项目名称:sillypoker,代码行数:63,
示例19: load_sort_win//.........这里部分代码省略......... } } else if (SORT_BY_MAXTS == field) { menu->items[i].name = alloc_string ("Max. Time Served"); if (sort->field == SORT_BY_MAXTS) { menu->items[i].checked = 1; menu->idx = i; } } else if (SORT_BY_PROT == field) { menu->items[i].name = alloc_string ("Protocol"); if (sort->field == SORT_BY_PROT) { menu->items[i].checked = 1; menu->idx = i; } } else if (SORT_BY_MTHD == field) { menu->items[i].name = alloc_string ("Method"); if (sort->field == SORT_BY_MTHD) { menu->items[i].checked = 1; menu->idx = i; } } } post_gmenu (menu); draw_header (win, "Sort active module by", " %s", 1, 1, w2, color_panel_header); mvwprintw (win, 2, 2, "[ENTER] to select field - [TAB] sort"); if (sort->sort == SORT_ASC) mvwprintw (win, SORT_WIN_H - 2, 1, " %s", SORT_ASC_SEL); else mvwprintw (win, SORT_WIN_H - 2, 1, " %s", SORT_DESC_SEL); wrefresh (win); while (quit) { c = wgetch (stdscr); switch (c) { case KEY_DOWN: gmenu_driver (menu, REQ_DOWN); break; case KEY_UP: gmenu_driver (menu, REQ_UP); break; case 9: /* TAB */ if (sort->sort == SORT_ASC) { /* ascending */ sort->sort = SORT_DESC; mvwprintw (win, SORT_WIN_H - 2, 1, " %s", SORT_DESC_SEL); } else { /* descending */ sort->sort = SORT_ASC; mvwprintw (win, SORT_WIN_H - 2, 1, " %s", SORT_ASC_SEL); } break; case 32: case 0x0a: case 0x0d: case KEY_ENTER: gmenu_driver (menu, REQ_SEL); for (i = 0; i < n; ++i) { if (menu->items[i].checked != 1) continue; if (strcmp ("Hits", menu->items[i].name) == 0) sort->field = SORT_BY_HITS; else if (strcmp ("Visitors", menu->items[i].name) == 0) sort->field = SORT_BY_VISITORS; else if (strcmp ("Data", menu->items[i].name) == 0) sort->field = SORT_BY_DATA;
开发者ID:arceduardvincent,项目名称:goaccess,代码行数:67,
示例20: main// this is where the magic happensint main(int argc, const char *argv[]) { WINDOW *menu_win; node_t *curr; int len, ch, count, highlight = 1; char directions[] = "Use arrow keys to navigate, press enter to select"; char insert_msg[] = "Enter the element you'd like to insert: "; char remove_msg[] = "Enter the element you'd like to remove: "; char count_msg[] = "Enter the element you'd like to count: "; // create a new node list list_t *node_list = new_list(); // initialize the ncurses session initscr(); clear(); noecho(); cbreak(); curs_set(0); getmaxyx(stdscr, stdscr_rows, stdscr_cols); mvprintw(2, 2, "%s", directions); // initialize the menu window menu_win = newwin(10, 50, ((stdscr_rows-10)/2), ((stdscr_cols-50)/2)); getmaxyx(menu_win, menu_win_rows, menu_win_cols); keypad(menu_win, TRUE); print_menu(menu_win, highlight); refresh(); // enter continuous loop to let user use the menu while (1) { switch(ch = wgetch(menu_win)) { case KEY_UP: if (highlight == 1) highlight = n_choices; else --highlight; break; case KEY_DOWN: if (highlight == n_choices) highlight = 1; else ++highlight; break; case 10: switch (highlight) { case 1: /* print */ if (node_list->len) { len = node_list->len; curr = node_list->head->next; mvprintw(stdscr_rows - 2, 2, "List elements:"); clrtoeol(); while (len--) { printw(" %d", curr->val); curr = curr->next; } } else { mvprintw(stdscr_rows - 2, 2, "The list is empty"); clrtoeol(); } break; case 2: /* insert one */ list_insert(node_list, new_node(get_input(insert_msg))); mvprintw(stdscr_rows - 2, 2, "Element Inserted!"); clrtoeol(); break; case 3: /* remove one */ curr = list_find(node_list, get_input(remove_msg)); if (curr) { list_remove(node_list, curr); mvprintw(stdscr_rows - 2, 2, "Element Removed!"); } else { mvprintw(stdscr_rows - 2, 2, "Element Not Found!"); } clrtoeol(); break; case 4: /* remove each */ curr = list_find(node_list, get_input(remove_msg)); if (curr) { list_remove_each(node_list, curr); mvprintw(stdscr_rows - 2, 2, "All Matching Elements Removed!"); } else { mvprintw(stdscr_rows - 2, 2, "Element Not Found!"); } clrtoeol(); break; case 5: /* remove all */ list_remove_all(node_list); mvprintw(stdscr_rows - 2, 2, "All Elements Removed!"); clrtoeol(); break; case 6: /* count elements */ mvprintw(stdscr_rows - 2, 2, "List length: %d", node_list->len); clrtoeol(); break; case 7: /* count occurrences *///.........这里部分代码省略.........
开发者ID:Morriskalb,项目名称:bmcc-classwork,代码行数:101,
示例21: input_string/* implement basic frame work to build a field input */char *input_string (WINDOW * win, int pos_y, int pos_x, size_t max_width, const char *str, int enable_case, int *toggle_case){ char *s = xmalloc (max_width + 1), *tmp; size_t i, c, pos = 0, x = 0, quit = 1, len = 0, size_x = 0, size_y = 0; getmaxyx (win, size_y, size_x); size_x -= 4; /* are we setting a default string */ if (str) { len = MIN (max_width, strlen (str)); memcpy (s, str, len); s[len] = '/0'; x = pos = 0; /* is the default str length greater than input field? */ if (strlen (s) > size_x) { tmp = xstrdup (&s[0]); tmp[size_x] = '/0'; mvwprintw (win, pos_y, pos_x, "%s", tmp); free (tmp); } else { mvwprintw (win, pos_y, pos_x, "%s", s); } } else { s[0] = '/0'; } if (enable_case) mvwprintw (win, size_y - 2, 1, " %s", CSENSITIVE); wmove (win, pos_y, pos_x + x); wrefresh (win); curs_set (1); while (quit) { c = wgetch (stdscr); switch (c) { case 1: /* ^a */ case 262: /* HOME */ pos = x = 0; break; case 5: case 360: /* END of line */ if (strlen (s) > size_x) { x = size_x; pos = strlen (s) - size_x; } else { pos = 0; x = strlen (s); } break; case 7: /* ^g */ case 27: /* ESC */ pos = x = 0; if (str && *str == '/0') s[0] = '/0'; quit = 0; break; case 9: /* TAB */ if (!enable_case) break; *toggle_case = *toggle_case == 0 ? 1 : 0; if (*toggle_case) mvwprintw (win, size_y - 2, 1, " %s", CISENSITIVE); else if (!*toggle_case) mvwprintw (win, size_y - 2, 1, " %s", CSENSITIVE); break; case 21: /* ^u */ s[0] = '/0'; pos = x = 0; break; case 8: /* xterm-256color */ case 127: case KEY_BACKSPACE: if (pos + x > 0) { memmove (&s[(pos + x) - 1], &s[pos + x], (max_width - (pos + x)) + 1); if (pos <= 0) x--; else pos--; } break; case KEY_LEFT: if (x > 0) x--; else if (pos > 0) pos--; break; case KEY_RIGHT: if ((x + pos) < strlen (s)) { if (x < size_x) x++; else pos++; } break;//.........这里部分代码省略.........
开发者ID:arceduardvincent,项目名称:goaccess,代码行数:101,
示例22: dialog_prgbox//.........这里部分代码省略......... width = COLS; if (height > LINES) height = LINES; /* center dialog box on screen */ x = DialogX ? DialogX : (COLS - width)/2; y = DialogY ? DialogY : (LINES - height)/2;#ifdef HAVE_NCURSES if (use_shadow) draw_shadow(stdscr, y, x, height, width);#endif dialog = newwin(height, width, y, x); if (dialog == NULL) { endwin(); fprintf(stderr, "/nnewwin(%d,%d,%d,%d) failed, maybe wrong dims/n", height,width,y,x); exit(1); } keypad(dialog, TRUE); draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); if (title != NULL) { wattrset(dialog, title_attr); wmove(dialog, 0, (width - strlen(title))/2 - 1); waddch(dialog, ' '); waddstr(dialog, title); waddch(dialog, ' '); } wattrset(dialog, dialog_attr); wmove(dialog, 1, 2); if (!use_shell) { char cmdline[MAX_LEN]; char *av[51], **ap = av, *val, *p; strcpy(cmdline, line); p = cmdline; while ((val = strsep(&p," /t")) != NULL) { if (*val != '/0') *ap++ = val; } *ap = NULL; f = raw_popen(name = av[0], av, "r"); } else f = raw_popen(name = line, NULL, "r"); status = -1; if (f == NULL) { err: sprintf(buf, "%s: %s/n", name, strerror(errno)); prr: print_autowrap(dialog, buf, height-(pause?3:1), width-2, width, 1, 2, FALSE, TRUE); wrefresh(dialog); } else { while (fgets(buf, sizeof(buf), f) != NULL) { i = strlen(buf); if (buf[i-1] == '/n') buf[i-1] = '/0'; s = buf; while ((s = strchr(s, '/t')) != NULL) *s++ = ' '; print_autowrap(dialog, buf, height-(pause?3:1), width-2, width, 1, 2, FALSE, TRUE); print_autowrap(dialog, "/n", height-(pause?3:1), width-2, width, 1, 2, FALSE, FALSE); wrefresh(dialog); } if ((status = raw_pclose(f)) == -1) goto err; if (WIFEXITED(status) && WEXITSTATUS(status) == 127) { sprintf(buf, "%s: program not found/n", name); goto prr; } } if (pause) { wattrset(dialog, border_attr); wmove(dialog, height-3, 0); waddch(dialog, ACS_LTEE); for (i = 0; i < width-2; i++) waddch(dialog, ACS_HLINE); wattrset(dialog, dialog_attr); waddch(dialog, ACS_RTEE); wmove(dialog, height-2, 1); for (i = 0; i < width-2; i++) waddch(dialog, ' '); display_helpline(dialog, height-1, width); print_button(dialog, " OK ", height-2, width/2-6, TRUE); wrefresh(dialog); while (key != ESC && key != '/n' && key != ' ' && key != '/r') key = wgetch(dialog); if (key == '/r') key = '/n'; } else { key = '/n'; wrefresh(dialog); } delwin(dialog); return (status);}
开发者ID:asdlei00,项目名称:freebsd,代码行数:101,
示例23: render_confdlg/* render config log date/format dialog */intrender_confdlg (GLog * logger, GSpinner * spinner){ GMenu *menu; WINDOW *win; char *cstm_log, *cstm_date, *cstm_time; int c, quit = 1, invalid = 1, y, x, h = CONF_WIN_H, w = CONF_WIN_W; int w2 = w - 2; size_t i, n, sel; /* conf dialog menu options */ const char *choices[] = { "NCSA Combined Log Format", "NCSA Combined Log Format with Virtual Host", "Common Log Format (CLF)", "Common Log Format (CLF) with Virtual Host", "W3C", "Squid Native Format", "CloudFront (Download Distribution)", "Google Cloud Storage", "AWS Elastic Load Balancing (HTTP/S)" }; n = ARRAY_SIZE (choices); getmaxyx (stdscr, y, x); win = newwin (h, w, (y - h) / 2, (x - w) / 2); keypad (win, TRUE); wborder (win, '|', '|', '-', '-', '+', '+', '+', '+'); /* create a new instance of GMenu and make it selectable */ menu = new_gmenu (win, CONF_MENU_H, CONF_MENU_W, CONF_MENU_Y, CONF_MENU_X); menu->size = n; menu->selectable = 1; /* add items to GMenu */ menu->items = (GItem *) xcalloc (n, sizeof (GItem)); for (i = 0; i < n; ++i) { menu->items[i].name = alloc_string (choices[i]); sel = get_selected_format_idx (); menu->items[i].checked = sel == i ? 1 : 0; } post_gmenu (menu); draw_header (win, "Log Format Configuration", " %s", 1, 1, w2, color_panel_header); mvwprintw (win, 2, 2, "[SPACE] to toggle - [ENTER] to proceed"); /* set log format from goaccessrc if available */ draw_header (win, "Log Format - [c] to add/edit format", " %s", 11, 1, w2, color_panel_header); if (conf.log_format) { log_format = escape_str (conf.log_format); mvwprintw (win, 12, 2, "%.*s", CONF_MENU_W, log_format); if (conf.log_format) free (conf.log_format); } /* set date format from goaccessrc if available */ draw_header (win, "Date Format - [d] to add/edit format", " %s", 14, 1, w2, color_panel_header); if (conf.date_format) { date_format = escape_str (conf.date_format); mvwprintw (win, 15, 2, "%.*s", CONF_MENU_W, date_format); if (conf.date_format) free (conf.date_format); } /* set time format from goaccessrc if available */ draw_header (win, "Time Format - [t] to add/edit format", " %s", 17, 1, w2, color_panel_header); if (conf.time_format) { time_format = escape_str (conf.time_format); mvwprintw (win, 18, 2, "%.*s", CONF_MENU_W, time_format); if (conf.time_format) free (conf.time_format); } wrefresh (win); while (quit) { c = wgetch (stdscr); switch (c) { case KEY_DOWN: gmenu_driver (menu, REQ_DOWN); clear_confdlg_status_bar (win, 3, 2, CONF_MENU_W); break; case KEY_UP: gmenu_driver (menu, REQ_UP); clear_confdlg_status_bar (win, 3, 2, CONF_MENU_W); break; case 32: /* space */ gmenu_driver (menu, REQ_SEL); clear_confdlg_status_bar (win, 12, 1, CONF_MENU_W); clear_confdlg_status_bar (win, 15, 1, CONF_MENU_W); clear_confdlg_status_bar (win, 18, 1, CONF_MENU_W); if (time_format) free (time_format); if (date_format)//.........这里部分代码省略.........
开发者ID:arceduardvincent,项目名称:goaccess,代码行数:101,
示例24: assertmenu_item_t *menu_wait(menu_t *menu, int timeout){ int c; menu_item_t *ret = NULL; assert(menu && menu == _libmenu_menus_l); /* Création de la fenêtre si nécessaire */ if(!_libmenu_window) { _libmenu_window = newwin(menu->win_h, menu->win_w, menu->win_y, menu->win_x); keypad(_libmenu_window, TRUE); /* Va au premier élément sélectionnable */ menu->item = _libmenu_selectable_item_after(menu, -1); _libmenu_invalid = 1; } if(_libmenu_invalid) { _libmenu_drawmenu(); _libmenu_invalid = 0; } if(timeout >= 0) halfdelay(timeout/100); else cbreak(); c = wgetch(_libmenu_window); switch(c) { case KEY_UP: menu->item = _libmenu_selectable_item_before(menu, menu->item); /* Scrolling */ if(menu->item != -1 && menu->item < menu->scroll_pos) menu->scroll_pos = menu->item; _libmenu_drawmenu(); break; case KEY_DOWN: menu->item = _libmenu_selectable_item_after(menu, menu->item); /* Scrolling */ if(menu->item >= menu->scroll_pos + menu->win_h-2) menu->item = menu->scroll_pos + menu->win_h - 3; _libmenu_drawmenu(); break; /* TODO : saut des items non-sélectionnables */ case 10: { menu_item_t *i = _libmenu_item_n(menu->items_f, menu->item); if(i->type != MENU_ITEM_LABEL) return i; } break; case 'q': case 'Q': ret = MENU_QUIT; break; } nocbreak(); return ret;}
开发者ID:remram44,项目名称:libmenu,代码行数:61,
示例25: printHelp/********************************************************/ * Description: outputs key command help * * Returns: none */********************************************************/void printHelp(WINS *win){ WINDOW *ctrl, *help, *small; ctrl = newwin(LINES - 2, 9, 1, 1), help = newwin(LINES - 2, hex_win_width, 1, 10), small = newwin(LINES - 2, ascii_win_width, 1, hex_outline_width + 2); if ((LINES < 18) || (COLS < 78)) /* min size to display*/ { mvwprintw(help, 0, 0, "Screen too small to display help"); wmove(help,0,0); } else { wmove(ctrl,0,0); mvwprintw(ctrl, 0, 1, "Ctrl Key"); /* print in address */ mvwprintw(ctrl, 2, 1, "CTRL+?"); mvwprintw(ctrl, 3, 1, "CTRL+S"); mvwprintw(ctrl, 4, 1, "CTRL+O"); mvwprintw(ctrl, 5, 1, "CTRL+G"); mvwprintw(ctrl, 6, 1, "CTRL+F"); mvwprintw(ctrl, 7, 1, "CTRL+A"); mvwprintw(ctrl, 8, 1, "TAB"); mvwprintw(ctrl, 9, 1, "CTRL+Q"); mvwprintw(ctrl, 11, 1, "CTRL+U"); mvwprintw(ctrl, 12, 1, "CTRL+D"); mvwprintw(ctrl, 13, 1, "CTRL+Z"); mvwprintw(ctrl, 14, 1, "CTRL+T"); mvwprintw(ctrl, 15, 1, "CTRL+B"); mvwprintw(small, 0, 1, "Function Keys"); /* print in ascii */ mvwprintw(small, 2, 1, "Help = F1"); mvwprintw(small, 3, 1, "Save = F2"); mvwprintw(small, 4, 1, "Open = F3"); mvwprintw(small, 5, 1, "Goto = F4"); mvwprintw(small, 6, 1, "Find = F5"); mvwprintw(small, 7, 1, "HexAdres = F6"); mvwprintw(small, 8, 1, "Hex Edit = F7"); mvwprintw(small, 9, 1, "Quit = F8"); mvwprintw(small, 11, 1, "Page up = PGUP"); mvwprintw(small, 12, 1, "Page down= PGDN"); mvwprintw(help, 0, 10, "HexCurse Keyboard Commands"); mvwprintw(help, 2, 2, "Help - you are reading it now"); mvwprintw(help, 3, 2, "Save - saves the current file open"); mvwprintw(help, 4, 2, "Open - opens a new file"); mvwprintw(help, 5, 2, "Goto - goto a specified address"); mvwprintw(help, 6, 2, "Find - search for a hex/ascii value"); mvwprintw(help, 7, 2, "HexAdres - toggle between hex/decimal address"); mvwprintw(help, 8, 2, "Hex Edit - toggle between hex/ASCII windows"); mvwprintw(help, 9, 2, "Quit - exit out of the program"); mvwprintw(help, 11, 2, "Page up - scrolls one screen up"); mvwprintw(help, 12, 2, "Page down- scrolls one screen down"); mvwprintw(help, 13, 2, "Undo - reverts last modification"); mvwprintw(help, 14, 2, "Home - returns to the top of the file"); mvwprintw(help, 15, 2, "End - jumps to the bottom of the file"); mvwprintw(help, 17, 12, "Press enter to continue"); } wnoutrefresh(ctrl); /* refresh new wins */ wnoutrefresh(help); wnoutrefresh(small); doupdate(); /* update screen */ wgetch(ctrl); /* wait for a char */ delwin(ctrl); /* delete help wins */ delwin(help); delwin(small); redrawwin(win->hex); /* redraw previous */ redrawwin(win->ascii); redrawwin(win->address); wnoutrefresh(win->hex); /* refresh */ wnoutrefresh(win->ascii); wnoutrefresh(win->address); doupdate(); /* update screen */}
开发者ID:nilcons-contrib,项目名称:hexcurse,代码行数:85,
示例26: handleInputbool handleInput(int sock, struct addrinfo * p) { int charRead; while(true) { if(timeForKeepAlive) { sendKeepAlivePacket(sock, p); timeForKeepAlive = false; } handleNetwork(sock, p); charRead = wgetch(inputWnd); if(charRead == 127 && nchars > 0) { int cy, cx; getyx(inputWnd, cy, cx); mvwaddch(inputWnd, cy, cx-1, ' '); wmove(inputWnd, cy, cx-1); line[nchars] = '/0'; --nchars; return true; } else if(charRead >= 32 && charRead <= 126 && nchars < MAXLINE) { wechochar(inputWnd, charRead); line[nchars] = charRead; refreshAll(); ++nchars; return true; } else if(charRead == '/n') { if(strncmp(line, "/exit", std::max(nchars, MAXLINE+1)) == 0) { return false; } else if(strncmp(line, "/join ", 6) == 0) { sendJoinPacket(sock, p, &(line[6])); memset(curChannel, '/0', CHANNEL_MAX+1); strncpy(curChannel, &(line[6]), CHANNEL_MAX); channelsJoined.insert(curChannel); } else if(strncmp(line, "/switch ", 8) == 0) { char chanName[CHANNEL_MAX+1]; memset(chanName, '/0', CHANNEL_MAX+1); strncpy(chanName, &(line[8]), CHANNEL_MAX); if(channelsJoined.count(chanName) > 0) { strncpy(curChannel, chanName, CHANNEL_MAX); } else { char err[256]; snprintf(err, 256, "you have not subscribed to channel %.32s", chanName); printErrorMsg(err); } } else if(strncmp(line, "/leave ", 7) == 0) { sendLeavePacket(sock, p, &(line[7])); memset(curChannel, '/0', CHANNEL_MAX+1); strncpy(curChannel, &(line[7]), CHANNEL_MAX); channelsJoined.erase(curChannel); memset(curChannel, '/0', CHANNEL_MAX); } else if(strncmp(line, "/list", 5) == 0) { sendListPacket(sock, p); } else if(strncmp(line, "/who ", 5) == 0) { sendWhoPacket(sock, p, &(line[5])); } else if(line[0] == '/') { printErrorMsg("unrecognized command"); } else if(curChannel[0] != '/0'){ sendSayPacket(sock, p, curChannel, line); } //wprintw(wnd, "%s/n", line); memset(line, '/0', MAXLINE+1); clearInput(); return true; } };}
开发者ID:nchaimov,项目名称:cis532-duckchat,代码行数:64,
示例27: start_ncursesint start_ncurses(const char *prog_name, const char *real_prog_name){#if defined(DJGPP) || defined(__MINGW32__) if(initscr()==NULL) { log_critical("initscr() has failed. Exiting/n"); printf("initscr() has failed. Exiting/n"); printf("Press Enter key to quit./n"); (void)getchar(); return 1; }#else get_newterm(real_prog_name); if(screenp==NULL) { log_critical("Terminfo file is missing./n");#if defined(__CYGWIN__) printf("The terminfo file '63//cygwin' is missing./n");#else printf("Terminfo file is missing./n");#endif printf("Extract all files and subdirectories before running the program./n"); printf("Press Enter key to quit./n"); (void)getchar(); return 1; }#endif /* Should solve a problem with users who redefined the colors */ if(has_colors()) { start_color();#ifdef HAVE_ASSUME_DEFAULT_COLORS assume_default_colors(COLOR_WHITE,COLOR_BLACK);#endif init_pair(1, COLOR_RED, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); } noecho();#ifndef DJGPP nonl(); /*don't use for Dos version but enter will work with it... dilema */#endif /* intrflush(stdscr, FALSE); */ cbreak(); curs_set(0); { int quit=0; while(LINES>=8 && LINES<MINIMUM_LINES && quit==0) { aff_copy(stdscr); wmove(stdscr,4,0); wprintw(stdscr,"%s need %d lines to work.", prog_name, MINIMUM_LINES); wmove(stdscr,5,0); wprintw(stdscr,"Please enlarge the terminal."); wmove(stdscr,LINES-2,0); wattrset(stdscr, A_REVERSE); waddstr(stdscr,"[ Quit ]"); wattroff(stdscr, A_REVERSE); wrefresh(stdscr); switch(wgetch(stdscr)) { case 'q': case 'Q': case KEY_ENTER:#ifdef PADENTER case PADENTER:#endif case '/n': case '/r': quit=1; break; } } } if(LINES < MINIMUM_LINES) { end_ncurses(); printf("%s need %d lines to work./nPlease enlarge the terminal and restart %s./n", prog_name, MINIMUM_LINES, prog_name); log_critical("Terminal has only %d lines/n",LINES); return 1; } return 0;}
开发者ID:AndrewSmart,项目名称:testdisk,代码行数:82,
示例28: mainint main(int argc, char *argv[]){ WINDOW *p; FILE *f; int ch; initscr(); savetty(); noecho();//disable auto-echoing cbreak();//making getch() work without a buffer I.E. raw characters keypad(stdscr,TRUE);//allows use of special keys, namely the arrow keys clear(); // empty the screen timeout(0); /* create a new pad */ p = newpad(WIDE,COLS); keypad(p, TRUE); if( p == NULL ) printf("Unable to create new pad/n"); load_file(p, f, argv[1]); // open and load the file on the screen /* display the pad’s contents on the screen */ prefresh(p,0, 0, 0,0, LINES-1,COLS-1); int c, cursorY=0, cursorX=0, linseCount = 0; while((c=wgetch(p))!='q'){ switch(c){ case KEY_LEFT: if(cursorX != 0) cursorX--; break; case KEY_RIGHT: if (cursorX != COLS-1) cursorX++; break; case KEY_UP: if(cursorY==0 && linseCount==0) break; else if(cursorY == linseCount){ cursorY--; linseCount--; prefresh(p,linseCount, 0, 0,0, LINES-1,COLS-1); } else cursorY--; break; case KEY_DOWN: if(cursorY==LINES-1 && linseCount==WIDE-1) break; else if(cursorY == linseCount+LINES-1){ cursorY++; linseCount++; prefresh(p,linseCount, 0, 0,0, LINES-1,COLS-1); } else cursorY++; break; } wmove(p,cursorY,cursorX); prefresh(p,linseCount, 0, 0,0, LINES-1,COLS-1); } endwin(); return 0;}
开发者ID:johnnywell,项目名称:NginTextEditor,代码行数:64,
示例29: get_stringint get_string(WINDOW *window, char *str, const int len, const char *def){ int c; int i = 0; int x, y; int use_def = FALSE; curs_set(1); getyx(window, y, x); str[0] = 0; if (def != NULL) { mvwaddstr(window,y, x, def); wmove(window,y, x); use_def = TRUE; } wrefresh(window); while ((c = wgetch(window)) != '/n' && c != key_CR#ifdef PADENTER && c!= PADENTER#endif ) { switch (c) { /* escape is generated by enter from keypad */ /* case key_ESC: wmove(window,y, x); wclrtoeol(window); curs_set(0); wrefresh(window); return GS_key_ESCAPE; */ case KEY_DC: case KEY_BACKSPACE: if (i > 0) { str[--i] = 0; mvwaddch(window, y, x+i, ' '); wmove(window,y, x+i); } else if (use_def) { wclrtoeol(window); use_def = FALSE; } break; default: if (i < len && isprint(c)) { mvwaddch(window, y, x+i, c); if (use_def) { wclrtoeol(window); use_def = FALSE; } str[i++] = c; str[i] = 0; } } wrefresh(window); } curs_set(0); wrefresh(window); if (use_def) return GS_DEFAULT; else return i;}
开发者ID:AndrewSmart,项目名称:testdisk,代码行数:64,
示例30: call_list_helpintcall_list_help(PANEL *panel){ WINDOW *help_win; int height, width; // Create a new panel and show centered height = 28; width = 65; help_win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2); // Set the window title mvwprintw(help_win, 1, 25, "Call List Help"); // Write border and boxes around the window wattron(help_win, COLOR_PAIR(CP_BLUE_ON_DEF)); box(help_win, 0, 0); mvwhline(help_win, 2, 1, ACS_HLINE, width - 2); mvwhline(help_win, 7, 1, ACS_HLINE, width - 2); mvwhline(help_win, height - 3, 1, ACS_HLINE, width - 2); mvwaddch(help_win, 2, 0, ACS_LTEE); mvwaddch(help_win, 7, 0, ACS_LTEE); mvwaddch(help_win, height - 3, 0, ACS_LTEE); mvwaddch(help_win, 2, 64, ACS_RTEE); mvwaddch(help_win, 7, 64, ACS_RTEE); mvwaddch(help_win, height - 3, 64, ACS_RTEE); // Set the window footer (nice blue?) mvwprintw(help_win, height - 2, 20, "Press any key to continue"); // Some brief explanation abotu what window shows wattron(help_win, COLOR_PAIR(CP_CYAN_ON_DEF)); mvwprintw(help_win, 3, 2, "This windows show the list of parsed calls from a pcap file "); mvwprintw(help_win, 4, 2, "(Offline) or a live capture with libpcap functions (Online)."); mvwprintw(help_win, 5, 2, "You can configure the columns shown in this screen and some"); mvwprintw(help_win, 6, 2, "static filters using sngreprc resource file."); wattroff(help_win, COLOR_PAIR(CP_CYAN_ON_DEF)); // A list of available keys in this window mvwprintw(help_win, 8, 2, "Available keys:"); mvwprintw(help_win, 10, 2, "Esc/Q Exit sngrep."); mvwprintw(help_win, 11, 2, "Enter Show selected calls message flow"); mvwprintw(help_win, 12, 2, "Space Select call"); mvwprintw(help_win, 13, 2, "F1/h Show this screen"); mvwprintw(help_win, 14, 2, "F2/S Save captured packages to a file"); mvwprintw(help_win, 15, 2, "F3// Display filtering (match string case insensitive)"); mvwprintw(help_win, 16, 2, "F4/X Show selected call-flow (Extended) if available"); mvwprintw(help_win, 17, 2, "F5 Clear call list (can not be undone!)"); mvwprintw(help_win, 18, 2, "F6/R Show selected call messages in raw mode"); mvwprintw(help_win, 19, 2, "F7/F Show filter options"); mvwprintw(help_win, 20, 2, "F8/c Turn on/off window colours"); mvwprintw(help_win, 21, 2, "F9/l Turn on/off resolved addresses"); mvwprintw(help_win, 22, 2, "F10/t Select displayed columns"); mvwprintw(help_win, 23, 2, "i/I Set display filter to invite"); mvwprintw(help_win, 24, 2, "p Stop/Resume packet capture"); // Press any key to close wgetch(help_win); delwin(help_win); return 0;}
开发者ID:dynax60,项目名称:sngrep,代码行数:62,
注:本文中的wgetch函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ wgetnstr函数代码示例 C++ wfree函数代码示例 |