X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fnew_pair.h;h=4dbeb9dc0fb949141eaf21e5ad48f975874a60b9;hp=8c344dab5ce0948e0bc61bbcc9862302ef43431b;hb=e348f7adec279f5453349ad13246a952a16e2094;hpb=90d42867e1296bc79021006a92032c76e59068b6 diff --git a/ncurses/new_pair.h b/ncurses/new_pair.h index 8c344dab..4dbeb9dc 100644 --- a/ncurses/new_pair.h +++ b/ncurses/new_pair.h @@ -33,7 +33,7 @@ /* * Common type definitions and macros for new_pair.c, lib_color.c * - * $Id: new_pair.h,v 1.2 2017/03/10 09:20:43 tom Exp $ + * $Id: new_pair.h,v 1.8 2017/08/11 18:15:11 tom Exp $ */ #ifndef NEW_PAIR_H @@ -42,6 +42,39 @@ #define USE_NEW_PAIR NCURSES_EXT_COLORS +#define LIMIT_TYPED(n,t) \ + (t)(((n) > MAX_OF_TYPE(t)) \ + ? MAX_OF_TYPE(t) \ + : ((n) < -MAX_OF_TYPE(t)) \ + ? -MAX_OF_TYPE(t) \ + : (n)) + +#define limit_COLOR(n) LIMIT_TYPED(n,NCURSES_COLOR_T) +#define limit_PAIRS(n) LIMIT_TYPED(n,NCURSES_PAIRS_T) + +#define MAX_XCURSES_PAIR MAX_OF_TYPE(NCURSES_PAIRS_T) + +#if USE_NEW_PAIR +#define OPTIONAL_PAIR GCC_UNUSED +#define USE_NEW_PAIR NCURSES_EXT_COLORS +#define get_extended_pair(opts, color_pair) \ + if ((opts) != NULL) { \ + *(int*)(opts) = color_pair; \ + } +#define set_extended_pair(opts, color_pair) \ + if ((opts) != NULL) { \ + color_pair = *(const int*)(opts); \ + } +#else +#define OPTIONAL_PAIR /* nothing */ +#define USE_NEW_PAIR NCURSES_EXT_COLORS +#define get_extended_pair(opts, color_pair) /* nothing */ +#define set_extended_pair(opts, color_pair) \ + if ((opts) != NULL) { \ + color_pair = -1; \ + } +#endif + #ifdef NEW_PAIR_INTERNAL typedef enum { @@ -56,7 +89,7 @@ typedef struct _color_pairs int fg; int bg; #if USE_NEW_PAIR - int mode; /* FIXME - needed? */ + int mode; /* tells if the entry is allocated or free */ int prev; /* index of previous item */ int next; /* index of next item */ #endif @@ -76,11 +109,14 @@ colorpair_t; ((sp != 0) && (pair >= 0) && (pair < sp->_pair_limit) && sp->_coloron) #if USE_NEW_PAIR -extern NCURSES_EXPORT(void) _nc_set_color_pair(SCREEN*, int, int); +extern NCURSES_EXPORT(void) _nc_copy_pairs(SCREEN*, colorpair_t*, colorpair_t*, int); +extern NCURSES_EXPORT(void) _nc_free_ordered_pairs(SCREEN*); extern NCURSES_EXPORT(void) _nc_reset_color_pair(SCREEN*, int, colorpair_t*); +extern NCURSES_EXPORT(void) _nc_set_color_pair(SCREEN*, int, int); #else -#define _nc_set_color_pair(sp, pair, mode) /* nothing */ +#define _nc_free_ordered_pairs(sp) /* nothing */ #define _nc_reset_color_pair(sp, pair, data) /* nothing */ +#define _nc_set_color_pair(sp, pair, mode) /* nothing */ #endif #else