+ /*
+ * Allow those assumed/default color assumptions to be overridden at
+ * runtime:
+ */
+ if ((env = getenv("NCURSES_ASSUMED_COLORS")) != 0) {
+ int fg, bg;
+ char sep1, sep2;
+ int count = sscanf(env, "%d%c%d%c", &fg, &sep1, &bg, &sep2);
+ if (count >= 1) {
+ sp->_default_fg = ((fg >= 0 && fg < MaxColors) ? fg : COLOR_DEFAULT);
+ if (count >= 3) {
+ sp->_default_bg = ((bg >= 0 && bg < MaxColors) ? bg : COLOR_DEFAULT);
+ }
+ TR(TRACE_CHARPUT | TRACE_MOVE,
+ ("from environment assumed fg=%d, bg=%d",
+ sp->_default_fg,
+ sp->_default_bg));
+ }
+ }
+#if USE_COLORFGBG
+ /*
+ * If rxvt's $COLORFGBG variable is set, use it to specify the assumed
+ * default colors. Note that rxvt (mis)uses bold colors, equating a bold
+ * color to that value plus 8. We'll only use the non-bold color for now -
+ * decide later if it is worth having default attributes as well.
+ */
+ if (getenv("COLORFGBG") != 0) {
+ const char *p = getenv("COLORFGBG");
+ TR(TRACE_CHARPUT | TRACE_MOVE, ("decoding COLORFGBG %s", p));
+ p = extract_fgbg(p, &(sp->_default_fg));
+ p = extract_fgbg(p, &(sp->_default_bg));
+ if (*p) /* assume rxvt was compiled with xpm support */
+ 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 >= MaxColors) {
+ if (set_a_foreground != ABSENT_STRING
+ && !strcmp(set_a_foreground, "\033[3%p1%dm")) {
+ set_a_foreground = strdup("\033[3%?%p1%{8}%>%t9%e%p1%d%;m");
+ } else {
+ sp->_default_fg %= MaxColors;
+ }
+ }
+ if (sp->_default_bg >= MaxColors) {
+ if (set_a_background != ABSENT_STRING
+ && !strcmp(set_a_background, "\033[4%p1%dm")) {
+ set_a_background = strdup("\033[4%?%p1%{8}%>%t9%e%p1%d%;m");
+ } else {
+ sp->_default_bg %= MaxColors;
+ }
+ }
+ }
+#endif
+#endif /* NCURSES_EXT_FUNCS */
+
+ sp->_maxclick = DEFAULT_MAXCLICK;
+ sp->_mouse_event = no_mouse_event;
+ sp->_mouse_inline = no_mouse_inline;
+ sp->_mouse_parse = no_mouse_parse;
+ sp->_mouse_resume = no_mouse_resume;
+ sp->_mouse_wrap = no_mouse_wrap;
+ sp->_mouse_fd = -1;
+
+ /*
+ * If we've no magic cookie support, we suppress attributes that xmc would
+ * affect, i.e., the attributes that affect the rendition of a space.
+ */
+ sp->_ok_attributes = NCURSES_SP_NAME(termattrs) (NCURSES_SP_ARG);
+ if (NCURSES_SP_NAME(has_colors) (NCURSES_SP_ARG)) {
+ sp->_ok_attributes |= A_COLOR;
+ }
+#ifdef USE_TERM_DRIVER
+ _nc_cookie_init(sp);
+#else
+#if USE_XMC_SUPPORT
+ /*
+ * If we have no magic-cookie support compiled-in, or if it is suppressed
+ * in the environment, reset the support-flag.
+ */
+ if (magic_cookie_glitch >= 0) {
+ if (getenv("NCURSES_NO_MAGIC_COOKIE") != 0) {
+ support_cookies = FALSE;
+ }
+ }
+#endif