NCURSES_SP_NAME(newpad) (NCURSES_SP_DCLx int l, int c) { WINDOW *win; NCURSES_CH_T *ptr; int i; T((T_CALLED("newpad(%p,%d, %d)"), (void *) SP_PARM, l, c)); if (l <= 0 || c <= 0) returnWin(0); win = NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_ARGx l, c, 0, 0, _ISPAD); if (win == NULL) returnWin(0); for (i = 0; i < l; i++) { if_USE_SCROLL_HINTS(win->_line[i].oldindex = _NEWINDEX); if ((win->_line[i].text = typeCalloc(NCURSES_CH_T, ((size_t) c))) == 0) { (void) _nc_freewin(win); returnWin(0); } for (ptr = win->_line[i].text; ptr < win->_line[i].text + c; ptr++) SetChar(*ptr, BLANK_TEXT, BLANK_ATTR); } returnWin(win); }
delwin(WINDOW *win) { int result = ERR; T((T_CALLED("delwin(%p)"), (void *) win)); if (_nc_try_global(curses) == 0) { if (win == 0 || cannot_delete(win)) { result = ERR; } else { #if NCURSES_SP_FUNCS SCREEN *sp = _nc_screen_of(win); #endif if (win->_flags & _SUBWIN) touchwin(win->_parent); else if (CurScreen(SP_PARM) != 0) touchwin(CurScreen(SP_PARM)); result = _nc_freewin(win); } _nc_unlock_global(curses); } returnCode(result); }
int delwin(WINDOW *win) { T((T_CALLED("delwin(%p)"), win)); if (win == 0 || have_children(win)) returnCode(ERR); if (win->_flags & _SUBWIN) touchwin(win->_parent); else if (curscr != 0) touchwin(curscr); _nc_freewin(win); returnCode(OK); }
delwin(WINDOW *win) { int result = ERR; T((T_CALLED("delwin(%p)"), win)); if (_nc_try_global(curses) == 0) { if (win == 0 || cannot_delete(win)) { result = ERR; } else { if (win->_flags & _SUBWIN) touchwin(win->_parent); else if (curscr != 0) touchwin(curscr); result = _nc_freewin(win); } _nc_unlock_global(curses); } returnCode(result); }
delscreen(SCREEN *sp) { SCREEN **scan = &_nc_screen_chain; int i; T((T_CALLED("delscreen(%p)"), sp)); while (*scan) { if (*scan == sp) { *scan = sp->_next_screen; break; } scan = &(*scan)->_next_screen; } (void) _nc_freewin(sp->_curscr); (void) _nc_freewin(sp->_newscr); (void) _nc_freewin(sp->_stdscr); if (sp->_slk != 0) { if (sp->_slk->ent != 0) { for (i = 0; i < sp->_slk->labcnt; ++i) { FreeIfNeeded(sp->_slk->ent[i].ent_text); FreeIfNeeded(sp->_slk->ent[i].form_text); } free(sp->_slk->ent); } free(sp->_slk); sp->_slk = 0; } _nc_free_keytry(sp->_keytry); sp->_keytry = 0; _nc_free_keytry(sp->_key_ok); sp->_key_ok = 0; FreeIfNeeded(sp->_current_attr); FreeIfNeeded(sp->_color_table); FreeIfNeeded(sp->_color_pairs); FreeIfNeeded(sp->oldhash); FreeIfNeeded(sp->newhash); FreeIfNeeded(sp->hashtab); del_curterm(sp->_term); /* * If the associated output stream has been closed, we can discard the * set-buffer. Limit the error check to EBADF, since fflush may fail * for other reasons than trying to operate upon a closed stream. */ if (sp->_ofp != 0 && sp->_setbuf != 0 && fflush(sp->_ofp) != 0 && errno == EBADF) { free(sp->_setbuf); } free(sp); /* * If this was the current screen, reset everything that the * application might try to use (except cur_term, which may have * multiple references in different screens). */ if (sp == SP) { curscr = 0; newscr = 0; stdscr = 0; COLORS = 0; COLOR_PAIRS = 0; _nc_set_screen(0); } returnVoid; }
delscreen(SCREEN *sp) { int i; T((T_CALLED("delscreen(%p)"), (void *) sp)); _nc_lock_global(curses); if (delink_screen(sp)) { #ifdef USE_SP_RIPOFF ripoff_t *rop; if (safe_ripoff_sp && safe_ripoff_sp != safe_ripoff_stack) { for (rop = safe_ripoff_stack; rop != safe_ripoff_sp && (rop - safe_ripoff_stack) < N_RIPS; rop++) { if (rop->win) { (void) delwin(rop->win); rop->win = 0; } } } #endif (void) _nc_freewin(CurScreen(sp)); (void) _nc_freewin(NewScreen(sp)); (void) _nc_freewin(StdScreen(sp)); if (sp->_slk != 0) { if (sp->_slk->ent != 0) { for (i = 0; i < sp->_slk->labcnt; ++i) { FreeIfNeeded(sp->_slk->ent[i].ent_text); FreeIfNeeded(sp->_slk->ent[i].form_text); } free(sp->_slk->ent); } free(sp->_slk); sp->_slk = 0; } _nc_free_keytry(sp->_keytry); sp->_keytry = 0; _nc_free_keytry(sp->_key_ok); sp->_key_ok = 0; FreeIfNeeded(sp->_current_attr); FreeIfNeeded(sp->_color_table); FreeIfNeeded(sp->_color_pairs); FreeIfNeeded(sp->oldhash); FreeIfNeeded(sp->newhash); FreeIfNeeded(sp->hashtab); FreeIfNeeded(sp->_acs_map); FreeIfNeeded(sp->_screen_acs_map); NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx sp->_term); free(sp); /* * If this was the current screen, reset everything that the * application might try to use (except cur_term, which may have * multiple references in different screens). */ if (sp == CURRENT_SCREEN) { #if !USE_REENTRANT curscr = 0; newscr = 0; stdscr = 0; COLORS = 0; COLOR_PAIRS = 0; #endif _nc_set_screen(0); } } _nc_unlock_global(curses); returnVoid; }