scr_restore(const char *file) { return NCURSES_SP_NAME(scr_restore) (CURRENT_SCREEN, file); }
set_tabsize(int value) { return NCURSES_SP_NAME(set_tabsize) (CURRENT_SCREEN, value); }
NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep) { WINDOW tmp, *nwin; int n; bool old_format = FALSE; T((T_CALLED("getwin(%p)"), (void *) filep)); if (filep == 0) { returnWin(0); } /* * Read the first 4 bytes to determine first if this is an old-format * screen-dump, or new-format. */ if (read_block(&tmp, 4, filep) < 0) { returnWin(0); } /* * If this is a new-format file, and we do not support it, give up. */ if (!memcmp(&tmp, my_magic, 4)) { #if NCURSES_EXT_PUTWIN if (read_win(&tmp, filep) < 0) #endif returnWin(0); } else if (read_block(((char *) &tmp) + 4, sizeof(WINDOW) - 4, filep) < 0) { returnWin(0); } else { old_format = TRUE; } /* * Check the window-size: */ if (tmp._maxy == 0 || tmp._maxy > MAX_SIZE || tmp._maxx == 0 || tmp._maxx > MAX_SIZE) { returnWin(0); } if (tmp._flags & _ISPAD) { nwin = NCURSES_SP_NAME(newpad) (NCURSES_SP_ARGx tmp._maxy + 1, tmp._maxx + 1); } else { nwin = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx tmp._maxy + 1, tmp._maxx + 1, 0, 0); } /* * We deliberately do not restore the _parx, _pary, or _parent * fields, because the window hierarchy within which they * made sense is probably gone. */ if (nwin != 0) { size_t linesize = sizeof(NCURSES_CH_T) * (size_t) (tmp._maxx + 1); nwin->_curx = tmp._curx; nwin->_cury = tmp._cury; nwin->_maxy = tmp._maxy; nwin->_maxx = tmp._maxx; nwin->_begy = tmp._begy; nwin->_begx = tmp._begx; nwin->_yoffset = tmp._yoffset; nwin->_flags = tmp._flags & ~(_SUBWIN); WINDOW_ATTRS(nwin) = WINDOW_ATTRS(&tmp); nwin->_nc_bkgd = tmp._nc_bkgd; nwin->_notimeout = tmp._notimeout; nwin->_clear = tmp._clear; nwin->_leaveok = tmp._leaveok; nwin->_idlok = tmp._idlok; nwin->_idcok = tmp._idcok; nwin->_immed = tmp._immed; nwin->_scroll = tmp._scroll; nwin->_sync = tmp._sync; nwin->_use_keypad = tmp._use_keypad; nwin->_delay = tmp._delay; nwin->_regtop = tmp._regtop; nwin->_regbottom = tmp._regbottom; if (tmp._flags & _ISPAD) nwin->_pad = tmp._pad; if (old_format) { T(("reading old-format screen dump")); for (n = 0; n <= nwin->_maxy; n++) { if (read_block(nwin->_line[n].text, linesize, filep) < 0) { delwin(nwin); returnWin(0); } } } #if NCURSES_EXT_PUTWIN else { char *txt = 0; bool success = TRUE; NCURSES_CH_T prior = blank; T(("reading new-format screen dump")); for (n = 0; n <= nwin->_maxy; n++) { long row; char *next; if ((txt = read_txt(filep)) == 0) { T(("...failed to read string for row %d", n + 1)); success = FALSE; break; } row = strtol(txt, &next, 10); if (row != (n + 1) || *next != ':') { T(("...failed to read row-number %d", n + 1)); success = FALSE; break; } if (read_row(++next, &prior, nwin->_line[n].text, tmp._maxx + 1) < 0) { T(("...failed to read cells for row %d", n + 1)); success = FALSE; break; } free(txt); txt = 0; } if (!success) { free(txt); delwin(nwin); returnWin(0); } } #endif touchwin(nwin); } returnWin(nwin); }
flash(void) { return NCURSES_SP_NAME(flash) (CURRENT_SCREEN); }
NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx NCURSES_CONST char *name, FILE *ofp, FILE *ifp) { int value; int errret; SCREEN *result = 0; SCREEN *current; TERMINAL *its_term; FILE *_ofp = ofp ? ofp : stdout; FILE *_ifp = ifp ? ifp : stdin; int cols; int slk_format; int filter_mode; TERMINAL *new_term = 0; START_TRACE(); T((T_CALLED("newterm(%p, \"%s\", %p,%p)"), (void *) SP_PARM, name, (void *) ofp, (void *) ifp)); #if NCURSES_SP_FUNCS assert(SP_PARM != 0); if (SP_PARM == 0) returnSP(SP_PARM); #endif _nc_init_pthreads(); _nc_lock_global(curses); current = CURRENT_SCREEN; its_term = (current ? current->_term : 0); INIT_TERM_DRIVER(); /* this loads the capability entry, then sets LINES and COLS */ if ( #if NCURSES_SP_FUNCS SP_PARM->_prescreen && #endif TINFO_SETUP_TERM(&new_term, name, fileno(_ofp), &errret, FALSE) != ERR) { _nc_set_screen(0); #ifdef USE_TERM_DRIVER assert(new_term != 0); #endif #if NCURSES_SP_FUNCS slk_format = SP_PARM->slk_format; filter_mode = SP_PARM->_filtered; #else slk_format = _nc_globals.slk_format; filter_mode = _nc_prescreen.filter_mode; #endif /* * This actually allocates the screen structure, and saves the original * terminal settings. */ if (NCURSES_SP_NAME(_nc_setupscreen) ( #if NCURSES_SP_FUNCS &SP_PARM, #endif *(ptrLines(SP_PARM)), *(ptrCols(SP_PARM)), _ofp, filter_mode, slk_format) == ERR) { _nc_set_screen(current); result = 0; } else { #ifdef USE_TERM_DRIVER TERMINAL_CONTROL_BLOCK *TCB; #elif !NCURSES_SP_FUNCS SP_PARM = CURRENT_SCREEN; #endif assert(SP_PARM != 0); cols = *(ptrCols(SP_PARM)); #ifdef USE_TERM_DRIVER _nc_set_screen(SP_PARM); TCB = (TERMINAL_CONTROL_BLOCK *) new_term; TCB->csp = SP_PARM; #endif /* * In setupterm() we did a set_curterm(), but it was before we set * CURRENT_SCREEN. So the "current" screen's terminal pointer was * overwritten with a different terminal. Later, in * _nc_setupscreen(), we set CURRENT_SCREEN and the terminal * pointer in the new screen. * * Restore the terminal-pointer for the pre-existing screen, if * any. */ if (current) current->_term = its_term; #ifdef USE_TERM_DRIVER SP_PARM->_term = new_term; #else new_term = SP_PARM->_term; #endif /* allow user to set maximum escape delay from the environment */ if ((value = _nc_getenv_num("ESCDELAY")) >= 0) { NCURSES_SP_NAME(set_escdelay) (NCURSES_SP_ARGx value); } /* if the terminal type has real soft labels, set those up */ if (slk_format && NumLabels > 0 && SLK_STDFMT(slk_format)) _nc_slk_initialize(StdScreen(SP_PARM), cols); SP_PARM->_ifd = fileno(_ifp); NCURSES_SP_NAME(typeahead) (NCURSES_SP_ARGx fileno(_ifp)); #ifdef TERMIOS SP_PARM->_use_meta = ((new_term->Ottyb.c_cflag & CSIZE) == CS8 && !(new_term->Ottyb.c_iflag & ISTRIP)); #else SP_PARM->_use_meta = FALSE; #endif SP_PARM->_endwin = FALSE; #ifndef USE_TERM_DRIVER /* * Check whether we can optimize scrolling under dumb terminals in * case we do not have any of these capabilities, scrolling * optimization will be useless. */ SP_PARM->_scrolling = ((scroll_forward && scroll_reverse) || ((parm_rindex || parm_insert_line || insert_line) && (parm_index || parm_delete_line || delete_line))); #endif NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG); /* sets a field in the screen structure */ SP_PARM->_keytry = 0; /* compute movement costs so we can do better move optimization */ #ifdef USE_TERM_DRIVER TCBOf(SP_PARM)->drv->scinit(SP_PARM); #else /* * Check for mismatched graphic-rendition capabilities. Most SVr4 * terminfo trees contain entries that have rmul or rmso equated to * sgr0 (Solaris curses copes with those entries). We do this only * for curses, since many termcap applications assume that * smso/rmso and smul/rmul are paired, and will not function * properly if we remove rmso or rmul. Curses applications * shouldn't be looking at this detail. */ #define SGR0_TEST(mode) (mode != 0) && (exit_attribute_mode == 0 || strcmp(mode, exit_attribute_mode)) SP_PARM->_use_rmso = SGR0_TEST(exit_standout_mode); SP_PARM->_use_rmul = SGR0_TEST(exit_underline_mode); /* compute movement costs so we can do better move optimization */ _nc_mvcur_init(); /* initialize terminal to a sane state */ _nc_screen_init(); #endif /* Initialize the terminal line settings. */ _nc_initscr(NCURSES_SP_ARG); _nc_signal_handler(TRUE); result = SP_PARM; } } _nc_unlock_global(curses); returnSP(result); }
use_default_colors(void) { return NCURSES_SP_NAME(use_default_colors) (CURRENT_SCREEN); }
has_il(void) { return NCURSES_SP_NAME(has_il) (CURRENT_SCREEN); }
tgetent(char *bufp, const char *name) { return NCURSES_SP_NAME(tgetent) (CURRENT_SCREEN, bufp, name); }
tgetflag(NCURSES_CONST char *id) { return NCURSES_SP_NAME(tgetflag) (CURRENT_SCREEN, id); }
napms(int ms) { return NCURSES_SP_NAME(napms) (CURRENT_SCREEN, ms); }
use_legacy_coding(int level) { return NCURSES_SP_NAME(use_legacy_coding) (CURRENT_SCREEN, level); }
slk_attroff(const chtype attr) { return NCURSES_SP_NAME(slk_attroff) (CURRENT_SCREEN, attr); }
_nc_init_acs(void) { NCURSES_SP_NAME(_nc_init_acs) (CURRENT_SCREEN); }
NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep) { WINDOW tmp, *nwin; int n; T((T_CALLED("getwin(%p)"), (void *) filep)); clearerr(filep); if (fread(&tmp, 1, sizeof(WINDOW), filep) < sizeof(WINDOW) || ferror(filep) || tmp._maxy == 0 || tmp._maxy > MAX_SIZE || tmp._maxx == 0 || tmp._maxx > MAX_SIZE) { returnWin(0); } if (tmp._flags & _ISPAD) { nwin = NCURSES_SP_NAME(newpad) (NCURSES_SP_ARGx tmp._maxy + 1, tmp._maxx + 1); } else { nwin = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx tmp._maxy + 1, tmp._maxx + 1, 0, 0); } /* * We deliberately do not restore the _parx, _pary, or _parent * fields, because the window hierarchy within which they * made sense is probably gone. */ if (nwin != 0) { size_t linesize = sizeof(NCURSES_CH_T) * (size_t) (tmp._maxx + 1); nwin->_curx = tmp._curx; nwin->_cury = tmp._cury; nwin->_maxy = tmp._maxy; nwin->_maxx = tmp._maxx; nwin->_begy = tmp._begy; nwin->_begx = tmp._begx; nwin->_yoffset = tmp._yoffset; nwin->_flags = tmp._flags & ~(_SUBWIN); WINDOW_ATTRS(nwin) = WINDOW_ATTRS(&tmp); nwin->_nc_bkgd = tmp._nc_bkgd; nwin->_notimeout = tmp._notimeout; nwin->_clear = tmp._clear; nwin->_leaveok = tmp._leaveok; nwin->_idlok = tmp._idlok; nwin->_idcok = tmp._idcok; nwin->_immed = tmp._immed; nwin->_scroll = tmp._scroll; nwin->_sync = tmp._sync; nwin->_use_keypad = tmp._use_keypad; nwin->_delay = tmp._delay; nwin->_regtop = tmp._regtop; nwin->_regbottom = tmp._regbottom; if (tmp._flags & _ISPAD) nwin->_pad = tmp._pad; for (n = 0; n <= nwin->_maxy; n++) { clearerr(filep); if (fread(nwin->_line[n].text, 1, linesize, filep) < linesize || ferror(filep)) { delwin(nwin); returnWin(0); } } touchwin(nwin); } returnWin(nwin); }
keyok(int c, bool flag) { return NCURSES_SP_NAME(keyok) (CURRENT_SCREEN, c, flag); }
tgetnum(NCURSES_CONST char *id) { return NCURSES_SP_NAME(tgetnum) (CURRENT_SCREEN, id); }
NCURSES_SP_NAME(use_default_colors) (NCURSES_SP_DCL0) { T((T_CALLED("use_default_colors(%p)"), (void *) SP_PARM)); returnCode(NCURSES_SP_NAME(assume_default_colors) (NCURSES_SP_ARGx -1, -1)); }
tgetstr(NCURSES_CONST char *id, char **area) { return NCURSES_SP_NAME(tgetstr) (CURRENT_SCREEN, id, area); }
assume_default_colors(int fg, int bg) { return NCURSES_SP_NAME(assume_default_colors) (CURRENT_SCREEN, fg, bg); }
NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name) { int rc = ERR; int n; bool found_cache = FALSE; #ifdef USE_TERM_DRIVER TERMINAL *termp = 0; #endif START_TRACE(); T((T_CALLED("tgetent()"))); TINFO_SETUP_TERM(&termp, (NCURSES_CONST char *) name, STDOUT_FILENO, &rc, TRUE); #ifdef USE_TERM_DRIVER if (termp == 0 || !((TERMINAL_CONTROL_BLOCK *) termp)->drv->isTerminfo) return (rc); #endif /* * In general we cannot tell if the fixed sgr0 is still used by the * caller, but if tgetent() is called with the same buffer, that is * good enough, since the previous data would be invalidated by the * current call. * * bufp may be a null pointer, e.g., GNU termcap. That allocates data, * which is good until the next tgetent() call. The conventional termcap * is inconvenient because of the fixed buffer size, but because it uses * caller-supplied buffers, can have multiple terminal descriptions in * use at a given time. */ for (n = 0; n < TGETENT_MAX; ++n) { bool same_result = (MyCache[n].last_used && MyCache[n].last_bufp == bufp); if (same_result) { CacheInx = n; if (FIX_SGR0 != 0) { FreeAndNull(FIX_SGR0); } /* * Also free the terminfo data that we loaded (much bigger leak). */ if (LAST_TRM != 0 && LAST_TRM != TerminalOf(SP_PARM)) { TERMINAL *trm = LAST_TRM; NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx LAST_TRM); for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) if (LAST_TRM == trm) LAST_TRM = 0; CacheInx = n; } found_cache = TRUE; break; } } if (!found_cache) { int best = 0; for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) { if (LAST_SEQ < MyCache[best].sequence) { best = CacheInx; } } CacheInx = best; } LAST_TRM = TerminalOf(SP_PARM); LAST_SEQ = ++CacheSeq; PC = 0; UP = 0; BC = 0; FIX_SGR0 = 0; /* don't free it - application may still use */ if (rc == 1) { if (cursor_left) if ((backspaces_with_bs = (char) !strcmp(cursor_left, "\b")) == 0) backspace_if_not_bs = cursor_left; /* we're required to export these */ if (pad_char != NULL) PC = pad_char[0]; if (cursor_up != NULL) UP = cursor_up; if (backspace_if_not_bs != NULL) BC = backspace_if_not_bs; if ((FIX_SGR0 = _nc_trim_sgr0(&(TerminalOf(SP_PARM)->type))) != 0) { if (!strcmp(FIX_SGR0, exit_attribute_mode)) { if (FIX_SGR0 != exit_attribute_mode) { free(FIX_SGR0); } FIX_SGR0 = 0; } } LAST_BUF = bufp; LAST_USE = TRUE; SetNoPadding(SP_PARM); (void) NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG); /* sets ospeed as a side-effect */ /* LINT_PREPRO #if 0*/ #include <capdefaults.c> /* LINT_PREPRO #endif*/ } #ifdef FREEBSD_NATIVE /* * This is a REALLY UGLY hack. Basically, if we originate with * a termcap source, try and copy it out. */ if (bufp && _nc_termcap[0]) strncpy(bufp, _nc_termcap, 1024); #endif returnCode(rc); }
safe_keyname (SCREEN *sp, int c) { int i; char name[20]; char *p; NCURSES_CONST char *result = 0; if (c == -1) { result = "-1"; } else { for (i = 0; _nc_key_names[i].offset != -1; i++) { if (_nc_key_names[i].code == c) { result = (NCURSES_CONST char *)key_names + _nc_key_names[i].offset; break; } } if (result == 0 && (c >= 0 && c < SIZEOF_TABLE)) { if (MyTable == 0) MyTable = typeCalloc(char *, SIZEOF_TABLE); if (MyTable != 0) { int m_prefix = (sp == 0 || sp->_use_meta); /* if sense of meta() changed, discard cached data */ if (MyInit != (m_prefix + 1)) { MyInit = m_prefix + 1; for (i = 0; i < SIZEOF_TABLE; ++i) { if (MyTable[i]) { FreeAndNull(MyTable[i]); } } } /* create and cache result as needed */ if (MyTable[c] == 0) { int cc = c; p = name; #define P_LIMIT (sizeof(name) - (size_t) (p - name)) if (cc >= 128 && m_prefix) { _nc_STRCPY(p, "M-", P_LIMIT); p += 2; cc -= 128; } if (cc < 32) _nc_SPRINTF(p, _nc_SLIMIT(P_LIMIT) "^%c", cc + '@'); else if (cc == 127) _nc_STRCPY(p, "^?", P_LIMIT); else _nc_SPRINTF(p, _nc_SLIMIT(P_LIMIT) "%c", cc); MyTable[c] = strdup(name); } result = MyTable[c]; } #if NCURSES_EXT_FUNCS && NCURSES_XNAMES } else if (result == 0 && HasTerminal(sp)) { int j, k; char * bound; TERMTYPE *tp = &(TerminalOf(sp)->type); unsigned save_trace = _nc_tracing; _nc_tracing = 0; /* prevent recursion via keybound() */ for (j = 0; (bound = NCURSES_SP_NAME(keybound)(NCURSES_SP_ARGx c, j)) != 0; ++j) { for(k = STRCOUNT; k < (int) NUM_STRINGS(tp); k++) { if (tp->Strings[k] != 0 && !strcmp(bound, tp->Strings[k])) { result = ExtStrname(tp, k, strnames); break; } } free(bound); if (result != 0) break; } _nc_tracing = save_trace; #endif } }
static void mouse_activate(SCREEN *sp, int on) { if (!on && !sp->_mouse_initialized) return; if (!_nc_mouse_init(sp)) return; if (on) { sp->_mouse_bstate = 0; switch (sp->_mouse_type) { case M_XTERM: #if NCURSES_EXT_FUNCS NCURSES_SP_NAME(keyok) (NCURSES_SP_ARGx KEY_MOUSE, on); #endif TPUTS_TRACE("xterm mouse initialization"); enable_xterm_mouse(sp, 1); break; #if USE_GPM_SUPPORT case M_GPM: if (enable_gpm_mouse(sp, TRUE)) { sp->_mouse_fd = *(my_gpm_fd); T(("GPM mouse_fd %d", sp->_mouse_fd)); } break; #endif #if USE_SYSMOUSE case M_SYSMOUSE: signal(SIGUSR2, handle_sysmouse); sp->_mouse_active = TRUE; break; #endif #ifdef USE_TERM_DRIVER case M_TERM_DRIVER: sp->_mouse_active = TRUE; break; #endif case M_NONE: return; } /* Make runtime binding to cut down on object size of applications that * do not use the mouse (e.g., 'clear'). */ sp->_mouse_event = _nc_mouse_event; sp->_mouse_inline = _nc_mouse_inline; sp->_mouse_parse = _nc_mouse_parse; sp->_mouse_resume = _nc_mouse_resume; sp->_mouse_wrap = _nc_mouse_wrap; } else { switch (sp->_mouse_type) { case M_XTERM: TPUTS_TRACE("xterm mouse deinitialization"); enable_xterm_mouse(sp, 0); break; #if USE_GPM_SUPPORT case M_GPM: enable_gpm_mouse(sp, FALSE); break; #endif #if USE_SYSMOUSE case M_SYSMOUSE: signal(SIGUSR2, SIG_IGN); sp->_mouse_active = FALSE; break; #endif #ifdef USE_TERM_DRIVER case M_TERM_DRIVER: sp->_mouse_active = FALSE; break; #endif case M_NONE: return; } } NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); }
baudrate(void) { return NCURSES_SP_NAME(baudrate) (CURRENT_SCREEN); }
ungetmouse(MEVENT * aevent) { return NCURSES_SP_NAME(ungetmouse) (CURRENT_SCREEN, aevent); }
newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp) { return NCURSES_SP_NAME(newterm) (CURRENT_SCREEN_PRE, name, ofp, ifp); }
mousemask(mmask_t newmask, mmask_t * oldmask) { return NCURSES_SP_NAME(mousemask) (CURRENT_SCREEN, newmask, oldmask); }
scr_set(const char *file) { return NCURSES_SP_NAME(scr_set) (CURRENT_SCREEN, file); }
mouseinterval(int maxclick) { return NCURSES_SP_NAME(mouseinterval) (CURRENT_SCREEN, maxclick); }
getwin(FILE *filep) { return NCURSES_SP_NAME(getwin) (CURRENT_SCREEN, filep); }
nofilter(void) { NCURSES_SP_NAME(nofilter) (CURRENT_SCREEN); }