]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_color.c
ncurses 5.6 - patch 20070310
[ncurses.git] / ncurses / base / lib_color.c
index a90ca9d3430874679b7c97f4a228316794dec382..ba2563c5e533d69072d000b8ed523d305a272dcf 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 #include <term.h>
 #include <tic.h>
 
-MODULE_ID("$Id: lib_color.c,v 1.80 2006/11/26 01:33:16 tom Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.84 2007/03/10 19:20:15 tom Exp $")
 
 /*
  * These should be screen structure members.  They need to be globals for
  * historical reasons.  So we assign them in start_color() and also in
  * set_term()'s screen-switching logic.
  */
+#if USE_REENTRANT
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(COLOR_PAIRS) (void)
+{
+    return SP ? SP->_pair_count : -1;
+}
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(COLORS) (void)
+{
+    return SP ? SP->_color_count : -1;
+}
+#else
 NCURSES_EXPORT_VAR(int) COLOR_PAIRS = 0;
 NCURSES_EXPORT_VAR(int) COLORS = 0;
+#endif
 
 #define DATA(r,g,b) {r,g,b, 0,0,0, 0}
 
@@ -239,8 +252,12 @@ start_color(void)
        }
 
        if (max_pairs > 0 && max_colors > 0) {
-           COLOR_PAIRS = SP->_pair_count = max_pairs;
-           COLORS = SP->_color_count = max_colors;
+           SP->_pair_count = max_pairs;
+           SP->_color_count = max_colors;
+#if !USE_REENTRANT
+           COLOR_PAIRS = max_pairs;
+           COLORS = max_colors;
+#endif
 
            if ((SP->_color_pairs = TYPE_CALLOC(colorpair_t,
                                                max_pairs)) != 0) {
@@ -368,10 +385,11 @@ init_pair(short pair, short f, short b)
     if (initialize_pair) {
        const color_t *tp = hue_lightness_saturation ? hls_palette : cga_palette;
 
-       T(("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)",
-          pair,
-          tp[f].red, tp[f].green, tp[f].blue,
-          tp[b].red, tp[b].green, tp[b].blue));
+       TR(TRACE_ATTRS,
+          ("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)",
+           pair,
+           tp[f].red, tp[f].green, tp[f].blue,
+           tp[b].red, tp[b].green, tp[b].blue));
 
        TPUTS_TRACE("initialize_pair");
        putp(TPARM_7(initialize_pair,
@@ -461,7 +479,8 @@ color_content(short color, short *r, short *g, short *b)
        if (b)
            *b = c_b;
 
-       T(("...color_content(%d,%d,%d,%d)", color, c_r, c_g, c_b));
+       TR(TRACE_ATTRS, ("...color_content(%d,%d,%d,%d)",
+                        color, c_r, c_g, c_b));
        result = OK;
     }
     returnCode(result);
@@ -492,7 +511,7 @@ pair_content(short pair, short *f, short *b)
        if (b)
            *b = bg;
 
-       T(("...pair_content(%d,%d,%d)", pair, fg, bg));
+       TR(TRACE_ATTRS, ("...pair_content(%d,%d,%d)", pair, fg, bg));
        result = OK;
     }
     returnCode(result);