static void enable_xterm_mouse(SCREEN *sp, int enable) { #if USE_EMX_MOUSE sp->_emxmouse_activated = enable; #else NCURSES_PUTP2("xterm-mouse", TPARM_1(sp->_mouse_xtermcap, enable)); #endif sp->_mouse_active = enable; }
NCURSES_SP_NAME(init_color) (NCURSES_SP_DCLx NCURSES_COLOR_T color, NCURSES_COLOR_T r, NCURSES_COLOR_T g, NCURSES_COLOR_T b) { int result = ERR; int maxcolors; T((T_CALLED("init_color(%p,%d,%d,%d,%d)"), (void *) SP_PARM, color, r, g, b)); if (SP_PARM == 0) returnCode(result); maxcolors = MaxColors; if (InitColor && SP_PARM->_coloron && (color >= 0 && OkColorHi(color)) && (okRGB(r) && okRGB(g) && okRGB(b))) { SP_PARM->_color_table[color].init = 1; SP_PARM->_color_table[color].r = r; SP_PARM->_color_table[color].g = g; SP_PARM->_color_table[color].b = b; if (UseHlsPalette) { rgb2hls(r, g, b, &SP_PARM->_color_table[color].red, &SP_PARM->_color_table[color].green, &SP_PARM->_color_table[color].blue); } else { SP_PARM->_color_table[color].red = r; SP_PARM->_color_table[color].green = g; SP_PARM->_color_table[color].blue = b; } #ifdef USE_TERM_DRIVER CallDriver_4(SP_PARM, td_initcolor, color, r, g, b); #else NCURSES_PUTP2("initialize_color", TPARM_4(initialize_color, color, r, g, b)); #endif SP_PARM->_color_defs = max(color + 1, SP_PARM->_color_defs); result = OK; } returnCode(result); }
/* * Reset the color pair, e.g., to whatever color pair 0 is. */ static bool reset_color_pair(NCURSES_SP_DCL0) { #ifdef USE_TERM_DRIVER return CallDriver(SP_PARM, td_rescol); #else bool result = FALSE; (void) SP_PARM; if (orig_pair != 0) { (void) NCURSES_PUTP2("orig_pair", orig_pair); result = TRUE; } return result; #endif }
NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_DCL0) { int result = FALSE; T((T_CALLED("_nc_reset_colors(%p)"), (void *) SP_PARM)); if (SP_PARM->_color_defs > 0) SP_PARM->_color_defs = -(SP_PARM->_color_defs); if (reset_color_pair(NCURSES_SP_ARG)) result = TRUE; #ifdef USE_TERM_DRIVER result = CallDriver(SP_PARM, td_rescolors); #else if (orig_colors != 0) { NCURSES_PUTP2("orig_colors", orig_colors); result = TRUE; } #endif returnBool(result); }
NCURSES_SP_NAME(init_pair) (NCURSES_SP_DCLx NCURSES_PAIRS_T pair, NCURSES_COLOR_T f, NCURSES_COLOR_T b) { colorpair_t result; colorpair_t previous; int maxcolors; T((T_CALLED("init_pair(%p,%d,%d,%d)"), (void *) SP_PARM, (int) pair, (int) f, (int) b)); if (!ValidPair(pair)) returnCode(ERR); maxcolors = MaxColors; previous = SP_PARM->_color_pairs[pair]; #if NCURSES_EXT_FUNCS if (SP_PARM->_default_color || SP_PARM->_assumed_color) { bool isDefault = FALSE; bool wasDefault = FALSE; int default_pairs = SP_PARM->_default_pairs; /* * Map caller's color number, e.g., -1, 0, 1, .., 7, etc., into * internal unsigned values which we will store in the _color_pairs[] * table. */ if (isDefaultColor(f)) { f = COLOR_DEFAULT; isDefault = TRUE; } else if (!OkColorHi(f)) { returnCode(ERR); } if (isDefaultColor(b)) { b = COLOR_DEFAULT; isDefault = TRUE; } else if (!OkColorHi(b)) { returnCode(ERR); } /* * Check if the table entry that we are going to init/update used * default colors. */ if ((FORE_OF(previous) == COLOR_DEFAULT) || (BACK_OF(previous) == COLOR_DEFAULT)) wasDefault = TRUE; /* * Keep track of the number of entries in the color pair table which * used a default color. */ if (isDefault && !wasDefault) { ++default_pairs; } else if (wasDefault && !isDefault) { --default_pairs; } /* * As an extension, ncurses allows the pair number to exceed the * terminal's color_pairs value for pairs using a default color. * * Note that updating a pair which used a default color with one * that does not will decrement the count - and possibly interfere * with sequentially adding new pairs. */ if (pair > (SP_PARM->_pair_count + default_pairs)) { returnCode(ERR); } SP_PARM->_default_pairs = default_pairs; } else #endif { if ((f < 0) || !OkColorHi(f) || (b < 0) || !OkColorHi(b) || (pair < 1)) { returnCode(ERR); } } /* * When a pair's content is changed, replace its colors (if pair was * initialized before a screen update is performed replacing original * pair colors with the new ones). */ result = PAIR_OF(f, b); if (previous != 0 && previous != result) { int y, x; for (y = 0; y <= CurScreen(SP_PARM)->_maxy; y++) { struct ldat *ptr = &(CurScreen(SP_PARM)->_line[y]); bool changed = FALSE; for (x = 0; x <= CurScreen(SP_PARM)->_maxx; x++) { if (GetPair(ptr->text[x]) == pair) { /* Set the old cell to zero to ensure it will be updated on the next doupdate() */ SetChar(ptr->text[x], 0, 0); CHANGED_CELL(ptr, x); changed = TRUE; } } if (changed) NCURSES_SP_NAME(_nc_make_oldhash) (NCURSES_SP_ARGx y); } } SP_PARM->_color_pairs[pair] = result; if (GET_SCREEN_PAIR(SP_PARM) == pair) SET_SCREEN_PAIR(SP_PARM, (int) (~0)); /* force attribute update */ #ifdef USE_TERM_DRIVER CallDriver_3(SP_PARM, td_initpair, pair, f, b); #else if (initialize_pair && InPalette(f) && InPalette(b)) { const color_t *tp = DefaultPalette; TR(TRACE_ATTRS, ("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)", (int) pair, (int) tp[f].red, (int) tp[f].green, (int) tp[f].blue, (int) tp[b].red, (int) tp[b].green, (int) tp[b].blue)); NCURSES_PUTP2("initialize_pair", TPARM_7(initialize_pair, pair, (int) tp[f].red, (int) tp[f].green, (int) tp[f].blue, (int) tp[b].red, (int) tp[b].green, (int) tp[b].blue)); } #endif returnCode(OK); }
/* * Write the soft labels to the soft-key window. */ static void slk_intern_refresh(SCREEN *sp) { int i; int fmt; SLK *slk; int numlab; if (sp == 0) return; slk = sp->_slk; fmt = sp->slk_format; numlab = NumLabels; if (slk->hidden) return; for (i = 0; i < slk->labcnt; i++) { if (slk->dirty || slk->ent[i].dirty) { if (slk->ent[i].visible) { if (numlab > 0 && SLK_STDFMT(fmt)) { #ifdef USE_TERM_DRIVER CallDriver_2(sp, td_hwlabel, i + 1, slk->ent[i].form_text); #else if (i < num_labels) { NCURSES_PUTP2("plab_norm", TPARM_2(plab_norm, i + 1, slk->ent[i].form_text)); } #endif } else { if (fmt == 4) slk_paint_info(slk->win); wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x); (void) wattrset(slk->win, (int) AttrOf(slk->attr)); waddstr(slk->win, slk->ent[i].form_text); /* if we simulate SLK's, it's looking much more natural to use the current ATTRIBUTE also for the label window */ (void) wattrset(slk->win, (int) WINDOW_ATTRS(StdScreen(sp))); } } slk->ent[i].dirty = FALSE; } } slk->dirty = FALSE; if (numlab > 0) { #ifdef USE_TERM_DRIVER CallDriver_1(sp, td_hwlabelOnOff, slk->hidden ? FALSE : TRUE); #else if (slk->hidden) { NCURSES_PUTP2("label_off", label_off); } else { NCURSES_PUTP2("label_on", label_on); } #endif } }
NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_DCL0) { chtype *fake_map = acs_map; chtype *real_map = SP_PARM != 0 ? SP_PARM->_acs_map : fake_map; int j; T(("initializing ACS map")); /* * If we're using this from curses (rather than terminfo), we are storing * the mapping information in the SCREEN struct so we can decide how to * render it. */ if (real_map != fake_map) { for (j = 1; j < ACS_LEN; ++j) { real_map[j] = 0; fake_map[j] = A_ALTCHARSET | (chtype) j; if (SP_PARM) SP_PARM->_screen_acs_map[j] = FALSE; } } else { for (j = 1; j < ACS_LEN; ++j) { real_map[j] = 0; } } /* * Initializations for a UNIX-like multi-terminal environment. Use * ASCII chars and count on the terminfo description to do better. */ real_map['l'] = '+'; /* should be upper left corner */ real_map['m'] = '+'; /* should be lower left corner */ real_map['k'] = '+'; /* should be upper right corner */ real_map['j'] = '+'; /* should be lower right corner */ real_map['u'] = '+'; /* should be tee pointing left */ real_map['t'] = '+'; /* should be tee pointing right */ real_map['v'] = '+'; /* should be tee pointing up */ real_map['w'] = '+'; /* should be tee pointing down */ real_map['q'] = '-'; /* should be horizontal line */ real_map['x'] = '|'; /* should be vertical line */ real_map['n'] = '+'; /* should be large plus or crossover */ real_map['o'] = '~'; /* should be scan line 1 */ real_map['s'] = '_'; /* should be scan line 9 */ real_map['`'] = '+'; /* should be diamond */ real_map['a'] = ':'; /* should be checker board (stipple) */ real_map['f'] = '\''; /* should be degree symbol */ real_map['g'] = '#'; /* should be plus/minus */ real_map['~'] = 'o'; /* should be bullet */ real_map[','] = '<'; /* should be arrow pointing left */ real_map['+'] = '>'; /* should be arrow pointing right */ real_map['.'] = 'v'; /* should be arrow pointing down */ real_map['-'] = '^'; /* should be arrow pointing up */ real_map['h'] = '#'; /* should be board of squares */ real_map['i'] = '#'; /* should be lantern symbol */ real_map['0'] = '#'; /* should be solid square block */ /* these defaults were invented for ncurses */ real_map['p'] = '-'; /* should be scan line 3 */ real_map['r'] = '-'; /* should be scan line 7 */ real_map['y'] = '<'; /* should be less-than-or-equal-to */ real_map['z'] = '>'; /* should be greater-than-or-equal-to */ real_map['{'] = '*'; /* should be greek pi */ real_map['|'] = '!'; /* should be not-equal */ real_map['}'] = 'f'; /* should be pound-sterling symbol */ /* thick-line-drawing */ real_map['L'] = '+'; /* upper left corner */ real_map['M'] = '+'; /* lower left corner */ real_map['K'] = '+'; /* upper right corner */ real_map['J'] = '+'; /* lower right corner */ real_map['T'] = '+'; /* tee pointing left */ real_map['U'] = '+'; /* tee pointing right */ real_map['V'] = '+'; /* tee pointing up */ real_map['W'] = '+'; /* tee pointing down */ real_map['Q'] = '-'; /* horizontal line */ real_map['X'] = '|'; /* vertical line */ real_map['N'] = '+'; /* large plus or crossover */ /* double-line-drawing */ real_map['C'] = '+'; /* upper left corner */ real_map['D'] = '+'; /* lower left corner */ real_map['B'] = '+'; /* upper right corner */ real_map['A'] = '+'; /* lower right corner */ real_map['G'] = '+'; /* tee pointing left */ real_map['F'] = '+'; /* tee pointing right */ real_map['H'] = '+'; /* tee pointing up */ real_map['I'] = '+'; /* tee pointing down */ real_map['R'] = '-'; /* horizontal line */ real_map['Y'] = '|'; /* vertical line */ real_map['E'] = '+'; /* large plus or crossover */ #ifdef USE_TERM_DRIVER CallDriver_2(SP_PARM, initacs, real_map, fake_map); #else if (ena_acs != NULL) { NCURSES_PUTP2("ena_acs", ena_acs); } #if NCURSES_EXT_FUNCS /* * Linux console "supports" the "PC ROM" character set by the coincidence * that smpch/rmpch and smacs/rmacs have the same values. ncurses has * no codepage support (see SCO Merge for an example). Outside of the * values defined in acsc, there are no definitions for the "PC ROM" * character set (assumed by some applications to be codepage 437), but we * allow those applications to use those codepoints. * * test/blue.c uses this feature. */ #define PCH_KLUDGE(a,b) (a != 0 && b != 0 && !strcmp(a,b)) if (PCH_KLUDGE(enter_pc_charset_mode, enter_alt_charset_mode) && PCH_KLUDGE(exit_pc_charset_mode, exit_alt_charset_mode)) { size_t i; for (i = 1; i < ACS_LEN; ++i) { if (real_map[i] == 0) { real_map[i] = (chtype) i; if (real_map != fake_map) { if (SP != 0) SP->_screen_acs_map[i] = TRUE; } } } } #endif if (acs_chars != NULL) { size_t i = 0; size_t length = strlen(acs_chars); while (i + 1 < length) { if (acs_chars[i] != 0 && UChar(acs_chars[i]) < ACS_LEN) { real_map[UChar(acs_chars[i])] = UChar(acs_chars[i + 1]) | A_ALTCHARSET; if (SP != 0) SP->_screen_acs_map[UChar(acs_chars[i])] = TRUE; } i += 2; } } #ifdef TRACE /* Show the equivalent mapping, noting if it does not match the * given attribute, whether by re-ordering or duplication. */ if (USE_TRACEF(TRACE_CALLS)) { size_t n, m; char show[ACS_LEN * 2 + 1]; for (n = 1, m = 0; n < ACS_LEN; n++) { if (real_map[n] != 0) { show[m++] = (char) n; show[m++] = (char) ChCharOf(real_map[n]); } } show[m] = 0; if (acs_chars == NULL || strcmp(acs_chars, show)) _tracef("%s acs_chars %s", (acs_chars == NULL) ? "NULL" : "READ", _nc_visbuf(acs_chars)); _tracef("%s acs_chars %s", (acs_chars == NULL) ? "NULL" : (strcmp(acs_chars, show) ? "DIFF" : "SAME"), _nc_visbuf(show)); _nc_unlock_global(tracef); } #endif /* TRACE */ #endif }