+ /*
+ * Allow those assumed/default color assumptions to be overridden at
+ * runtime:
+ */
+ if (getenv("NCURSES_ASSUMED_COLORS") != 0) {
+ char *p = getenv("NCURSES_ASSUMED_COLORS");
+ int fg, bg;
+ char sep1, sep2;
+ int count = sscanf(p, "%d%c%d%c", &fg, &sep1, &bg, &sep2);
+ if (count >= 1) {
+ SP->_default_fg = (fg >= 0 && fg < max_colors) ? fg : C_MASK;
+ if (count >= 3) {
+ SP->_default_bg = (bg >= 0 && bg < max_colors) ? bg : C_MASK;
+ }
+ 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) {
+ 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 >= max_colors) {
+ 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;
+ }
+ }
+ if (SP->_default_bg >= max_colors) {
+ 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;
+ }
+ }
+ }
+#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;
+
+ /* initialize the panel hooks */
+ SP->_panelHook.top_panel = (struct panel *) 0;
+ SP->_panelHook.bottom_panel = (struct panel *) 0;
+ SP->_panelHook.stdscr_pseudo_panel = (struct panel *) 0;
+
+ /*
+ * 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 = termattrs();
+ if (has_colors()) {
+ SP->_ok_attributes |= A_COLOR;
+ }
+#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