- if (set_original_colors() != TRUE)
- {
- set_foreground_color(COLOR_WHITE, _nc_outch);
- set_background_color(COLOR_BLACK, _nc_outch);
+ if (set_original_colors() != TRUE) {
+ set_foreground_color(default_fg(), _nc_outch);
+ set_background_color(default_bg(), _nc_outch);
+ }
+
+ if (VALID_NUMERIC(max_pairs))
+ COLOR_PAIRS = SP->_pair_count = max_pairs;
+ else
+ returnCode(ERR);
+ if ((SP->_color_pairs = typeCalloc(unsigned short, max_pairs)) == 0)
+ returnCode(ERR);
+ SP->_color_pairs[0] = PAIR_OF(default_fg(), default_bg());
+ if (VALID_NUMERIC(max_colors))
+ COLORS = SP->_color_count = max_colors;
+ else
+ returnCode(ERR);
+ SP->_coloron = 1;
+
+ 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;
+ }