소스 검색

* Add missing methods in Caca::Display and add empty Caca::Event

tags/v0.99.beta14
Pascal Terjan pterjan 17 년 전
부모
커밋
061ca415b0
4개의 변경된 파일73개의 추가작업 그리고 1개의 파일을 삭제
  1. +3
    -1
      ruby/Makefile.am
  2. +39
    -0
      ruby/caca-display.c
  3. +22
    -0
      ruby/caca-event.c
  4. +9
    -0
      ruby/caca-event.h

+ 3
- 1
ruby/Makefile.am 파일 보기

@@ -12,13 +12,15 @@ cucul_la_LDFLAGS = -module -avoid-version -shared -L$(RUBY_LIBDIR) -l$(RUBY_SO_N
cucul_la_LIBADD = ../cucul/libcucul.la

caca_la_CPPFLAGS = -I$(top_srcdir)/caca -I$(RUBY_ARCHDIR)
caca_la_SOURCES = caca.c caca-display.c
caca_la_SOURCES = caca.c caca-display.c caca-event.c
caca_la_LDFLAGS = -module -avoid-version -shared -L$(RUBY_LIBDIR) -l$(RUBY_SO_NAME)
caca_la_LIBADD = ../caca/libcaca.la

EXTRA_DIST = cucul-canvas.h \
cucul-dither.h \
cucul-font.h \
caca-display.h \
caca-event.h \
common.h \
test.rb \
t/tc_canvas.rb \


+ 39
- 0
ruby/caca-display.c 파일 보기

@@ -12,6 +12,7 @@
#include <ruby.h>
#include <caca.h>
#include <errno.h>
#include "caca-event.h"
#include "cucul-canvas.h"
#include "common.h"

@@ -97,6 +98,39 @@ static VALUE set_title2(VALUE self, VALUE t)
return self;
}

static VALUE get_mouse_x(VALUE self)
{
return NUM2UINT(caca_get_mouse_x(_SELF));
}

static VALUE get_mouse_y(VALUE self)
{
return NUM2UINT(caca_get_mouse_y(_SELF));
}

static VALUE set_mouse(VALUE self, VALUE visible)
{
caca_set_display_time(_SELF, visible);
return visible;
}

static VALUE set_mouse2(VALUE self, VALUE visible)
{
set_mouse(self, visible);
return self;
}

static VALUE get_event(VALUE self, VALUE event_mask, VALUE timeout)
{
caca_event_t ev;
if(caca_get_event(_SELF, NUM2UINT(event_mask), &ev, NUM2INT(timeout)) == 0)
{
return Qnil;
}
//FIXME
return Qnil;
}

void Init_caca_display(VALUE mCaca)
{
cDisplay = rb_define_class_under(mCaca, "Display", rb_cObject);
@@ -111,4 +145,9 @@ void Init_caca_display(VALUE mCaca)
rb_define_method(cDisplay, "height", get_height, 0);
rb_define_method(cDisplay, "title=", set_title, 1);
rb_define_method(cDisplay, "set_title", set_title2, 1);
rb_define_method(cDisplay, "mouse_x", get_mouse_x, 0);
rb_define_method(cDisplay, "mouse_y", get_mouse_y, 0);
rb_define_method(cDisplay, "mouse=", set_mouse, 1);
rb_define_method(cDisplay, "set_mouse", set_mouse2, 1);
rb_define_method(cDisplay, "get_event", get_event, 3);
}

+ 22
- 0
ruby/caca-event.c 파일 보기

@@ -0,0 +1,22 @@
/*
* libcaca Ruby bindings
* Copyright (c) 2007 Pascal Terjan <pterjan@linuxfr.org>
*
* This library is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

#include <ruby.h>
#include <caca.h>
#include <errno.h>
#include "common.h"

VALUE cEvent;

void Init_caca_event(VALUE mCaca)
{
cEvent = rb_define_class_under(mCaca, "Event", rb_cObject);
}

+ 9
- 0
ruby/caca-event.h 파일 보기

@@ -0,0 +1,9 @@
#ifndef __CACA_DISPLAY_H__
#define __CACA_DISPLAY_H__

#include <ruby.h>

extern VALUE cEvent;
extern void Init_caca_event(VALUE);

#endif

불러오는 중...
취소
저장