这篇教程C++ waddch函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中waddch函数的典型用法代码示例。如果您正苦于以下问题:C++ waddch函数的具体用法?C++ waddch怎么用?C++ waddch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了waddch函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: input_string//.........这里部分代码省略......... 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; case 0x0a: case 0x0d: case KEY_ENTER: quit = 0; break; default: if (strlen (s) == max_width) break; if (!isprint (c)) break; if (strlen (s) == pos) { s[pos + x] = c; s[pos + x + 1] = '/0'; waddch (win, c); } else { memmove (&s[pos + x + 1], &s[pos + x], strlen (&s[pos + x]) + 1); s[pos + x] = c; } if ((x + pos) < max_width) { if (x < size_x) x++; else pos++; } } tmp = xstrdup (&s[pos > 0 ? pos : 0]); tmp[MIN (strlen (tmp), size_x)] = '/0'; for (i = strlen (tmp); i < size_x; i++) mvwprintw (win, pos_y, pos_x + i, "%s", " "); mvwprintw (win, pos_y, pos_x, "%s", tmp); free (tmp); wmove (win, pos_y, pos_x + x); wrefresh (win); } curs_set (0); return s;}
开发者ID:arceduardvincent,项目名称:goaccess,代码行数:101,
示例2: wadd_wch//------------------------------------------------------------------------------int wadd_wch( WINDOW* win, const cchar_t* wch ){ __QCS_FCONTEXT( "wadd_wch" ); return wch ? waddch( win, *wch ) : ERR;}
开发者ID:chenbk85,项目名称:QOR,代码行数:7,
示例3: dialog_yesno/* * Display a dialog box with two buttons - Yes and No */int dialog_yesno(const char *title, const char *prompt, int height, int width){ int i, x, y, key = 0, button = 0; WINDOW *dialog;do_resize: if (getmaxy(stdscr) < (height + YESNO_HEIGTH_MIN)) return -ERRDISPLAYTOOSMALL; if (getmaxx(stdscr) < (width + YESNO_WIDTH_MIN)) return -ERRDISPLAYTOOSMALL; /* center dialog box on screen */ x = (getmaxx(stdscr) - width) / 2; y = (getmaxy(stdscr) - 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, dlg.dialog.atr, dlg.border.atr); wattrset(dialog, dlg.border.atr); mvwaddch(dialog, height - 3, 0, ACS_LTEE); for (i = 0; i < width - 2; i++) waddch(dialog, ACS_HLINE); wattrset(dialog, dlg.dialog.atr); waddch(dialog, ACS_RTEE); print_title(dialog, title, width); wattrset(dialog, dlg.dialog.atr); print_autowrap(dialog, prompt, width - 2, 1, 3); print_buttons(dialog, height, width, 0); while (key != KEY_ESC) { key = wgetch(dialog); switch (key) { case 'Y': case 'y': delwin(dialog); return 0; case 'N': case 'n': delwin(dialog); return 1; case TAB: case KEY_LEFT: case KEY_RIGHT: button = ((key == KEY_LEFT ? --button : ++button) < 0) ? 1 : (button > 1 ? 0 : button); print_buttons(dialog, height, width, button); wrefresh(dialog); break; case ' ': case '/n': delwin(dialog); return button; case KEY_ESC: key = on_key_esc(dialog); break; case KEY_RESIZE: delwin(dialog); on_key_resize(); goto do_resize; } } delwin(dialog); return key; /* ESC pressed */}
开发者ID:21cnbao,项目名称:training,代码行数:76,
示例4: drawbox/* * drawbox: draw a box with an optional horizontal dividing line. */voiddrawbox(WINDOW *win, /* ... in the given WINDOW */ int y, int x, /* at this origin */ int height, int width, /* this high, this wide */ int slice, /* with a dividing line */ int sunlight, int shade) /* cheesy 3-d effects */{ int i, j; int right = width-1, bottom = height-1; for (i = 0; i < height; i++) { wmove(win, i+y, x); for (j = 0; j < width; j++) { if (i == 0) /* topline */ if (j == 0) { /* upper left corner */ setcolor(win, sunlight); waddch(win, ACS_ULCORNER); } else if (j == right) { /* upper right corner */ setcolor(win, shade); waddch(win, ACS_URCORNER); } else { setcolor(win, sunlight); waddch(win, ACS_HLINE); } else if (i == bottom) /* bottom line */ if (j == 0) { /* lower left corner */ setcolor(win, sunlight); waddch(win, ACS_LLCORNER); } else if (j == right) { /* lower right corner */ setcolor(win, shade); waddch(win, ACS_LRCORNER); } else { setcolor(win, shade); waddch(win, ACS_HLINE); } else if (i == slice) /* dividing line */ if (j == 0) { /* left side */ setcolor(win, sunlight); waddch(win, ACS_LTEE); } else if (j == right) { /* or right side */ setcolor(win, shade); waddch(win, ACS_RTEE); } else { setcolor(win, sunlight); waddch(win, ACS_HLINE); } else { if (j == 0) { /* left side */ setcolor(win, sunlight); waddch(win, ACS_VLINE); } else if (j == right) { /* or right side */ setcolor(win, shade); waddch(win, ACS_VLINE); } else { setcolor(win, WINDOW_COLOR); waddch(win, ' '); } } } }} /* drawbox */
开发者ID:Orc,项目名称:ndialog,代码行数:73,
示例5: waddch//------------------------------------------------------------------------------int waddch( WINDOW* win, const chtype ch ){ __QCS_FCONTEXT( "waddch" ); int x, y; chtype text, attr; bool xlat; PDC_LOG(("waddch() - called: win=%p ch=%x (text=%c attr=0x%x)/n", win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES)); if( !win ) { return ERR; } x = win->_curx; y = win->_cury; if( y > win->_maxy || x > win->_maxx || y < 0 || x < 0 ) { return ERR; } xlat = !SP->raw_out && !(ch & A_ALTCHARSET); text = ch & A_CHARTEXT; attr = ch & A_ATTRIBUTES; if( xlat && ( text < ' ' || text == 0x7f ) ) { int x2; switch( text ) { case '/t': for( x2 = ( ( x / TABSIZE ) + 1 ) * TABSIZE; x < x2; x++ ) { if( waddch( win, attr | ' ' ) == ERR ) { return ERR; } // if tab to next line, exit the loop if( !win->_curx ) { break; } } return 0; case '/n': // if lf -> crlf if( !SP->raw_out ) { x = 0; } wclrtoeol( win ); if( ++y > win->_bmarg ) { y--; if( wscrl( win, 1 ) == ERR ) { return ERR; } } break; case '/b': // don't back over left margin if( --x < 0 ) case '/r': { x = 0; } break; case 0x7f: if( waddch( win, attr | '^' ) == ERR ) { return ERR; } return waddch( win, attr | '?' ); default: // handle control chars if( waddch( win, attr | '^' ) == ERR ) { return ERR; }//.........这里部分代码省略.........
开发者ID:chenbk85,项目名称:QOR,代码行数:101,
示例6: tui_redisplay_readline/* Readline callback. Redisplay the command line with its prompt after readline has changed the edited text. */voidtui_redisplay_readline (void){ int prev_col; int height; int col, line; int c_pos; int c_line; int in; WINDOW *w; char *prompt; int start_line; /* Detect when we temporarily left SingleKey and now the readline edit buffer is empty, automatically restore the SingleKey mode. */ if (tui_current_key_mode == TUI_ONE_COMMAND_MODE && rl_end == 0) tui_set_key_mode (TUI_SINGLE_KEY_MODE); if (tui_current_key_mode == TUI_SINGLE_KEY_MODE) prompt = ""; else prompt = tui_rl_saved_prompt; c_pos = -1; c_line = -1; w = TUI_CMD_WIN->generic.handle; start_line = TUI_CMD_WIN->detail.command_info.start_line; wmove (w, start_line, 0); prev_col = 0; height = 1; for (in = 0; prompt && prompt[in]; in++) { waddch (w, prompt[in]); getyx (w, line, col); if (col < prev_col) height++; prev_col = col; } for (in = 0; in < rl_end; in++) { unsigned char c; c = (unsigned char) rl_line_buffer[in]; if (in == rl_point) { getyx (w, c_line, c_pos); } if (CTRL_CHAR (c) || c == RUBOUT) { waddch (w, '^'); waddch (w, CTRL_CHAR (c) ? UNCTRL (c) : '?'); } else { waddch (w, c); } if (c == '/n') { getyx (w, TUI_CMD_WIN->detail.command_info.start_line, TUI_CMD_WIN->detail.command_info.curch); } getyx (w, line, col); if (col < prev_col) height++; prev_col = col; } wclrtobot (w); getyx (w, TUI_CMD_WIN->detail.command_info.start_line, TUI_CMD_WIN->detail.command_info.curch); if (c_line >= 0) { wmove (w, c_line, c_pos); TUI_CMD_WIN->detail.command_info.cur_line = c_line; TUI_CMD_WIN->detail.command_info.curch = c_pos; } TUI_CMD_WIN->detail.command_info.start_line -= height - 1; wrefresh (w); fflush(stdout);}
开发者ID:OpenInkpot-archive,项目名称:iplinux-gdb,代码行数:85,
示例7: display/* * Display a symbol on somebody's window, processing some control * characters while we are at it. */voiddisplay(xwin_t *win, wchar_t *wc){ /* * Alas, can't use variables in C switch statement. * Workaround these 3 cases with goto. */ if (*wc == win->kill) goto kill; else if (*wc == win->cerase) goto cerase; else if (*wc == win->werase) goto werase; switch (*wc) { case L'/n': case L'/r': wadd_wch(win->x_win, makecchar(L'/n')); getyx(win->x_win, win->x_line, win->x_col); wrefresh(win->x_win); return; case 004: if (win == &my_win) { /* Ctrl-D clears the screen. */ werase(my_win.x_win); getyx(my_win.x_win, my_win.x_line, my_win.x_col); wrefresh(my_win.x_win); werase(his_win.x_win); getyx(his_win.x_win, his_win.x_line, his_win.x_col); wrefresh(his_win.x_win); } return; /* Erase character. */ case 010: /* BS */ case 0177: /* DEL */cerase: wmove(win->x_win, win->x_line, max(--win->x_col, 0)); getyx(win->x_win, win->x_line, win->x_col); waddch(win->x_win, ' '); wmove(win->x_win, win->x_line, win->x_col); getyx(win->x_win, win->x_line, win->x_col); wrefresh(win->x_win); return; case 027: /* ^W */werase: { /* * On word erase search backwards until we find * the beginning of a word or the beginning of * the line. */ int endcol, xcol, c; endcol = win->x_col; xcol = endcol - 1; while (xcol >= 0) { c = readwin(win->x_win, win->x_line, xcol); if (c != ' ') break; xcol--; } while (xcol >= 0) { c = readwin(win->x_win, win->x_line, xcol); if (c == ' ') break; xcol--; } wmove(win->x_win, win->x_line, xcol + 1); for (int i = xcol + 1; i < endcol; i++) waddch(win->x_win, ' '); wmove(win->x_win, win->x_line, xcol + 1); getyx(win->x_win, win->x_line, win->x_col); wrefresh(win->x_win); return; } case 025: /* ^U */kill: wmove(win->x_win, win->x_line, 0); wclrtoeol(win->x_win); getyx(win->x_win, win->x_line, win->x_col); wrefresh(win->x_win); return; case L'/f': if (win == &my_win) wrefresh(curscr); return; case L'/7': write(STDOUT_FILENO, wc, sizeof(*wc)); return;//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:freebsd,代码行数:101,
示例8: dialog_textbox/* * Display text from a file in a dialog box. */int dialog_textbox(const char *title, const char *file, int height, int width){ int i, x, y, cur_x, cur_y, fpos, key = 0; int passed_end; char search_term[MAX_LEN + 1]; 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; draw_shadow(stdscr, y, x, height, width); dialog = newwin(height, width, y, x); keypad(dialog, TRUE); /* Create window for text region, used for scrolling text */ text = subwin(dialog, height - 4, width - 2, y + 1, x + 1); wattrset(text, dialog_attr); wbkgdset(text, dialog_attr & A_COLOR); keypad(text, TRUE); /* register the new window, along with its borders */ 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); wbkgdset(dialog, dialog_attr & A_COLOR); waddch(dialog, ACS_RTEE); print_title(dialog, title, width); 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')) { key = wgetch(dialog); switch (key) { case 'E': /* Exit */ case 'e': case 'X': case 'x': delwin(dialog); free(buf); close(fd); return 0; case 'g': /* First page */ case KEY_HOME: if (!begin_reached) { begin_reached = 1;//.........这里部分代码省略.........
开发者ID:0xD34D,项目名称:android_external_busybox,代码行数:101,
示例9: waddchvoid CursedWindow::putChar(int ch){ waddch(contentWindow, ch); wrefresh(contentWindow);}
开发者ID:yeeking,项目名称:custardlanguage,代码行数:5,
示例10: eq_ctrls_gen//.........这里部分代码省略......... db->slider_w = calloc (nbands,sizeof (WINDOW*)); hz->cell_w = calloc (nbands,sizeof (WINDOW*)); hz->cell_p = calloc (nbands,sizeof (PANEL*)); bw->bar_w = calloc (nbands,sizeof (WINDOW*)); bw->slider_w = calloc (nbands,sizeof (WINDOW*)); bw->cell_w = calloc (nbands,sizeof (WINDOW*)); bw->bar_p = calloc (nbands,sizeof (PANEL*)); bw->slider_p = calloc (nbands,sizeof (PANEL*)); bw->cell_p = calloc (nbands,sizeof (PANEL*)); getmaxyx (eq_win,max_ro,max_co); max_co = floor (max_co / nctrls); h_gap = floor (max_co / nbands); v_gap = floor (max_ro*0.7 / nbands); /* Start Drawing */ maxy = getmaxy (eq_win); db_win = newwin (max_ro*0.7,max_co,maxy * 0.20,max_co*0); db->pan = new_panel (db_win); //box (db_win,0,0); hz_win = newwin (max_ro*0.7,max_co,maxy * 0.20,max_co*1); hz->pan = new_panel (hz_win); //box (hz_win,0,0); bw_win = newwin (max_ro*0.7,max_co,maxy * 0.20,max_co*2); bw->pan = new_panel (bw_win); //box (bw_win,0,0); v_bar_h = floor (getmaxy(db_win)*0.80) + 2; h_bar_h = floor (getmaxx(bw_win)*0.80) + 2; for (i=0;i<nbands;i++) { /* Power */ db->bar_w[i] = newwin (v_bar_h,3,getbegy (db_win) + getmaxy (db_win) - (v_bar_h) - 2 , ( getbegx (db_win) + ((getmaxx (db_win)/nbands) / 2) ) + h_offs - 2); db->bar_p[i] = new_panel (db->bar_w[i]); wattron (db->bar_w[i],A_BOLD | COLOR_PAIR (4)); box (db->bar_w[i],ACS_VLINE,ACS_HLINE); db->slider_w[i] = newwin (1,8,getbegy (db->bar_w[i])+ (v_bar_h/2),getbegx (db->bar_w[i]) - 2 ); wattron (db->slider_w[i],A_BOLD |COLOR_PAIR (8)); wprintw (db->slider_w[i]," dB"); db->slider_p[i] = new_panel (db->slider_w[i]); /* Frequency */ hz->cell_w[i] = newwin (1+2,7+2,( getbegy (hz_win) + ((getmaxy (hz_win)/nbands) / 2) ) + v_offs - 1, getbegx (hz_win) + (getmaxx (hz_win) / 2) - 5); hz->cell_p[i] = new_panel (hz->cell_w[i]); wattron (hz->cell_w[i], A_BOLD | COLOR_PAIR (4)); box (hz->cell_w[i],0,0); wattron (hz->cell_w[i],COLOR_PAIR (8)); mvwprintw (hz->cell_w[i],1,1," Hz"); /* Bandwidth */ bw->bar_w[i] = newwin (2,h_bar_h,( getbegy (bw_win) + ((getmaxy (bw_win)/nbands) / 2) ) + v_offs, getbegx (bw_win) + (getmaxx (bw_win) / 2) - (h_bar_h/2)); bw->bar_p[i] = new_panel (bw->bar_w[i]); wattron (bw->bar_w[i], A_BOLD | COLOR_PAIR (4)); box (bw->bar_w[i],0,0); bw->slider_w[i] = newwin (2,1,getbegy (bw->bar_w[i]) ,getbegx (bw->bar_w[i]) + (h_bar_h/2) -1 ); bw->slider_p[i] = new_panel (bw->slider_w[i]); wattron (bw->slider_w[i],COLOR_PAIR (1)); waddch (bw->slider_w[i],' '|A_REVERSE); waddch (bw->slider_w[i],' '|A_REVERSE); bw->cell_w[i] = newwin (1,4,getbegy (bw->bar_w[i]) + 3,getbegx (bw->bar_w[i]) + (h_bar_h/2) - 2); bw->cell_p[i] = new_panel (bw->cell_w[i]); wattron (bw->cell_w[i],A_BOLD | COLOR_PAIR (8)); wprintw (bw->cell_w[i]," "); h_offs += h_gap; v_offs += v_gap; } update_panels (); doupdate (); return ctrls;}
开发者ID:dsheeler,项目名称:krad_radio,代码行数:101,
示例11: read_scroll/* * read_scroll: * Let the hero read a scroll */int read_scroll(){ struct object *obj; struct linked_list *item; int i, j, wh; unsigned long ch, nch; struct room *rp; struct linked_list *titem; char buf[LINLEN]; bool bless, curse; if ((item = get_item("read", SCROLL)) == NULL) return 0; obj = OBJPTR(item); if (obj->o_type != SCROLL) { msg("Nothing to read."); after = FALSE; return 0; } msg("As you read the scroll, it vanishes."); wh = obj->o_which; bless = o_on(obj, ISBLESS); curse = o_on(obj, ISCURSED); del_pack(item); /* Get rid of the thing */ /* * Calculate the effect it has on the hero */ switch(wh) { case S_KNOWALL: if (!curse) { idenpack(); /* identify all the pack */ msg("You feel more knowledgable."); chg_abil(WIS,1,TRUE); s_know[S_KNOWALL] = TRUE; } when S_CONFUSE: if (!curse) { /* * Scroll of monster confusion. Give him that power. */ msg("Your hands begin to glow red."); player.t_flags |= CANHUH; s_know[S_CONFUSE] = TRUE; } when S_LIGHT: rp = player.t_room; if (!curse) { if (rp == NULL) { s_know[S_LIGHT] = TRUE; msg("The corridor glows and then fades."); } else { if (rf_on(rp,ISDARK)) { s_know[S_LIGHT] = TRUE; msg("The room is lit."); rp->r_flags &= ~ISDARK; } light(&hero); mvwaddch(cw, hero.y, hero.x, PLAYER); } } when S_ARMOR: if (!curse) { if (cur_armor != NULL && o_off(cur_armor,ISPROT)) { s_know[S_ARMOR] = TRUE; msg("Your armor glows faintly for a moment."); if (o_on(cur_armor,ISCURSED)) cur_armor->o_ac = armors[cur_armor->o_which].a_class; else cur_armor->o_ac--; resoflg(cur_armor,ISCURSED); } } when S_HOLD: if (!curse) { /* * Hold monster scroll. Stop all monsters within 3 spaces * from chasing after the hero. */ int x,y; struct linked_list *mon; for (x = hero.x - 3; x <= hero.x + 3; x++) { for (y = hero.y - 3; y <= hero.y + 3; y++) { if (y > 0 && x > 0 && isalpha(mvwinch(mw, y, x))) { if ((mon = find_mons(y, x)) != NULL) { struct thing *th; th = THINGPTR(mon); th->t_flags &= ~ISRUN; th->t_flags |= ISHELD; th->t_flags |= ISSTUCK; } } }//.........这里部分代码省略.........
开发者ID:ajpaulson,项目名称:srogue11,代码行数:101,
示例12: wputchvoid wputch(WINDOW *w, nc_color FG, long ch){ wattron(w, FG); waddch(w, ch); wattroff(w, FG);}
开发者ID:Devanon,项目名称:Cataclysm-DDA,代码行数:6,
示例13: HEXTUI_actionmenuint HEXTUI_actionmenu() { int m = 0;#ifdef HEXT_PLATFORM_CURSES /* w, h,x, y */ WINDOW* am_win = newwin( 10,10,1,10); wattron( am_win, A_REVERSE ); wmove( am_win, 1, 0 ); /* move to beginning of line */ waddch( am_win, ' ' ); /* insert blank before (inner-margin) */ /* TODO:: if is mnemonic, then */ wattron( am_win, A_UNDERLINE ); /* */ waddch( am_win, 'E' ); wattroff( am_win, A_UNDERLINE ); waddch( am_win, 'd' ); waddch( am_win, 'i' ); waddch( am_win, 't' ); waddch( am_win, '/t' ); waddch( am_win, '>' ); waddch( am_win, ' ' ); /* insert blank after (inner-margin) */ //mvwprintw( am_win, 1, 1, "dit/t/t> " ); /* including trailing space */ wattron( am_win, A_UNDERLINE ); wmove( am_win, 2, 0 ); waddch( am_win, 'V' ); wattroff( am_win, A_UNDERLINE ); mvwprintw( am_win, 2, 1, "iew/t->" ); wattron( am_win, A_UNDERLINE ); wmove( am_win, 3, 0 ); waddch( am_win, 'C' ); wattroff( am_win, A_UNDERLINE ); mvwprintw( am_win, 3, 1, "onsole/t^C" ); wattron( am_win, A_UNDERLINE ); wmove( am_win, 4, 0 ); waddch( am_win, 'A' ); wattroff( am_win, A_UNDERLINE ); mvwprintw( am_win, 4, 1, "bout/t^G" ); mvwprintw( am_win, 5, 0, "________" ); wattron( am_win, A_UNDERLINE ); wmove( am_win, 6, 0 ); waddch( am_win, 'Q' ); wattroff( am_win, A_UNDERLINE ); mvwprintw( am_win, 6, 1, "uit/t^Q" ); wattron( am_win, A_UNDERLINE ); wmove( am_win, 0, 0 ); waddch( am_win, 'F' ); wattroff( am_win, A_UNDERLINE ); mvwprintw( am_win, 0, 1, "ile/t->" ); wmove( am_win, 0, 0 ); wattroff( am_win, A_REVERSE ); wrefresh( am_win ); m = getch(); delwin(am_win);#endifreturn m;}
开发者ID:kb3c,项目名称:hext,代码行数:73,
示例14: display/* * Display some text on somebody's window, processing some control * characters while we are at it. */voiddisplay(xwin_t *win, char *text, int size){ int i; char cch; for (i = 0; i < size; i++) { if (*text == '/n' || *text == '/r') { waddch(win->x_win, '/n'); getyx(win->x_win, win->x_line, win->x_col); text++; continue; } if (*text == 004 && win == &my_win) { /* control-D clears the screen */ werase(my_win.x_win); getyx(my_win.x_win, my_win.x_line, my_win.x_col); wrefresh(my_win.x_win); werase(his_win.x_win); getyx(his_win.x_win, his_win.x_line, his_win.x_col); wrefresh(his_win.x_win); text++; continue; } /* erase character */ if ( *text == win->cerase || *text == 010 /* BS */ || *text == 0177 /* DEL */ ) { wmove(win->x_win, win->x_line, max(--win->x_col, 0)); getyx(win->x_win, win->x_line, win->x_col); waddch(win->x_win, ' '); wmove(win->x_win, win->x_line, win->x_col); getyx(win->x_win, win->x_line, win->x_col); text++; continue; } /* * On word erase search backwards until we find * the beginning of a word or the beginning of * the line. */ if ( *text == win->werase || *text == 027 /* ^W */ ) { int endcol, xcol, ii, c; endcol = win->x_col; xcol = endcol - 1; while (xcol >= 0) { c = readwin(win->x_win, win->x_line, xcol); if (c != ' ') break; xcol--; } while (xcol >= 0) { c = readwin(win->x_win, win->x_line, xcol); if (c == ' ') break; xcol--; } wmove(win->x_win, win->x_line, xcol + 1); for (ii = xcol + 1; ii < endcol; ii++) waddch(win->x_win, ' '); wmove(win->x_win, win->x_line, xcol + 1); getyx(win->x_win, win->x_line, win->x_col); text++; continue; } /* line kill */ if ( *text == win->kill || *text == 025 /* ^U */ ) { wmove(win->x_win, win->x_line, 0); wclrtoeol(win->x_win); getyx(win->x_win, win->x_line, win->x_col); text++; continue; } if (*text == '/f') { if (win == &my_win) wrefresh(curscr); text++; continue; } if (*text == '/7') { write(STDOUT_FILENO, text, 1); text++; continue; } if (!isprint((unsigned char)*text) && *text != '/t') { waddch(win->x_win, '^'); getyx(win->x_win, win->x_line, win->x_col); cch = (*text & 63) + 64; waddch(win->x_win, cch);//.........这里部分代码省略.........
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:101,
示例15: _nc_Post_Item_nc_Post_Item(const MENU * menu, const ITEM * item){ int i; chtype ch; int item_x, item_y; int count = 0; bool isfore = FALSE, isback = FALSE, isgrey = FALSE; int name_len; int desc_len; assert(menu->win); getyx(menu->win, item_y, item_x); /* We need a marker iff - it is a onevalued menu and it is the current item - or it has a selection value */ wattron(menu->win, menu->back); if (item->value || (item == menu->curitem)) { if (menu->marklen) { /* In a multi selection menu we use the fore attribute for a selected marker that is not the current one. This improves visualization of the menu, because now always the 'normal' marker denotes the current item. */ if (!(menu->opt & O_ONEVALUE) && item->value && item != menu->curitem) { wattron(menu->win, menu->fore); isfore = TRUE; } waddstr(menu->win, menu->mark); if (isfore) { wattron(menu->win, menu->fore); isfore = FALSE; } } } else /* otherwise we have to wipe out the marker area */ for (ch = ' ', i = menu->marklen; i > 0; i--) waddch(menu->win, ch); wattroff(menu->win, menu->back); count += menu->marklen; /* First we have to calculate the attribute depending on selectability and selection status */ if (!(item->opt & O_SELECTABLE)) { wattron(menu->win, menu->grey); isgrey = TRUE; } else { if (item->value || item == menu->curitem) { wattron(menu->win, menu->fore); isfore = TRUE; } else { wattron(menu->win, menu->back); isback = TRUE; } } waddnstr(menu->win, item->name.str, item->name.length); name_len = _nc_Calculate_Text_Width(&(item->name)); for (ch = ' ', i = menu->namelen - name_len; i > 0; i--) { waddch(menu->win, ch); } count += menu->namelen; /* Show description if required and available */ if ((menu->opt & O_SHOWDESC) && menu->desclen > 0) { int m = menu->spc_desc / 2; int cy = -1, cx = -1; for (ch = ' ', i = 0; i < menu->spc_desc; i++) { if (i == m) { waddch(menu->win, menu->pad); getyx(menu->win, cy, cx); } else waddch(menu->win, ch); } if (item->description.length) waddnstr(menu->win, item->description.str, item->description.length); desc_len = _nc_Calculate_Text_Width(&(item->description)); for (ch = ' ', i = menu->desclen - desc_len; i > 0; i--) { waddch(menu->win, ch); }//.........这里部分代码省略.........
开发者ID:ysleu,项目名称:RTL8685,代码行数:101,
示例16: 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){ int i, x, y, box_y, box_x, box_width; int input_x = 0, key = 0, button = -1; int show_x, len, pos; char *instr = dialog_input_result; WINDOW *dialog; if (!init) instr[0] = '/0'; else strcpy(instr, init);do_resize: if (getmaxy(stdscr) <= (height - 2)) return -ERRDISPLAYTOOSMALL; if (getmaxx(stdscr) <= (width - 2)) return -ERRDISPLAYTOOSMALL; /* 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, dlg.dialog.atr, dlg.border.atr); wattrset(dialog, dlg.border.atr); mvwaddch(dialog, height - 3, 0, ACS_LTEE); for (i = 0; i < width - 2; i++) waddch(dialog, ACS_HLINE); wattrset(dialog, dlg.dialog.atr); waddch(dialog, ACS_RTEE); print_title(dialog, title, width); wattrset(dialog, dlg.dialog.atr); 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, dlg.dialog.atr, dlg.border.atr); print_buttons(dialog, height, width, 0); /* Set up the initial value */ wmove(dialog, box_y, box_x); wattrset(dialog, dlg.inputbox.atr); len = strlen(instr); pos = len; if (len >= box_width) { show_x = len - box_width + 1; input_x = box_width - 1; for (i = 0; i < box_width - 1; i++) waddch(dialog, instr[show_x + i]); } else { show_x = 0; input_x = len; waddstr(dialog, instr); } wmove(dialog, box_y, box_x + input_x); wrefresh(dialog); while (key != KEY_ESC) { key = wgetch(dialog); if (button == -1) { /* Input box selected */ switch (key) { case TAB: case KEY_UP: case KEY_DOWN: break; case KEY_BACKSPACE: case 127: if (pos) { wattrset(dialog, dlg.inputbox.atr); if (input_x == 0) { show_x--; } else input_x--; if (pos < len) { for (i = pos - 1; i < len; i++) { instr[i] = instr[i+1]; }//.........这里部分代码省略.........
开发者ID:whble,项目名称:trunk,代码行数:101,
示例17: dialog_checklist/* * Display a dialog box with a list of options that can be turned on or off */int dialog_checklist(char *title, char *prompt, int height, int width, int list_height, int item_no, char **items){ int i, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, choice = 0, scrolli = 0, max_choice, *status; WINDOW *dialog, *list; /* Allocate space for storing item on/off status */ if ((status = malloc(sizeof(int)*item_no)) == NULL) { endwin(); fprintf(stderr, "/nCan't allocate memory in dialog_checklist()./n"); exit(-1); } /* Initializes status */ for (i = 0; i < item_no; i++) status[i] = !strcasecmp(items[i*3 + 2], "on"); max_choice = MIN(list_height, item_no); /* center dialog box on screen */ x = (COLS - width)/2; y = (LINES - height)/2; #ifdef HAVE_NCURSES if (use_shadow) draw_shadow(stdscr, y, x, height, width);#endif dialog = newwin(height, width, y, x); keypad(dialog, TRUE); 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, ' '); } wattrset(dialog, dialog_attr); print_autowrap(dialog, prompt, width, 1, 3); list_width = width-6; getyx(dialog, cur_y, cur_x); box_y = cur_y + 1; box_x = (width - list_width)/2 - 1; /* create new window for the list */ list = subwin(dialog, list_height, list_width, y + box_y + 1, x + box_x + 1); keypad(list, TRUE); /* 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); check_x = 0; item_x = 0; /* Find length of longest item in order to center checklist */ for (i = 0; i < item_no; i++) { check_x = MAX(check_x, strlen(items[i*3]) + strlen(items[i*3 + 1]) + 6); item_x = MAX(item_x, strlen(items[i*3])); } check_x = (list_width - check_x) / 2; item_x = check_x + item_x + 6; /* Print the list */ for (i = 0; i < max_choice; i++) print_item(list, items[i*3], items[i*3 + 1], status[i], i, i == choice); wnoutrefresh(list); if (list_height < item_no) { wattrset(dialog, darrow_attr); wmove(dialog, box_y + list_height + 1, box_x + check_x + 5); waddch(dialog, ACS_DARROW); wmove(dialog, box_y + list_height + 1, box_x + check_x + 6); waddstr(dialog, "(+)"); } x = width/2-11; y = height-2; print_button(dialog, "Cancel", y, x+14, FALSE); print_button(dialog, " OK ", y, x, TRUE); wrefresh(dialog); while (key != ESC) { key = wgetch(dialog); /* Check if key pressed matches first character of any item tag in list */ for (i = 0; i < max_choice; i++) if (toupper(key) == toupper(items[(scrolli+i)*3][0]))//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:texlive,代码行数:101,
示例18: show_panelsstatic voidshow_panels(PANEL * px[MAX_PANELS + 1]){ static const char *help[] = { "", "Commands are letter/digit pairs. Digits are the panel number.", "", " b - put the panel on the bottom of the stack", " c - create the panel", " d - delete the panel", " h - hide the panel", " m - move the panel (M for continuous move)", " r - resize the panel", " s - show the panel", " b - put the panel on the top of the stack" }; struct { bool valid; bool hidden; PANEL *above; PANEL *below; } table[MAX_PANELS + 1]; WINDOW *win; PANEL *pan; int j; memset(table, 0, sizeof(table)); for (j = 1; j <= MAX_PANELS; ++j) { table[j].valid = (px[j] != 0); if (table[j].valid) { table[j].hidden = panel_hidden(px[j]); table[j].above = panel_above(px[j]); table[j].below = panel_below(px[j]); } } if ((win = newwin(LINES - 1, COLS, 0, 0)) != 0) { keypad(win, TRUE); if ((pan = new_panel(win)) != 0) { werase(win); mvwprintw(win, 0, 0, "Panels:/n"); for (j = 1; j <= MAX_PANELS; ++j) { if (table[j].valid) { wprintw(win, " %d:", j); if (table[j].hidden) { waddstr(win, " hidden"); } else { if (table[j].above) { wprintw(win, " above %d", which_panel(px, table[j].above)); } if (table[j].below) { wprintw(win, "%s below %d", table[j].above ? "," : "", which_panel(px, table[j].below)); } } waddch(win, '/n'); } } for (j = 0; j < (int) SIZEOF(help); ++j) { if (wprintw(win, "%s/n", help[j]) == ERR) break; } wgetch(win); del_panel(pan); pflush(); } delwin(win); }}
开发者ID:tizenorg,项目名称:external.ncurses,代码行数:74,
示例19: mvwaddch//adds a character to the windowint mvwaddch(WINDOW *win, int y, int x, const chtype ch){ if (wmove(win,y,x)==0) return 0; return waddch(win, ch);};
开发者ID:BurnZeZ,项目名称:Cataclysm-DDA,代码行数:6,
示例20: waddchvoidshNCursesInterface::winPutchar (Window win, const char c){ waddch (mWin[win], c);}
开发者ID:ronw23,项目名称:prime-osx,代码行数:5,
示例21: test_opaquestatic inttest_opaque(int level, char **argv, WINDOW *stswin){ WINDOW *txtbox = 0; WINDOW *txtwin = 0; FILE *fp; int ch; int txt_x = 0, txt_y = 0; int base_y; bool in_status = FALSE; int active = 0; if (argv[level] == 0) { beep(); return FALSE; } if (level > 1) { txtbox = newwin(LINES - BASE_Y, COLS - level, BASE_Y, level); box(txtbox, 0, 0); wnoutrefresh(txtbox); txtwin = derwin(txtbox, getmaxy(txtbox) - 2, getmaxx(txtbox) - 2, 1, 1); base_y = 0; } else { txtwin = stdscr; base_y = BASE_Y; } keypad(txtwin, TRUE); /* enable keyboard mapping */ (void) cbreak(); /* take input chars one at a time, no wait for /n */ (void) noecho(); /* don't echo input */ txt_y = base_y; txt_x = 0; wmove(txtwin, txt_y, txt_x); if ((fp = fopen(argv[level], "r")) != 0) { while ((ch = fgetc(fp)) != EOF) { if (waddch(txtwin, UChar(ch)) != OK) { break; } } fclose(fp); } else { wprintw(txtwin, "Cannot open:/n%s", argv[1]); } for (;;) { if (in_status) { to_keyword(stswin, active); ch = wgetch(stswin); show_opaque(stswin, txtwin, TRUE, active); if (Quit(ch)) break; switch (ch) { case '/t': in_status = FALSE; break; case KEY_DOWN: case 'j': if (active < (int) SIZEOF(bool_funcs) - 1) active++; else beep(); break; case KEY_UP: case 'k': if (active > 0) active--; else beep(); break; case ' ': bool_funcs[active].func(txtwin, !bool_funcs[active].func(txtwin, -1)); break; default: beep(); break; } show_opaque(stswin, txtwin, FALSE, in_status ? active : -1); } else { ch = mvwgetch(txtwin, txt_y, txt_x); show_opaque(stswin, txtwin, TRUE, -1); if (Quit(ch)) break; switch (ch) { case '/t': in_status = TRUE; break; case KEY_DOWN: case 'j': if (txt_y < getmaxy(txtwin) - 1)//.........这里部分代码省略.........
开发者ID:010001111,项目名称:darling,代码行数:101,
示例22: addch//------------------------------------------------------------------------------int addch( const chtype ch ){ __QCS_FCONTEXT( "addch" ); return waddch( stdscr, ch );}
开发者ID:chenbk85,项目名称:QOR,代码行数:7,
示例23: dialog_textbox/* * Display text from a file in a dialog box. */int dialog_textbox(const char *title, const char *tbuf, int initial_height, int initial_width){ int i, x, y, cur_x, cur_y, key = 0; int height, width, boxh, boxw; int passed_end; WINDOW *dialog, *box; begin_reached = 1; end_reached = 0; page_length = 0; hscroll = 0; buf = tbuf; page = buf; /* page is pointer to start of page to be displayed */do_resize: getmaxyx(stdscr, height, width); if (height < 8 || width < 8) return -ERRDISPLAYTOOSMALL; if (initial_height != 0) height = initial_height; else if (height > 4) height -= 4; else height = 0; if (initial_width != 0) width = initial_width; else if (width > 5) width -= 5; else width = 0; /* 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); /* Create window for box region, used for scrolling text */ boxh = height - 4; boxw = width - 2; box = subwin(dialog, boxh, boxw, y + 1, x + 1); wattrset(box, dlg.dialog.atr); wbkgdset(box, dlg.dialog.atr & A_COLOR); keypad(box, TRUE); /* register the new window, along with its borders */ draw_box(dialog, 0, 0, height, width, dlg.dialog.atr, dlg.border.atr); wattrset(dialog, dlg.border.atr); mvwaddch(dialog, height - 3, 0, ACS_LTEE); for (i = 0; i < width - 2; i++) waddch(dialog, ACS_HLINE); wattrset(dialog, dlg.dialog.atr); wbkgdset(dialog, dlg.dialog.atr & A_COLOR); waddch(dialog, ACS_RTEE); print_title(dialog, title, width); print_button(dialog, gettext(" 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(box, boxh, boxw, dlg.dialog.atr); refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x); while ((key != KEY_ESC) && (key != '/n')) { key = wgetch(dialog); switch (key) { case 'E': /* Exit */ case 'e': case 'X': case 'x': delwin(box); delwin(dialog); return 0; case 'g': /* First page */ case KEY_HOME: if (!begin_reached) { begin_reached = 1; page = buf; refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x); } break; case 'G': /* Last page */ case KEY_END: end_reached = 1;//.........这里部分代码省略.........
开发者ID:leehongming,项目名称:wr-lm32-sw,代码行数:101,
示例24: display_apliststatic void display_aplist(WINDOW *w_aplst){ char s[IW_ESSID_MAX_SIZE << 3]; const char *sort_type[] = { [SO_CHAN] = "Chan", [SO_SIGNAL] = "Sig", [SO_MAC] = "Mac", [SO_ESSID] = "Essid", [SO_OPEN] = "Open", [SO_CHAN_SIG] = "Ch/Sg", [SO_OPEN_SIG] = "Op/Sg" }; int i, col, line = START_LINE; struct scan_entry *cur; /* Scanning can take several seconds - do not refresh if locked. */ if (pthread_mutex_trylock(&sr.mutex)) return; if (sr.head || *sr.msg) for (i = 1; i <= MAXYLEN; i++) mvwclrtoborder(w_aplst, i, 1); if (!sr.head) waddstr_center(w_aplst, WAV_HEIGHT/2 - 1, sr.msg); sort_scan_list(&sr.head); /* Truncate overly long access point lists to match screen height. */ for (cur = sr.head; cur && line < MAXYLEN; line++, cur = cur->next) { col = CP_SCAN_NON_AP; if (!WLAN_CAPABILITY_IS_STA_BSS(cur->bss_capa) && (cur->bss_capa & WLAN_CAPABILITY_ESS)) { col = cur->has_key ? CP_SCAN_CRYPT : CP_SCAN_UNENC; } wmove(w_aplst, line, 1); if (!*cur->essid) { sprintf(s, "%-*s ", sr.max_essid_len, "<hidden ESSID>"); wattron(w_aplst, COLOR_PAIR(col)); waddstr(w_aplst, s); } else if (str_is_ascii(cur->essid)) { sprintf(s, "%-*s ", sr.max_essid_len, cur->essid); waddstr_b(w_aplst, s); wattron(w_aplst, COLOR_PAIR(col)); } else { sprintf(s, "%-*s ", sr.max_essid_len, "<cryptic ESSID>"); wattron(w_aplst, COLOR_PAIR(col)); waddstr(w_aplst, s); } waddstr(w_aplst, ether_addr(&cur->ap_addr)); wattroff(w_aplst, COLOR_PAIR(col)); fmt_scan_entry(cur, s, sizeof(s)); waddstr(w_aplst, " "); waddstr(w_aplst, s); } if (sr.num.entries < MAX_CH_STATS) goto done; wmove(w_aplst, MAXYLEN, 1); wadd_attr_str(w_aplst, A_REVERSE, "total:"); sprintf(s, " %d ", sr.num.entries); waddstr(w_aplst, s); sprintf(s, "%s %ssc", sort_type[conf.scan_sort_order], conf.scan_sort_asc ? "a" : "de"); wadd_attr_str(w_aplst, A_REVERSE, s); if (sr.num.entries + START_LINE > line) { sprintf(s, ", %d not shown", sr.num.entries + START_LINE - line); waddstr(w_aplst, s); } if (sr.num.open) { sprintf(s, ", %d open", sr.num.open); waddstr(w_aplst, s); } if (sr.num.two_gig && sr.num.five_gig) { waddch(w_aplst, ' '); wadd_attr_str(w_aplst, A_REVERSE, "5/2GHz:"); sprintf(s, " %d/%d", sr.num.five_gig, sr.num.two_gig); waddstr(w_aplst, s); } if (sr.channel_stats) { waddch(w_aplst, ' '); if (conf.scan_sort_order == SO_CHAN && !conf.scan_sort_asc) sprintf(s, "bottom-%d:", (int)sr.num.ch_stats); else sprintf(s, "top-%d:", (int)sr.num.ch_stats); wadd_attr_str(w_aplst, A_REVERSE, s); for (i = 0; i < sr.num.ch_stats; i++) { waddstr(w_aplst, i ? ", " : " "); sprintf(s, "ch#%d", sr.channel_stats[i].val); wadd_attr_str(w_aplst, A_BOLD, s); sprintf(s, " (%d)", sr.channel_stats[i].count); waddstr(w_aplst, s);//.........这里部分代码省略.........
开发者ID:KISSMonX,项目名称:wavemon,代码行数:101,
示例25: dialog_yesno/* * Display a dialog box with two buttons - Yes and No */intdialog_yesno (const char *title, const char *prompt, int height, int width){ int i, x, y, key = 0, button = 0; WINDOW *dialog; /* 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 && strlen(title) >= width-2 ) { /* truncate long title -- mec */ char * title2 = malloc(width-2+1); memcpy( title2, title, width-2 ); title2[width-2] = '/0'; title = title2; } 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); print_buttons(dialog, height, width, 0); while (key != ESC) { key = wgetch (dialog); switch (key) { case 'Y': case 'y': delwin (dialog); return 0; case 'N': case 'n': delwin (dialog); return 1; case TAB: case KEY_LEFT: case KEY_RIGHT: button = ((key == KEY_LEFT ? --button : ++button) < 0) ? 1 : (button > 1 ? 0 : button); print_buttons(dialog, height, width, button); wrefresh (dialog); break; case ' ': case '/n': delwin (dialog); return button; case ESC: break; } } delwin (dialog); return -1; /* ESC pressed */}
开发者ID:OpenSDE,项目名称:opensde-nopast,代码行数:79,
示例26: Paintvoid Paint(STATE* state){ size_t X = 0, Y = 0; attron(COLOR_PAIR(12) | A_BOLD); mvprintw(0, 0, "%s/n", gs_appname); move(state->Wy - 1, 0); for (X = 0; X < sizeof(state->keymap) / sizeof(int); X++) { attron(COLOR_PAIR(15)); printw("%s", keymap_desc[X]); attron(COLOR_PAIR(11)); printw("["); attron(COLOR_PAIR(14)); printw("%s", keyname(state->keymap[X])); attron(COLOR_PAIR(11)); printw("] "); } attroff(A_BOLD); attron(COLOR_PAIR(13)); mvprintw(state->Wy - 1, state->Wx - strlen(state->clock), "%s", state->clock); // begin painting the status window if (state->statuswin) { StatusWindowPaint(state); } // begin painting the board werase(state->fieldwin); wattrset(state->fieldwin, A_NORMAL); box(state->fieldwin, 0, 0); if (! state->pause_f || state->do_pause_blocks) { for (Y = 0; Y < state->By; Y++) { wmove(state->fieldwin, Y + 1, 1); for (X = 0; X < state->Bx; X++) { wattrset(state->fieldwin, A_NORMAL); if (state->field[state->Bx * Y + X] == CLEARED) { switch (state->do_clear) { case CLEAR_FLASH: wattron(state->fieldwin, COLOR_PAIR(rand() % 7 + 1)); break; case CLEAR_BLANK: default: break; } } else { wattron(state->fieldwin, COLOR_PAIR(state->field[state->Bx * Y + X])); } waddch(state->fieldwin, ' '); waddch(state->fieldwin, ' '); } } } if (state->pause_f) { StatusMessage(state, state->fieldwin, gs_pause); } wattrset(state->fieldwin, A_NORMAL); if (state->game_over_f) { StatusMessage(state, state->fieldwin, gs_gameover); } // paint the tetrad if (state->tetrad) TetradPaint(state->fieldwin, state->tetrad->y + 1, state->tetrad->x + 1, state->tetrad); return;}
开发者ID:KungFuJesus,项目名称:ntetris,代码行数:77,
示例27: _win_print_wrappedstatic void_win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pad_indent){ int starty = getcury(win); int wordi = 0; char *word = malloc(strlen(message) + 1); gchar *curr_ch = g_utf8_offset_to_pointer(message, 0); while (*curr_ch != '/0') { // handle space if (*curr_ch == ' ') { waddch(win, ' '); curr_ch = g_utf8_next_char(curr_ch); // handle newline } else if (*curr_ch == '/n') { waddch(win, '/n'); _win_indent(win, indent + pad_indent); curr_ch = g_utf8_next_char(curr_ch); // handle word } else { wordi = 0; int wordlen = 0; while (*curr_ch != ' ' && *curr_ch != '/n' && *curr_ch != '/0') { size_t ch_len = mbrlen(curr_ch, MB_CUR_MAX, NULL); if ((ch_len == (size_t)-2) || (ch_len == (size_t)-1)) { curr_ch++; continue; } int offset = 0; while (offset < ch_len) { word[wordi++] = curr_ch[offset++]; } curr_ch = g_utf8_next_char(curr_ch); } word[wordi] = '/0'; wordlen = utf8_display_len(word); int curx = getcurx(win); int cury = getcury(win); int maxx = getmaxx(win); // wrap required if (curx + wordlen > maxx) { int linelen = maxx - (indent + pad_indent); // word larger than line if (wordlen > linelen) { gchar *word_ch = g_utf8_offset_to_pointer(word, 0); while(*word_ch != '/0') { curx = getcurx(win); cury = getcury(win); gboolean firstline = cury == starty; if (firstline && curx < indent) { _win_indent(win, indent); } if (!firstline && curx < (indent + pad_indent)) { _win_indent(win, indent + pad_indent); } gchar copy[wordi+1]; g_utf8_strncpy(copy, word_ch, 1); waddstr(win, copy); word_ch = g_utf8_next_char(word_ch); } // newline and print word } else { waddch(win, '/n'); curx = getcurx(win); cury = getcury(win); gboolean firstline = cury == starty; if (firstline && curx < indent) { _win_indent(win, indent); } if (!firstline && curx < (indent + pad_indent)) { _win_indent(win, indent + pad_indent); } waddstr(win, word); } // no wrap required } else { curx = getcurx(win); cury = getcury(win); gboolean firstline = cury == starty; if (firstline && curx < indent) { _win_indent(win, indent); } if (!firstline && curx < (indent + pad_indent)) { _win_indent(win, indent + pad_indent); } waddstr(win, word);//.........这里部分代码省略.........
开发者ID:sizeofvoid,项目名称:profanity,代码行数:101,
注:本文中的waddch函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ waddnstr函数代码示例 C++ w_string_delref函数代码示例 |