Browse Source

* Add Caca::Display#canvas

tags/v0.99.beta14
Pascal Terjan pterjan 17 years ago
parent
commit
0456c906e4
5 changed files with 15 additions and 1 deletions
  1. +5
    -0
      ruby/caca-display.c
  2. +5
    -0
      ruby/cucul-canvas.c
  3. +1
    -0
      ruby/cucul-canvas.h
  4. +3
    -0
      ruby/lib/caca.rb
  5. +1
    -1
      ruby/ruby-caca.dox

+ 5
- 0
ruby/caca-display.c View File

@@ -33,6 +33,7 @@ static VALUE display_alloc(VALUE klass)
static VALUE display_initialize(int argc, VALUE* argv, VALUE self)
{
caca_display_t *display;
cucul_canvas_t *canvas;
VALUE cv;

rb_scan_args(argc, argv, "01", &cv);
@@ -40,6 +41,8 @@ static VALUE display_initialize(int argc, VALUE* argv, VALUE self)
if(NIL_P(cv))
{
display = caca_create_display(NULL);
canvas = caca_get_canvas(display);
cv = canvas_create(canvas);
}
else
{
@@ -58,6 +61,8 @@ static VALUE display_initialize(int argc, VALUE* argv, VALUE self)

_SELF = display;

rb_iv_set(self, "@canvas", cv);

return self;
}



+ 5
- 0
ruby/cucul-canvas.c View File

@@ -49,6 +49,11 @@ static VALUE canvas_alloc(VALUE klass)
return obj;
}

VALUE canvas_create(cucul_canvas_t *canvas)
{
return Data_Wrap_Struct(cCanvas, 0, canvas_free, canvas);
}

static VALUE canvas_initialize(VALUE self, VALUE width, VALUE height)
{
unsigned int w, h;


+ 1
- 0
ruby/cucul-canvas.h View File

@@ -5,5 +5,6 @@

extern VALUE cCanvas;
extern void Init_cucul_canvas(VALUE);
extern VALUE canvas_create(cucul_canvas_t *canvas);

#endif

+ 3
- 0
ruby/lib/caca.rb View File

@@ -2,6 +2,9 @@ require 'cucul'
require 'caca.so'

module Caca
class Display
attr_reader :canvas
end
class Event
def Event.to_i
const_get("TYPE")


+ 1
- 1
ruby/ruby-caca.dox View File

@@ -33,7 +33,7 @@ irb(main):009:0> Caca.my_methods

\code
irb(main):010:0> Caca::Display.my_instance_methods
=> ["get_event", "height", "mouse=", "mouse_x", "mouse_y", "refresh",
=> ["canvas", "get_event", "height", "mouse=", "mouse_x", "mouse_y", "refresh",
"set_mouse", "set_time", "set_title", "time", "time=", "title=", "width"]
\endcode



Loading…
Cancel
Save