- if ((SP->_color_table = typeMalloc(color_t, COLORS)) == 0)
- returnCode(ERR);
- tp = (hue_lightness_saturation) ? hls_palette : cga_palette;
- for (n = 0; n < COLORS; n++) {
- if (n < 8) {
- SP->_color_table[n] = tp[n];
- } else {
- SP->_color_table[n] = tp[n % 8];
- if (hue_lightness_saturation) {
- SP->_color_table[n].green = 100;
- } else {
- if (SP->_color_table[n].red)
- SP->_color_table[n].red = 1000;
- if (SP->_color_table[n].green)
- SP->_color_table[n].green = 1000;
- if (SP->_color_table[n].blue)
- SP->_color_table[n].blue = 1000;
+ if (max_pairs > 0 && max_colors > 0) {
+ SP_PARM->_pair_limit = max_pairs;
+
+#if NCURSES_EXT_FUNCS
+ /*
+ * If using default colors, allocate extra space in table to
+ * allow for default-color as a component of a color-pair.
+ */
+ SP_PARM->_pair_limit += (1 + (2 * max_colors));
+#endif
+ SP_PARM->_pair_count = max_pairs;
+ SP_PARM->_color_count = max_colors;
+#if !USE_REENTRANT
+ COLOR_PAIRS = max_pairs;
+ COLORS = max_colors;
+#endif
+
+ SP_PARM->_color_pairs = TYPE_CALLOC(colorpair_t,
+ SP_PARM->_pair_limit);
+ if (SP_PARM->_color_pairs != 0) {
+ SP_PARM->_color_table = TYPE_CALLOC(color_t, max_colors);
+ if (SP_PARM->_color_table != 0) {
+ SP_PARM->_color_pairs[0] = PAIR_OF(default_fg(),
+ default_bg());
+ init_color_table(NCURSES_SP_ARG);
+
+ T(("started color: COLORS = %d, COLOR_PAIRS = %d",
+ COLORS, COLOR_PAIRS));
+
+ SP_PARM->_coloron = 1;
+ result = OK;
+ } else if (SP_PARM->_color_pairs != 0) {
+ FreeAndNull(SP_PARM->_color_pairs);
+ }