[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcaca] Re: [PATH] Add set_cursor to the ruby binding.



Here is my revised patch, adding a second set_cursor function as pterjan suggested.

It is still available in the repository and branch mentioned in the last email.

---
 ruby/caca-display.c  |   17 +++++++++++++++++
 ruby/t/tc_display.rb |    4 ++++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/ruby/caca-display.c b/ruby/caca-display.c
index 934ae9d..aec9686 100644
--- a/ruby/caca-display.c
+++ b/ruby/caca-display.c
@@ -263,6 +263,21 @@ 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 flag;
+}
+
+static VALUE set_cursor2(VALUE self, VALUE driver)
+{
+    set_driver(self, driver);
+    return self;
+}
+
 void Init_caca_display(VALUE mCaca)
 {
     cDisplay = rb_define_class_under(mCaca, "Display", rb_cObject);
@@ -287,4 +302,6 @@ 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);
+    rb_define_method(cDisplay, "set_cursor", set_cursor2, 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.6

-- 
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/