Skip to content

Commit d3302c0

Browse files
committed
Use NCURSES_EXT_COLORS and NCURSES_EXT_FUNCS to check extended color support
1 parent 3857e8d commit d3302c0

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

ext/curses/curses.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@
8282
# define USE_MOUSE 1
8383
#endif
8484

85+
#if defined(NCURSES_EXT_COLORS) && defined(NCURSES_EXT_FUNCS)
86+
# define SUPPORT_EXTENDED_COLORS 1
87+
#else
88+
# define SUPPORT_EXTENDED_COLORS 0
89+
#endif
90+
8591
#define OBJ2CHTYPE rb_obj2chtype_inline
8692

8793
static inline chtype
@@ -1321,7 +1327,7 @@ curses_init_pair(VALUE obj, VALUE pair, VALUE f, VALUE b)
13211327
{
13221328
/* may have to raise exception on ERR */
13231329
curses_stdscr();
1324-
#ifdef HAVE_INIT_EXTENDED_PAIR
1330+
#if SUPPORT_EXTENDED_COLORS
13251331
return (init_extended_pair(NUM2INT(pair), NUM2INT(f), NUM2INT(b)) == OK) ? Qtrue : Qfalse;
13261332
#else
13271333
return (init_pair(NUM2INT(pair),NUM2INT(f),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
@@ -1349,7 +1355,7 @@ curses_init_color(VALUE obj, VALUE color, VALUE r, VALUE g, VALUE b)
13491355
{
13501356
/* may have to raise exception on ERR */
13511357
curses_stdscr();
1352-
#ifdef HAVE_INIT_EXTENDED_COLOR
1358+
#if SUPPORT_EXTENDED_COLORS
13531359
return (init_extended_color(NUM2INT(color), NUM2INT(r),
13541360
NUM2INT(g), NUM2INT(b)) == OK) ? Qtrue : Qfalse;
13551361
#else
@@ -1407,7 +1413,7 @@ static VALUE
14071413
curses_color_content(VALUE obj, VALUE color)
14081414
{
14091415
curses_stdscr();
1410-
#ifdef HAVE_EXTENDED_COLOR_CONTENT
1416+
#if SUPPORT_EXTENDED_COLORS
14111417
{
14121418
int r, g, b;
14131419
if (extended_color_content(NUM2INT(color), &r, &g, &b) == ERR)
@@ -1451,7 +1457,7 @@ static VALUE
14511457
curses_pair_content(VALUE obj, VALUE pair)
14521458
{
14531459
curses_stdscr();
1454-
#ifdef HAVE_EXTENDED_PAIR_CONTENT
1460+
#if SUPPORT_EXTENDED_COLORS
14551461
{
14561462
int f, b;
14571463
if (extended_pair_content(NUM2INT(pair), &f, &b) == ERR)
@@ -1501,14 +1507,12 @@ curses_pair_number(VALUE obj, VALUE attrs)
15011507
* Document-method: Curses.support_extended_colors?
15021508
*
15031509
* Returns +true+ if the ncurses library was compiled with extended color
1504-
* support (i.e., init_extended_pair, init_extended_color, etc. are available),
1505-
* +false+ otherwise.
1510+
* support, +false+ otherwise.
15061511
*/
15071512
static VALUE
15081513
curses_support_extended_colors(VALUE obj)
15091514
{
1510-
#if defined(HAVE_INIT_EXTENDED_PAIR) && defined(HAVE_INIT_EXTENDED_COLOR) && \
1511-
defined(HAVE_EXTENDED_COLOR_CONTENT) && defined(HAVE_EXTENDED_PAIR_CONTENT)
1515+
#if SUPPORT_EXTENDED_COLORS
15121516
return Qtrue;
15131517
#else
15141518
return Qfalse;

0 commit comments

Comments
 (0)