diff options
Diffstat (limited to 'ext/curses')
-rw-r--r-- | ext/curses/curses.c | 21 | ||||
-rw-r--r-- | ext/curses/extconf.rb | 2 |
2 files changed, 20 insertions, 3 deletions
diff --git a/ext/curses/curses.c b/ext/curses/curses.c index a8952bf18..d36610a88 100644 --- a/ext/curses/curses.c +++ b/ext/curses/curses.c @@ -124,7 +124,7 @@ curses_init_screen() if (rb_stdscr) return rb_stdscr; initscr(); if (stdscr == 0) { - rb_raise(rb_eRuntimeError, "cannot initialize curses"); + rb_raise(rb_eRuntimeError, "can't initialize curses"); } clear(); rb_stdscr = prep_window(cWindow, stdscr); @@ -561,7 +561,7 @@ curses_resizeterm(VALUE obj, VALUE lin, VALUE col) #endif } -#ifdef USE_COLOR +#if defined(USE_COLOR) && defined(HAVE_WCOLOR_SET) static VALUE curses_start_color(VALUE obj) { @@ -1195,6 +1195,20 @@ window_setscrreg(VALUE obj, VALUE top, VALUE bottom) #endif } +#if defined(USE_COLOR) && defined(HAVE_WCOLOR_SET) +static VALUE +window_color_set(VALUE obj, VALUE col) +{ + struct windata *winp; + int res; + + GetWINDOW(obj, winp); + res = wcolor_set(winp->window, NUM2INT(col), NULL); + return (res == OK) ? Qtrue : Qfalse; + return Qfalse; +} +#endif /* USE_COLOR */ + static VALUE window_scroll(VALUE obj) { @@ -1471,6 +1485,9 @@ Init_curses() rb_define_method(cWindow, "box", window_box, -1); rb_define_method(cWindow, "move", window_move, 2); rb_define_method(cWindow, "setpos", window_setpos, 2); +#if defined(USE_COLOR) && defined(HAVE_WCOLOR_SET) + rb_define_method(cWindow, "color_set", window_color_set, 1); +#endif /* USE_COLOR && HAVE_WCOLOR_SET */ rb_define_method(cWindow, "cury", window_cury, 0); rb_define_method(cWindow, "curx", window_curx, 0); rb_define_method(cWindow, "maxy", window_maxy, 0); diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb index 9b319ba30..01fe97109 100644 --- a/ext/curses/extconf.rb +++ b/ext/curses/extconf.rb @@ -19,7 +19,7 @@ elsif have_header(*curses=%w"curses.h") and have_library("curses", "initscr") end if make - for f in %w(beep bkgd bkgdset curs_set deleteln doupdate flash getbkgd getnstr init isendwin keyname keypad resizeterm scrl set setscrreg ungetch wattroff wattron wattrset wbkgd wbkgdset wdeleteln wgetnstr wresize wscrl wsetscrreg def_prog_mode reset_prog_mode timeout wtimeout nodelay init_color) + for f in %w(beep bkgd bkgdset curs_set deleteln doupdate flash getbkgd getnstr init isendwin keyname keypad resizeterm scrl set setscrreg ungetch wattroff wattron wattrset wbkgd wbkgdset wdeleteln wgetnstr wresize wscrl wsetscrreg def_prog_mode reset_prog_mode timeout wtimeout nodelay init_color wcolor_set) have_func(f) end flag = "-D_XOPEN_SOURCE_EXTENDED" |