Skip to content

Commit c2932b5

Browse files
committed
Do not use wattr_set() if wattr_get() is unavailable to avoid resetting attrs
1 parent ffcc80f commit c2932b5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

ext/curses/curses.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2783,7 +2783,7 @@ window_setscrreg(VALUE obj, VALUE top, VALUE bottom)
27832783
#endif
27842784
}
27852785

2786-
#if defined(USE_COLOR) && (defined(HAVE_WCOLOR_SET) || defined(HAVE_WATTR_SET))
2786+
#if defined(USE_COLOR) && ((defined(HAVE_WATTR_SET) && defined(HAVE_WATTR_GET)) || defined(HAVE_WCOLOR_SET))
27872787
/*
27882788
* Document-method: Curses::Window.color_set
27892789
* call-seq: color_set(col)
@@ -2810,13 +2810,11 @@ window_color_set(VALUE obj, VALUE col)
28102810
return Qfalse;
28112811
return (wattr_set(winp->window, attrs, NUM2INT(col), NULL) == OK) ? Qtrue : Qfalse;
28122812
}
2813-
#elif defined(HAVE_WATTR_SET)
2814-
return (wattr_set(winp->window, 0, NUM2INT(col), NULL) == OK) ? Qtrue : Qfalse;
28152813
#else
28162814
return (wcolor_set(winp->window, NUM2INT(col), NULL) == OK) ? Qtrue : Qfalse;
28172815
#endif
28182816
}
2819-
#endif /* defined(USE_COLOR) && (defined(HAVE_WCOLOR_SET) || defined(HAVE_WATTR_SET)) */
2817+
#endif /* defined(USE_COLOR) && ((defined(HAVE_WATTR_SET) && defined(HAVE_WATTR_GET)) || defined(HAVE_WCOLOR_SET)) */
28202818

28212819
/*
28222820
* Document-method: Curses::Window.scroll
@@ -5286,9 +5284,9 @@ Init_curses(void)
52865284
rb_define_method(cWindow, "move", window_move, 2);
52875285
rb_define_method(cWindow, "move_relative", window_move_relative, 2);
52885286
rb_define_method(cWindow, "setpos", window_setpos, 2);
5289-
#if defined(USE_COLOR) && (defined(HAVE_WCOLOR_SET) || defined(HAVE_WATTR_SET))
5287+
#if defined(USE_COLOR) && ((defined(HAVE_WATTR_SET) && defined(HAVE_WATTR_GET)) || defined(HAVE_WCOLOR_SET))
52905288
rb_define_method(cWindow, "color_set", window_color_set, 1);
5291-
#endif /* USE_COLOR && (HAVE_WCOLOR_SET || HAVE_WATTR_SET) */
5289+
#endif
52925290
rb_define_method(cWindow, "cury", window_cury, 0);
52935291
rb_define_method(cWindow, "curx", window_curx, 0);
52945292
rb_define_method(cWindow, "maxy", window_maxy, 0);

0 commit comments

Comments
 (0)