Skip to content

Commit

Permalink
* ext/curses/curses.c (curses_colors): new method added. a patch
Browse files Browse the repository at this point in the history
  from Alexander Beisig in [ruby-core:22331].

* ext/curses/curses.c (curses_color_pairs): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Feb 24, 2009
1 parent ca29209 commit 02316f1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Wed Feb 25 00:15:15 2009 Yukihiro Matsumoto <matz@ruby-lang.org>

* ext/curses/curses.c (curses_colors): new method added. a patch
from Alexander Beisig in [ruby-core:22331].

* ext/curses/curses.c (curses_color_pairs): ditto.

Wed Feb 25 00:05:13 2009 Akinori MUSHA <knu@iDaemons.org>

* class.c (rb_scan_args): Revamp rb_scan_args() to compute the
Expand Down
23 changes: 23 additions & 0 deletions ext/curses/curses.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,16 @@ curses_can_change_color(VALUE obj)
return can_change_color() ? Qtrue : Qfalse;
}

static VALUE
curses_colors(VALUE obj)
{
#if defined(HAVE_COLORS)
return INT2FIX(COLORS);
#else
rb_notimplement();
#endif
}

static VALUE
curses_color_content(VALUE obj, VALUE color)
{
Expand All @@ -685,6 +695,17 @@ curses_color_content(VALUE obj, VALUE color)
return rb_ary_new3(3,INT2FIX(r),INT2FIX(g),INT2FIX(b));
}


static VALUE
curses_color_pairs(VALUE obj)
{
#if defined(HAVE_COLOR_PAIRS)
return INT2FIX(COLOR_PAIRS);
#else
rb_notimplement();
#endif
}

static VALUE
curses_pair_content(VALUE obj, VALUE pair)
{
Expand Down Expand Up @@ -1537,7 +1558,9 @@ Init_curses(void)
rb_define_module_function(mCurses, "has_colors?", curses_has_colors, 0);
rb_define_module_function(mCurses, "can_change_color?",
curses_can_change_color, 0);
rb_define_module_function(mCurses, "colors", curses_colors, 0);
rb_define_module_function(mCurses, "color_content", curses_color_content, 1);
rb_define_module_function(mCurses, "color_pairs", curses_color_pairs, 0);
rb_define_module_function(mCurses, "pair_content", curses_pair_content, 1);
rb_define_module_function(mCurses, "color_pair", curses_color_pair, 1);
rb_define_module_function(mCurses, "pair_number", curses_pair_number, 1);
Expand Down
2 changes: 2 additions & 0 deletions ext/curses/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@
end
have_var("ESCDELAY", curses)
have_var("TABSIZE", curses)
have_var("COLORS", curses)
have_var("COLOR_PAIRS", curses)
create_makefile("curses")
end

0 comments on commit 02316f1

Please sign in to comment.