1 /****************************************************************************
2 * Copyright (c) 2017 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Thomas E. Dickey *
31 ****************************************************************************/
34 * Common type definitions and macros for new_pair.c, lib_color.c
36 * $Id: new_pair.h,v 1.2 2017/03/10 09:20:43 tom Exp $
43 #define USE_NEW_PAIR NCURSES_EXT_COLORS
45 #ifdef NEW_PAIR_INTERNAL
48 cpKEEP = -1, /* color pair 0 */
49 cpFREE = 0, /* free for use */
50 cpINIT = 1, /* init_pair() */
51 cpAUTO = 1 /* alloc_pair() */
54 typedef struct _color_pairs
59 int mode; /* FIXME - needed? */
60 int prev; /* index of previous item */
61 int next; /* index of next item */
66 #define MakeColorPair(target,f,b) target.fg = f, target.bg = b
67 #define isSamePair(a,b) ((a).fg == (b).fg && (a).bg == (b).bg)
68 #define FORE_OF(c) (c).fg
69 #define BACK_OF(c) (c).bg
72 * Ensure that we use color pairs only when colors have been started, and also
73 * that the index is within the limits of the table which we allocated.
75 #define ValidPair(sp,pair) \
76 ((sp != 0) && (pair >= 0) && (pair < sp->_pair_limit) && sp->_coloron)
79 extern NCURSES_EXPORT(void) _nc_set_color_pair(SCREEN*, int, int);
80 extern NCURSES_EXPORT(void) _nc_reset_color_pair(SCREEN*, int, colorpair_t*);
82 #define _nc_set_color_pair(sp, pair, mode) /* nothing */
83 #define _nc_reset_color_pair(sp, pair, data) /* nothing */
88 typedef struct _color_pairs colorpair_t;
90 #endif /* NEW_PAIR_INTERNAL */
93 extern NCURSES_EXPORT(void) _nc_new_pair_leaks(SCREEN*);
98 #endif /* NEW_PAIR_H */