Accepting request 71674 from home:plater

Removed python bindings patches, the python bindings will build properly with the next release and I'll enable them then.

OBS-URL: https://build.opensuse.org/request/show/71674
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/libcaca?expand=0&rev=11
This commit is contained in:
Dave Plater 2011-05-27 11:34:04 +00:00 committed by Git OBS Bridge
parent b4a76b9744
commit e1692b9c95
13 changed files with 0 additions and 853 deletions

View File

@ -1,42 +0,0 @@
diff -u libcaca-0.99.beta17/python/Makefile.am libcaca-0.99.beta18/python/Makefile.am
--- python/Makefile.am 2010-02-08 14:34:28.000000000 +0200
+++ python/Makefile.am 2010-05-28 19:28:43.000000000 +0200
@@ -1,22 +1,18 @@
-EXTRA_DIST = caca.txt pypycaca.c pypycaca.h snake.py test1.py test2.py
+if USE_PYTHON
+cacadir = $(pythondir)/caca
+caca_PYTHON = \
+ caca/__init__.py \
+ caca/canvas.py \
+ caca/common.py \
+ caca/display.py \
+ caca/dither.py \
+ caca/font.py
+endif
+
+EXTRA_DIST = \
+ setup.py \
+ examples/cacainfo.py \
+ examples/drawing.py \
+ examples/gol.py
-CC = gcc
-RM = rm -f
-CACAFLAGS = `caca-config --cflags`
-CACALIBS = `caca-config --libs`
-
-PYTHONFLAGS = -I/usr/include/python2.4
-PYTHONLIBS = -lpython2.4
-
-NAME = caca.so
-
-all:
-
-python:
- $(CC) pypycaca.c -c $(CACAFLAGS) $(PYTHONFLAGS) -Wall
- $(LD) pypycaca.o -o $(NAME) $(CACALIBS) $(PYTHONLIBS) -shared
-
-
-clean:
- $(RM) *.o $(NAME)

View File

@ -1,83 +0,0 @@
* Add optional pointer argument to Canvas class. * get_canvas method now return Python Canvas object.
git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libcaca/trunk@4408 92316355-f0b4-4df1-b90c-862c8a59935f
diff --git a/python/caca/canvas.py b/python/caca/canvas.py
index 292ab87..4373e0e 100644
@@ -56,17 +56,21 @@ class Canvas(_Canvas):
""" Canvas object, methods are libcaca functions with canvas_t as
first parameter.
"""
- def __init__(self, width=0, height=0):
+ def __init__(self, width=0, height=0, pointer=None):
""" Canvas constructor.
width -- the desired canvas width
height -- the desired canvas height
+ cv -- pointer to libcaca canvas
"""
_lib.caca_create_canvas.argtypes = [ctypes.c_int, ctypes.c_int]
- self._cv = _lib.caca_create_canvas(width, height)
- if self._cv == 0:
- raise CanvasError, "Failed to create canvas"
+ if cv is not None:
+ self._cv = _lib.caca_create_canvas(width, height)
+ if self._cv == 0:
+ raise CanvasError, "Failed to create canvas"
+ else:
+ self._cv = cv
def manage(self, *args, **kw):
""" Not implemented.
@@ -940,7 +944,7 @@ class Canvas(_Canvas):
_Canvas, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int,
ctypes.c_char_p, p_size_t
]
- _lib.caca_export_area_to_memory.restype = ctypes.c_void_p
+ _lib.caca_export_area_to_memory.restype = ctypes.POINTER(ctypes.c_char_p)
p = ctypes.c_size_t()
ret = _lib.caca_export_area_to_memory(self, x, y, width, height, fmt, p)
diff --git a/python/caca/display.py b/python/caca/display.py
index 451b40a..8bdd887 100644
@@ -17,7 +17,7 @@
import ctypes
from caca import _lib
-from caca.canvas import _Canvas
+from caca.canvas import _Canvas, Canvas
class _Display(object):
""" Model for Display objects.
@@ -63,6 +63,9 @@ class Display(_Display):
]
self._dp = _lib.caca_create_display_with_driver(cv, driver)
+ if self._dp == 0:
+ raise DisplayError, "Failed to create display"
+
def get_driver(self):
""" Return the caca graphical context's current output driver.
"""
@@ -89,8 +92,9 @@ class Display(_Display):
""" Get the canvas attached to a caca graphical context.
"""
_lib.caca_get_canvas.argtypes = [_Display]
+ _lib.caca_get_canvas.restype = ctypes.POINTER(ctypes.c_char_p)
- return _lib.caca_get_canvas(self)
+ return Canvas(pointer=_lib.caca_get_canvas(self))
def refresh(self):
""" Flush pending changes and redraw the screen.
@@ -194,6 +198,9 @@ class Display(_Display):
return _lib.caca_get_mouse_y(self)
+class DisplayError(Exception):
+ pass
+
class Event(ctypes.Structure):
""" Object to store libcaca event.
"""

View File

@ -1,15 +0,0 @@
* Fix bad condition.
git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libcaca/trunk@4410 92316355-f0b4-4df1-b90c-862c8a59935f
diff --git a/python/caca/canvas.py b/python/caca/canvas.py
index bbf5b7e..0e0dcd3 100644
@@ -65,7 +65,7 @@ class Canvas(_Canvas):
"""
_lib.caca_create_canvas.argtypes = [ctypes.c_int, ctypes.c_int]
- if pointer is not None:
+ if pointer is None:
self._cv = _lib.caca_create_canvas(width, height)
if self._cv == 0:
raise CanvasError, "Failed to create canvas"

View File

@ -1,74 +0,0 @@
* Bind export functions.
git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libcaca/trunk@4402 92316355-f0b4-4df1-b90c-862c8a59935f
diff --git a/python/caca/canvas.py b/python/caca/canvas.py
index d95336c..5cdec0d 100644
@@ -801,6 +801,67 @@ class Canvas(_Canvas):
return _lib.caca_import_canvas_from_memory(self, data, length, fmt)
+ def export_to_memory(self, fmt):
+ """ Export a canvas into a foreign format.
+
+ fmt -- a string describing the input format
+
+ Valid values for format are:
+ - caca: export native libcaca files.
+ - ansi: export ANSI art (CP437 charset with ANSI colour codes).
+ - html: export an HTML page with CSS information.
+ - html3: export an HTML table that should be compatible with
+ most navigators, including textmode ones.
+ - irc: export UTF-8 text with mIRC colour codes.
+ - ps: export a PostScript document.
+ - svg: export an SVG vector image.
+ - tga: export a TGA image.
+ """
+ #initialize pointer
+ p_size_t = ctypes.POINTER(ctypes.c_size_t)
+
+ _lib.caca_export_canvas_to_memory.argtypes = [
+ _Canvas, ctypes.c_char_p, p_size_t
+ ]
+ _lib.caca_export_canvas_to_memory.restype = ctypes.c_void_p
+
+ ret = _lib.caca_export_canvas_to_memory(self, fmt,
+ p_size_t(ctypes.c_size_t()))
+ return ctypes.c_char_p(ret).value
+
+ def export_area_to_memory(self, x, y, width, height, fmt):
+ """ Export a canvas portion into a foreign format.
+
+ x -- the leftmost coordinate of the area to export
+ y -- the topmost coordinate of the area to export
+ width -- the width of the area to export
+ height -- the height of the area to export
+ fmt -- a string describing the input format
+
+ Valid values for format are:
+ - caca: export native libcaca files.
+ - ansi: export ANSI art (CP437 charset with ANSI colour codes).
+ - html: export an HTML page with CSS information.
+ - html3: export an HTML table that should be compatible with
+ most navigators, including textmode ones.
+ - irc: export UTF-8 text with mIRC colour codes.
+ - ps: export a PostScript document.
+ - svg: export an SVG vector image.
+ - tga: export a TGA image.
+ """
+ #initialize pointer
+ p_size_t = ctypes.POINTER(ctypes.c_size_t)
+
+ _lib.caca_export_area_to_memory.argtypes = [
+ _Canvas, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int,
+ ctypes.c_char_p, p_size_t
+ ]
+ _lib.caca_export_area_to_memory.restype = ctypes.c_void_p
+
+ ret = _lib.caca_export_area_to_memory(self, x, y, width, height,
+ fmt, p_size_t(ctypes.c_size_t()))
+ return ctypes.c_char_p(ret).value
+
class NullCanvas(_Canvas):
""" Represent a NULL canvas_t, eg to use as canvas mask for blit operations.
"""

View File

@ -1,32 +0,0 @@
--- configure.ac 2011-01-29 13:52:25.000000000 +0200
+++ configure.ac 2010-10-09 11:43:25.000000000 +0200
@@ -1,5 +1,5 @@
-AC_INIT(libcaca, 0.99.beta17)
+AC_INIT(libcaca, 0.99.beta18)
AC_PREREQ(2.50)
AC_CONFIG_AUX_DIR(.auto)
AC_CANONICAL_SYSTEM
@@ -85,6 +85,8 @@
[ --enable-java Java bindings (autodetected)])
AC_ARG_ENABLE(cxx,
[ --enable-cxx C++ bindings (autodetected)])
+AC_ARG_ENABLE(python,
+ [ --enable-python Python bindings (autodetected)])
AC_ARG_ENABLE(ruby,
[ --enable-ruby Ruby bindings (autodetected)])
@@ -464,6 +450,13 @@
fi
AM_CONDITIONAL(USE_JAVA, test "${ac_cv_my_have_java}" = "yes")
+# Build the Python bindings?
+ac_cv_my_have_python="no"
+if test "${enable_python}" != "no"; then
+ AM_PATH_PYTHON(2.2, ac_cv_my_have_python="yes", :)
+fi
+AM_CONDITIONAL(USE_PYTHON, test "${ac_cv_my_have_python}" = "yes")
+
# Build the Ruby bindings?
ac_cv_my_have_ruby="no"
if test "${enable_ruby}" != "no"; then

View File

@ -1,96 +0,0 @@
--- configure.ac 2011-01-29 13:52:25.000000000 +0200
+++ configure.ac 2010-10-09 11:43:25.000000000 +0200
@@ -1,5 +1,5 @@
-AC_INIT(libcaca, 0.99.beta17)
+AC_INIT(libcaca, 0.99.beta18)
AC_PREREQ(2.50)
AC_CONFIG_AUX_DIR(.auto)
AC_CANONICAL_SYSTEM
@@ -85,6 +85,8 @@
[ --enable-java Java bindings (autodetected)])
AC_ARG_ENABLE(cxx,
[ --enable-cxx C++ bindings (autodetected)])
+AC_ARG_ENABLE(python,
+ [ --enable-python Python bindings (autodetected)])
AC_ARG_ENABLE(ruby,
[ --enable-ruby Ruby bindings (autodetected)])
@@ -130,7 +132,6 @@
if test "$ac_cv_have_getopt_long" != "no"; then
AC_DEFINE(HAVE_GETOPT_LONG, 1, Define to 1 if you have the getopt_long function.)
fi
-AM_CONDITIONAL(NEED_GETOPT_LONG, test "$ac_cv_have_getopt_long" = "no")
AC_SUBST(GETOPT_LIBS)
AC_MSG_CHECKING(for Sleep)
@@ -213,7 +214,7 @@
AC_CHECK_LIB(X11, XOpenDisplay,
[ac_cv_my_have_x11="yes"
if test -n "${x_includes}"; then X_CFLAGS="-I${x_includes}"; fi
- if test -n "${x_libraries}" -a "${x_libraries}" != "/usr"; then X_LIBS="-L${x_libraries}"; fi
+ if test -n "${x_libraries}"; then X_LIBS="-L${x_libraries}"; fi
AC_DEFINE(USE_X11, 1, Define to 1 to activate the X11 backend driver)
CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
X11_LIBS="${X11_LIBS} -lX11 ${X_LIBS}"
@@ -368,21 +369,6 @@
AC_SUBST(GL_CFLAGS)
AC_SUBST(GL_LIBS)
-# How to get the C99 types. See caca/caca_types.h.in for details about
-# the CACA_TYPES variable
-if test "${ac_cv_my_have_kernel}" = "yes"; then
- CACA_TYPES=0
-else
- AC_CHECK_HEADERS(stdint.h,
- [CACA_TYPES=1],
- [AC_CHECK_HEADERS(inttypes.h,
- [CACA_TYPES=2],
- [AC_CHECK_HEADERS(windows.h,
- [CACA_TYPES=3],
- [CACA_TYPES=0])])])
-fi
-AC_SUBST(CACA_TYPES)
-
# Optimizations
CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"
# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
@@ -464,6 +450,13 @@
fi
AM_CONDITIONAL(USE_JAVA, test "${ac_cv_my_have_java}" = "yes")
+# Build the Python bindings?
+ac_cv_my_have_python="no"
+if test "${enable_python}" != "no"; then
+ AM_PATH_PYTHON(2.2, ac_cv_my_have_python="yes", :)
+fi
+AM_CONDITIONAL(USE_PYTHON, test "${ac_cv_my_have_python}" = "yes")
+
# Build the Ruby bindings?
ac_cv_my_have_ruby="no"
if test "${enable_ruby}" != "no"; then
@@ -471,12 +464,12 @@
if test "${RUBY}" != "no"; then
RUBY_CFLAGS="-I$(ruby -r rbconfig -e 'print Config::CONFIG@<:@"archdir"@:>@')"
RUBY_LIBS="-L$(ruby -r rbconfig -e 'print Config::CONFIG@<:@"libdir"@:>@') -l$(ruby -r rbconfig -e 'print Config::CONFIG@<:@"RUBY_SO_NAME"@:>@')"
- RUBY_VENDORARCHDIR=`ruby -r rbconfig -e 'print Config::CONFIG@<:@"vendorarchdir"@:>@'`
- RUBY_VENDORLIBDIR=`ruby -r rbconfig -e 'print Config::CONFIG@<:@"vendorlibdir"@:>@'`
+ RUBY_SITEARCHDIR=`ruby -r rbconfig -e 'print Config::CONFIG@<:@"sitearchdir"@:>@'`
+ RUBY_SITELIBDIR=`ruby -r rbconfig -e 'print Config::CONFIG@<:@"sitelibdir"@:>@'`
AC_SUBST(RUBY_CFLAGS)
AC_SUBST(RUBY_LIBS)
- AC_SUBST(RUBY_VENDORARCHDIR)
- AC_SUBST(RUBY_VENDORLIBDIR)
+ AC_SUBST(RUBY_SITEARCHDIR)
+ AC_SUBST(RUBY_SITELIBDIR)
CPPFLAGS="${CPPFLAGS} ${RUBY_CFLAGS}"
AC_CHECK_HEADERS([ruby.h],
[ac_cv_my_have_ruby="yes"
@@ -571,7 +564,6 @@
win32/Makefile
])
AC_CONFIG_FILES([
- caca/caca_types.h
caca/caca.pc
caca-sharp/caca-sharp.dll.config
cxx/caca++.pc

View File

@ -1,145 +0,0 @@
* Bind event functions.
git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libcaca/trunk@4411 92316355-f0b4-4df1-b90c-862c8a59935f
diff --git a/python/caca/display.py b/python/caca/display.py
index 8bdd887..8757ae4 100644
@@ -155,15 +155,7 @@ class Display(_Display):
return _lib.caca_set_cursor(self, flag)
def get_event(self, event_mask, event, timeout):
- """ Poll the event queue for mouse or keyboard events matching the event mask
- and return the first matching event. Non-matching events are discarded.
- If event_mask is zero, the function returns immediately.
- The timeout value tells how long this function needs to wait for an event.
- A value of zero returns immediately and the function returns zero if no more events
- are pending in the queue. A negative value causes the function to wait indefinitely
- until a matching event is received.
- If not null, ev will be filled with information about the event received. If null,
- the function will return but no information about the event will be sent.
+ """ Get the next mouse or keyboard input event.
event_mask -- bitmask of requested events
event -- a pointer to caca_event structure or NULL
@@ -175,24 +167,16 @@ class Display(_Display):
return _lib.caca_get_event(self, event_mask, ctypes.byref(event), timeout)
def get_mouse_x(self):
- """ Return the X coordinate of the mouse position last time it was detected.
- This function is not reliable if the ncurses or S-Lang drivers are being used,
- because mouse position is only detected when the mouse is clicked.
- Other drivers such as X11 work well.
+ """ Return the X mouse coordinate.
"""
-
_lib.caca_get_mouse_x.argtypes = [Display]
_lib.caca_get_mouse_x.restype = ctypes.c_int
return _lib.caca_get_mouse_x(self)
def get_mouse_y(self):
- """ Return the Y coordinate of the mouse position last time it was detected.
- This function is not reliable if the ncurses or S-Lang drivers are being used,
- because mouse position is only detected when the mouse is clicked.
- Other drivers such as X11 work well.
+ """ Return the Y mouse coordinate.
"""
-
_lib.caca_get_mouse_y.argtypes = [Display]
_lib.caca_get_mouse_y.restype = ctypes.c_int
@@ -214,45 +198,76 @@ class Event(ctypes.Structure):
return ctypes.byref(self)
def get_type(self):
- """ Return the type of an event. This function may always be called
- on an event after caca_get_event() was called, and its return value
- indicates which other functions may be called.
+ """ Return an event's type.
"""
_lib.caca_get_event_type.argtypes = [Event]
- _lib.caca_get_event_type.restype = ctypes.c_int
+ _lib.caca_get_event_type.restype = ctypes.c_int
return _lib.caca_get_event_type(self)
def get_key_ch(self):
- """ Return either the ASCII value for an event's key, or if the key is not
- an ASCII character, an appropriate KEY_* value
+ """ Return a key press or key release event's value.
"""
_lib.caca_get_event_key_ch.argtypes = [Event]
- _lib.caca_get_event_key_ch.restype = ctypes.c_int
+ _lib.caca_get_event_key_ch.restype = ctypes.c_int
return _lib.caca_get_event_key_ch(self)
def get_key_utf32(self):
- """ Return the UTF-32/UCS-4 value for an event's key if it resolves
- to a printable character.
+ """ Not implemented.
"""
- _lib.caca_get_event_key_utf32.argtypes = [Event]
- _lib.caca_get_event_key_utf32.restype = ctypes.c_uint32
-
- return _lib.caca_get_event_key_utf32(self)
+ raise DisplayError, "Not implemented"
def get_key_utf8(self):
- """ Write the UTF-8 value for an event's key if it resolves to a
- printable character. Up to 6 UTF-8 bytes and a null termination
- are written.
+ """ Return a key press or key release event's UTF-8 value.
"""
# set buffer for writing utf8 value
- buf = ctypes.c_buffer(2)
+ buf = ctypes.c_buffer(7)
_lib.caca_get_event_key_utf8.argtypes = [Event, ctypes.c_char_p]
- _lib.caca_get_event_key_utf8.restype = ctypes.c_int
+ _lib.caca_get_event_key_utf8.restype = ctypes.c_int
_lib.caca_get_event_key_utf8(self, buf)
return buf
+ def get_mouse_button(self):
+ """ Return a mouse press or mouse release event's button.
+ """
+ _lib.caca_get_event_mouse_button.argtypes = [Event]
+ _lib.caca_get_event_mouse_button.restype = ctypes.c_int
+
+ return _lib.caca_get_event_mouse_button(self)
+
+ def get_mouse_x(self):
+ """ Return a mouse motion event's X coordinate.
+ """
+ _lib.caca_get_event_mouse_x.argtypes = [Event]
+ _lib.caca_get_event_mouse_x.restype = ctypes.c_int
+
+ return _lib.caca_get_event_mouse_x(self)
+
+ def get_mouse_y(self):
+ """ Return a mouse motion event's Y coordinate.
+ """
+ _lib.caca_get_event_mouse_y.argtypes = [Event]
+ _lib.caca_get_event_mouse_y.restype = ctypes.c_int
+
+ return _lib.caca_get_event_mouse_y(self)
+
+ def get_resize_width(self):
+ """ Return a resize event's display width value.
+ """
+ _lib.caca_get_event_resize_width.argtypes = [Event]
+ _lib.caca_get_event_resize_width.restype = ctypes.c_int
+
+ return _lib.caca_get_event_resize_width(self)
+
+ def get_resize_height(self):
+ """ Return a resize event's display height value.
+ """
+ _lib.caca_get_event_resize_height.argtypes = [Event]
+ _lib.caca_get_event_resize_height.restype = ctypes.c_int
+
+ return _lib.caca_get_event_resize_height(self)
+

View File

@ -1,59 +0,0 @@
* Fix export functions.
git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libcaca/trunk@4405 92316355-f0b4-4df1-b90c-862c8a59935f
diff --git a/python/caca/canvas.py b/python/caca/canvas.py
index e51520a..292ab87 100644
@@ -888,7 +888,7 @@ class Canvas(_Canvas):
def export_to_memory(self, fmt):
""" Export a canvas into a foreign format.
- fmt -- a string describing the input format
+ fmt -- a string describing the output format
Valid values for format are:
- caca: export native libcaca files.
@@ -903,15 +903,15 @@ class Canvas(_Canvas):
"""
#initialize pointer
p_size_t = ctypes.POINTER(ctypes.c_size_t)
-
_lib.caca_export_canvas_to_memory.argtypes = [
_Canvas, ctypes.c_char_p, p_size_t
]
- _lib.caca_export_canvas_to_memory.restype = ctypes.c_void_p
+ _lib.caca_export_canvas_to_memory.restype = ctypes.POINTER(ctypes.c_char_p)
+
+ p = ctypes.c_size_t()
+ ret = _lib.caca_export_canvas_to_memory(self, fmt, p)
- ret = _lib.caca_export_canvas_to_memory(self, fmt,
- p_size_t(ctypes.c_size_t()))
- return ctypes.c_char_p(ret).value
+ return ctypes.string_at(ret, p.value)
def export_area_to_memory(self, x, y, width, height, fmt):
""" Export a canvas portion into a foreign format.
@@ -920,7 +920,7 @@ class Canvas(_Canvas):
y -- the topmost coordinate of the area to export
width -- the width of the area to export
height -- the height of the area to export
- fmt -- a string describing the input format
+ fmt -- a string describing the output format
Valid values for format are:
- caca: export native libcaca files.
@@ -942,9 +942,10 @@ class Canvas(_Canvas):
]
_lib.caca_export_area_to_memory.restype = ctypes.c_void_p
- ret = _lib.caca_export_area_to_memory(self, x, y, width, height,
- fmt, p_size_t(ctypes.c_size_t()))
- return ctypes.c_char_p(ret).value
+ p = ctypes.c_size_t()
+ ret = _lib.caca_export_area_to_memory(self, x, y, width, height, fmt, p)
+
+ return ctypes.string_at(ret, p.value)
class NullCanvas(_Canvas):
""" Represent a NULL canvas_t, eg to use as canvas mask for blit operations.

View File

@ -1,108 +0,0 @@
* Fix get_dirty_rect function. * Add exceptions for missing methods.
git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libcaca/trunk@4404 92316355-f0b4-4df1-b90c-862c8a59935f
diff --git a/python/caca/canvas.py b/python/caca/canvas.py
index 1ce59ae..e51520a 100644
@@ -68,6 +68,16 @@ class Canvas(_Canvas):
if self._cv == 0:
raise CanvasError, "Failed to create canvas"
+ def manage(self, *args, **kw):
+ """ Not implemented.
+ """
+ raise CanvasError, "Not implemented"
+
+ def unmanage(self, *args, **kw):
+ """ Not implemented.
+ """
+ raise CanvasError, "Not implemented"
+
def set_size(self, width, height):
""" Resize a canvas.
@@ -97,25 +107,15 @@ class Canvas(_Canvas):
return _lib.caca_get_canvas_height(self)
- def get_chars(self):
- """ Get the canvas character array, return python list.
+ def get_chars(self, *args, **kw):
+ """ Not implemented.
"""
- chlist = []
- #get canvas size
- w, h = self.get_width(), self.get_height()
-
- _lib.caca_get_canvas_chars.argtypes = [_Canvas]
- _lib.caca_get_canvas_chars.restype = \
- ctypes.POINTER(ctypes.c_uint8 * (w * h))
+ raise CanvasError, "Not implemented"
- plist = _lib.caca_get_canvas_chars(self)
-
- #build character list
- for item in plist.contents:
- if item != 0:
- chlist.append(chr(item))
-
- return chlist
+ def get_attrs(self, *args, **kw):
+ """ Not implemented.
+ """
+ raise CanvasError, "Not implemented"
def gotoxy(self, x, y):
""" Set cursor position.
@@ -200,6 +200,11 @@ class Canvas(_Canvas):
return _lib.caca_printf(self, x, y, fmt, *args)
+ def vprintf(self, *args, **kw):
+ """ Not implemented.
+ """
+ raise CanvasError, "Not implemented"
+
def clear(self):
""" Clear the canvas.
"""
@@ -293,14 +298,17 @@ class Canvas(_Canvas):
return _lib.caca_get_dirty_rect_count(self)
def get_dirty_rect(self, idx):
- """ Get a canvas's dirty rectangle.
+ """ Get a canvas's dirty rectangle. Return python dictionnary with
+ coords as keys: x, y, width, height.
idx -- the requested rectangle index
"""
- x = ctypes.POINTER(ctypes.c_int)
- y = ctypes.POINTER(ctypes.c_int)
- w = ctypes.POINTER(ctypes.c_int)
- h = ctypes.POINTER(ctypes.c_int)
+ #initialize dictionnary and pointers
+ dct = None
+ x = ctypes.c_int()
+ y = ctypes.c_int()
+ width = ctypes.c_int()
+ height = ctypes.c_int()
_lib.caca_get_dirty_rect.argtypes = [
_Canvas, ctypes.c_int,
@@ -309,10 +317,13 @@ class Canvas(_Canvas):
]
_lib.caca_get_dirty_rect.restype = ctypes.c_int
- _lib.caca_get_dirty_rect(self, idx, x, y, w, h)
+ if _lib.caca_get_dirty_rect(self, idx, x, y, width, height) > -1:
+ dct = {
+ 'x': x.value, 'y': y.value,
+ 'width': width.value, 'height': height.value,
+ }
- return [x.contents.value, y.contents.value,
- w.contents.value, h.contents.value]
+ return dct
def add_dirty_rect(self, x, y, width, height):
""" Add an area to the canvas's dirty rectangle list.

View File

@ -1,112 +0,0 @@
* Bind import functions.
git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libcaca/trunk@4403 92316355-f0b4-4df1-b90c-862c8a59935f
diff --git a/python/caca/canvas.py b/python/caca/canvas.py
index 5cdec0d..1ce59ae 100644
@@ -784,23 +784,96 @@ class Canvas(_Canvas):
return _lib.caca_free_frame(self, idx)
- def import_from_memory(self, data, length, fmt):
- """ Import a memory buffer into the given libcaca canvas's current frame.
- The current frame is resized accordingly and its contents are replaced
- with the imported data.
+ def import_from_memory(self, data, fmt):
+ """ Import a memory buffer into a canvas.
- data -- a memory area containing the data to be loaded into the canvas
- length -- the size in bytes of the memory area
- fmt -- a string describing the input format
- """
+ data -- a memory area containing the data to be loaded into the canvas
+ fmt -- a string describing the input format
+ Valid values for format are:
+ - "": attempt to autodetect the file format.
+ - caca: import native libcaca files.
+ - text: import ASCII text files.
+ - ansi: import ANSI files.
+ - utf8: import UTF-8 files with ANSI colour codes.
+ """
+ #set data size
+ length = ctypes.c_size_t(len(data))
_lib.caca_import_canvas_from_memory.argtypes = [
- Canvas, ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p
+ Canvas, ctypes.c_char_p, ctypes.c_size_t, ctypes.c_char_p
]
_lib.caca_import_canvas_from_memory.restype = ctypes.c_int
return _lib.caca_import_canvas_from_memory(self, data, length, fmt)
+ def import_from_file(self, filename, fmt):
+ """ Import a file into a canvas.
+
+ filename -- the name of the file to load
+ fmt -- a string describing the input format
+
+ Valid values for format are:
+ - "": attempt to autodetect the file format.
+ - caca: import native libcaca files.
+ - text: import ASCII text files.
+ - ansi: import ANSI files.
+ - utf8: import UTF-8 files with ANSI colour codes.
+ """
+ _lib.caca_import_canvas_from_file.argtypes = [
+ _Canvas, ctypes.c_char_p, ctypes.c_char_p
+ ]
+ _lib.caca_import_canvas_from_file.restype = ctypes.c_int
+
+ return _lib.caca_import_canvas_from_file(self, filename, fmt)
+
+ def import_area_from_memory(self, x, y, data, fmt):
+ """ Import a memory buffer into a canvas area.
+
+ x -- the leftmost coordinate of the area to import to
+ y -- the topmost coordinate of the area to import to
+ data -- a memory area containing the data to be loaded into the canvas
+ fmt -- a string describing the input format
+
+ Valid values for format are:
+ - "": attempt to autodetect the file format.
+ - caca: import native libcaca files.
+ - text: import ASCII text files.
+ - ansi: import ANSI files.
+ - utf8: import UTF-8 files with ANSI colour codes.
+ """
+ #set data size
+ length = ctypes.c_size_t(len(data))
+ _lib.caca_import_area_from_memory.argtypes = [
+ _Canvas, ctypes.c_int, ctypes.c_int,
+ ctypes.c_char_p, ctypes.c_size_t, ctypes.c_char_p
+ ]
+ _lib.caca_import_area_from_memory.restype = ctypes.c_int
+
+ return _lib.caca_import_area_from_memory(self, x, y, data, length, fmt)
+
+ def import_area_from_file(self, x, y, filename, fmt):
+ """ Import a file into a canvas area.
+
+ x -- the leftmost coordinate of the area to import to
+ y -- the topmost coordinate of the area to import to
+ filename -- the name of the file to be load
+ fmt -- a string describing the input format
+
+ Valid values for format are:
+ - "": attempt to autodetect the file format.
+ - caca: import native libcaca files.
+ - text: import ASCII text files.
+ - ansi: import ANSI files.
+ - utf8: import UTF-8 files with ANSI colour codes.
+ """
+ _lib.caca_import_area_from_file.argtypes = [
+ _Canvas, ctypes.c_int, ctypes.c_int,
+ ctypes.c_char_p, ctypes.c_char_p
+ ]
+ _lib.caca_import_area_from_file.restype = ctypes.c_int
+
+ return _lib.caca_import_area_from_file(self, x, y, filename, fmt)
+
def export_to_memory(self, fmt):
""" Export a canvas into a foreign format.

View File

@ -1,15 +0,0 @@
* Fix python Makefile.
git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libcaca/trunk@4401 92316355-f0b4-4df1-b90c-862c8a59935f
diff --git a/python/Makefile.am b/python/Makefile.am
index 60a69a5..c0977d2 100644
@@ -1,6 +1,7 @@
if USE_PYTHON
-python_PYTHON = \
+cacadir = $(pythondir)/caca
+caca_PYTHON = \
caca/__init__.py \
caca/canvas.py \
caca/common.py \

View File

@ -1,26 +0,0 @@
* Rename cv variable to pointer.
git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libcaca/trunk@4409 92316355-f0b4-4df1-b90c-862c8a59935f
diff --git a/python/caca/canvas.py b/python/caca/canvas.py
index 4373e0e..bbf5b7e 100644
@@ -61,16 +61,16 @@ class Canvas(_Canvas):
width -- the desired canvas width
height -- the desired canvas height
- cv -- pointer to libcaca canvas
+ pointer -- pointer to libcaca canvas
"""
_lib.caca_create_canvas.argtypes = [ctypes.c_int, ctypes.c_int]
- if cv is not None:
+ if pointer is not None:
self._cv = _lib.caca_create_canvas(width, height)
if self._cv == 0:
raise CanvasError, "Failed to create canvas"
else:
- self._cv = cv
+ self._cv = pointer
def manage(self, *args, **kw):
""" Not implemented.

View File

@ -15,8 +15,6 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# norootforbuild
%define withjava 0
%define withpython 0
@ -40,20 +38,6 @@ Patch4: libcaca-ruby_am_cflags.patch
Patch5: libcaca-ruby_vendor_install.patch
Patch7: libcaca-0.99.beta16-missing-GLU.patch
Patch9: caca-no-build-date.patch
# Patches from git for python bindings
%if %{withpython} == 1
Patch10: libcaca-python-makefile.patch
Patch11: libcaca-python-canvas.patch
Patch12: libcaca-python-import.patch
Patch13: libcaca-python-fixdirt.patch
Patch14: libcaca-python-export.patch
Patch15: libcaca-python-args.patch
Patch16: libcaca-python-pointer.patch
Patch17: libcaca-python-bad.patch
Patch18: libcaca-python-events.patch
Patch19: libcaca-python-configure.ac.patch
Patch20: libcaca-python-Makefile.am.patch
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%define rb_vendorarch %{_libdir}/ruby/vendor_ruby/%{rb_ver}/%{rb_arch}
%define rb_vendorlib %{_libdir}/ruby/vendor_ruby/%{rb_ver}
@ -238,12 +222,6 @@ that shows the libcaca rendering features such as line and ellipses
drawing, triangle filling and sprite blitting.
Authors:
--------
Sam Hocevar <sam@zoy.org>
Jean-Yves Lamoureux <jylam@lnxscene.org>
%prep
chmod 0644 %{S:0}
%setup -q -n libcaca-%{version}
@ -253,30 +231,6 @@ chmod 0644 %{S:0}
%patch7
%patch9
%patch1
%if %{withpython} == 1
cat <<EOF
++++++++++++++++++++++++++++++++++++'
Patches from git for python bindings
to be removed in next release.
++++++++++++++++++++++++++++++++++++'
EOF
%patch10 -p1
mkdir -p python/caca
touch python/caca/canvas.py
touch python/caca/display.py
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19
%patch20
%endif
%build
find ./ -name Makefile.in -delete