X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fnew_pair.h;h=bc031a70ca5c0d9763ee97bbb0018d4ff91ad2c9;hp=4df40c6fcd14aa99eabacae7c7b91627f4d4c5c3;hb=493e2f7b3fc309879f561a094fdfc15e5304b3d6;hpb=5e1e572b71ae31a6071daa24e2460a68a6f1003c diff --git a/ncurses/new_pair.h b/ncurses/new_pair.h index 4df40c6f..bc031a70 100644 --- a/ncurses/new_pair.h +++ b/ncurses/new_pair.h @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 2017 Free Software Foundation, Inc. * + * Copyright 2018-2020,2021 Thomas E. Dickey * + * Copyright 2017 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 * @@ -33,25 +34,34 @@ /* * Common type definitions and macros for new_pair.c, lib_color.c * - * $Id: new_pair.h,v 1.5 2017/04/02 14:46:34 tom Exp $ + * $Id: new_pair.h,v 1.12 2021/08/18 19:18:12 tom Exp $ */ #ifndef NEW_PAIR_H #define NEW_PAIR_H 1 /* *INDENT-OFF* */ -#define USE_NEW_PAIR NCURSES_EXT_COLORS +#include +#include -#define LIMIT_TYPED(n,t) (t)(((t)(n) < 0) ? MAX_OF_TYPE(t) : (n)) +#include + +typedef struct screen SCREEN; + +#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 +#if NCURSES_EXT_COLORS #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; \ @@ -62,7 +72,6 @@ } #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) { \ @@ -75,15 +84,14 @@ typedef enum { cpKEEP = -1, /* color pair 0 */ cpFREE = 0, /* free for use */ - cpINIT = 1, /* init_pair() */ - cpAUTO = 1 /* alloc_pair() */ + cpINIT = 1 /* initialized */ } CPMODE; typedef struct _color_pairs { int fg; int bg; -#if USE_NEW_PAIR +#if NCURSES_EXT_COLORS int mode; /* tells if the entry is allocated or free */ int prev; /* index of previous item */ int next; /* index of next item */ @@ -103,12 +111,15 @@ colorpair_t; #define ValidPair(sp,pair) \ ((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); +#if NCURSES_EXT_COLORS +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