int startupmenu(int i) { while (1) { drawbox(5, STARTUP_Y-2, 22, STARTUP_N+4, NULL); printmenuhelp(19); i = startup_menu(i-1, 8, STARTUP_Y); # ifndef TTY_SOCKET if (!i) break; # else if (i==2 && !select_2p_tty(24, STARTUP_Y+1)) continue; if (!i) { setcurs(5, STARTUP_Y-2); wclrtobot(window); if ((i = menu_checkinvit(1, 7)) == -1) { refresh(); setwcurs(0, 5, 7); i = 1; continue; } if (!i) break; } move(term_height-1, 0); clrtoeol(); refresh(); # endif setcurs(5, STARTUP_Y-2); wclrtobot(window); break; } return i; }
void quit(void) { int c, y, x; struct itimerval itv; getyx(input, y, x); wmove(input, 2, 0); waddstr(input, "Really quit? (y/n) "); wclrtobot(input); wrefresh(input); fflush(stdout); c = getchar(); if (c == EOF || c == 'y') { /* disable timer */ itv.it_value.tv_sec = 0; itv.it_value.tv_usec = 0; setitimer(ITIMER_REAL, &itv, NULL); fflush(stdout); clear(); refresh(); endwin(); log_score(0); exit(0); } wmove(input, 2, 0); wclrtobot(input); wmove(input, y, x); wrefresh(input); fflush(stdout); }
int gamemenu() { int i = 0; #ifdef TWOPLAYER int y = 7; while (1) { if (!TWOPLAYER_MODE) { if (term_height >= 23) show_hiscorelist5(5, GAMEMENU_LENGTH+9, 0); } else if (term_height < 23) { setcurs(1, 4); cleartoeol(); y = 5; } i = game_menu(0, 1, y); if (i != 4) break; wclrtobot(window); inputsetup_box(0, 1, 7); } if (!i) { setcurs(1, 4); wclrtobot(window); print_vitetris_ver(19, 4); } #else while (1) { printmenuhelp(19); i = game_menu(i, 1, 7); if (!i) break; clearbox(0, 7, 0, GAMEMENU_LENGTH); if (i != 4 && i < GAMEMENU_LENGTH-1) break; wclrtobot(window); switch (i) { case 4: inputsetup_box(0, 1, 7); i = 0; continue; case GAMEMENU_LENGTH-1: optionsmenu(); break; default: hiscorelist(); } i--; } #endif return i; }
void ui::ValMonitor::refresh(void) { //Clear the screen wmove(_valmonitor, 0, 0); wclrtobot(_valmonitor); printVals(); wrefresh(_valmonitor); }
void ui::CamSettings::refresh(void) { //Clear the screen wmove(_camsettings, 0, 0); wclrtobot(_camsettings); printVals(); wrefresh(_camsettings); }
void ioclrtobot(void) { wclrtobot(input); wrefresh(input); fflush(stdout); }
/* * Prints either the left (unselected) or right (selected) list. */ static void print_1_list(ALL_DATA * data, int choice, int selected) { MY_DATA *moi = data->list + selected; WINDOW *win = moi->win; int i, j; int last = 0; int max_rows = getmaxy(win); for (i = j = 0; j < max_rows; i++) { int ii = i + moi->top_index; if (ii >= data->item_no) { break; } else if (!(selected ^ (data->items[ii].state != 0))) { print_item(data, win, &data->items[ii], j, ii == choice); last = ++j; } } if (wmove(win, last, 0) != ERR) wclrtobot(win); (void) wnoutrefresh(win); }
void loser(const PLANE *p, const char *s) { int c; struct itimerval itv; /* disable timer */ itv.it_value.tv_sec = 0; itv.it_value.tv_usec = 0; setitimer(ITIMER_REAL, &itv, NULL); wmove(input, 0, 0); wclrtobot(input); wprintw(input, "Plane '%c' %s\n\nHit space for top players list...", name(p), s); wrefresh(input); fflush(stdout); while ((c = getchar()) != EOF && c != ' ') ; clear(); /* move to top of screen */ refresh(); endwin(); log_score(0); exit(0); }
void showpigs(void) { int i, j, y, k; const char *uname, *pname; char pidname[30]; if (pt == NULL) return; qsort(pt, nproc, sizeof (struct p_times), compar); y = 1; i = nproc; if (i > wnd->_maxy-1) i = wnd->_maxy-1; for (k = 0; i > 0 && pt[k].pt_pctcpu > 0.01; i--, y++, k++) { uname = user_from_uid(pt[k].pt_kp->ki_uid, 0); pname = pt[k].pt_kp->ki_comm; wmove(wnd, y, 0); wclrtoeol(wnd); mvwaddstr(wnd, y, 0, uname); snprintf(pidname, sizeof(pidname), "%10.10s", pname); mvwaddstr(wnd, y, 9, pidname); wmove(wnd, y, 20); for (j = pt[k].pt_pctcpu * 50 + 0.5; j > 0; j--) waddch(wnd, 'X'); } wmove(wnd, y, 0); wclrtobot(wnd); }
void ui::Footer::refresh(void) { wmove(_footer, 0, 0); wclrtobot(_footer); time = std::time(nullptr); std::string timestring = std::asctime(std::localtime(&time)); mvwaddstr(_footer, 0, (xsize - (int)timestring.size()), timestring.c_str()); wrefresh(_footer); }
static void _useceod(int topy, int boty) { short *begns, *begch; /* skip lines already blanked */ begch = _virtscr->_firstch + topy; begns = _BEGNS + topy; for (; topy < boty; ++topy, ++begns, ++begch) if (*begns < scrco || *begch == _REDRAW) break; else *begch = _INFINITY; /* nothing to do */ if (topy + 1 >= boty) return; /* see if bottom is clear */ for (begns = _BEGNS + boty; boty < scrli; ++boty, ++begns) if (*begns < scrco) return; /* use clear-screen if appropriate */ if (topy == 0) { /* SS: colors */ if (back_color_erase) _turn_off_background(); _PUTS(clear_screen, scrli); cy = 0; cx = 0; (void) werase(curscr); } else /* use clear-to-end-of-display or delete lines */ if (clr_eos || (parm_delete_line && !memory_below)) { (void) mvcur(cy, cx, topy, 0); /* LINTED */ cy = (short) topy; cx = 0; /* SS: colors */ if (back_color_erase) _turn_off_background(); _PUTS(clr_eos ? clr_eos : tparm_p1(parm_delete_line, scrli - topy), scrli - topy); /* update curscr */ /* LINTED */ curscr->_cury = (short) topy; curscr->_curx = 0; (void) wclrtobot(curscr); } else /* no hardware support */ return; /* correct the update structure */ (void) wtouchln(_virtscr, topy, scrli, FALSE); }
void optionsmenu() { const char *items[2] = {"Term BG", "Line Drawing"}; int n = 1+!(textgfx_flags & CYGWIN); draw_options_box(); options_menu(items, n, op_handler, 3, 9); setcurs(0, 7); wclrtobot(window); }
int werase(WINDOW *win) { PDC_LOG(("werase() - called\n")); if (wmove(win, 0, 0) == ERR) return ERR; return wclrtobot(win); }
void labelsensors(void) { wmove(wnd, 0, 0); wclrtobot(wnd); mvwaddstr(wnd, 0, 0, "Sensor"); mvwaddstr(wnd, 0, 34, "Value"); mvwaddstr(wnd, 0, 45, "Status"); mvwaddstr(wnd, 0, 58, "Description"); }
void showdf(void) { int i, j, skip; char s[MNAMELEN]; char s2[MNAMELEN]; float pct; int64_t used, bsize, bavail, availblks; int y; y=2; /* at what line to start displaying */ for (i=0; i<nfss; i++) { skip = 0; for(j=0; nodisplay[j] != NULL; j++) { if (strcmp(nodisplay[j], fss[i].f_fstypename) == 0) { skip=1; break; } } if (displayall || !skip) { wmove(wnd, y, 0); wclrtoeol(wnd); snprintf(s, sizeof(s), "%s", fss[i].f_mntonname); mvwaddstr(wnd, y, 0, s); used = fss[i].f_blocks - fss[i].f_bfree; bavail = fss[i].f_bavail; availblks = bavail + used; bsize = fss[i].f_frsize; if (availblks == 0) { pct = 1.0; /* full pseudo-disk */ } else { pct = (1.0 * used) / availblks; } #define FREELEN 7 humanize_number(s2, FREELEN, bavail*bsize, " |", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); snprintf(s, sizeof(s), "%*s", FREELEN, s2); mvwaddstr(wnd, y, 25-FREELEN, s); #undef FREELEN mvwhline(wnd, y, 25, 'X', (int)(51*pct)); y++; } } wmove(wnd, y, 0); wclrtobot(wnd); }
value caml_curses_wclrtobot(value mlwindow) { CAMLparam1(mlwindow); WINDOW *window = window_of_ml(mlwindow); /* Erase to end of current line, then clear all remaining lines. */ wclrtobot(window); CAMLreturn(Val_unit); }
int recvp(WINDOW *chatwin,int* chy,int chx,int maxcol,WINDOW* usrwin,char* uname,int sd,char *buf,size_t len,int flags){ int response= recv(sd,buf,len,flags); if(response!=-1){ int i,x; int ux=2; int uy=2; x=0; char username[MAXUSERSIZE]; bzero(username,MAXUSERSIZE); //trying to add username displays and whether or not they are away if(memcmp(buf,":users:",7)==0){ //clear the window and restore border wmove(usrwin,0,0); wclrtobot(usrwin); box(usrwin, 0 , 0); wrefresh(usrwin); attron(A_BOLD|A_UNDERLINE); mvwprintw(usrwin,1,10,"USERS"); wrefresh(usrwin); attroff(A_BOLD|A_UNDERLINE); for(i=7;i<len&&buf[i]!='\0';i++){ if(buf[i]==(char)6){ x=0; mvwprintw(usrwin,uy,ux,"%s",username); wrefresh(usrwin); uy++; bzero(username,MAXUSERSIZE); continue; } username[x++]=buf[i]; } return response; } if(memcmp(buf,"close\0",6)==0){ mvwprintw(chatwin,*chy,chx,"%s has left the chat",uname); wrefresh(chatwin); (*chy)++; }else{ mvwprintw(chatwin,*chy,chx,"%s\n",buf); wrefresh(chatwin); for(i=0;i<response/maxcol+1;i++) (*chy)++; } return response; }else return response; }
// function that refreshes grid of screen void update(int header) { if (cmd_multiplier > 1) return; if (atoi(get_conf_value("nocurses"))) return; // Limpio desde comienzo hacia to bottom if (header) { wmove(main_win, 0, rescol); wclrtobot(main_win); } // calculo las filas y columnas que quedan ocultas // mxcol-1 es el numero de la ultima sc_col que se ve en pantalla // mxrow-1 es el numero de la ultima sc_row que se ve en pantalla int off_cols = calc_offscr_sc_cols(); int off_rows = calc_offscr_sc_rows(); int mxcol = offscr_sc_cols + off_cols - 1; int mxrow = offscr_sc_rows + off_rows - 1; /* You can't hide the last row or col */ while (row_hidden[currow]) currow++; while (col_hidden[curcol]) curcol++; // Muestro en pantalla el contenido de las celdas // Valores numericos, strings justificados, centrados y expresiones. show_content(main_win, mxrow, mxcol); // Show sc_col headings: A, B, C, D.. show_sc_col_headings(main_win, mxcol, mxrow); // Show sc_row headings: 0, 1, 2, 3.. show_sc_row_headings(main_win, mxrow); // Refresco ventanas de curses wrefresh(main_win); // Muestro detalle de celda en header (primera fila) if (header) show_celldetails(input_win); // print mode (void) print_mode(input_win); return; }
void wclear (WINDOW *win) { if (! win->subwin) { /* Yippie, root window, clear it all up ... */ TTYDEBUG ("clearing root-window.\n"); memset (tty_image, 32, LINES * COLS); tty_ll_clear (); win->y = 0; win->x = 0; return; } wmove (win, 0, 0); wclrtobot (win); }
void hud_display(struct game_t *game) { wmove(game->hud_window, 0, 0); wclrtobot(game->hud_window); /* Remaining flags */ wmove(game->hud_window, 0, 0); int flags = grid_count_cells(&game->grid, CELL_FLAGGED); int bombs = game->grid.total_bombs; wprintw(game->hud_window, "%d", bombs - flags); /* Smiley */ wmove(game->hud_window, 0, 5); const char *smiley = smilies[game->state]; wprintw(game->hud_window, "%s", smiley); wrefresh(game->hud_window); }
void labeliostat(void) { int row; row = 0; wmove(wnd, row, 0); wclrtobot(wnd); mvwaddstr(wnd, row++, INSET, "/0% /10 /20 /30 /40 /50 /60 /70 /80 /90 /100"); mvwaddstr(wnd, row++, 0, "cpu user|"); mvwaddstr(wnd, row++, 0, " nice|"); mvwaddstr(wnd, row++, 0, " system|"); mvwaddstr(wnd, row++, 0, "interrupt|"); mvwaddstr(wnd, row++, 0, " idle|"); if (numbers) row = numlabels(row + 1); else row = barlabels(row + 1); }
void planewin(void) { PLANE *pp; int warning = 0; #ifdef BSD wclear(planes); #endif wmove(planes, 0,0); #ifdef SYSV wclrtobot(planes); #endif wprintw(planes, "Time: %-4d Safe: %d", clck, safe_planes); wmove(planes, 2, 0); waddstr(planes, "pl dt comm"); for (pp = air.head; pp != NULL; pp = pp->next) { if (waddch(planes, '\n') == ERR) { warning++; break; } waddstr(planes, command(pp)); } waddch(planes, '\n'); for (pp = ground.head; pp != NULL; pp = pp->next) { if (waddch(planes, '\n') == ERR) { warning++; break; } waddstr(planes, command(pp)); } if (warning) { wmove(planes, LINES - INPUT_LINES - 1, 0); waddstr(planes, "---- more ----"); wclrtoeol(planes); } wrefresh(planes); fflush(stdout); }
static int op_handler(int k, int *pos) { const struct termopt opts[2] = { { WHITE_BG, "black white", "bg" }, { ASCII, "VT100 ASCII", "drawing" } }; int i = *pos-2; if (i < 0) { if (k) { setcurs(0, 16); wclrtobot(window); inputsetup_box(k-1, 1, 7); } draw_options_box(); return 1; } if (!i && !k) { getyx(window, i, k); setcurs(2, i+5+!(textgfx_flags & CYGWIN)); putnchars(HLINE, 28); help_cmdline(); setcurs(k, i); i = k = 0; } if (i < 1+!(textgfx_flags & CYGWIN)) i = term_optionhandler(k, opts+i); #ifndef NO_BLOCKSTYLES else i = select_blockstyle(k); #endif if (i == 3) { draw_tetris_logo(0, 0); if (!_MONOCHROME) { init_color_pairs(); if (*pos == 2) clearok(window, TRUE); } draw_options_box(); } return i; }
/* Fill the screen with blank after the file ** -------------------------- */ PRIVATE void fill_screen (HText * text, int n) { if (n<=0 || n>1000) return; /* Large value means no pagination */ if (text->target) return; #ifdef CURSES waddstr(w_text, end_mark); wclrtobot(w_text); wrefresh(w_text); #else #ifndef VIOLA if (!text->target) OutputData(LineMode_getView(text->pLm), "%s\n", end_mark); else { PUTS(end_mark); PUTC('\n'); } n--; for (; n; n--) { if (!text->target) OutputData(LineMode_getView(text->pLm), "\n"); else PUTC('\n'); } #endif #endif /* Not CURSES */ }
void print_lines(GList *start_line, GList *end_line, gboolean clear_bottom_lines) { GList *line_ptr; int line_number; if (end_line == NULL) end_line = last_line; else if (start_line != NULL) { for (line_ptr = start_line; g_list_position(first_line, line_ptr) < getmaxy(tree_window); line_ptr = g_list_next(line_ptr)) { print_line(line_ptr); if (line_ptr == end_line) break; } } line_number = g_list_position(first_line, last_line) + 1; if (clear_bottom_lines && line_number < getmaxy(tree_window)) { wmove(tree_window, line_number, 0); wclrtobot(tree_window); } }
void showmbufs(void) { int i, j, max, idx; char buf[10]; if (mb == 0) return; for (j = 1; j <= getmaxy(wnd); j++) { max = 0, idx = -1; for (i = 0; i < getmaxy(wnd); i++) if (mb->m_mtypes[i] > max) { max = mb->m_mtypes[i]; idx = i; } if (max == 0) break; if (j >= (int)NNAMES) mvwprintw(wnd, j, 0, "%10d", idx); else mvwprintw(wnd, j, 0, "%-10.10s", &mbuftypes[idx][2]); wmove(wnd, j, 10); if (max > 60) { snprintf(buf, sizeof buf, " %5d", max); max = 60; while (max--) waddch(wnd, 'X'); waddstr(wnd, buf); } else { wclrtoeol(wnd); whline(wnd, 'X', max); } mb->m_mtypes[idx] = 0; } wmove(wnd, j, 0); wclrtobot(wnd); }
int dump_new_vars(struct user_regs_struct *regs, struct user_regs_struct *old_regs, void *stack_frame, WINDOW *win, unsigned *hl) { size_t idx; size_t var_len; size_t c_co; char disa; if (old_regs->rsp > regs->rsp) { idx = regs->rbp - old_regs->rsp + 8; var_len = old_regs->rsp - regs->rsp; addr_prefix(regs->rbp, idx, var_len + idx, win); if ((var_len + idx) / 16 < WIN_OSTACK_LI) update_var(win, (char *)stack_frame + idx, idx, var_len, hl, COLOR_PAIR(2)); prefresh(win, 0, 0, WIN_BORDER_LEN, WIN_BORDER_LEN, WIN_STACK_LI, WIN_STACK_CO); } else { disa = (regs->rbp % 16 ? 1 : 0) ^ (regs->rbp - regs->rsp % 16 ? 1 : 0); idx = regs->rbp - regs->rsp + 8; c_co = idx % 16; c_co += c_co + c_co / 2 + c_co / 8; wmove(win, idx / 16, c_co + (disa ? ADDR_PLEN : 0)); if (disa) wmove(win, idx / 16, 45 + idx % 16 + ADDR_PLEN); wclrtobot(win); prefresh(win, 0, 0, WIN_BORDER_LEN, WIN_BORDER_LEN, WIN_STACK_LI, WIN_STACK_CO); } return (0); }
void wscroll (WINDOW *win, uint8_t lines) { TTYDEBUG ("wscroll: lines=%d, maxy=%d\n", lines, win->maxy); if (lines > win->maxy) { wclear (win); /* Cursor home. */ return; } for (uint8_t y = 0; y <= win->maxy - lines; y ++) { TTYDEBUG_MAP ("wscroll: copying y=%d\n", y); wmove (win, y, 0); for (uint8_t x = 0; x <= win->maxx; x ++) waddch (win, map (win, y + lines, win->x)); /* Copy content. */ } /* Finally position the cursor to the beginning of the first clear line and clear till the end. */ wmove (win, win->maxy - lines + 1, 0); wclrtobot (win); /* Restores cursor. */ }
int clrtobot(void) { PDC_LOG(("clrtobot() - called\n")); return wclrtobot(stdscr); }
static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key) { ChatContext *ctx = (ChatContext *) self->chatwin; struct tm *timeinfo = get_time(); int x, y, y2, x2; getyx(self->window, y, x); getmaxyx(self->window, y2, x2); /* BACKSPACE key: Remove one character from line */ if (key == 0x107 || key == 0x8 || key == 0x7f) { if (ctx->pos > 0) { ctx->line[--ctx->pos] = L'\0'; if (x == 0) mvwdelch(self->window, y - 1, x2 - 1); else mvwdelch(self->window, y, x - 1); } } else /* Add printable chars to buffer and print on input space */ #if HAVE_WIDECHAR if (iswprint(key)) { #else if (isprint(key)) { #endif if (ctx->pos < (MAX_STR_SIZE-1)) { mvwaddstr(self->window, y, x, wc_to_char(key)); ctx->line[ctx->pos++] = key; ctx->line[ctx->pos] = L'\0'; } } /* RETURN key: Execute command or print line */ else if (key == '\n') { uint8_t *line = wcs_to_char(ctx->line); wclear(ctx->linewin); wmove(self->window, y2 - CURS_Y_OFFSET, 0); wclrtobot(self->window); bool close_win = false; if (line[0] == '/') { if (close_win = strncmp(line, "/close", strlen("/close")) == 0) { set_active_window(0); int groupnum = self->num; delwin(ctx->linewin); del_window(self); close_groupchatwin(m, groupnum); } else if (strncmp(line, "/help", strlen("/help")) == 0) print_groupchat_help(ctx); else execute(ctx->history, self->prompt, m, line, ctx->pos); } else { /* make sure the string has at least non-space character */ if (!string_is_empty(line)) { // uint8_t selfname[TOX_MAX_NAME_LENGTH]; // tox_getselfname(m, selfname, TOX_MAX_NAME_LENGTH); // wattron(ctx->history, COLOR_PAIR(CYAN)); // wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec); // wattroff(ctx->history, COLOR_PAIR(CYAN)); // wattron(ctx->history, COLOR_PAIR(GREEN)); // wprintw(ctx->history, "%s: ", selfname); // wattroff(ctx->history, COLOR_PAIR(GREEN)); // wprintw(ctx->history, "%s\n", line); if (tox_group_message_send(m, self->num, line, strlen(line) + 1) == -1) { wattron(ctx->history, COLOR_PAIR(RED)); wprintw(ctx->history, " * Failed to send message.\n"); wattroff(ctx->history, COLOR_PAIR(RED)); } } } if (close_win) free(ctx); else { ctx->line[0] = L'\0'; ctx->pos = 0; } free(line); } } static void groupchat_onDraw(ToxWindow *self, Tox *m) { curs_set(1); int x, y; getmaxyx(self->window, y, x); ChatContext *ctx = (ChatContext *) self->chatwin; mvwhline(ctx->linewin, 0, 0, '_', x); wrefresh(self->window); }