[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcaca] [PATH] Add set_cursor to the ruby binding.
- To: libcaca@lists.zoy.org
- Subject: [libcaca] [PATH] Add set_cursor to the ruby binding.
- From: Tony Miller <mcfiredrill@gmail.com>
- Date: Sat, 23 Jul 2011 21:24:04 -0700
- Delivered-to: list-libcaca@zoy.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=eJ3i6/dfnLHreSo/U0rzVU7P8XcrDldUgYX/uHpGFXQ=; b=qtz5WIiixahQtBDEiry7TyiJoBXB81YAQNwbTS1MSY9bqtZJp6OgJyZS6J0Xx12Ed4 IjLH9ehLAg76AJrlLsIh8WLeaYAEQPvBu+W9kL+e9+sRKInfSpqfu8gO2iyPQ4c+lYjr fkYcVsPiuEd9tQH4Zxash721Zt0VdseR7SXj4=
- Reply-to: libcaca@lists.zoy.org
- Sender: libcaca-bounce@lists.zoy.org
- User-agent: Mutt/1.5.21 (2010-09-15)
Hi,
I implemented caca_set_cursor for the ruby binding. The ruby method is
called 'cursor='. I've noticed the other set methods have a set_* method in
addtion to a '=' method. I wasn't sure what the purpose of that was, but should
I make a set_cursor method as well?
The patch is attached to the email, and also in my repo here, in a
branch named 'ruby-stuffs':
git://github.com/mcfiredrill/libcaca.git
Let me know what you think of the patch!
Thanks!
-Tony
---
ruby/caca-display.c | 10 ++++++++++
ruby/t/tc_display.rb | 4 ++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/ruby/caca-display.c b/ruby/caca-display.c
index 934ae9d..9ceb3d6 100644
--- a/ruby/caca-display.c
+++ b/ruby/caca-display.c
@@ -263,6 +263,15 @@ static VALUE set_driver2(VALUE self, VALUE driver)
return self;
}
+static VALUE set_cursor(VALUE self, VALUE flag)
+{
+ if(caca_set_cursor(_SELF, flag)<0)
+ {
+ rb_raise(rb_eRuntimeError, strerror(errno));
+ }
+ return self;
+}
+
void Init_caca_display(VALUE mCaca)
{
cDisplay = rb_define_class_under(mCaca, "Display", rb_cObject);
@@ -287,4 +296,5 @@ void Init_caca_display(VALUE mCaca)
rb_define_method(cDisplay, "driver=", set_driver, 1);
rb_define_method(cDisplay, "set_mouse", set_mouse2, 1);
rb_define_method(cDisplay, "get_event", get_event, 2);
+ rb_define_method(cDisplay, "cursor=", set_cursor, 1);
}
diff --git a/ruby/t/tc_display.rb b/ruby/t/tc_display.rb
index 7f9abd0..ff2b64e 100644
--- a/ruby/t/tc_display.rb
+++ b/ruby/t/tc_display.rb
@@ -27,4 +27,8 @@ class TC_Canvas < Test::Unit::TestCase
d = Caca::Display.new(c)
d.title = "Test !"
end
+ def test_set_cursor
+ d = Caca::Display.new()
+ d.cursor = 1
+ end
end
--
1.7.3.4
--
This is the Caca Labs mailing-list, see http://caca.zoy.org/
Trouble unsubscribing? Please contact <sam@zoy.org>
List archives are at http://caca.zoy.org/list/