#include <curses.priv.h>
-#include <term.h> /* cur_term */
#include <tic.h>
#ifndef CUR
-#define CUR SP_TERMTYPE
+#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_set_term.c,v 1.122 2009/05/10 00:48:29 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.126 2009/09/05 18:18:10 tom Exp $")
+
+#ifdef USE_TERM_DRIVER
+#define MaxColors InfoOf(sp).maxcolors
+#define NumLabels InfoOf(sp).numlabels
+#else
+#define MaxColors max_colors
+#define NumLabels num_labels
+#endif
NCURSES_EXPORT(SCREEN *)
set_term(SCREEN *screenp)
newSP = SP;
if (newSP != 0) {
- set_curterm(newSP->_term);
+ TINFO_SET_CURTERM(newSP, newSP->_term);
#if !USE_REENTRANT
curscr = newSP->_curscr;
newscr = newSP->_newscr;
COLOR_PAIRS = newSP->_pair_count;
#endif
} else {
- set_curterm(0);
+ TINFO_SET_CURTERM(oldSP, 0);
#if !USE_REENTRANT
curscr = 0;
newscr = 0;
_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(sp->_curscr);
(void) _nc_freewin(sp->_newscr);
free(sp->_setbuf);
}
- del_curterm(sp->_term);
+ NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx sp->_term);
free(sp);
/*
}
#endif
+#if NCURSES_SP_FUNCS
+/*
+ * In case of handling multiple screens, we need to have a screen before
+ * initialization in setupscreen takes place. This is to extend the substitute
+ * for some of the stuff in _nc_prescreen, especially for slk and ripoff
+ * handling which should be done per screen.
+ */
+NCURSES_EXPORT(SCREEN *)
+new_prescr(void)
+{
+ SCREEN *sp = _nc_alloc_screen_sp();
+ if (sp) {
+ sp->rsp = sp->rippedoff;
+ sp->_filtered = _nc_prescreen.filter_mode;
+ sp->_use_env = _nc_prescreen.use_env;
+#if NCURSES_NO_PADDING
+ sp->_no_padding = _nc_prescreen._no_padding;
+#endif
+ sp->slk_format = 0;
+ sp->_slk = 0;
+ sp->_prescreen = TRUE;
+ SP_PRE_INIT(sp);
+#if USE_REENTRANT
+ sp->_TABSIZE = _nc_prescreen._TABSIZE;
+ sp->_ESCDELAY = _nc_prescreen._ESCDELAY;
+#endif
+ _nc_set_screen(sp);
+ }
+ return sp;
+}
+#endif
+
+#define ReturnScreenError() _nc_set_screen(0); \
+ returnCode(ERR)
+
/* OS-independent screen initializations */
NCURSES_EXPORT(int)
_nc_setupscreen(int slines GCC_UNUSED,
}
T(("created SP %p", SP));
+#if NCURSES_SP_FUNCS
+ sp = SP; /* fixup so SET_LINES and SET_COLS works */
+#endif
SP->_next_screen = _nc_screen_chain;
_nc_screen_chain = SP;
if (filtered) {
slines = 1;
SET_LINES(slines);
+#ifdef USE_TERM_DRIVER
+ CallDriver(sp, setfilter);
+#else
clear_screen = 0;
cursor_down = parm_down_cursor = 0;
cursor_address = 0;
row_address = 0;
cursor_home = carriage_return;
+#endif
T(("filter screensize %dx%d", LINES, COLS));
}
#ifdef __DJGPP__
char sep1, sep2;
int count = sscanf(env, "%d%c%d%c", &fg, &sep1, &bg, &sep2);
if (count >= 1) {
- SP->_default_fg = (fg >= 0 && fg < max_colors) ? fg : C_MASK;
+ SP->_default_fg = (fg >= 0 && fg < MaxColors) ? fg : C_MASK;
if (count >= 3) {
- SP->_default_bg = (bg >= 0 && bg < max_colors) ? bg : C_MASK;
+ SP->_default_bg = (bg >= 0 && bg < MaxColors) ? bg : C_MASK;
}
TR(TRACE_CHARPUT | TRACE_MOVE,
("from environment assumed fg=%d, bg=%d",
p = extract_fgbg(p, &(SP->_default_bg));
TR(TRACE_CHARPUT | TRACE_MOVE, ("decoded fg=%d, bg=%d",
SP->_default_fg, SP->_default_bg));
- if (SP->_default_fg >= max_colors) {
+ if (SP->_default_fg >= MaxColors) {
if (set_a_foreground != ABSENT_STRING
&& !strcmp(set_a_foreground, "\033[3%p1%dm")) {
set_a_foreground = "\033[3%?%p1%{8}%>%t9%e%p1%d%;m";
} else {
- SP->_default_fg %= max_colors;
+ SP->_default_fg %= MaxColors;
}
}
- if (SP->_default_bg >= max_colors) {
+ if (SP->_default_bg >= MaxColors) {
if (set_a_background != ABSENT_STRING
&& !strcmp(set_a_background, "\033[4%p1%dm")) {
set_a_background = "\033[4%?%p1%{8}%>%t9%e%p1%d%;m";
} else {
- SP->_default_bg %= max_colors;
+ SP->_default_bg %= MaxColors;
}
}
}
curscr = SP->_curscr;
#endif
#if USE_SIZECHANGE
- SP->_resize = resizeterm;
+ SP->_resize = NCURSES_SP_NAME(resizeterm);
#endif
newscr->_clear = TRUE;
formats (4-4 or 3-2-3) for which there may be some hardware
support. */
if (rop->hook == _nc_slk_initialize)
- if (!(num_labels <= 0 || !SLK_STDFMT(slk_format)))
+ if (!(NumLabels <= 0 || !SLK_STDFMT(slk_format)))
continue;
if (rop->hook) {
int count;