这篇教程C++ waddstr函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中waddstr函数的典型用法代码示例。如果您正苦于以下问题:C++ waddstr函数的具体用法?C++ waddstr怎么用?C++ waddstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了waddstr函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: get_search_term/* * Display a dialog box and get the search term from user */static intget_search_term (WINDOW * win, char *search_term, int height, int width){ int i, x, y, input_x = 0, scroll = 0, key = 0; int box_height = 3, box_width = 30; x = (width - box_width) / 2; y = (height - box_height) / 2;#ifdef HAVE_LIBNCURSES if (use_shadow) draw_shadow (win, y, x, box_height, box_width);#endif draw_box (win, y, x, box_height, box_width, dialog_attr, searchbox_border_attr); wattrset (win, searchbox_title_attr); wmove (win, y, x + box_width / 2 - 4); waddstr (win, " Search "); box_width -= 2; wmove (win, y + 1, x + 1); wrefresh (win); search_term[0] = '/0'; wattrset (win, searchbox_attr); while (key != ESC) { key = wgetch (win); switch (key) { case '/n': if (search_term[0] != '/0') return 0; break; case KEY_BACKSPACE: case 127: if (input_x || scroll) { if (!input_x) { scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); wmove (win, y + 1, x + 1); for (i = 0; i < box_width; i++) waddch (win, search_term[scroll + input_x + i] ? search_term[scroll + input_x + i] : ' '); input_x = strlen (search_term) - scroll; } else input_x--; search_term[scroll + input_x] = '/0'; wmove (win, y + 1, input_x + x + 1); waddch (win, ' '); wmove (win, y + 1, input_x + x + 1); wrefresh (win); } break; case ESC: break; default: if (isprint (key)) if (scroll + input_x < MAX_LEN) { search_term[scroll + input_x] = key; search_term[scroll + input_x + 1] = '/0'; if (input_x == box_width - 1) { scroll++; wmove (win, y + 1, x + 1); for (i = 0; i < box_width - 1; i++) waddch (win, search_term[scroll + i]); } else { wmove (win, y + 1, input_x++ + x + 1); waddch (win, key); } wrefresh (win); } } } return -1; /* ESC pressed */}
开发者ID:zear,项目名称:sabre,代码行数:76,
示例2: switchvoid Screen::Print() { w->ReadLock(); if ( updated || !player ) { w->Unlock(); return; } updated=true; switch ( player->UsingType() ) { case OPEN: PrintInv(rightWin, player->UsingBlock()->HasInventory()); break; default: PrintFront(rightWin); } switch ( player->UsingSelfType() ) { case OPEN: if ( player->PlayerInventory() ) { PrintInv(leftWin, player->PlayerInventory()); break; } //no break; default: PrintNormal(leftWin); } const short dur=player->HP(); const short breath=player->Breath(); const short satiation=player->Satiation(); werase(hudWin); ushort i; //quick inventory Inventory * const inv=player->GetP() ? player->GetP()->HasInventory() : 0; if ( inv ) { for (i=0; i<inv->Size(); ++i) { wstandend(hudWin); const int x=36+i*2; mvwaddch(hudWin, 0, x, 'a'+i); if ( inv->Number(i) ) { wcolor_set(hudWin, Color( inv->GetInvKind(i), inv->GetInvSub(i) ), NULL); mvwaddch(hudWin, 1, x, CharName( inv->GetInvKind(i), inv->GetInvSub(i) )); mvwprintw(hudWin, 2, x, "%hu", inv->Number(i)); } } } w->Unlock(); wstandend(leftWin); QString str; if ( -1!=dur ) { //HitPoints line str=QString("%1").arg(dur, -10, 10, QChar('.')); mvwaddstr(leftWin, SCREEN_SIZE+1, 1, "HP[..........]"); wcolor_set(leftWin, WHITE_RED, NULL); mvwaddstr(leftWin, SCREEN_SIZE+1, 4, qPrintable(str.left(10*dur/MAX_DURABILITY+1))); wstandend(leftWin); } if ( -1!=breath ) { //breath line str=QString("%1").arg(breath, -10, 10, QChar('.')); mvwaddstr(leftWin, SCREEN_SIZE+1, SCREEN_SIZE*2-13, "BR[..........]"); wcolor_set(leftWin, WHITE_BLUE, NULL); mvwaddstr(leftWin, SCREEN_SIZE+1, SCREEN_SIZE*2-13+3, qPrintable(str.left(10*breath/MAX_BREATH+1))); } //action mode (void)wmove(hudWin, 0, 0); wstandend(hudWin); waddstr(hudWin, "Action: "); switch ( actionMode ) { case USE: waddstr(hudWin, "Use in inventory"); break; case THROW: waddstr(hudWin, "Throw"); break; case OBTAIN: waddstr(hudWin, "Obtain"); break; case WIELD: waddstr(hudWin, "Wield"); break; case INSCRIBE: waddstr(hudWin, "Inscribe in inventory"); break; case EAT: waddstr(hudWin, "Eat"); break; case BUILD: waddstr(hudWin, "Build"); break; case CRAFT: waddstr(hudWin, "Craft"); break; case TAKEOFF: waddstr(hudWin, "Take off"); break; default: waddstr(hudWin, "Unknown"); fprintf(stderr, "Screen::Print: Unlisted actionMode: %d/n", actionMode); } if ( -1!=satiation ) { //satiation line (void)wmove(hudWin, 1, 0); if ( SECONDS_IN_DAY<satiation ) { wcolor_set(hudWin, BLUE_BLACK, NULL); waddstr(hudWin, "Gorged"); } else if ( 3*SECONDS_IN_DAY/4<satiation ) { wcolor_set(hudWin, GREEN_BLACK, NULL); waddstr(hudWin, "Full"); } else if (SECONDS_IN_DAY/4>satiation) {//.........这里部分代码省略.........
开发者ID:Panzerschrek,项目名称:FREG,代码行数:101,
示例3: print_channelvoid print_channel(struct deviceinfo *unit){ int i = 0, option = EOF, scr_opt = 0; int rc; fd_set rfds; struct timeval tv; int max_fd; struct digi_node node; struct digi_chan chan; int port = 0; char ttyname[100]; int d_invokes_capture = 1; /* 0 if 'D' should invoke "exam_panel" */ /* 1 if 'D' should invoke "scope_panel" */ WINDOW *chanwin = GetWin(ChanWin); /* * scr_opt is just used to determine which field to * highlight. */ show_panel (GetPan(ChanWin)); update_panels (); doupdate (); DPAOpenDevice(unit); while ((option != 'Q') && (option != 'q') && (option != ESC)) { /* Get port info for current port */ DPAGetNode(unit, &node); DPAGetChannel(unit, &chan, port); if (DPAGetPortName(unit, &node, &chan, port, ttyname) == NULL) { ttyname[0] = '/0'; } max_fd = 0; FD_ZERO(&rfds); FD_SET(0, &rfds); mvwprintw (chanwin, 1, 2, "Device Description: %-54.54s", node.nd_ps_desc); mvwprintw (chanwin, 5, 35, "Name: %-10.10s", ttyname); wattrset (chanwin, make_attr (A_BOLD, WHITE, BLACK)); mvwprintw (chanwin, 5, 56, "Status: %-10.10s", chan.ch_open ? "Open" : "Closed"); wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK)); if (scr_opt == 1) { wattrset (chanwin, make_attr (A_REVERSE | A_STANDOUT, WHITE, BLACK)); mvwprintw (chanwin, 3, 5, "Unit IP Address: %-15.15s", unit->host); wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK)); mvwprintw (chanwin, 5, 8, "Port Number : %-2d", port + 1); } else if (scr_opt == 2) { wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK)); mvwprintw (chanwin, 3, 5, "Unit IP Address: %-15.15s", unit->host); wattrset (chanwin, make_attr (A_REVERSE | A_STANDOUT, WHITE, BLACK)); mvwprintw (chanwin, 5, 8, "Port Number : %-2d", port + 1); wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK)); } else { mvwprintw (chanwin, 3, 5, "Unit IP Address: %-15.15s", unit->host); mvwprintw (chanwin, 5, 8, "Port Number : %-2d", port + 1); } if (!vanilla) wattrset (chanwin, make_attr (A_ALTCHARSET, GREEN, BLACK)); else wattrset (chanwin, make_attr (A_NORMAL, GREEN, BLACK)); for (i = 0; i < 62; i++) mvwaddch (chanwin, 6, 8 + i, mapchar(ACS_HLINE)); mvwaddch (chanwin, 6, 7, mapchar(ACS_ULCORNER)); mvwaddch (chanwin, 6, 70, mapchar(ACS_URCORNER)); mvwaddch (chanwin, 7, 7, mapchar(ACS_VLINE)); mvwaddch (chanwin, 7, 70, mapchar(ACS_VLINE)); mvwaddch (chanwin, 8, 7, mapchar(ACS_VLINE)); mvwaddch (chanwin, 8, 70, mapchar(ACS_VLINE)); wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK)); mvwprintw (chanwin, 12, 24, "Signal Active = "); wattrset (chanwin, make_attr (A_STANDOUT, WHITE, GREEN)); waddstr (chanwin, "X"); wattrset (chanwin, make_attr (A_NORMAL, WHITE, BLACK)); mvwaddstr (chanwin, 12, 46, "Inactive ="); wattrset (chanwin, make_attr (A_NORMAL, GREEN, BLACK)); mvwaddstr (chanwin, 12, 57, "_");//.........这里部分代码省略.........
开发者ID:linuxha,项目名称:dgrp,代码行数:101,
示例4: help_edit_field/* * Display a temporary window listing the keystroke-commands we recognize. */voidhelp_edit_field(void){ int x0 = 4; int y0 = 2; int y1 = 0; int y2 = 0; int wide = COLS - ((x0 + 1) * 2); int high = LINES - ((y0 + 1) * 2); WINDOW *help = newwin(high, wide, y0, x0); WINDOW *data = newpad(2 + SIZEOF(commands), wide - 4); unsigned n; int ch = ERR; begin_popup(); keypad(help, TRUE); keypad(data, TRUE); waddstr(data, "Defined form edit/traversal keys:/n"); for (n = 0; n < SIZEOF(commands); ++n) { const char *name;#ifdef NCURSES_VERSION if ((name = form_request_name(commands[n].result)) == 0)#endif name = commands[n].help; wprintw(data, "%s -- %s/n", keyname(commands[n].code), name != 0 ? name : commands[n].help); } waddstr(data, "Arrow keys move within a field as you would expect."); y2 = getcury(data); do { switch (ch) { case KEY_HOME: y1 = 0; break; case KEY_END: y1 = y2; break; case KEY_PREVIOUS: case KEY_PPAGE: if (y1 > 0) { y1 -= high / 2; if (y1 < 0) y1 = 0; } else { beep(); } break; case KEY_NEXT: case KEY_NPAGE: if (y1 < y2) { y1 += high / 2; if (y1 >= y2) y1 = y2; } else { beep(); } break; case CTRL('P'): case KEY_UP: if (y1 > 0) --y1; else beep(); break; case CTRL('N'): case KEY_DOWN: if (y1 < y2) ++y1; else beep(); break; default: beep(); break; case ERR: break; } werase(help); box(help, 0, 0); wnoutrefresh(help); pnoutrefresh(data, y1, 0, y0 + 1, x0 + 1, high, wide); doupdate(); } while ((ch = wgetch(data)) != ERR && ch != QUIT && ch != ESCAPE); werase(help); wrefresh(help); delwin(help); delwin(data); end_popup();}
开发者ID:AaronDP,项目名称:ncurses-5.9_adbshell,代码行数:96,
示例5: show_interactive_menuvoidshow_interactive_menu (void){ int search_win = 0; int time_win = 0; int i; int y, x; time_t t; WINDOW *win = initscr (); start_color (); cbreak (); noecho (); nonl (); intrflush (win, FALSE); curs_set (0); keypad (win, TRUE); while (1) { werase (win); getmaxyx (win, y, x); time (&t); /* * Check if there is enough horizontal space to draw the package * name, version and date+time. */ if (x > strlen (PACKAGE_NAME) + strlen (PACKAGE_VERSION) + 28) { wmove (win, 0, 1); waddstr (win, PACKAGE_NAME); wmove (win, 0, (x - 24) / 2); attrset (A_BOLD); waddnstr (win, ctime (&t), 24); attrset (A_NORMAL); wmove (win, 0, x - strlen (PACKAGE_VERSION) - 1); waddstr (win, PACKAGE_VERSION); } else { /* * Check if there is enough horizontal space to draw the package * name and date+time. */ if (x > strlen (PACKAGE_NAME) + 26) { wmove (win, 0, 1); waddstr (win, PACKAGE_NAME); wmove (win, 0, x - 25); waddnstr (win, ctime (&t), 24); } else { /* * Check if there is enough horizontal space to draw the * date+time. */ if (x >= 24) { wmove (win, 0, (x - 24) / 2); waddnstr (win, ctime (&t), 24); } } } wmove (win, y - 1, 0); //waddnstr (win, "3.3k records", 12); waddnstr (win, "<CONN ERROR>", 12); wmove (win, y - 1, x - 5); waddnstr (win, "user", 4); /* Draw a horizontal line */ wmove (win, 1, 0); hline ('-', x); wmove (win, 1, x - 4); waddstr (win, "[R]"); wmove (win, 1, x - 8); waddstr (win, "[A]"); wmove (win, 1, x - 30); waddstr (win, "[Time ]"); wmove (win, 1, x - 60); waddstr (win, "[Value ]"); wmove (win, 1, 0); waddstr (win, "[Item ]"); if (time_win) { show_timeframe_dialog (win, 1, 5); } if (search_win)//.........这里部分代码省略.........
开发者ID:argux,项目名称:argux,代码行数:101,
示例6: put_boolvoidput_bool(void *b){ waddstr(hw, *(bool *) b ? "True" : "False");}
开发者ID:ashaindlin,项目名称:rogue,代码行数:5,
示例7: put_inv_tvoidput_inv_t(void *ip){ waddstr(hw, inv_t_name[*(int *) ip]);}
开发者ID:ashaindlin,项目名称:rogue,代码行数:5,
示例8: emu_exceptionvoid emu_exception(struct em8051 *aCPU, int aCode){ WINDOW * exc; switch (aCode) { case EXCEPTION_IRET_SP_MISMATCH: if (opt_exception_iret_sp) return; break; case EXCEPTION_IRET_ACC_MISMATCH: if (opt_exception_iret_acc) return; break; case EXCEPTION_IRET_PSW_MISMATCH: if (opt_exception_iret_psw) return; break; case EXCEPTION_ACC_TO_A: if (!opt_exception_acc_to_a) return; break; case EXCEPTION_STACK: if (!opt_exception_stack) return; break; case EXCEPTION_ILLEGAL_OPCODE: if (!opt_exception_invalid) return; break; } nocbreak(); cbreak(); nodelay(stdscr, FALSE); halfdelay(1); while (getch() > 0) {} runmode = 0; setSpeed(speed, runmode); exc = subwin(stdscr, 7, 50, (LINES-6)/2, (COLS-50)/2); wattron(exc,A_REVERSE); werase(exc); box(exc,ACS_VLINE,ACS_HLINE); mvwaddstr(exc, 0, 2, "Exception"); wattroff(exc,A_REVERSE); wmove(exc, 2, 2); switch (aCode) { case -1: waddstr(exc,"Breakpoint reached"); break; case EXCEPTION_STACK: waddstr(exc,"SP exception: stack address > 127"); wmove(exc, 3, 2); waddstr(exc,"with no upper memory, or SP roll over."); break; case EXCEPTION_ACC_TO_A: waddstr(exc,"Invalid operation: acc-to-a move operation"); break; case EXCEPTION_IRET_PSW_MISMATCH: waddstr(exc,"PSW not preserved over interrupt call"); break; case EXCEPTION_IRET_SP_MISMATCH: waddstr(exc,"SP not preserved over interrupt call"); break; case EXCEPTION_IRET_ACC_MISMATCH: waddstr(exc,"ACC not preserved over interrupt call"); break; case EXCEPTION_ILLEGAL_OPCODE: waddstr(exc,"Invalid opcode: 0xA5 encountered"); break; default: waddstr(exc,"Unknown exception"); } wmove(exc, 6, 12); wattron(exc,A_REVERSE); waddstr(exc, "Press any key to continue"); wattroff(exc,A_REVERSE); wrefresh(exc); getch(); delwin(exc); change_view(aCPU, MAIN_VIEW);}
开发者ID:Tonyxu82,项目名称:TFX8051,代码行数:75,
示例9: dialog_inputbox/* * Display a dialog box for inputing a string */int dialog_inputbox(const char *title, const char *prompt, int height, int width, const char *init){ WINDOW *dialog; unsigned char *instr = dialog_input_result; int i, x, y, box_y, box_x, box_width; int input_x = 0, scroll = 0, key = 0, button = -1; /* center dialog box on screen */ x = (COLS - width) / 2; y = (LINES - height) / 2; draw_shadow(stdscr, y, x, height, width); dialog = newwin(height, width, y, x); keypad(dialog, TRUE); draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); wattrset(dialog, border_attr); mvwaddch(dialog, height - 3, 0, ACS_LTEE); for (i = 0; i < width - 2; i++) waddch(dialog, ACS_HLINE); wattrset(dialog, dialog_attr); waddch(dialog, ACS_RTEE); if (title != NULL) { wattrset(dialog, title_attr); mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' '); waddstr(dialog, (char *) title); waddch(dialog, ' '); } wattrset(dialog, dialog_attr); print_autowrap(dialog, prompt, width - 2, 1, 3); /* Draw the input field box */ box_width = width - 6; getyx(dialog, y, x); box_y = y + 2; box_x = (width - box_width) / 2; draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, border_attr, dialog_attr); print_buttons(dialog, height, width, 0); /* Set up the initial value */ wmove(dialog, box_y, box_x); wattrset(dialog, inputbox_attr); if (!init) instr[0] = '/0'; else strcpy(instr, init); input_x = strlen(instr); if (input_x >= box_width) { scroll = input_x - box_width + 1; input_x = box_width - 1; for (i = 0; i < box_width - 1; i++) waddch(dialog, instr[scroll + i]); } else waddstr(dialog, instr); wmove(dialog, box_y, box_x + input_x); wrefresh(dialog); while (key != ESC) { key = wgetch(dialog); if (button == -1) { /* Input box selected */ switch (key) { case TAB: case KEY_UP: case KEY_DOWN: break; case KEY_LEFT: continue; case KEY_RIGHT: continue; case KEY_BACKSPACE: case 127: if (input_x || scroll) { wattrset(dialog, inputbox_attr); if (!input_x) { scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); wmove(dialog, box_y, box_x); for (i = 0; i < box_width; i++) waddch(dialog, instr[scroll + input_x + i] ? instr[scroll + input_x + i] : ' '); input_x = strlen(instr) - scroll; } else input_x--; instr[scroll + input_x] = '/0'; mvwaddch(dialog, box_y, input_x + box_x, ' ');//.........这里部分代码省略.........
开发者ID:Edwin-Edward,项目名称:elks,代码行数:101,
示例10: emu_loadvoid emu_load(struct em8051 *aCPU){ WINDOW * exc; int pos = 0; int ch = 0; int result; pos = (int)strlen(filename); runmode = 0; setSpeed(speed, runmode); exc = subwin(stdscr, 5, 50, (LINES-6)/2, (COLS-50)/2); wattron(exc, A_REVERSE); werase(exc); box(exc,ACS_VLINE,ACS_HLINE); mvwaddstr(exc, 0, 2, "Load Intel HEX File"); wattroff(exc, A_REVERSE); wmove(exc, 2, 2); // 12345678901234567890123456780123456789012345 waddstr(exc,"[____________________________________________]"); wmove(exc,2,3); waddstr(exc, filename); wrefresh(exc); while (ch != '/n') { ch = getch(); if (ch > 31 && ch < 127 || ch > 127 && ch < 255) { if (pos < 44) { filename[pos] = ch; pos++; filename[pos] = 0; waddch(exc,ch); wrefresh(exc); } } if (ch == KEY_DC || ch == 8 || ch == KEY_BACKSPACE) { if (pos > 0) { pos--; filename[pos] = 0; wmove(exc,2,3+pos); waddch(exc,'_'); wmove(exc,2,3+pos); wrefresh(exc); } } } result = load_obj(aCPU, filename); delwin(exc); refreshview(aCPU); switch (result) { case -1: emu_popup(aCPU, "Load error", "File not found."); break; case -2: emu_popup(aCPU, "Load error", "Bad file format."); break; case -3: emu_popup(aCPU, "Load error", "Unsupported HEX file version."); break; case -4: emu_popup(aCPU, "Load error", "Checksum failure."); break; case -5: emu_popup(aCPU, "Load error", "No end of data marker found."); break; }}
开发者ID:Tonyxu82,项目名称:TFX8051,代码行数:74,
示例11: emu_readvalueint emu_readvalue(struct em8051 *aCPU, const char *aPrompt, int aOldvalue, int aValueSize){ WINDOW * exc; int pos = 0; int ch = 0; char temp[16]; pos = aValueSize; runmode = 0; setSpeed(speed, runmode); if (aValueSize == 2) exc = subwin(stdscr, 5, 30, (LINES-6)/2, (COLS-30)/2); else exc = subwin(stdscr, 5, 50, (LINES-6)/2, (COLS-50)/2); wattron(exc,A_REVERSE); werase(exc); box(exc,ACS_VLINE,ACS_HLINE); mvwaddstr(exc, 0, 2, aPrompt); wattroff(exc,A_REVERSE); wmove(exc, 2, 2); if (aValueSize == 2) { sprintf(temp, "%02X", aOldvalue); waddstr(exc,"[__]"); wmove(exc,2,3); waddstr(exc, temp); } else { sprintf(temp, "%04X", aOldvalue); waddstr(exc,"[____]"); wmove(exc,2,3); waddstr(exc, temp); } wrefresh(exc); do { if (aValueSize == 2) { int currvalue = strtol(temp, NULL, 16); wmove(exc,2,5 + aValueSize); wprintw(exc,"%d %d %d %d %d %d %d %d", (currvalue >> 7) & 1, (currvalue >> 6) & 1, (currvalue >> 5) & 1, (currvalue >> 4) & 1, (currvalue >> 3) & 1, (currvalue >> 2) & 1, (currvalue >> 1) & 1, (currvalue >> 0) & 1); } else { int currvalue = strtol(temp, NULL, 16); char assembly[64]; decode(aCPU, currvalue, assembly); wmove(exc,2,5 + aValueSize); waddstr(exc, " "); wmove(exc,2,5 + aValueSize); waddstr(exc, assembly); } wmove(exc,2,3 + pos); wrefresh(exc); ch = getch(); if (ch >= '0' && ch <= '9' || ch >= 'a' && ch <= 'f' || ch >= 'A' && ch <= 'F') { if (pos < aValueSize) { temp[pos] = ch; pos++; temp[pos] = 0; waddch(exc,ch); } } if (ch == KEY_DC || ch == 8 || ch == KEY_BACKSPACE) { if (pos > 0) { pos--; temp[pos] = 0; wmove(exc,2,3+pos); waddch(exc,'_'); wmove(exc,2,3+pos); } } }
开发者ID:Tonyxu82,项目名称:TFX8051,代码行数:87,
示例12: wgetnstr// for emscriptenint wgetnstr(WINDOW *win, char *str, int n){#ifdef PDC_WIDE wchar_t wstr[MAXLINE + 1]; if (n < 0 || n > MAXLINE) n = MAXLINE; if (wgetn_wstr(win, (wint_t *)wstr, n) == ERR) return ERR; return PDC_wcstombs(str, wstr, n);#else int ch, i, num, x, chars; char *p; bool stop, oldecho, oldcbreak, oldnodelay; PDC_LOG(("wgetnstr() - called/n")); if (!win || !str) return ERR; chars = 0; p = str; stop = FALSE; x = win->_curx; oldcbreak = SP->cbreak; /* remember states */ oldecho = SP->echo; oldnodelay = win->_nodelay; SP->echo = FALSE; /* we do echo ourselves */ cbreak(); /* ensure each key is returned immediately */ win->_nodelay = FALSE; /* don't return -1 */ wrefresh(win); while (!stop) { ch = wgetch(win); switch (ch) { case '/t': ch = ' '; num = TABSIZE - (win->_curx - x) % TABSIZE; for (i = 0; i < num; i++) { if (chars < n) { if (oldecho) waddch(win, ch); *p++ = ch; ++chars; } else beep(); } break; case _ECHAR: /* CTRL-H -- Delete character */ if (p > str) { if (oldecho) waddstr(win, "/b /b"); ch = (unsigned char)(*--p); if ((ch < ' ') && (oldecho)) waddstr(win, "/b /b"); chars--; } break; case _DLCHAR: /* CTRL-U -- Delete line */ while (p > str) { if (oldecho) waddstr(win, "/b /b"); ch = (unsigned char)(*--p); if ((ch < ' ') && (oldecho)) waddstr(win, "/b /b"); } chars = 0; break; case _DWCHAR: /* CTRL-W -- Delete word */ while ((p > str) && (*(p - 1) == ' ')) { if (oldecho) waddstr(win, "/b /b"); --p; /* remove space */ chars--; } while ((p > str) && (*(p - 1) != ' ')) { if (oldecho) //.........这里部分代码省略.........
开发者ID:ethanliew,项目名称:PDCurses-emscripten,代码行数:101,
示例13: wgetnstr_async_1static void wgetnstr_async_1(void *arg){ char *p = wgetnstr_async__p; char *str = wgetnstr_async__str; int chars = wgetnstr_async__chars; int n = wgetnstr_async__n; WINDOW * win = wgetnstr_async__win; bool oldecho = wgetnstr_async__oldecho; bool oldcbreak = wgetnstr_async__oldcbreak; bool oldnodelay = wgetnstr_async__oldnodelay; int ch = (int)arg; int i,num; switch (ch) { case '/t': ch = ' '; num = TABSIZE - (win->_curx - wgetnstr_async__x) % TABSIZE; for (i = 0; i < num; i++) { if (chars < n) { if (oldecho) waddch(win, ch); *p++ = ch; ++chars; } else beep(); } break; case _ECHAR: /* CTRL-H -- Delete character */ if (p > str) { if (oldecho) waddstr(win, "/b /b"); ch = (unsigned char)(*--p); if ((ch < ' ') && (oldecho)) waddstr(win, "/b /b"); chars--; } break; case _DLCHAR: /* CTRL-U -- Delete line */ while (p > str) { if (oldecho) waddstr(win, "/b /b"); ch = (unsigned char)(*--p); if ((ch < ' ') && (oldecho)) waddstr(win, "/b /b"); } chars = 0; break; case _DWCHAR: /* CTRL-W -- Delete word */ while ((p > str) && (*(p - 1) == ' ')) { if (oldecho) waddstr(win, "/b /b"); --p; /* remove space */ chars--; } while ((p > str) && (*(p - 1) != ' ')) { if (oldecho) waddstr(win, "/b /b"); ch = (unsigned char)(*--p); if ((ch < ' ') && (oldecho)) waddstr(win, "/b /b"); chars--; } break; case '/n': case '/r': wgetnstr_async__stop = TRUE; if (oldecho) waddch(win, '/n'); break; default: if (chars < n) { if (!SP->key_code && ch < 0x100) { *p++ = ch; if (oldecho) waddch(win, ch); chars++; } } else beep();//.........这里部分代码省略.........
开发者ID:ethanliew,项目名称:PDCurses-emscripten,代码行数:101,
示例14: get_monster_numberintget_monster_number(char *message){ int i; int pres_monst = 1; int ret_val = -1; char buf[2 * LINELEN]; char monst_name[2 * LINELEN]; while (ret_val == -1) { msg("Which monster do you wish to %s? (* for list)", message); if ((get_string(buf, cw)) != NORM) return(0); if ((i = atoi(buf)) != 0) ret_val = i; else if (buf[0] != '*') { for (i = 1; i < nummonst; i++) if ((strcmp(monsters[i].m_name, buf) == 0)) ret_val = i; } /* The following hack should be redone by the windowing code */ else while (pres_monst < nummonst) /* Print out the monsters */ { int num_lines = LINES - 3; wclear(hw); touchwin(hw); wmove(hw, 2, 0); for (i = 0; i < num_lines && pres_monst < nummonst; i++) { sprintf(monst_name, "[%d] %s/n", pres_monst, monsters[pres_monst].m_name); waddstr(hw, monst_name); pres_monst++; } if (pres_monst < nummonst) { mvwaddstr(hw, LINES - 1, 0, morestr); wrefresh(hw); wait_for(' '); } else { mvwaddstr(hw, 0, 0, "Which monster"); waddstr(hw, "? "); wrefresh(hw); } }get_monst: get_string(monst_name, hw); ret_val = atoi(monst_name); if ((ret_val < 1 || ret_val > nummonst - 1)) { mvwaddstr(hw, 0, 0, "Please enter a number in the displayed range -- "); wrefresh(hw); goto get_monst; } /* Set up for redraw */ clearok(cw, TRUE); touchwin(cw); } return(ret_val);}
开发者ID:RoguelikeRestorationProject,项目名称:urogue,代码行数:76,
示例15: cstrlen// Force text to the input screenvoid Terminal::in_print_(const char* input_){ cursX += cstrlen(input_); waddstr(input_window, input_); update_cursor_(); refresh_();}
开发者ID:pixie16,项目名称:PixieSuite2,代码行数:7,
示例16: _owl_fmtext_curs_waddstr/* add the formatted text to the curses window 'w'. The window 'w' * must already be initiatlized with curses */static void _owl_fmtext_curs_waddstr(const owl_fmtext *f, WINDOW *w, int do_search){ /* char *tmpbuff; */ /* int position, trans1, trans2, trans3, len, lastsame; */ char *s, *p; char attr; short fg, bg, pair = 0; if (w==NULL) { owl_function_debugmsg("Hit a null window in owl_fmtext_curs_waddstr."); return; } s = f->textbuff; /* Set default attributes. */ attr = f->default_attrs; fg = f->default_fgcolor; bg = f->default_bgcolor; _owl_fmtext_wattrset(w, attr); _owl_fmtext_update_colorpair(fg, bg, &pair); _owl_fmtext_wcolor_set(w, pair); /* Find next possible format character. */ p = strchr(s, OWL_FMTEXT_UC_STARTBYTE_UTF8); while(p) { if (owl_fmtext_is_format_char(g_utf8_get_char(p))) { /* Deal with all text from last insert to here. */ char tmp; tmp = p[0]; p[0] = '/0'; if (owl_global_is_search_active(&g)) { /* Search is active, so highlight search results. */ char tmp2; int start, end; while (owl_regex_compare(owl_global_get_search_re(&g), s, &start, &end) == 0) { /* Prevent an infinite loop matching the empty string. */ if (end == 0) break; /* Found search string, highlight it. */ tmp2 = s[start]; s[start] = '/0'; waddstr(w, s); s[start] = tmp2; _owl_fmtext_wattrset(w, attr ^ OWL_FMTEXT_ATTR_REVERSE); _owl_fmtext_wcolor_set(w, pair); tmp2 = s[end]; s[end] = '/0'; waddstr(w, s + start); s[end] = tmp2; _owl_fmtext_wattrset(w, attr); _owl_fmtext_wcolor_set(w, pair); s += end; } } /* Deal with remaining part of string. */ waddstr(w, s); p[0] = tmp; /* Deal with new attributes. Initialize to defaults, then process all consecutive formatting characters. */ attr = f->default_attrs; fg = f->default_fgcolor; bg = f->default_bgcolor; while (owl_fmtext_is_format_char(g_utf8_get_char(p))) { _owl_fmtext_update_attributes(g_utf8_get_char(p), &attr, &fg, &bg); p = g_utf8_next_char(p); } _owl_fmtext_wattrset(w, attr | f->default_attrs); if (fg == OWL_COLOR_DEFAULT) fg = f->default_fgcolor; if (bg == OWL_COLOR_DEFAULT) bg = f->default_bgcolor; _owl_fmtext_update_colorpair(fg, bg, &pair); _owl_fmtext_wcolor_set(w, pair); /* Advance to next non-formatting character. */ s = p; p = strchr(s, OWL_FMTEXT_UC_STARTBYTE_UTF8); } else { p = strchr(p+1, OWL_FMTEXT_UC_STARTBYTE_UTF8); } } if (s) { waddstr(w, s); } wbkgdset(w, 0);}
开发者ID:alexmv,项目名称:barnowl,代码行数:96,
示例17: print_autowrap/* * Print a string of text in a window, automatically wrap around to the * next line if the string is too long to fit on one line. Newline * characters '/n' are propperly processed. We start on a new line * if there is no room for at least 4 nonblanks following a double-space. */void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x){ int newl, cur_x, cur_y; int prompt_len, room, wlen; char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0; strcpy(tempstr, prompt); prompt_len = strlen(tempstr); if (prompt_len <= width - x * 2) { /* If prompt is short */ wmove(win, y, (width - prompt_len) / 2); waddstr(win, tempstr); } else { cur_x = x; cur_y = y; newl = 1; word = tempstr; while (word && *word) { sp = strpbrk(word, "/n "); if (sp && *sp == '/n') newline_separator = sp; if (sp) *sp++ = 0; /* Wrap to next line if either the word does not fit, or it is the first word of a new sentence, and it is short, and the next word does not fit. */ room = width - cur_x; wlen = strlen(word); if (wlen > room || (newl && wlen < 4 && sp && wlen + 1 + strlen(sp) > room && (!(sp2 = strpbrk(sp, "/n ")) || wlen + 1 + (sp2 - sp) > room))) { cur_y++; cur_x = x; } wmove(win, cur_y, cur_x); waddstr(win, word); getyx(win, cur_y, cur_x); /* Move to the next line if the word separator was a newline */ if (newline_separator) { cur_y++; cur_x = x; newline_separator = 0; } else cur_x++; if (sp && *sp == ' ') { cur_x++; /* double space */ while (*++sp == ' ') ; newl = 1; } else newl = 0; word = sp; } }}
开发者ID:01org,项目名称:CODK-A-Firmware,代码行数:67,
示例18: deathvoiddeath(int monst){ char **dp = (char **) rip, *killer; struct tm *lt; time_t date; char buf[80]; int c; if (is_wearing(R_RESURRECT) || rnd(wizard ? 3 : 67) == 0) { int die = TRUE; if (resurrect-- == 0) msg("You've run out of lives."); else if (!save_resurrect(ring_value(R_RESURRECT))) msg("Your attempt to return from the grave fails."); else { struct linked_list *item; struct linked_list *next_item; struct object *obj; int rm, flags; coord pos; die = FALSE; msg("You feel a sudden warmth and then nothingness."); teleport(); if (ring_value(R_RESURRECT) > 1 && rnd(10)) { pstats.s_hpt = 2 * pstats.s_const; pstats.s_const = max(pstats.s_const - 1, 3); } else { for (item = pack; item != NULL; item = next_item) { obj = OBJPTR(item); if (obj->o_flags & ISOWNED || obj->o_flags & ISPROT) { next_item = next(item); continue; } flags = obj->o_flags; obj->o_flags &= ~ISCURSED; dropcheck(obj); obj->o_flags = flags; next_item = next(item); rem_pack(obj); if (obj->o_type == ARTIFACT) has_artifact &= ~(1 << obj->o_which); do { rm = rnd_room(); rnd_pos(&rooms[rm], &pos); } while(winat(pos.y, pos.x) != FLOOR); obj->o_pos = pos; add_obj(item, obj->o_pos.y, obj->o_pos.x); } pstats.s_hpt = pstats.s_const; pstats.s_const = max(pstats.s_const - roll(2, 2), 3); } chg_str(roll(1, 4), TRUE, FALSE); pstats.s_lvl = max(pstats.s_lvl, 1); no_command += 2 + rnd(4); if (on(player, ISHUH)) lengthen_fuse(FUSE_UNCONFUSE, rnd(8) + HUHDURATION); else light_fuse(FUSE_UNCONFUSE, 0, rnd(8) + HUHDURATION, AFTER); turn_on(player, ISHUH); light(&hero); } if (die) { wmove(cw, mpos, 0); waddstr(cw, morestr); wrefresh(cw); wait_for(' '); } else return; } time(&date); lt = localtime(&date); clear(); wclear(cw); move(8, 0);//.........这里部分代码省略.........
开发者ID:RoguelikeRestorationProject,项目名称:urogue,代码行数:101,
示例19: put_strvoidput_str(void *str){ waddstr(hw, (char *) str);}
开发者ID:ashaindlin,项目名称:rogue,代码行数:5,
示例20: curses_form_draw/* * Render the given form (and all of the widgets it contains) in the * curses backing store. Does not cause the form to be displayed. */voidcurses_form_draw(struct curses_form *cf){ struct curses_widget *w; float sb_factor = 0.0; size_t sb_off = 0, sb_size = 0; curses_colors_set(cf->win, CURSES_COLORS_NORMAL); curses_window_blank(cf->win); curses_colors_set(cf->win, CURSES_COLORS_BORDER); /* draw_frame(cf->left - 1, cf->top - 1, cf->width + 2, cf->height + 2); */ wborder(cf->win, 0, 0, 0, 0, 0, 0, 0, 0); /* * If the internal dimensions of the form exceed the physical * dimensions, draw scrollbar(s) as appropriate. */ if (cf->int_height > cf->height) { sb_factor = (float)cf->height / (float)cf->int_height; sb_size = cf->height * sb_factor; if (sb_size == 0) sb_size = 1; sb_off = cf->y_offset * sb_factor; curses_colors_set(cf->win, CURSES_COLORS_SCROLLAREA); mvwvline(cf->win, 1, cf->width + 1, ACS_CKBOARD, cf->height); curses_colors_set(cf->win, CURSES_COLORS_SCROLLBAR); mvwvline(cf->win, 1 + sb_off, cf->width + 1, ACS_BLOCK, sb_size); } if (cf->int_width > cf->width) { sb_factor = (float)cf->width / (float)cf->int_width; sb_size = cf->width * sb_factor; if (sb_size == 0) sb_size = 1; sb_off = cf->x_offset * sb_factor; curses_colors_set(cf->win, CURSES_COLORS_SCROLLAREA); mvwhline(cf->win, cf->height + 1, 1, ACS_CKBOARD, cf->width); curses_colors_set(cf->win, CURSES_COLORS_SCROLLBAR); mvwhline(cf->win, cf->height + 1, 1 + sb_off, ACS_BLOCK, sb_size); } curses_colors_set(cf->win, CURSES_COLORS_BORDER); /* * Render the title bar text. */ wmove(cf->win, 0, (cf->width - strlen(cf->title)) / 2 - 1); waddch(cf->win, ACS_RTEE); waddch(cf->win, ' '); curses_colors_set(cf->win, CURSES_COLORS_FORMTITLE); waddstr(cf->win, cf->title); curses_colors_set(cf->win, CURSES_COLORS_BORDER); waddch(cf->win, ' '); waddch(cf->win, ACS_LTEE); /* * Render a "how to get help" reminder. */ if (cf->help_text != NULL) { static const char *help_msg = "Press F1 for Help"; wmove(cf->win, cf->height + 1, (cf->width - strlen(help_msg)) / 2 - 1); waddch(cf->win, ACS_RTEE); waddch(cf->win, ' '); curses_colors_set(cf->win, CURSES_COLORS_FORMTITLE); waddstr(cf->win, help_msg); curses_colors_set(cf->win, CURSES_COLORS_BORDER); waddch(cf->win, ' '); waddch(cf->win, ACS_LTEE); } /* * Render the widgets. */ for (w = cf->widget_head; w != NULL; w = w->next) { curses_widget_draw(w); } /* to put the cursor there */ curses_widget_draw_tooltip(cf->widget_focus); curses_widget_draw(cf->widget_focus);}
开发者ID:Key4ce,项目名称:bsdinstaller,代码行数:86,
示例21: get_strintget_str(void *vopt, WINDOW *win){ char *opt = (char *) vopt; char *sp; int oy, ox; int i; signed char c; static char buf[MAXSTR]; getyx(win, oy, ox); wrefresh(win); /* * loop reading in the string, and put it in a temporary buffer */ for (sp = buf; (c = readchar()) != '/n' && c != '/r' && c != ESCAPE; wclrtoeol(win), wrefresh(win)) { if (c == -1) continue; else if (c == erasechar() || c == 8 || c == 127) /* process erase character */ { if (sp > buf) { sp--; for (i = (int) strlen(unctrl(*sp)); i; i--) waddch(win, '/b'); } continue; } else if (c == killchar()) /* process kill character */ { sp = buf; wmove(win, oy, ox); continue; } else if (sp == buf) { if (c == '-' && win != stdscr) break; else if (c == '~') { strcpy(buf, home); waddstr(win, home); sp += strlen(home); continue; } } if (sp >= &buf[MAXINP] || !(isprint(c) || c == ' ')) putchar(CTRL('G')); else { *sp++ = c; waddstr(win, unctrl(c)); } } *sp = '/0'; if (sp > buf) /* only change option if something has been typed */ strucpy(opt, buf, (int) strlen(buf)); mvwprintw(win, oy, ox, "%s/n", opt); wrefresh(win); if (win == stdscr) mpos += (int)(sp - buf); if (c == '-') return MINUS; else if (c == ESCAPE) return QUIT; else return NORM;}
开发者ID:ashaindlin,项目名称:rogue,代码行数:70,
示例22: test_redraw//.........这里部分代码省略......... assert(win != 0); scrollok(win, TRUE); keypad(win, TRUE); getmaxyx(win, max_y, max_x); getbegyx(win, beg_y, beg_x); while (!done) { ch = wgetch(win); getyx(win, y, x); switch (ch) { case 'q': /* FALLTHRU */ case QUIT: case ESCAPE: done = TRUE; break; case 'w': win1 = newwin(max_y, max_x, beg_y, beg_x); win2 = newwin(max_y - 2, max_x - 2, beg_y + 1, beg_x + 1); box(win1, 0, 0); wrefresh(win1); test_redraw(win2); delwin(win2); delwin(win1); touchwin(win); break; case '!': /* * redrawwin() and wredrawln() do not take into account the * possibility that the cursor may have moved. That makes them * cumbersome for using with a shell command. So we simply * trash the current line of the window using backspace/overwrite. */ trash(beg_x, max_x, x + beg_x); break;#ifdef NCURSES_VERSION case '@': /* * For a shell command, we can work around the problem noted above * using mvcur(). It is ifdef'd for NCURSES, since X/Open does * not define the case where the old location is unknown. */ IGNORE_RC(system("date")); mvcur(-1, -1, y, x); break;#endif case CTRL('W'): redrawwin(win); break; case CTRL('L'): wredrawln(win, y, 1); break; case KEY_UP: if (y > 0) wmove(win, y - 1, x); break; case KEY_DOWN: if (y < max_y) wmove(win, y + 1, x); break; case KEY_LEFT: if (x > 0) wmove(win, y, x - 1); break; case KEY_RIGHT: if (x < max_x) wmove(win, y, x + 1); break; case HELP_KEY_1: popup_msg(win, help); break; default: if (ch > KEY_MIN) { waddstr(win, keyname(ch)); waddch(win, '/n'); } else { waddstr(win, unctrl(UChar(ch))); } break; } wnoutrefresh(win); doupdate(); }}
开发者ID:ThomasDickey,项目名称:ncurses-snapshots,代码行数:101,
示例23: display_calibrationvoid display_calibration(){ char line[COLS]; s_mouse_cal* mcal = cal_get_mouse(current_mouse, current_conf); if(current_cal == NONE) { mvaddstr(CAL_Y_P, CAL_X_P + 1, _("Mouse calibration (Ctrl+F1 to edit)")); } else { mvaddstr(CAL_Y_P, CAL_X_P + 1, _("Mouse calibration (Ctrl+F1 to save)(mouse wheel to change values)")); } clrtoeol(); wmove(wcal, 1, 1); if(GE_GetMKMode() == GE_MK_MODE_MULTIPLE_INPUTS) { waddstr(wcal, "Mouse:"); if(current_cal == MC) { wattron(wcal, COLOR_PAIR(4)); } snprintf(line, COLS, " %s (%d) (F1) ", GE_MouseName(current_mouse), GE_MouseVirtualId(current_mouse)); waddstr(wcal, line); if(current_cal == MC) { wattron(wcal, COLOR_PAIR(1)); } } waddstr(wcal, _("Profile:")); if(current_cal == CC) { wattron(wcal, COLOR_PAIR(4)); } snprintf(line, COLS, " %d (F2)", current_conf + 1); waddstr(wcal, line); if(current_cal == CC) { wattron(wcal, COLOR_PAIR(1)); } wclrtoeol(wcal); mvwaddstr(wcal, 2, 1, _("Dead zone:")); if(current_cal == DZX) { wattron(wcal, COLOR_PAIR(4)); } waddstr(wcal, " x="); if(mcal->dzx) { snprintf(line, COLS, "%d", *mcal->dzx); waddstr(wcal, line); } else { waddstr(wcal, _("N/A")); } waddstr(wcal, " (F3)"); if(current_cal == DZX) { wattron(wcal, COLOR_PAIR(1)); } if(current_cal == DZY) { wattron(wcal, COLOR_PAIR(4)); } waddstr(wcal, " y="); if(mcal->dzy) { snprintf(line, COLS, "%d", *mcal->dzy); waddstr(wcal, line); } else { waddstr(wcal, _("N/A")); } waddstr(wcal, " (F4)"); if(current_cal == DZY) { wattron(wcal, COLOR_PAIR(1)); } if(current_cal == DZS) { wattron(wcal, COLOR_PAIR(4)); } waddstr(wcal, _(" shape=")); if(mcal->dzs) { if (*mcal->dzs == E_SHAPE_CIRCLE) { waddstr(wcal, _("circle")); } else { waddstr(wcal, _("rectangle")); } } else { waddstr(wcal, _(" N/A")); }//.........这里部分代码省略.........
开发者ID:alama,项目名称:GIMX,代码行数:101,
示例24: inventory/* * inventory: * list what is in the pack */intinventory(struct linked_list *list, int type){ struct object *obj; int ch; int n_objs; char inv_temp[80]; n_objs = 0; for (ch = 'a'; list != NULL; ch++, list = next(list)) { obj = (struct object *) ldata(list); if (type && type != obj->o_type && !(type == CALLABLE && (obj->o_type == SCROLL || obj->o_type == POTION || obj->o_type == RING || obj->o_type == STICK))) continue; switch (n_objs++) { /* * For the first thing in the inventory, just save the string * in case there is only one. */ case 0: sprintf(inv_temp, "%c) %s", ch, inv_name(obj, FALSE)); break; /* * If there is more than one, clear the screen, print the * saved message and fall through to ... */ case 1: if (slow_invent) msg(inv_temp); else { wclear(hw); waddstr(hw, inv_temp); waddch(hw, '/n'); } /* * Print the line for this object */ default: if (slow_invent) msg("%c) %s", ch, inv_name(obj, FALSE)); else wprintw(hw, "%c) %s/n", ch, inv_name(obj, FALSE)); } } if (n_objs == 0) { if (terse) msg(type == 0 ? "Empty handed." : "Nothing appropriate"); else msg(type == 0 ? "You are empty handed." : "You don't have anything appropriate"); return FALSE; } if (n_objs == 1) { msg(inv_temp); return TRUE; } if (!slow_invent) { mvwaddstr(hw, LINES-1, 0, "--Press space to continue--"); draw(hw); wait_for(hw,' '); clearok(cw, TRUE); touchwin(cw); } return TRUE;}
开发者ID:RoguelikeRestorationProject,项目名称:rogue3.6,代码行数:77,
示例25: redraw_attr_dialogvoidredraw_attr_dialog(void){ const char *title; int x, y; size_t title_len; int need_ellipsis; werase(change_win); if(file_is_dir) wresize(change_win, 22, 30); else wresize(change_win, 20, 30); mvwaddstr(change_win, 3, 2, "Owner [ ] Read"); if(perms[0]) mvwaddch(change_win, 3, 9, (perms[0] < 0) ? 'X' : '*'); mvwaddstr(change_win, 4, 6, " [ ] Write"); if(perms[1]) mvwaddch(change_win, 4, 9, (perms[1] < 0) ? 'X' : '*'); mvwaddstr(change_win, 5, 6, " [ ] Execute"); if(perms[2]) mvwaddch(change_win, 5, 9, (perms[2] < 0) ? 'X' : '*'); mvwaddstr(change_win, 6, 6, " [ ] SetUID"); if(perms[3]) mvwaddch(change_win, 6, 9, (perms[3] < 0) ? 'X' : '*'); mvwaddstr(change_win, 8, 2, "Group [ ] Read"); if(perms[4]) mvwaddch(change_win, 8, 9, (perms[4] < 0) ? 'X' : '*'); mvwaddstr(change_win, 9, 6, " [ ] Write"); if(perms[5]) mvwaddch(change_win, 9, 9, (perms[5] < 0) ? 'X' : '*'); mvwaddstr(change_win, 10, 6, " [ ] Execute"); if(perms[6]) mvwaddch(change_win, 10, 9, (perms[6] < 0) ? 'X' : '*'); mvwaddstr(change_win, 11, 6, " [ ] SetGID"); if(perms[7]) mvwaddch(change_win, 11, 9, (perms[7] < 0) ? 'X' : '*'); mvwaddstr(change_win, 13, 2, "Other [ ] Read"); if(perms[8]) mvwaddch(change_win, 13, 9, (perms[8] < 0) ? 'X' : '*'); mvwaddstr(change_win, 14, 6, " [ ] Write"); if(perms[9]) mvwaddch(change_win, 14, 9, (perms[9] < 0) ? 'X' : '*'); mvwaddstr(change_win, 15, 6, " [ ] Execute"); if(perms[10]) mvwaddch(change_win, 15, 9, (perms[10] < 0) ? 'X' : '*'); mvwaddstr(change_win, 16, 6, " [ ] Sticky"); if(perms[11]) mvwaddch(change_win, 16, 9, (perms[11] < 0) ? 'X' : '*'); if(file_is_dir) mvwaddstr(change_win, 18, 6, " [ ] Set Recursively"); getmaxyx(stdscr, y, x); mvwin(change_win, (y - (20 + (file_is_dir != 0)*2))/2, (x - 30)/2); box(change_win, 0, 0); x = getmaxx(change_win); title = get_title(); title_len = strlen(title); need_ellipsis = (title_len > (size_t)x - 2); if(need_ellipsis) { x -= 3; title_len = x; } mvwaddnstr(change_win, 0, (getmaxx(change_win) - title_len)/2, title, x - 2); if(need_ellipsis) { waddstr(change_win, "..."); } curs_set(1); checked_wmove(change_win, curr, col); wrefresh(change_win);}
开发者ID:onovy,项目名称:vifm,代码行数:89,
示例26: menu_photorecvoid menu_photorec(struct ph_param *params, struct ph_options *options, alloc_data_t*list_search_space){ list_part_t *list_part;#ifdef HAVE_NCURSES list_part_t *current_element; unsigned int current_element_num; int done=0; int command; unsigned int offset=0; unsigned int menu=0; static const struct MenuItem menuMain[]= { {'S',"Search","Start file recovery"}, {'O',"Options","Modify options"}, {'F',"File Opt","Modify file options"}, {'G',"Geometry", "Change disk geometry" }, {'Q',"Quit","Return to disk selection"}, {0,NULL,NULL} };#endif params->blocksize=0; list_part=init_list_part(params->disk, options); if(list_part==NULL) return; log_all_partitions(params->disk, list_part); if(params->cmd_run!=NULL) { if(menu_photorec_cli(list_part, params, options, list_search_space) > 0) { if(params->recup_dir==NULL) { char *res;#ifdef HAVE_NCURSES res=ask_location("Please select a destination to save the recovered files./nDo not choose to write the files to the same partition they were stored on.", "", NULL);#else res=get_default_location();#endif if(res!=NULL) { params->recup_dir=(char *)MALLOC(strlen(res)+1+strlen(DEFAULT_RECUP_DIR)+1); strcpy(params->recup_dir,res); strcat(params->recup_dir,"/"); strcat(params->recup_dir,DEFAULT_RECUP_DIR); free(res); } } if(params->recup_dir!=NULL) photorec(params, options, list_search_space); } } if(params->cmd_run!=NULL) { part_free_list(list_part); return; }#ifdef HAVE_NCURSES if(list_part->next!=NULL) { current_element_num=1; current_element=list_part->next; } else { current_element_num=0; current_element=list_part; } while(done==0) { /* ncurses interface */ list_part_t *element; unsigned int i; aff_copy(stdscr); wmove(stdscr,4,0); wprintw(stdscr,"%s",params->disk->description_short(params->disk)); mvwaddstr(stdscr,6,0,msg_PART_HEADER_LONG);#if defined(KEY_MOUSE) && defined(ENABLE_MOUSE) mousemask(ALL_MOUSE_EVENTS, NULL);#endif for(i=0,element=list_part; element!=NULL && i<offset+INTER_SELECT;element=element->next,i++) { if(i<offset) continue; wmove(stdscr,7+i-offset,0); wclrtoeol(stdscr); /* before addstr for BSD compatibility */ if(element==current_element) { wattrset(stdscr, A_REVERSE); waddstr(stdscr, ">"); aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,params->disk,element->part); wattroff(stdscr, A_REVERSE); } else { waddstr(stdscr, " "); aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,params->disk,element->part); } } wmove(stdscr,7+INTER_SELECT,5); wclrtoeol(stdscr); if(element!=NULL) wprintw(stdscr, "Next"); command = wmenuSelect(stdscr, INTER_SELECT_Y+1, INTER_SELECT_Y, INTER_SELECT_X, menuMain, 8,//.........这里部分代码省略.........
开发者ID:AndychenCL,项目名称:TestDisk,代码行数:101,
示例27: wstandendvoid Screen::PrintFront(WINDOW * const window) const { const int dir=player->Dir(); if ( UP==dir || DOWN==dir ) { wstandend(window); werase(window); box(window, 0, 0); mvwaddstr(window, 0, 1, "No view"); wnoutrefresh(window); return; } short x_step, z_step, x_end, z_end, * x, * z, i, j, k; const ushort pX=player->X(); const ushort pY=player->Y(); const ushort pZ=player->Z(); const ushort begin_x = ( pX/SHRED_WIDTH )*SHRED_WIDTH + ( SHRED_WIDTH-SCREEN_SIZE )/2; const ushort begin_y = ( pY/SHRED_WIDTH )*SHRED_WIDTH + ( SHRED_WIDTH-SCREEN_SIZE )/2; ushort x_start, z_start, k_start; ushort arrow_Y, arrow_X; switch ( dir ) { case NORTH: x=&i; x_step=1; x_start=begin_x; x_end=x_start+SCREEN_SIZE; z=&j; z_step=-1; z_start=pY-1; z_end=pY-SHRED_WIDTH-1; arrow_X=(pX-begin_x)*2+1; break; case SOUTH: x=&i; x_step=-1; x_start=SCREEN_SIZE-1+begin_x; x_end=begin_x-1; z=&j; z_step=1; z_start=pY+1; z_end=pY+SHRED_WIDTH+1; arrow_X=(SCREEN_SIZE-pX+begin_x)*2-1; break; case WEST: x=&j; x_step=-1; x_start=SCREEN_SIZE-1+begin_y; x_end=begin_y-1; z=&i; z_step=-1; z_start=pX-1; z_end=pX-SHRED_WIDTH-1; arrow_X=(SCREEN_SIZE-pY+begin_y)*2-1; break; case EAST: x=&j; x_step=1; x_start=begin_y; x_end=SCREEN_SIZE+begin_y; z=&i; z_step=1; z_start=pX+1; z_end=pX+SHRED_WIDTH+1; arrow_X=(pY-begin_y)*2+1; break; default: fprintf(stderr, "Screen::PrintFront(WINDOW *): / unlisted dir: %d/n", (int)dir); return; } if ( pZ+SCREEN_SIZE/2>=HEIGHT ) { k_start=HEIGHT-2; arrow_Y=HEIGHT-pZ; } else if ( pZ-SCREEN_SIZE/2<0 ) { k_start=SCREEN_SIZE-1; arrow_Y=SCREEN_SIZE-pZ; } else { k_start=pZ+SCREEN_SIZE/2; arrow_Y=SCREEN_SIZE/2+1; } const int block_side=w->Anti(dir); (void)wmove(window, 1, 1); for (k=k_start; k_start-k<SCREEN_SIZE; --k, waddstr(window, "/n_")) { for (*x=x_start; *x!=x_end; *x+=x_step) { for (*z=z_start; *z!=z_end; *z+=z_step) if ( w->Transparent(i, j, k) != INVISIBLE ) { if ( (w->Enlightened(i, j, k, block_side) && player-> Visible(i, j, k)) || player-> GetCreativeMode() ) { PrintBlock(i, j, k, window); waddch(window,//.........这里部分代码省略.........
开发者ID:Panzerschrek,项目名称:FREG,代码行数:101,
示例28: redraw_file_info_dialogvoidredraw_file_info_dialog(void){ const dir_entry_t *entry; char perm_buf[26]; char size_buf[56]; char buf[256];#ifndef _WIN32 char id_buf[26];#endif int curr_y; uint64_t size; int size_not_precise; assert(view != NULL); if(resize_for_menu_like() != 0) { return; } werase(menu_win); entry = &view->dir_entry[view->list_pos]; size = DCACHE_UNKNOWN; if(entry->type == FT_DIR) { dcache_get_of(entry, &size, NULL); } if(size == DCACHE_UNKNOWN) { size = entry->size; } size_not_precise = friendly_size_notation(size, sizeof(size_buf), size_buf); curr_y = 2; curr_y += print_item("Path: ", entry->origin, curr_y); curr_y += print_item("Name: ", entry->name, curr_y); mvwaddstr(menu_win, curr_y, 2, "Size: "); mvwaddstr(menu_win, curr_y, 8, size_buf); if(size_not_precise) { snprintf(size_buf, sizeof(size_buf), " (%" PRId64 " bytes)", size); waddstr(menu_win, size_buf); } curr_y += 2; curr_y += show_file_type(view, curr_y); curr_y += show_mime_type(view, curr_y);#ifndef _WIN32 get_perm_string(perm_buf, sizeof(perm_buf), entry->mode); curr_y += print_item("Permissions: ", perm_buf, curr_y);#else copy_str(perm_buf, sizeof(perm_buf), attr_str_long(entry->attrs)); curr_y += print_item("Attributes: ", perm_buf, curr_y);#endif format_time(entry->mtime, buf, sizeof(buf)); curr_y += print_item("Modified: ", buf, curr_y); format_time(entry->atime, buf, sizeof(buf)); curr_y += print_item("Accessed: ", buf, curr_y); format_time(entry->ctime, buf, sizeof(buf));#ifndef _WIN32 curr_y += print_item("Changed: ", buf, curr_y);#else curr_y += print_item("Created: ", buf, curr_y);#endif#ifndef _WIN32 get_uid_string(entry, 0, sizeof(id_buf), id_buf); curr_y += print_item("Owner: ", id_buf, curr_y); get_gid_string(entry, 0, sizeof(id_buf), id_buf); curr_y += print_item("Group: ", id_buf, curr_y);#endif /* Fake use after last assignment. */ (void)curr_y; box(menu_win, 0, 0); checked_wmove(menu_win, 0, 3); wprint(menu_win, " File Information "); wrefresh(menu_win); was_redraw = 1;}
开发者ID:cfillion,项目名称:vifm,代码行数:94,
示例29: mvaddstrintmvaddstr(int y, int x, char *str){ return (wmove(stdscr, y, x) == ERR ? ERR : waddstr(stdscr, str));}
开发者ID:andreiw,项目名称:polaris,代码行数:5,
示例30: dialog_textbox/* * Display text from a file in a dialog box. */intdialog_textbox (const char *title, const char *file, int height, int width){ int i, x, y, cur_x, cur_y, fpos, key = 0, dir, temp, temp1;#ifdef HAVE_LIBNCURSES int passed_end;#endif char search_term[MAX_LEN + 1], *tempptr, *found; WINDOW *dialog, *text; search_term[0] = '/0'; /* no search term entered yet */ /* Open input file for reading */ if ((fd = open (file, O_RDONLY)) == -1) { endwin (); fprintf (stderr, "/nCan't open input file in dialog_textbox()./n"); exit (-1); } /* Get file size. Actually, 'file_size' is the real file size - 1, since it's only the last byte offset from the beginning */ if ((file_size = lseek (fd, 0, SEEK_END)) == -1) { endwin (); fprintf (stderr, "/nError getting file size in dialog_textbox()./n"); exit (-1); } /* Restore file pointer to beginning of file after getting file size */ if (lseek (fd, 0, SEEK_SET) == -1) { endwin (); fprintf (stderr, "/nError moving file pointer in dialog_textbox()./n"); exit (-1); } /* Allocate space for read buffer */ if ((buf = malloc (BUF_SIZE + 1)) == NULL) { endwin (); fprintf (stderr, "/nCan't allocate memory in dialog_textbox()./n"); exit (-1); } if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { endwin (); fprintf (stderr, "/nError reading file in dialog_textbox()./n"); exit (-1); } buf[bytes_read] = '/0'; /* mark end of valid data */ page = buf; /* page is pointer to start of page to be displayed */ /* center dialog box on screen */ x = (COLS - width) / 2; y = (LINES - height) / 2;#ifdef HAVE_LIBNCURSES if (use_shadow) draw_shadow (stdscr, y, x, height, width);#endif dialog = newwin (height, width, y, x); mouse_setbase (x, y); keypad (dialog, TRUE); /* Create window for text region, used for scrolling text */ text = subwin (dialog, height - 4, width - 2, y + 1, x + 1); keypad (text, TRUE); /* register the new window, along with its borders */ mouse_mkbigregion (0, 0, height - 2, width, 1, 0, 2 /* not normal */ ); draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); 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, ' '); if (title != NULL) { wattrset (dialog, title_attr); wmove (dialog, 0, (width - strlen (title)) / 2 - 1); waddch (dialog, ' '); waddstr (dialog, title); waddch (dialog, ' '); } print_button (dialog, " EXIT ", height - 2, width / 2 - 4, TRUE); wnoutrefresh (dialog); getyx (dialog, cur_y, cur_x); /* Save cursor position */ /* Print first page of text */ attr_clear (text, height - 4, width - 2, dialog_attr); print_page (text, height - 4, width - 2); print_position (dialog, height, width); wmove (dialog, cur_y, cur_x); /* Restore cursor position */ wrefresh (dialog); while ((key != ESC) && (key != '/n')) {//.........这里部分代码省略.........
开发者ID:zear,项目名称:sabre,代码行数:101,
注:本文中的waddstr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ wai_sem函数代码示例 C++ waddnstr函数代码示例 |