void showiostat(void) { int i, row, _col; struct kinfo_cputime diff_cp_time; uint64_t cp_total; diff_cp_time.cp_user = cp_time.cp_user - old_cp_time.cp_user; diff_cp_time.cp_nice = cp_time.cp_nice - old_cp_time.cp_nice; diff_cp_time.cp_sys = cp_time.cp_sys - old_cp_time.cp_sys; diff_cp_time.cp_intr = cp_time.cp_intr - old_cp_time.cp_intr; diff_cp_time.cp_idle = cp_time.cp_idle - old_cp_time.cp_idle; old_cp_time = cp_time; row = 1; cp_total = diff_cp_time.cp_user + diff_cp_time.cp_nice + diff_cp_time.cp_sys + diff_cp_time.cp_intr + diff_cp_time.cp_idle; stat1(row++, diff_cp_time.cp_user, cp_total); stat1(row++, diff_cp_time.cp_nice, cp_total); stat1(row++, diff_cp_time.cp_sys, cp_total); stat1(row++, diff_cp_time.cp_intr, cp_total); stat1(row++, diff_cp_time.cp_idle, cp_total); if (!numbers) { row += 2; for (i = 0; i < num_devices; i++) if (dev_select[i].selected) { if (row > wnd->_maxy - linesperregion) break; row = devstats(row, INSET, i); } return; } _col = INSET; wmove(wnd, row + linesperregion, 0); wdeleteln(wnd); wmove(wnd, row + 3, 0); winsertln(wnd); for (i = 0; i < num_devices; i++) if (dev_select[i].selected) { if (_col + COLWIDTH >= wnd->_maxx - INSET) { _col = INSET, row += linesperregion + 1; if (row > wnd->_maxy - (linesperregion + 1)) break; wmove(wnd, row + linesperregion, 0); wdeleteln(wnd); wmove(wnd, row + 3, 0); winsertln(wnd); } (void) devstats(row + 3, _col, i); _col += COLWIDTH; } }
/* * === FUNCTION ====================================================================== * Name: printWindow * Description: * ===================================================================================== */ int printWindow(WIN win, int *cpt, char *s) { if (*cpt >= win.height - 3) { wmove(win.win, 1, 2); wdeleteln(win.win); wmove(win.win, win.height -2, 2); wdeleteln(win.win); defineBorder(win); mvwprintw(win.win, *cpt, 2, s); } else { mvwprintw(win.win, *cpt, 2, s); (*cpt)++; } return 1; } /* ----- end of function printWindow ----- */
void showiostat(void) { long t; int i, row, _col; #define X(fld) t = cur.fld[i]; cur.fld[i] -= last.fld[i]; last.fld[i] = t etime = 0; for(i = 0; i < CPUSTATES; i++) { X(cp_time); etime += cur.cp_time[i]; } if (etime == 0.0) etime = 1.0; etime /= hertz; row = 1; for (i = 0; i < CPUSTATES; i++) stat1(row++, i); if (!numbers) { row += 2; for (i = 0; i < num_devices; i++) if (dev_select[i].selected) { if (row > wnd->_maxy - linesperregion) break; row = devstats(row, INSET, i); } return; } _col = INSET; wmove(wnd, row + linesperregion, 0); wdeleteln(wnd); wmove(wnd, row + 3, 0); winsertln(wnd); for (i = 0; i < num_devices; i++) if (dev_select[i].selected) { if (_col + COLWIDTH >= wnd->_maxx - INSET) { _col = INSET, row += linesperregion + 1; if (row > wnd->_maxy - (linesperregion + 1)) break; wmove(wnd, row + linesperregion, 0); wdeleteln(wnd); wmove(wnd, row + 3, 0); winsertln(wnd); } (void) devstats(row + 3, _col, i); _col += COLWIDTH; } }
/* * scroll -- * Scroll the window up a line. */ int scroll(WINDOW *win) { register int oy, ox; #ifdef DEBUG __CTRACE("scroll: (%0.2o)\n", win); #endif if (!(win->flags & __SCROLLOK)) return (ERR); getyx(win, oy, ox); wmove(win, 0, 0); wdeleteln(win); wmove(win, oy, ox); if (win == curscr) { putchar('\n'); if (!NONL) win->curx = 0; #ifdef DEBUG __CTRACE("scroll: win == curscr\n"); #endif } return (OK); }
int winsdelln(WINDOW *win, int n) { int i; PDC_LOG(("winsdelln() - called\n")); if (!win) return ERR; if (n > 0) { for (i = 0; i < n; i++) if (winsertln(win) == ERR) return ERR; } else if (n < 0) { n = -n; for (i = 0; i < n; i++) if (wdeleteln(win) == ERR) return ERR; } return OK; }
void delete_user (pid_t pid_name) { int name,i,c,int_name; char r[getmaxx(user_list)-2]; int_name=(int)pid_name; // приводим ПИД к Int (???) /*Считываем поочерёдно номера текущих пользователей в чате в строку*/ for (i=0;i<=(getmaxy(user_list));i++){ wmove(user_list,i,0); for (c=0;c<=getmaxx(user_list);c++){ r[c]=mvwinch(user_list,i,c); } name=atoi(r); // приводим строку к INT /*если номер совпадает, то удаляем пользователя и подтягиваем список вверх*/ if (name==int_name) { wdeleteln(user_list); wrefresh(user_list); y_ptr_list--; return; } } return; }
void delline (void) { if (!ConioInitialized) textmode (LASTMODE); wdeleteln (CurrentWindow); wrefresh (CurrentWindow); }
/* * cl_deleteln -- * Delete the current line, scrolling all lines below it. * * PUBLIC: int cl_deleteln __P((SCR *)); */ int cl_deleteln(SCR *sp) { CHAR_T ch; CL_PRIVATE *clp; WINDOW *win; size_t col, lno, spcnt, y, x; clp = CLP(sp); win = CLSP(sp) ? CLSP(sp) : stdscr; /* * This clause is required because the curses screen uses reverse * video to delimit split screens. If the screen does not do this, * this code won't be necessary. * * If the bottom line was in reverse video, rewrite it in normal * video before it's scrolled. * * Check for the existence of a chgat function; XSI requires it, but * historic implementations of System V curses don't. If it's not * a #define, we'll fall back to doing it by hand, which is slow but * acceptable. * * By hand means walking through the line, retrieving and rewriting * each character. Curses has no EOL marker, so track strings of * spaces, and copy the trailing spaces only if there's a non-space * character following. */ if (!F_ISSET(sp, SC_SCR_EXWROTE) && IS_SPLIT(sp)) { getyx(win, y, x); #ifdef mvchgat mvwchgat(win, RLNO(sp, LASTLINE(sp)), 0, -1, A_NORMAL, 0, NULL); #else for (lno = RLNO(sp, LASTLINE(sp)), col = spcnt = 0;;) { (void)wmove(win, lno, col); ch = winch(win); if (isblank(ch)) ++spcnt; else { (void)wmove(win, lno, col - spcnt); for (; spcnt > 0; --spcnt) (void)waddch(win, ' '); (void)waddch(win, ch); } if (++col >= sp->cols) break; } #endif (void)wmove(win, y, x); } /* * The bottom line is expected to be blank after this operation, * and other screens must support that semantic. */ return (wdeleteln(win) == ERR); }
int mvwdeleteln(WINDOW *win, int y, int x) { PDC_LOG(("mvwdeleteln() - called\n")); if (wmove(win, y, x) == ERR) return ERR; return wdeleteln(win); }
void get_string(WINDOW *my_win){ memset(&input, 0, sizeof(input)); mvwgetnstr(my_win, 0, 7, input, sizeof(input)-1); // The -1 insures a null. // mvwscanw(my_win, 0, 7, "%25c", &input); wdeleteln(my_win); mvwprintw(my_win, 0, 0, "Input: "); update_panels(); doupdate(); }
void scrollup(int top, int bot) { wmove(curwin, top, 0); wdeleteln(curwin); wmove(curwin, bot, 0); winsertln(curwin); wrefresh(curwin); }
int mvdeleteln(int y, int x) { PDC_LOG(("mvdeleteln() - called\n")); if (move(y, x) == ERR) return ERR; return wdeleteln(stdscr); }
void print_win(WINDOW *my_win, char *str){ getmaxyx(my_win, y, x); getyx(my_win, y2, x2); if(y2 == y-1){ // Matches max y on the first run, moves a blank line up, and prints. wmove(my_win, 0, 0); wdeleteln(my_win); wmove(my_win, y2, 0); } for(;*str;str++) if(*str == '\n' || *str == '\r'){ if(y2 == y-1){ wmove(my_win, 0, 0); wdeleteln(my_win); wmove(my_win, y2, 0); } // else waddch(win[1], '\n'); } else waddch(win[1], *str); // wprintw(my_win, "%s", str); update_panels(); doupdate(); }
static void test_winsdelln(WINDOW *win) { STATUS st; int n; init_status(win, &st); do { (void) wattrset(win, st.attr | COLOR_PAIR(st.pair)); switch (st.ch) { case 'i': for (n = 0; n < st.count; ++n) winsertln(win); break; case 'd': for (n = 0; n < st.count; ++n) wdeleteln(win); break; case 'I': winsdelln(win, st.count); break; case 'D': winsdelln(win, -st.count); break; case 'f': fill_window(win); reshow_status(win, &st); break; case 'w': do_subwindow(win, &st, test_winsdelln); break; case 'q': return; default: update_status(win, &st); break; } } while ((st.ch = wgetch(win)) != ERR); }
EIF_INTEGER c_ecurses_wdeleteln (EIF_POINTER w ) { return wdeleteln ((WINDOW *)w) ; };
void option_handler (BOARD_WIDGET* board) { int ch; int i; while ((ch = getch ()) != '\n') { wdeleteln (board -> headerWnd); wmove (board -> headerWnd, 0, 0); wattron (board -> headerWnd, A_BOLD); wprintw (board -> headerWnd, "set options [bs]"); wrefresh (board -> headerWnd); switch (ch) { case 'b' : i = 0; werase (board -> headerWnd); wbkgd (board -> headerWnd, COLOR_PAIR (i) | A_BOLD); wprintw (board -> headerWnd, "Base_col [0-7] : %d", i); wrefresh (board -> headerWnd); while ((ch = getch ()) != '\n') { switch (ch) { case KEY_UP : i = (++i < 8) ? i : 7; werase (board -> headerWnd); wbkgd (board -> headerWnd, COLOR_PAIR (i) | A_BOLD); wprintw (board -> headerWnd, "Base_color [0-7] : %d", i); wrefresh (board -> headerWnd); break; case KEY_DOWN : i = (--i > 0) ? i : 0; werase (board -> headerWnd); wbkgd (board -> headerWnd, COLOR_PAIR (i) | A_BOLD); wprintw (board -> headerWnd, "Base_color [0-7] : %d", i); wrefresh (board -> headerWnd); break; } usleep (1000); } set_colors (board, COLOR_PAIR (i), board -> point_info -> selected_color); break; case 's' : i = 0; werase (board -> headerWnd); wbkgd (board -> headerWnd, COLOR_PAIR (i) | A_BOLD); wprintw (board -> headerWnd, "selected_color [0-7] : %d", i); wrefresh (board -> headerWnd); while ((ch = getch ()) != '\n') { switch (ch) { case KEY_UP : i = (++i < 8) ? i : 7; werase (board -> headerWnd); wbkgd (board -> headerWnd, COLOR_PAIR (i) | A_BOLD); wprintw (board -> headerWnd, "selected_color [0-7] : %d", i); wrefresh (board -> headerWnd); break; case KEY_DOWN : i = (--i > 0) ? i : 0; werase (board -> headerWnd); wbkgd (board -> headerWnd, COLOR_PAIR (i) | A_BOLD); wprintw (board -> headerWnd, "selected_color [0-7] : %d", i); wrefresh (board -> headerWnd); break; } usleep (1000); } set_colors (board, board -> point_info -> base_color, COLOR_PAIR (i)); break; } usleep (1000); } resize_handler (board); }
int deleteln(void) { PDC_LOG(("deleteln() - called\n")); return wdeleteln(stdscr); }
static void outputTest(WINDOW *win) { WINDOW *win1; char Buffer[80]; chtype ch; int by, bx; #if !HAVE_TIGETSTR #if HAVE_TGETENT char tc_buffer[4096]; char tc_parsed[4096]; char *area_pointer = tc_parsed; tgetent(tc_buffer, getenv("TERM")); #else #define tgetstr(a,b) 0 #endif #endif /* !HAVE_TIGETSTR */ nl(); wclear(win); MvWAddStr(win, 1, 1, "You should now have a screen in the upper left corner, and this text should have wrapped"); mvwin(win, 2, 1); waddstr(win, "\nThis text should be down\n"); waddstr(win, "and broken into two here ^"); Continue(win); wclear(win); wattron(win, A_BOLD); MvWAddStr(win, 1, 1, "A new window will appear with this text in it"); MvWAddStr(win, 8, 1, "Press any key to continue"); wrefresh(win); wgetch(win); getbegyx(win, by, bx); if (LINES < 24 || COLS < 75) { MvWAddStr(win, 5, 1, "Some tests have been skipped as they require a"); MvWAddStr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS"); Continue(win); } else { win1 = newwin(10, 50, 14, 25); if (win1 == NULL) { endwin(); return; } #ifdef A_COLOR if (has_colors()) { init_pair(3, COLOR_BLUE, COLOR_WHITE); wbkgd(win1, (chtype) COLOR_PAIR(3)); } else wbkgd(win1, A_NORMAL); #else wbkgd(win1, A_NORMAL); #endif wclear(win1); MvWAddStr(win1, 5, 1, "This text should appear; using overlay option"); copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE); #if defined(PDCURSES) && !defined(XCURSES) box(win1, 0xb3, 0xc4); #else box(win1, ACS_VLINE, ACS_HLINE); #endif wmove(win1, 8, 26); wrefresh(win1); wgetch(win1); wclear(win1); wattron(win1, A_BLINK); MvWAddStr(win1, 4, 1, "This blinking text should appear in only the second window"); wattroff(win1, A_BLINK); mvwin(win1, by, bx); overlay(win, win1); mvwin(win1, 14, 25); wmove(win1, 8, 26); wrefresh(win1); wgetch(win1); delwin(win1); } clear(); wclear(win); wrefresh(win); MvWAddStr(win, 6, 2, "This line shouldn't appear"); MvWAddStr(win, 4, 2, "Only half of the next line is visible"); MvWAddStr(win, 5, 2, "Only half of the next line is visible"); wmove(win, 6, 1); wclrtobot(win); wmove(win, 5, 20); wclrtoeol(win); MvWAddStr(win, 8, 2, "This line also shouldn't appear"); wmove(win, 8, 1); wdeleteln(win); Continue(win); wmove(win, 5, 9); ch = winch(win); wclear(win); wmove(win, 6, 2); waddstr(win, "The next char should be l: "); winsch(win, ch); Continue(win); #if HAVE_WINSSTR (void) mvwinsstr(win, 6, 2, "A1B2C3D4E5"); Continue(win); #endif wmove(win, 5, 1); winsertln(win); MvWAddStr(win, 5, 2, "The lines below should have moved down"); Continue(win); wclear(win); wmove(win, 2, 2); wprintw(win, "This is a formatted string in a window: %d %s\n", 42, "is it"); MvWAddStr(win, 10, 1, "Enter a string: "); wrefresh(win); noraw(); echo(); *Buffer = 0; wscanw(win, "%s", Buffer); printw("This is a formatted string in stdscr: %d %s\n", 42, "is it"); MvAddStr(10, 1, "Enter a string: "); *Buffer = 0; scanw("%s", Buffer); if (TIGETSTR("cvvis", "vs") != 0) { wclear(win); curs_set(2); MvWAddStr(win, 1, 1, "The cursor should appear as a block (visible)"); Continue(win); } if (TIGETSTR("civis", "vi") != 0) { wclear(win); curs_set(0); MvWAddStr(win, 1, 1, "The cursor should have disappeared (invisible)"); Continue(win); } if (TIGETSTR("cnorm", "ve") != 0) { wclear(win); curs_set(1); MvWAddStr(win, 1, 1, "The cursor should be an underline (normal)"); Continue(win); } #ifdef A_COLOR if (has_colors()) { wclear(win); MvWAddStr(win, 1, 1, "Colors should change after you press a key"); Continue(win); init_pair(1, COLOR_RED, COLOR_WHITE); wrefresh(win); } #endif werase(win); #if HAVE_TERMNAME MvWAddStr(win, 1, 1, "Information About Your Terminal"); MvWAddStr(win, 3, 1, termname()); MvWAddStr(win, 4, 1, longname()); if (termattrs() & A_BLINK) MvWAddStr(win, 5, 1, "This terminal supports blinking."); else MvWAddStr(win, 5, 1, "This terminal does NOT support blinking."); #endif (void) mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16); wrefresh(win); (void) mvwinnstr(win, 7, 5, Buffer, 18); MvAddStr(LINES - 2, 10, Buffer); refresh(); Continue(win); }
void scr_delline(struct wdgt *w, u32 l) { wmove(w->wd, l, 0); wdeleteln(w->wd); }
void delline (void) { if (initialized==0) init_lconio(); wdeleteln(conio_scr); wrefresh(conio_scr); }