Changeset 2821


Ignore:
Timestamp:
Sep 27, 2008, 3:12:46 PM (11 years ago)
Author:
Sam Hocevar
Message:

Starting refactoring to get rid of libcucul. The initial reason for the
split is rendered moot by the plugin system: when enabled, binaries do
not link directly with libX11 or libGL. I hope this is a step towards
more consisteny and clarity.

Location:
libcaca/trunk
Files:
3 deleted
82 edited
20 copied
7 moved

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/Makefile.am

    r2299 r2821  
    11# $Id$
    22
    3 SUBDIRS = kernel cucul caca src examples tests tools csharp cxx python ruby doc
     3SUBDIRS = kernel caca src examples tests tools csharp cxx python ruby doc
    44DIST_SUBDIRS = $(SUBDIRS) msvc
    55
     
    2121
    2222fonts: tools/makefont
    23         tools/makefont mono9 "Monospace 9" 96 4 >| $(srcdir)/cucul/mono9.data
    24         tools/makefont monobold12 "Monospace Bold 12" 96 4 >| $(srcdir)/cucul/monobold12.data
     23        tools/makefont mono9 "Monospace 9" 96 4 >| $(srcdir)/caca/mono9.data
     24        tools/makefont monobold12 "Monospace Bold 12" 96 4 >| $(srcdir)/caca/monobold12.data
    2525
    2626FORCE:
  • libcaca/trunk/build-kernel

    r2299 r2821  
    77set -e
    88
    9 CFLAGS="-fno-builtin -O2 -I. -I.. -I../cucul/ -Wall"
     9CFLAGS="-fno-builtin -O2 -I. -I.. -I../caca/ -Wall"
    1010CPPFLAGS="-D__KERNEL__ -nostdinc -include kernel/kernel.h"
    1111LDFLAGS="-nostdlib -Wl,-N -Wl,-Ttext -Wl,100000"
     
    1919make clean
    2020
    21 cd cucul && make && cd ..
    2221cd caca && make && cd ..
    2322
     
    2928cd ..
    3029
    31 gcc $LDFLAGS -o src/cacademo kernel/multiboot.o kernel/kernel.o src/cacademo.o caca/.libs/libcaca.a cucul/.libs/libcucul.a
     30gcc $LDFLAGS -o src/cacademo kernel/multiboot.o kernel/kernel.o src/cacademo.o caca/.libs/libcaca.a
    3231
    3332objcopy -O binary src/cacademo cacademo.boot
  • libcaca/trunk/caca-config.in

    r1018 r2821  
    6868      echo_libs=yes
    6969      ;;
    70     cucul)
    71       libs="$libs -lcucul"
    72       ;;
    7370    caca)
    74       libs="$libs -lcaca -lcucul"
     71      libs="$libs -lcaca"
    7572      ;;
    7673    *)
     
    8380if test "$libs" = ""
    8481then
    85   libs="-lcaca -lcucul"
     82  libs="-lcaca"
    8683fi
    8784
  • libcaca/trunk/caca/Makefile.am

    r2517 r2821  
    11# $Id$
    22
    3 EXTRA_DIST = caca.pc.in
    4 DISTCLEANFILES = caca.pc
     3EXTRA_DIST = caca_types.h.in caca.pc.in mono9.data monobold12.data
     4DISTCLEANFILES = caca_types.h caca.pc
    55
    6 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/cucul -I../cucul \
    7               -DPLUGINDIR=\"$(plugindir)\"
     6AM_CPPFLAGS = -I$(top_srcdir) -DPLUGINDIR=\"$(plugindir)\"
    87
    98pkgconfig_DATA = caca.pc
    109pkgconfigdir = $(libdir)/pkgconfig
    1110
    12 include_HEADERS = caca.h caca0.h
     11include_HEADERS = caca.h caca_types.h caca0.h
    1312
    1413lib_LTLIBRARIES = libcaca.la
     
    1716        caca.c \
    1817        caca.h \
     18        caca_types.h \
    1919        caca_internals.h \
    2020        caca0.c \
    2121        caca0.h \
     22        canvas.c \
     23        string.c \
     24        legacy.c \
     25        transform.c \
     26        charset.c \
     27        attr.c \
     28        line.c \
     29        box.c \
     30        conic.c \
     31        triangle.c \
     32        frame.c \
     33        dither.c \
     34        font.c \
     35        import.c \
     36        export.c \
     37        file.c \
     38        figfont.c \
    2239        graphics.c \
    2340        event.c \
     
    3249        $(extra_source) \
    3350        $(NULL)
     51libcaca_la_DEPENDENCIES = \
     52        mono9.data \
     53        monobold12.data \
     54        $(NULL)
    3455libcaca_la_CPPFLAGS = $(AM_CPPFLAGS) @CACA_CFLAGS@
    3556libcaca_la_LDFLAGS = -no-undefined -version-number @LT_VERSION@
    36 libcaca_la_LIBADD = ../cucul/libcucul.la @CACA_LIBS@
     57libcaca_la_LIBADD = @CACA_LIBS@ $(ZLIB_LIBS)
    3758
    3859if USE_PLUGINS
     
    4364libx11_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) $(X11_CFLAGS)
    4465libx11_plugin_la_LDFLAGS = -no-undefined -module -no-version
    45 libx11_plugin_la_LIBADD = libcaca.la ../cucul/libcucul.la $(X11_LIBS)
     66libx11_plugin_la_LIBADD = libcaca.la $(X11_LIBS)
    4667
    4768libgl_plugin_la_SOURCES = driver_gl.c
    4869libgl_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) $(GL_CFLAGS) #$(FTGL_CFLAGS)
    4970libgl_plugin_la_LDFLAGS = -no-undefined -module -no-version
    50 libgl_plugin_la_LIBADD = libcaca.la ../cucul/libcucul.la $(GL_LIBS) #$(FTGL_LIBS)
     71libgl_plugin_la_LIBADD = libcaca.la $(GL_LIBS) #$(FTGL_LIBS)
    5172else
    5273extra_source = driver_x11.c driver_gl.c
  • libcaca/trunk/caca/attr.c

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
    44 *                All Rights Reserved
     
    2020#include "config.h"
    2121
    22 #include "cucul.h"
    23 #include "cucul_internals.h"
     22#include "caca.h"
     23#include "caca_internals.h"
    2424
    2525static uint8_t nearest_ansi(uint16_t);
     
    4343/** \brief Get the text attribute at the given coordinates.
    4444 *
    45  *  Get the internal \e libcucul attribute value of the character at the
     45 *  Get the internal \e libcaca attribute value of the character at the
    4646 *  given coordinates. The attribute value has 32 significant bits,
    4747 *  organised as follows from MSB to LSB:
     
    6161 *  This function never fails.
    6262 *
    63  *  \param cv A handle to the libcucul canvas.
     63 *  \param cv A handle to the libcaca canvas.
    6464 *  \param x X coordinate.
    6565 *  \param y Y coordinate.
    6666 *  \return The requested attribute.
    6767 */
    68 uint32_t cucul_get_attr(cucul_canvas_t const *cv, int x, int y)
     68uint32_t caca_get_attr(caca_canvas_t const *cv, int x, int y)
    6969{
    7070    if(x < 0 || x >= (int)cv->width || y < 0 || y >= (int)cv->height)
     
    8383 *
    8484 *  The value of \e attr is either:
    85  *  - a 32-bit integer as returned by cucul_get_attr(), in which case it
     85 *  - a 32-bit integer as returned by caca_get_attr(), in which case it
    8686 *    also contains colour information,
    87  *  - a combination (bitwise OR) of style values (\e CUCUL_UNDERLINE,
    88  *    \e CUCUL_BLINK, \e CUCUL_BOLD and \e CUCUL_ITALICS), in which case
     87 *  - a combination (bitwise OR) of style values (\e CACA_UNDERLINE,
     88 *    \e CACA_BLINK, \e CACA_BOLD and \e CACA_ITALICS), in which case
    8989 *    setting the attribute does not modify the current colour information.
    9090 *
    91  *  To retrieve the current attribute value, use cucul_get_attr(-1,-1).
     91 *  To retrieve the current attribute value, use caca_get_attr(-1,-1).
    9292 *
    9393 *  This function never fails.
    9494 *
    95  *  \param cv A handle to the libcucul canvas.
     95 *  \param cv A handle to the libcaca canvas.
    9696 *  \param attr The requested attribute value.
    9797 *  \return This function always returns 0.
    9898 */
    99 int cucul_set_attr(cucul_canvas_t *cv, uint32_t attr)
     99int caca_set_attr(caca_canvas_t *cv, uint32_t attr)
    100100{
    101101    if(attr < 0x00000010)
     
    114114 *
    115115 *  The value of \e attr is either:
    116  *  - a 32-bit integer as returned by cucul_get_attr(), in which case it
     116 *  - a 32-bit integer as returned by caca_get_attr(), in which case it
    117117 *    also contains colour information,
    118  *  - a combination (bitwise OR) of style values (\e CUCUL_UNDERLINE,
    119  *    \e CUCUL_BLINK, \e CUCUL_BOLD and \e CUCUL_ITALICS), in which case
     118 *  - a combination (bitwise OR) of style values (\e CACA_UNDERLINE,
     119 *    \e CACA_BLINK, \e CACA_BOLD and \e CACA_ITALICS), in which case
    120120 *    setting the attribute does not modify the current colour information.
    121121 *
    122122 *  This function never fails.
    123123 *
    124  *  \param cv A handle to the libcucul canvas.
     124 *  \param cv A handle to the libcaca canvas.
    125125 *  \param x X coordinate.
    126126 *  \param y Y coordinate.
     
    128128 *  \return This function always returns 0.
    129129 */
    130 int cucul_put_attr(cucul_canvas_t *cv, int x, int y, uint32_t attr)
     130int caca_put_attr(caca_canvas_t *cv, int x, int y, uint32_t attr)
    131131{
    132132    uint32_t *curattr, *curchar;
     
    143143        curattr[0] = attr;
    144144
    145     if(x && curchar[0] == CUCUL_MAGIC_FULLWIDTH)
     145    if(x && curchar[0] == CACA_MAGIC_FULLWIDTH)
    146146        curattr[-1] = curattr[0];
    147     else if(x + 1 < (int)cv->width && curchar[1] == CUCUL_MAGIC_FULLWIDTH)
     147    else if(x + 1 < (int)cv->width && curchar[1] == CACA_MAGIC_FULLWIDTH)
    148148        curattr[1] = curattr[0];
    149149
     
    157157 *  will use these attributes.
    158158 *
    159  *  Color values are those defined in cucul.h, such as CUCUL_RED
    160  *  or CUCUL_TRANSPARENT.
     159 *  Color values are those defined in caca.h, such as CACA_RED
     160 *  or CACA_TRANSPARENT.
    161161 *
    162162 *  If an error occurs, 0 is returned and \b errno is set accordingly:
    163163 *  - \c EINVAL At least one of the colour values is invalid.
    164164 *
    165  *  \param cv A handle to the libcucul canvas.
     165 *  \param cv A handle to the libcaca canvas.
    166166 *  \param fg The requested ANSI foreground colour.
    167167 *  \param bg The requested ANSI background colour.
    168168 *  \return 0 in case of success, -1 if an error occurred.
    169169 */
    170 int cucul_set_color_ansi(cucul_canvas_t *cv, uint8_t fg, uint8_t bg)
     170int caca_set_color_ansi(caca_canvas_t *cv, uint8_t fg, uint8_t bg)
    171171{
    172172    uint32_t attr;
     
    196196 *  This function never fails.
    197197 *
    198  *  \param cv A handle to the libcucul canvas.
     198 *  \param cv A handle to the libcaca canvas.
    199199 *  \param fg The requested ARGB foreground colour.
    200200 *  \param bg The requested ARGB background colour.
    201201 *  \return This function always returns 0.
    202202 */
    203 int cucul_set_color_argb(cucul_canvas_t *cv, uint16_t fg, uint16_t bg)
     203int caca_set_color_argb(caca_canvas_t *cv, uint16_t fg, uint16_t bg)
    204204{
    205205    uint32_t attr;
     
    227227 *
    228228 *  If the attribute has ARGB colours, the nearest colour is used. Special
    229  *  attributes such as \e CUCUL_DEFAULT and \e CUCUL_TRANSPARENT are not
    230  *  handled and are both replaced with \e CUCUL_LIGHTGRAY for the foreground
    231  *  colour and \e CUCUL_BLACK for the background colour.
     229 *  attributes such as \e CACA_DEFAULT and \e CACA_TRANSPARENT are not
     230 *  handled and are both replaced with \e CACA_LIGHTGRAY for the foreground
     231 *  colour and \e CACA_BLACK for the background colour.
    232232 *
    233233 *  This function never fails. If the attribute value is outside the expected
     
    237237 *  \return The corresponding DOS ANSI value.
    238238 */
    239 uint8_t cucul_attr_to_ansi(uint32_t attr)
     239uint8_t caca_attr_to_ansi(uint32_t attr)
    240240{
    241241    uint8_t fg = nearest_ansi((attr >> 4) & 0x3fff);
    242242    uint8_t bg = nearest_ansi(attr >> 18);
    243243
    244     return (fg < 0x10 ? fg : CUCUL_LIGHTGRAY)
    245             | ((bg < 0x10 ? bg : CUCUL_BLACK) << 4);
     244    return (fg < 0x10 ? fg : CACA_LIGHTGRAY)
     245            | ((bg < 0x10 ? bg : CACA_BLACK) << 4);
    246246}
    247247
     
    249249 *
    250250 *  Get the ANSI foreground colour value for a given attribute. The returned
    251  *  value is either one of the \e CUCUL_RED, \e CUCUL_BLACK etc. predefined
    252  *  colours, or the special value \e CUCUL_DEFAULT meaning the media's
    253  *  default foreground value, or the special value \e CUCUL_TRANSPARENT.
     251 *  value is either one of the \e CACA_RED, \e CACA_BLACK etc. predefined
     252 *  colours, or the special value \e CACA_DEFAULT meaning the media's
     253 *  default foreground value, or the special value \e CACA_TRANSPARENT.
    254254 *
    255255 *  If the attribute has ARGB colours, the nearest colour is returned.
     
    261261 *  \return The corresponding ANSI foreground value.
    262262 */
    263 uint8_t cucul_attr_to_ansi_fg(uint32_t attr)
     263uint8_t caca_attr_to_ansi_fg(uint32_t attr)
    264264{
    265265    return nearest_ansi(((uint16_t)attr >> 4) & 0x3fff);
     
    269269 *
    270270 *  Get the ANSI background colour value for a given attribute. The returned
    271  *  value is either one of the \e CUCUL_RED, \e CUCUL_BLACK etc. predefined
    272  *  colours, or the special value \e CUCUL_DEFAULT meaning the media's
    273  *  default background value, or the special value \e CUCUL_TRANSPARENT.
     271 *  value is either one of the \e CACA_RED, \e CACA_BLACK etc. predefined
     272 *  colours, or the special value \e CACA_DEFAULT meaning the media's
     273 *  default background value, or the special value \e CACA_TRANSPARENT.
    274274 *
    275275 *  If the attribute has ARGB colours, the nearest colour is returned.
     
    281281 *  \return The corresponding ANSI background value.
    282282 */
    283 uint8_t cucul_attr_to_ansi_bg(uint32_t attr)
     283uint8_t caca_attr_to_ansi_bg(uint32_t attr)
    284284{
    285285    return nearest_ansi(attr >> 18);
     
    301301 *  \return The corresponding 12-bit RGB foreground value.
    302302 */
    303 uint16_t cucul_attr_to_rgb12_fg(uint32_t attr)
     303uint16_t caca_attr_to_rgb12_fg(uint32_t attr)
    304304{
    305305    uint16_t fg = (attr >> 4) & 0x3fff;
     
    308308        return ansitab16[fg ^ 0x40] & 0x0fff;
    309309
    310     if(fg == (CUCUL_DEFAULT | 0x40))
    311         return ansitab16[CUCUL_LIGHTGRAY] & 0x0fff;
    312 
    313     if(fg == (CUCUL_TRANSPARENT | 0x40))
    314         return ansitab16[CUCUL_LIGHTGRAY] & 0x0fff;
     310    if(fg == (CACA_DEFAULT | 0x40))
     311        return ansitab16[CACA_LIGHTGRAY] & 0x0fff;
     312
     313    if(fg == (CACA_TRANSPARENT | 0x40))
     314        return ansitab16[CACA_LIGHTGRAY] & 0x0fff;
    315315
    316316    return (fg << 1) & 0x0fff;
     
    332332 *  \return The corresponding 12-bit RGB background value.
    333333 */
    334 uint16_t cucul_attr_to_rgb12_bg(uint32_t attr)
     334uint16_t caca_attr_to_rgb12_bg(uint32_t attr)
    335335{
    336336    uint16_t bg = attr >> 18;
     
    339339        return ansitab16[bg ^ 0x40] & 0x0fff;
    340340
    341     if(bg == (CUCUL_DEFAULT | 0x40))
    342         return ansitab16[CUCUL_BLACK] & 0x0fff;
    343 
    344     if(bg == (CUCUL_TRANSPARENT | 0x40))
    345         return ansitab16[CUCUL_BLACK] & 0x0fff;
     341    if(bg == (CACA_DEFAULT | 0x40))
     342        return ansitab16[CACA_BLACK] & 0x0fff;
     343
     344    if(bg == (CACA_TRANSPARENT | 0x40))
     345        return ansitab16[CACA_BLACK] & 0x0fff;
    346346
    347347    return (bg << 1) & 0x0fff;
     
    367367 *  \param argb An array of 8-bit integers.
    368368 */
    369 void cucul_attr_to_argb64(uint32_t attr, uint8_t argb[8])
     369void caca_attr_to_argb64(uint32_t attr, uint8_t argb[8])
    370370{
    371371    uint16_t fg = (attr >> 4) & 0x3fff;
     
    374374    if(bg < (0x10 | 0x40))
    375375        bg = ansitab16[bg ^ 0x40];
    376     else if(bg == (CUCUL_DEFAULT | 0x40))
    377         bg = ansitab16[CUCUL_BLACK];
    378     else if(bg == (CUCUL_TRANSPARENT | 0x40))
     376    else if(bg == (CACA_DEFAULT | 0x40))
     377        bg = ansitab16[CACA_BLACK];
     378    else if(bg == (CACA_TRANSPARENT | 0x40))
    379379        bg = 0x0fff;
    380380    else
     
    388388    if(fg < (0x10 | 0x40))
    389389        fg = ansitab16[fg ^ 0x40];
    390     else if(fg == (CUCUL_DEFAULT | 0x40))
    391         fg = ansitab16[CUCUL_LIGHTGRAY];
    392     else if(fg == (CUCUL_TRANSPARENT | 0x40))
     390    else if(fg == (CACA_DEFAULT | 0x40))
     391        fg = ansitab16[CACA_LIGHTGRAY];
     392    else if(fg == (CACA_TRANSPARENT | 0x40))
    393393        fg = 0x0fff;
    394394    else
     
    412412        return argb14 ^ 0x40;
    413413
    414     if(argb14 == (CUCUL_DEFAULT | 0x40) || argb14 == (CUCUL_TRANSPARENT | 0x40))
     414    if(argb14 == (CACA_DEFAULT | 0x40) || argb14 == (CACA_TRANSPARENT | 0x40))
    415415        return argb14 ^ 0x40;
    416416
    417417    if(argb14 < 0x0fff) /* too transparent */
    418         return CUCUL_TRANSPARENT;
    419 
    420     best = CUCUL_DEFAULT;
     418        return CACA_TRANSPARENT;
     419
     420    best = CACA_DEFAULT;
    421421    dist = 0x3fff;
    422422    for(i = 0; i < 16; i++)
     
    452452  | ((uint32_t)(i & 0x00f) * 0x000011))
    453453
    454 uint32_t _cucul_attr_to_rgb24fg(uint32_t attr)
    455 {
    456     return RGB12TO24(cucul_attr_to_rgb12_fg(attr));
    457 }
    458 
    459 uint32_t _cucul_attr_to_rgb24bg(uint32_t attr)
    460 {
    461     return RGB12TO24(cucul_attr_to_rgb12_bg(attr));
    462 }
    463 
     454uint32_t _caca_attr_to_rgb24fg(uint32_t attr)
     455{
     456    return RGB12TO24(caca_attr_to_rgb12_fg(attr));
     457}
     458
     459uint32_t _caca_attr_to_rgb24bg(uint32_t attr)
     460{
     461    return RGB12TO24(caca_attr_to_rgb12_bg(attr));
     462}
     463
  • libcaca/trunk/caca/box.c

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
    44 *                All Rights Reserved
     
    2323#endif
    2424
    25 #include "cucul.h"
    26 #include "cucul_internals.h"
     25#include "caca.h"
     26#include "caca_internals.h"
    2727
    2828/** \brief Draw a box on the canvas using the given character.
     
    3030 *  This function never fails.
    3131 *
    32  *  \param cv The handle to the libcucul canvas.
     32 *  \param cv The handle to the libcaca canvas.
    3333 *  \param x X coordinate of the upper-left corner of the box.
    3434 *  \param y Y coordinate of the upper-left corner of the box.
     
    3838 *  \return This function always returns 0.
    3939 */
    40 int cucul_draw_box(cucul_canvas_t *cv, int x, int y, int w, int h, uint32_t ch)
    41 {
    42     int x2 = x + w - 1;
    43     int y2 = y + h - 1;
    44 
    45     cucul_draw_line(cv,  x,  y,  x, y2, ch);
    46     cucul_draw_line(cv,  x, y2, x2, y2, ch);
    47     cucul_draw_line(cv, x2, y2, x2,  y, ch);
    48     cucul_draw_line(cv, x2,  y,  x,  y, ch);
     40int caca_draw_box(caca_canvas_t *cv, int x, int y, int w, int h, uint32_t ch)
     41{
     42    int x2 = x + w - 1;
     43    int y2 = y + h - 1;
     44
     45    caca_draw_line(cv,  x,  y,  x, y2, ch);
     46    caca_draw_line(cv,  x, y2, x2, y2, ch);
     47    caca_draw_line(cv, x2, y2, x2,  y, ch);
     48    caca_draw_line(cv, x2,  y,  x,  y, ch);
    4949
    5050    return 0;
     
    5555 *  This function never fails.
    5656 *
    57  *  \param cv The handle to the libcucul canvas.
    58  *  \param x X coordinate of the upper-left corner of the box.
    59  *  \param y Y coordinate of the upper-left corner of the box.
    60  *  \param w Width of the box.
    61  *  \param h Height of the box.
    62  *  \return This function always returns 0.
    63  */
    64 int cucul_draw_thin_box(cucul_canvas_t *cv, int x, int y, int w, int h)
     57 *  \param cv The handle to the libcaca canvas.
     58 *  \param x X coordinate of the upper-left corner of the box.
     59 *  \param y Y coordinate of the upper-left corner of the box.
     60 *  \param w Width of the box.
     61 *  \param h Height of the box.
     62 *  \return This function always returns 0.
     63 */
     64int caca_draw_thin_box(caca_canvas_t *cv, int x, int y, int w, int h)
    6565{
    6666    int i, j, xmax, ymax;
     
    9090    if(y >= 0)
    9191        for(i = x < 0 ? 1 : x + 1; i < x2 && i < xmax; i++)
    92             cucul_put_char(cv, i, y, '-');
     92            caca_put_char(cv, i, y, '-');
    9393
    9494    if(y2 <= ymax)
    9595        for(i = x < 0 ? 1 : x + 1; i < x2 && i < xmax; i++)
    96             cucul_put_char(cv, i, y2, '-');
     96            caca_put_char(cv, i, y2, '-');
    9797
    9898    if(x >= 0)
    9999        for(j = y < 0 ? 1 : y + 1; j < y2 && j < ymax; j++)
    100             cucul_put_char(cv, x, j, '|');
     100            caca_put_char(cv, x, j, '|');
    101101
    102102    if(x2 <= xmax)
    103103        for(j = y < 0 ? 1 : y + 1; j < y2 && j < ymax; j++)
    104             cucul_put_char(cv, x2, j, '|');
     104            caca_put_char(cv, x2, j, '|');
    105105
    106106    /* Draw corners */
    107     cucul_put_char(cv, x, y, ',');
    108     cucul_put_char(cv, x, y2, '`');
    109     cucul_put_char(cv, x2, y, '.');
    110     cucul_put_char(cv, x2, y2, '\'');
     107    caca_put_char(cv, x, y, ',');
     108    caca_put_char(cv, x, y2, '`');
     109    caca_put_char(cv, x2, y, '.');
     110    caca_put_char(cv, x2, y2, '\'');
    111111
    112112    return 0;
     
    117117 *  This function never fails.
    118118 *
    119  *  \param cv The handle to the libcucul canvas.
    120  *  \param x X coordinate of the upper-left corner of the box.
    121  *  \param y Y coordinate of the upper-left corner of the box.
    122  *  \param w Width of the box.
    123  *  \param h Height of the box.
    124  *  \return This function always returns 0.
    125  */
    126 int cucul_draw_cp437_box(cucul_canvas_t *cv, int x, int y, int w, int h)
     119 *  \param cv The handle to the libcaca canvas.
     120 *  \param x X coordinate of the upper-left corner of the box.
     121 *  \param y Y coordinate of the upper-left corner of the box.
     122 *  \param w Width of the box.
     123 *  \param h Height of the box.
     124 *  \return This function always returns 0.
     125 */
     126int caca_draw_cp437_box(caca_canvas_t *cv, int x, int y, int w, int h)
    127127{
    128128    int i, j, xmax, ymax;
     
    152152    if(y >= 0)
    153153        for(i = x < 0 ? 1 : x + 1; i < x2 && i < xmax; i++)
    154             cucul_put_char(cv, i, y, 0x2500); /* ─ */
     154            caca_put_char(cv, i, y, 0x2500); /* ─ */
    155155
    156156    if(y2 <= ymax)
    157157        for(i = x < 0 ? 1 : x + 1; i < x2 && i < xmax; i++)
    158             cucul_put_char(cv, i, y2, 0x2500); /* ─ */
     158            caca_put_char(cv, i, y2, 0x2500); /* ─ */
    159159
    160160    if(x >= 0)
    161161        for(j = y < 0 ? 1 : y + 1; j < y2 && j < ymax; j++)
    162             cucul_put_char(cv, x, j, 0x2502); /* │ */
     162            caca_put_char(cv, x, j, 0x2502); /* │ */
    163163
    164164    if(x2 <= xmax)
    165165        for(j = y < 0 ? 1 : y + 1; j < y2 && j < ymax; j++)
    166             cucul_put_char(cv, x2, j, 0x2502); /* │ */
     166            caca_put_char(cv, x2, j, 0x2502); /* │ */
    167167
    168168    /* Draw corners */
    169     cucul_put_char(cv, x, y, 0x250c); /* ┌ */
    170     cucul_put_char(cv, x, y2, 0x2514); /* └ */
    171     cucul_put_char(cv, x2, y, 0x2510); /* ┐ */
    172     cucul_put_char(cv, x2, y2, 0x2518); /* ┘ */
     169    caca_put_char(cv, x, y, 0x250c); /* ┌ */
     170    caca_put_char(cv, x, y2, 0x2514); /* └ */
     171    caca_put_char(cv, x2, y, 0x2510); /* ┐ */
     172    caca_put_char(cv, x2, y2, 0x2518); /* ┘ */
    173173
    174174    return 0;
     
    179179 *  This function never fails.
    180180 *
    181  *  \param cv The handle to the libcucul canvas.
     181 *  \param cv The handle to the libcaca canvas.
    182182 *  \param x X coordinate of the upper-left corner of the box.
    183183 *  \param y Y coordinate of the upper-left corner of the box.
     
    187187 *  \return This function always returns 0.
    188188 */
    189 int cucul_fill_box(cucul_canvas_t *cv, int x, int y, int w, int h,
     189int caca_fill_box(caca_canvas_t *cv, int x, int y, int w, int h,
    190190                   uint32_t ch)
    191191{
     
    220220    for(j = y; j <= y2; j++)
    221221        for(i = x; i <= x2; i++)
    222             cucul_put_char(cv, i, j, ch);
    223 
    224     return 0;
    225 }
    226 
     222            caca_put_char(cv, i, j, ch);
     223
     224    return 0;
     225}
     226
  • libcaca/trunk/caca/caca.c

    r2519 r2821  
    3232#endif
    3333
    34 #include "cucul.h"
    3534#include "caca.h"
    3635#include "caca_internals.h"
     
    4948#endif
    5049
    51 /** \brief Attach a caca graphical context to a cucul canvas.
     50/** \brief Attach a caca graphical context to a caca canvas.
    5251 *
    5352 *  Create a graphical context using device-dependent features (ncurses for
    5453 *  terminals, an X11 window, a DOS command window...) that attaches to a
    55  *  libcucul canvas. Everything that gets drawn in the libcucul canvas can
     54 *  libcaca canvas. Everything that gets drawn in the libcaca canvas can
    5655 *  then be displayed by the libcaca driver.
    5756 *
    58  *  If no cucul canvas is provided, a new one is created. Its handle can be
     57 *  If no caca canvas is provided, a new one is created. Its handle can be
    5958 *  retrieved using caca_get_canvas() and it is automatically destroyed when
    6059 *  caca_free_display() is called.
     
    6665 *  - \c ENODEV Graphical device could not be initialised.
    6766 *
    68  *  \param cv The cucul canvas or NULL to create a canvas automatically.
     67 *  \param cv The caca canvas or NULL to create a canvas automatically.
    6968 *  \return The caca graphical context or NULL if an error occurred.
    7069 */
    71 caca_display_t * caca_create_display(cucul_canvas_t *cv)
     70caca_display_t * caca_create_display(caca_canvas_t *cv)
    7271{
    7372    return caca_create_display_with_driver(cv, NULL);
    7473}
    7574
    76 /** \brief Attach a specific caca graphical context to a cucul canvas.
     75/** \brief Attach a specific caca graphical context to a caca canvas.
    7776 *
    7877 *  Create a graphical context using device-dependent features (ncurses for
    7978 *  terminals, an X11 window, a DOS command window...) that attaches to a
    80  *  libcucul canvas. Everything that gets drawn in the libcucul canvas can
     79 *  libcaca canvas. Everything that gets drawn in the libcaca canvas can
    8180 *  then be displayed by the libcaca driver.
    8281 *
    83  *  If no cucul canvas is provided, a new one is created. Its handle can be
     82 *  If no caca canvas is provided, a new one is created. Its handle can be
    8483 *  retrieved using caca_get_canvas() and it is automatically destroyed when
    8584 *  caca_free_display() is called.
     
    9493 *  - \c ENODEV Graphical device could not be initialised.
    9594 *
    96  *  \param cv The cucul canvas or NULL to create a canvas automatically.
     95 *  \param cv The caca canvas or NULL to create a canvas automatically.
    9796 *  \param driver A string describing the desired output driver or NULL to
    9897 *                choose the best driver automatically.
    9998 *  \return The caca graphical context or NULL if an error occurred.
    10099 */
    101 caca_display_t * caca_create_display_with_driver(cucul_canvas_t *cv,
     100caca_display_t * caca_create_display_with_driver(caca_canvas_t *cv,
    102101                                                 char const *driver)
    103102{
     
    112111    if((dp->autorelease = (cv == NULL)))
    113112    {
    114         cv = cucul_create_canvas(0, 0);
     113        cv = caca_create_canvas(0, 0);
    115114    }
    116115
    117116    dp->cv = cv;
    118117
    119     if(cucul_manage_canvas(cv, (int (*)(void *))caca_can_resize, (void *)dp))
     118    if(caca_manage_canvas(cv, (int (*)(void *))caca_can_resize, (void *)dp))
    120119    {
    121120        if(dp->autorelease)
    122             cucul_free_canvas(dp->cv);
     121            caca_free_canvas(dp->cv);
    123122        free(dp);
    124123        seterrno(EBUSY);
     
    128127    if(caca_install_driver(dp, driver))
    129128    {
    130         cucul_unmanage_canvas(cv, (int (*)(void *))caca_can_resize, (void *)dp);
     129        caca_unmanage_canvas(cv, (int (*)(void *))caca_can_resize, (void *)dp);
    131130        if(dp->autorelease)
    132             cucul_free_canvas(dp->cv);
     131            caca_free_canvas(dp->cv);
    133132        free(dp);
    134133        seterrno(ENODEV);
     
    224223}
    225224
    226 /** \brief Detach a caca graphical context from a cucul backend context.
    227  *
    228  *  Detach a graphical context from its cucul backend and destroy it. The
    229  *  libcucul canvas continues to exist and other graphical contexts can be
     225/** \brief Detach a caca graphical context from a caca backend context.
     226 *
     227 *  Detach a graphical context from its caca backend and destroy it. The
     228 *  libcaca canvas continues to exist and other graphical contexts can be
    230229 *  attached to it afterwards.
    231230 *
    232  *  If the cucul canvas was automatically created by caca_create_display(),
     231 *  If the caca canvas was automatically created by caca_create_display(),
    233232 *  it is automatically destroyed and any handle to it becomes invalid.
    234233 *
     
    241240{
    242241    caca_uninstall_driver(dp);
    243     cucul_unmanage_canvas(dp->cv, (int (*)(void *))caca_can_resize, (void *)dp);
     242    caca_unmanage_canvas(dp->cv, (int (*)(void *))caca_can_resize, (void *)dp);
    244243    if(dp->autorelease)
    245         cucul_free_canvas(dp->cv);
     244        caca_free_canvas(dp->cv);
    246245    free(dp);
    247246
     
    251250/** \brief Get the canvas attached to a caca graphical context.
    252251 *
    253  *  Return a handle on the \e cucul_canvas_t object that was either attached
     252 *  Return a handle on the \e caca_canvas_t object that was either attached
    254253 *  or created by caca_create_display().
    255254 *
     
    257256 *
    258257 *  \param dp The libcaca graphical context.
    259  *  \return The libcucul canvas.
    260  */
    261 cucul_canvas_t * caca_get_canvas(caca_display_t *dp)
     258 *  \return The libcaca canvas.
     259 */
     260caca_canvas_t * caca_get_canvas(caca_display_t *dp)
    262261{
    263262    return dp->cv;
     
    331330
    332331    /* Mouse position */
    333     dp->mouse.x = cucul_get_canvas_width(dp->cv) / 2;
    334     dp->mouse.y = cucul_get_canvas_height(dp->cv) / 2;
     332    dp->mouse.x = caca_get_canvas_width(dp->cv) / 2;
     333    dp->mouse.y = caca_get_canvas_height(dp->cv) / 2;
    335334
    336335    /* Resize events */
  • libcaca/trunk/caca/caca.h

    r2305 r2821  
    2525#define __CACA_H__
    2626
    27 #include <cucul.h>
     27#include <caca_types.h>
    2828
    2929#undef __extern
     
    4343#endif
    4444
     45/** \e libcaca canvas */
     46typedef struct caca_canvas caca_canvas_t;
     47/** dither structure */
     48typedef struct caca_dither caca_dither_t;
     49/** font structure */
     50typedef struct caca_font caca_font_t;
     51/** file handle structure */
     52typedef struct caca_file caca_file_t;
    4553/** \e libcaca display context */
    4654typedef struct caca_display caca_display_t;
    4755/** \e libcaca event structure */
    4856typedef struct caca_event caca_event_t;
     57
     58/** \defgroup caca_attr libcaca attribute definitions
     59 *
     60 *  Colours and styles that can be used with caca_set_attr().
     61 *
     62 *  @{ */
     63#define CACA_BLACK 0x00 /**< The colour index for black. */
     64#define CACA_BLUE 0x01 /**< The colour index for blue. */
     65#define CACA_GREEN 0x02 /**< The colour index for green. */
     66#define CACA_CYAN 0x03 /**< The colour index for cyan. */
     67#define CACA_RED 0x04 /**< The colour index for red. */
     68#define CACA_MAGENTA 0x05 /**< The colour index for magenta. */
     69#define CACA_BROWN 0x06 /**< The colour index for brown. */
     70#define CACA_LIGHTGRAY 0x07 /**< The colour index for light gray. */
     71#define CACA_DARKGRAY 0x08 /**< The colour index for dark gray. */
     72#define CACA_LIGHTBLUE 0x09 /**< The colour index for blue. */
     73#define CACA_LIGHTGREEN 0x0a /**< The colour index for light green. */
     74#define CACA_LIGHTCYAN 0x0b /**< The colour index for light cyan. */
     75#define CACA_LIGHTRED 0x0c /**< The colour index for light red. */
     76#define CACA_LIGHTMAGENTA 0x0d /**< The colour index for light magenta. */
     77#define CACA_YELLOW 0x0e /**< The colour index for yellow. */
     78#define CACA_WHITE 0x0f /**< The colour index for white. */
     79#define CACA_DEFAULT 0x10 /**< The output driver's default colour. */
     80#define CACA_TRANSPARENT 0x20 /**< The transparent colour. */
     81
     82#define CACA_BOLD 0x01 /**< The style mask for bold. */
     83#define CACA_ITALICS 0x02 /**< The style mask for italics. */
     84#define CACA_UNDERLINE 0x04 /**< The style mask for underline. */
     85#define CACA_BLINK 0x08 /**< The style mask for blink. */
     86/*  @} */
    4987
    5088/** \brief User event type enumeration.
     
    159197/** \defgroup libcaca libcaca basic functions
    160198 *
    161  *  These functions provide the basic \e libcaca routines for driver
     199 *  These functions provide the basic \e libcaca routines for library
    162200 *  initialisation, system information retrieval and configuration.
    163201 *
    164202 *  @{ */
    165 __extern caca_display_t * caca_create_display(cucul_canvas_t *);
    166 __extern caca_display_t * caca_create_display_with_driver(cucul_canvas_t *,
     203__extern caca_canvas_t * caca_create_canvas(int, int);
     204__extern int caca_manage_canvas(caca_canvas_t *, int (*)(void *), void *);
     205__extern int caca_unmanage_canvas(caca_canvas_t *, int (*)(void *), void *);
     206__extern int caca_set_canvas_size(caca_canvas_t *, int, int);
     207__extern int caca_get_canvas_width(caca_canvas_t const *);
     208__extern int caca_get_canvas_height(caca_canvas_t const *);
     209__extern uint8_t const * caca_get_canvas_chars(caca_canvas_t const *);
     210__extern uint8_t const * caca_get_canvas_attrs(caca_canvas_t const *);
     211__extern int caca_free_canvas(caca_canvas_t *);
     212__extern int caca_rand(int, int);
     213__extern char const * caca_get_version(void);
     214/*  @} */
     215
     216/** \defgroup caca_canvas libcaca canvas drawing
     217 *
     218 *  These functions provide low-level character printing routines and
     219 *  higher level graphics functions.
     220 *
     221 *  @{ */
     222#define CACA_MAGIC_FULLWIDTH 0x000ffffe /**< Used to indicate that the previous character was a fullwidth glyph. */
     223__extern int caca_gotoxy(caca_canvas_t *, int, int);
     224__extern int caca_get_cursor_x(caca_canvas_t const *);
     225__extern int caca_get_cursor_y(caca_canvas_t const *);
     226__extern int caca_put_char(caca_canvas_t *, int, int, uint32_t);
     227__extern uint32_t caca_get_char(caca_canvas_t const *, int, int);
     228__extern int caca_put_str(caca_canvas_t *, int, int, char const *);
     229__extern uint32_t caca_get_attr(caca_canvas_t const *, int, int);
     230__extern int caca_set_attr(caca_canvas_t *, uint32_t);
     231__extern int caca_put_attr(caca_canvas_t *, int, int, uint32_t);
     232__extern int caca_set_color_ansi(caca_canvas_t *, uint8_t, uint8_t);
     233__extern int caca_set_color_argb(caca_canvas_t *, uint16_t, uint16_t);
     234__extern int caca_printf(caca_canvas_t *, int, int, char const *, ...);
     235__extern int caca_clear_canvas(caca_canvas_t *);
     236__extern int caca_set_canvas_handle(caca_canvas_t *, int, int);
     237__extern int caca_get_canvas_handle_x(caca_canvas_t const *);
     238__extern int caca_get_canvas_handle_y(caca_canvas_t const *);
     239__extern int caca_blit(caca_canvas_t *, int, int, caca_canvas_t const *,
     240                        caca_canvas_t const *);
     241__extern int caca_set_canvas_boundaries(caca_canvas_t *, int, int, int, int);
     242/*  @} */
     243
     244/** \defgroup caca_transform libcaca canvas transformation
     245 *
     246 *  These functions perform horizontal and vertical canvas flipping.
     247 *
     248 *  @{ */
     249__extern int caca_invert(caca_canvas_t *);
     250__extern int caca_flip(caca_canvas_t *);
     251__extern int caca_flop(caca_canvas_t *);
     252__extern int caca_rotate_180(caca_canvas_t *);
     253__extern int caca_rotate_left(caca_canvas_t *);
     254__extern int caca_rotate_right(caca_canvas_t *);
     255__extern int caca_stretch_left(caca_canvas_t *);
     256__extern int caca_stretch_right(caca_canvas_t *);
     257/*  @} */
     258
     259/** \defgroup caca_attributes libcaca attribute conversions
     260 *
     261 *  These functions perform conversions between attribute values.
     262 *
     263 *  @{ */
     264__extern uint8_t caca_attr_to_ansi(uint32_t);
     265__extern uint8_t caca_attr_to_ansi_fg(uint32_t);
     266__extern uint8_t caca_attr_to_ansi_bg(uint32_t);
     267__extern uint16_t caca_attr_to_rgb12_fg(uint32_t);
     268__extern uint16_t caca_attr_to_rgb12_bg(uint32_t);
     269__extern void caca_attr_to_argb64(uint32_t, uint8_t[8]);
     270/*  @} */
     271
     272/** \defgroup caca_charset libcaca character set conversions
     273 *
     274 *  These functions perform conversions between usual character sets.
     275 *
     276 *  @{ */
     277__extern uint32_t caca_utf8_to_utf32(char const *, size_t *);
     278__extern size_t caca_utf32_to_utf8(char *, uint32_t);
     279__extern uint8_t caca_utf32_to_cp437(uint32_t);
     280__extern uint32_t caca_cp437_to_utf32(uint8_t);
     281__extern char caca_utf32_to_ascii(uint32_t);
     282__extern int caca_utf32_is_fullwidth(uint32_t);
     283/*  @} */
     284
     285/** \defgroup caca_primitives libcaca primitives drawing
     286 *
     287 *  These functions provide routines for primitive drawing, such as lines,
     288 *  boxes, triangles and ellipses.
     289 *
     290 *  @{ */
     291__extern int caca_draw_line(caca_canvas_t *, int, int, int, int, uint32_t);
     292__extern int caca_draw_polyline(caca_canvas_t *, int const x[],
     293                                 int const y[], int, uint32_t);
     294__extern int caca_draw_thin_line(caca_canvas_t *, int, int, int, int);
     295__extern int caca_draw_thin_polyline(caca_canvas_t *, int const x[],
     296                                      int const y[], int);
     297
     298__extern int caca_draw_circle(caca_canvas_t *, int, int, int, uint32_t);
     299__extern int caca_draw_ellipse(caca_canvas_t *, int, int, int, int, uint32_t);
     300__extern int caca_draw_thin_ellipse(caca_canvas_t *, int, int, int, int);
     301__extern int caca_fill_ellipse(caca_canvas_t *, int, int, int, int, uint32_t);
     302
     303__extern int caca_draw_box(caca_canvas_t *, int, int, int, int, uint32_t);
     304__extern int caca_draw_thin_box(caca_canvas_t *, int, int, int, int);
     305__extern int caca_draw_cp437_box(caca_canvas_t *, int, int, int, int);
     306__extern int caca_fill_box(caca_canvas_t *, int, int, int, int, uint32_t);
     307
     308__extern int caca_draw_triangle(caca_canvas_t *, int, int, int, int, int,
     309                                 int, uint32_t);
     310__extern int caca_draw_thin_triangle(caca_canvas_t *, int, int, int, int,
     311                                      int, int);
     312__extern int caca_fill_triangle(caca_canvas_t *, int, int, int, int, int,
     313                                 int, uint32_t);
     314/*  @} */
     315
     316/** \defgroup caca_frame libcaca canvas frame handling
     317 *
     318 *  These functions provide high level routines for canvas frame insertion,
     319 *  removal, copying etc.
     320 *
     321 *  @{ */
     322__extern int caca_get_frame_count(caca_canvas_t const *);
     323__extern int caca_set_frame(caca_canvas_t *, int);
     324__extern char const *caca_get_frame_name(caca_canvas_t const *);
     325__extern int caca_set_frame_name(caca_canvas_t *, char const *);
     326__extern int caca_create_frame(caca_canvas_t *, int);
     327__extern int caca_free_frame(caca_canvas_t *, int);
     328/*  @} */
     329
     330/** \defgroup caca_dither libcaca bitmap dithering
     331 *
     332 *  These functions provide high level routines for dither allocation and
     333 *  rendering.
     334 *
     335 *  @{ */
     336__extern caca_dither_t *caca_create_dither(int, int, int, int,
     337                                             uint32_t, uint32_t,
     338                                             uint32_t, uint32_t);
     339__extern int caca_set_dither_palette(caca_dither_t *,
     340                                      uint32_t r[], uint32_t g[],
     341                                      uint32_t b[], uint32_t a[]);
     342__extern int caca_set_dither_brightness(caca_dither_t *, float);
     343__extern float caca_get_dither_brightness(caca_dither_t const *);
     344__extern int caca_set_dither_gamma(caca_dither_t *, float);
     345__extern float caca_get_dither_gamma(caca_dither_t const *);
     346__extern int caca_set_dither_contrast(caca_dither_t *, float);
     347__extern float caca_get_dither_contrast(caca_dither_t const *);
     348__extern int caca_set_dither_antialias(caca_dither_t *, char const *);
     349__extern char const * const * caca_get_dither_antialias_list(caca_dither_t
     350                                                              const *);
     351__extern char const * caca_get_dither_antialias(caca_dither_t const *);
     352__extern int caca_set_dither_color(caca_dither_t *, char const *);
     353__extern char const * const * caca_get_dither_color_list(caca_dither_t
     354                                                          const *);
     355__extern char const * caca_get_dither_color(caca_dither_t const *);
     356__extern int caca_set_dither_charset(caca_dither_t *, char const *);
     357__extern char const * const * caca_get_dither_charset_list(caca_dither_t
     358                                                            const *);
     359__extern char const * caca_get_dither_charset(caca_dither_t const *);
     360__extern int caca_set_dither_algorithm(caca_dither_t *, char const *);
     361__extern char const * const * caca_get_dither_algorithm_list(caca_dither_t
     362                                                              const *);
     363__extern char const * caca_get_dither_algorithm(caca_dither_t const *);
     364__extern int caca_dither_bitmap(caca_canvas_t *, int, int, int, int,
     365                         caca_dither_t const *, void *);
     366__extern int caca_free_dither(caca_dither_t *);
     367/*  @} */
     368
     369/** \defgroup caca_font libcaca font handling
     370 *
     371 *  These functions provide font handling routines and high quality
     372 *  canvas to bitmap rendering.
     373 *
     374 *  @{ */
     375__extern caca_font_t *caca_load_font(void const *, size_t);
     376__extern char const * const * caca_get_font_list(void);
     377__extern int caca_get_font_width(caca_font_t const *);
     378__extern int caca_get_font_height(caca_font_t const *);
     379__extern uint32_t const *caca_get_font_blocks(caca_font_t const *);
     380__extern int caca_render_canvas(caca_canvas_t const *, caca_font_t const *,
     381                                 void *, int, int, int);
     382__extern int caca_free_font(caca_font_t *);
     383/*  @} */
     384
     385/** \defgroup caca_figfont libcaca FIGfont handling
     386 *
     387 *  These functions provide FIGlet and TOIlet font handling routines.
     388 *
     389 *  @{ */
     390__extern int caca_canvas_set_figfont(caca_canvas_t *, char const *);
     391__extern int caca_put_figchar(caca_canvas_t *, uint32_t);
     392__extern int caca_flush_figlet(caca_canvas_t *);
     393/*  @} */
     394
     395/** \defgroup caca_file libcaca file IO
     396 *
     397 *  These functions allow to read and write files in a platform-independent
     398 *  way.
     399 *  @{ */
     400__extern caca_file_t *caca_file_open(char const *, const char *);
     401__extern int caca_file_close(caca_file_t *);
     402__extern uint64_t caca_file_tell(caca_file_t *);
     403__extern size_t caca_file_read(caca_file_t *, void *, size_t);
     404__extern size_t caca_file_write(caca_file_t *, const void *, size_t);
     405__extern char * caca_file_gets(caca_file_t *, char *, int);
     406__extern int caca_file_eof(caca_file_t *);
     407/*  @} */
     408
     409/** \defgroup caca_importexport libcaca importers/exporters from/to various
     410 *  formats
     411 *
     412 *  These functions import various file formats into a new canvas, or export
     413 *  the current canvas to various text formats.
     414 *
     415 *  @{ */
     416__extern ssize_t caca_import_memory(caca_canvas_t *, void const *,
     417                                     size_t, char const *);
     418__extern ssize_t caca_import_file(caca_canvas_t *, char const *,
     419                                   char const *);
     420__extern char const * const * caca_get_import_list(void);
     421__extern void *caca_export_memory(caca_canvas_t const *, char const *,
     422                                   size_t *);
     423__extern char const * const * caca_get_export_list(void);
     424/*  @} */
     425
     426/** \defgroup caca_display libcaca display functions
     427 *
     428 *  These functions provide the basic \e libcaca routines for display
     429 *  initialisation, system information retrieval and configuration.
     430 *
     431 *  @{ */
     432__extern caca_display_t * caca_create_display(caca_canvas_t *);
     433__extern caca_display_t * caca_create_display_with_driver(caca_canvas_t *,
    167434                                                          char const *);
    168435__extern char const * const * caca_get_display_driver_list(void);
     
    170437__extern int caca_set_display_driver(caca_display_t *, char const *);
    171438__extern int caca_free_display(caca_display_t *);
    172 __extern cucul_canvas_t * caca_get_canvas(caca_display_t *);
     439__extern caca_canvas_t * caca_get_canvas(caca_display_t *);
    173440__extern int caca_refresh_display(caca_display_t *);
    174441__extern int caca_set_display_time(caca_display_t *, int);
     
    179446__extern int caca_set_mouse(caca_display_t *, int);
    180447__extern int caca_set_cursor(caca_display_t *, int);
    181 __extern char const * caca_get_version(void);
    182448/*  @} */
    183449
     
    202468/*  @} */
    203469
     470#if !defined(_DOXYGEN_SKIP_ME)
     471    /* Legacy stuff from beta versions, will probably disappear in 1.0 */
     472typedef struct cucul_buffer cucul_buffer_t;
     473#define cucul_canvas_t caca_canvas_t
     474#define cucul_dither_t caca_dither_t
     475#define cucul_font_t caca_font_t
     476#define cucul_file_t caca_file_t
     477#define cucul_display_t caca_display_t
     478#define cucul_event_t caca_event_t
     479
     480#   if defined __GNUC__ && __GNUC__ >= 3
     481#       define CACA_DEPRECATED __attribute__ ((__deprecated__))
     482#   else
     483#       define CACA_DEPRECATED
     484#   endif
     485__extern int cucul_putchar(cucul_canvas_t *, int, int,
     486                           unsigned long int) CACA_DEPRECATED;
     487__extern unsigned long int cucul_getchar(cucul_canvas_t *,
     488                                         int, int) CACA_DEPRECATED;
     489__extern int cucul_putstr(cucul_canvas_t *, int, int,
     490                          char const *) CACA_DEPRECATED;
     491__extern int cucul_set_color(cucul_canvas_t *, unsigned char,
     492                             unsigned char) CACA_DEPRECATED;
     493__extern int cucul_set_truecolor(cucul_canvas_t *, unsigned int,
     494                                 unsigned int) CACA_DEPRECATED;
     495__extern unsigned int cucul_get_canvas_frame_count(cucul_canvas_t *)
     496                                                   CACA_DEPRECATED;
     497__extern int cucul_set_canvas_frame(cucul_canvas_t *,
     498                                    unsigned int) CACA_DEPRECATED;
     499__extern int cucul_create_canvas_frame(cucul_canvas_t *,
     500                                       unsigned int) CACA_DEPRECATED;
     501__extern int cucul_free_canvas_frame(cucul_canvas_t *,
     502                                     unsigned int) CACA_DEPRECATED;
     503__extern cucul_buffer_t *cucul_load_memory(void *,
     504                                           unsigned long int) CACA_DEPRECATED;
     505__extern cucul_buffer_t *cucul_load_file(char const *) CACA_DEPRECATED;
     506__extern unsigned long int cucul_get_buffer_size(cucul_buffer_t *)
     507                                                 CACA_DEPRECATED;
     508__extern void * cucul_get_buffer_data(cucul_buffer_t *) CACA_DEPRECATED;
     509__extern int cucul_free_buffer(cucul_buffer_t *) CACA_DEPRECATED;
     510__extern cucul_buffer_t * cucul_export_canvas(cucul_canvas_t *,
     511                                              char const *) CACA_DEPRECATED;
     512__extern cucul_canvas_t * cucul_import_canvas(cucul_buffer_t *,
     513                                              char const *) CACA_DEPRECATED;
     514__extern int cucul_rotate(cucul_canvas_t *) CACA_DEPRECATED;
     515__extern int cucul_set_dither_invert(cucul_dither_t *, int) CACA_DEPRECATED;
     516__extern int cucul_set_dither_mode(cucul_dither_t *,
     517                                   char const *) CACA_DEPRECATED;
     518__extern char const * const * cucul_get_dither_mode_list(cucul_dither_t
     519                                                         const *)
     520                                                         CACA_DEPRECATED;
     521#   define CUCUL_COLOR_BLACK CACA_BLACK
     522#   define CUCUL_COLOR_BLUE CACA_BLUE
     523#   define CUCUL_COLOR_GREEN CACA_GREEN
     524#   define CUCUL_COLOR_CYAN CACA_CYAN
     525#   define CUCUL_COLOR_RED CACA_RED
     526#   define CUCUL_COLOR_MAGENTA CACA_MAGENTA
     527#   define CUCUL_COLOR_BROWN CACA_BROWN
     528#   define CUCUL_COLOR_LIGHTGRAY CACA_LIGHTGRAY
     529#   define CUCUL_COLOR_DARKGRAY CACA_DARKGRAY
     530#   define CUCUL_COLOR_LIGHTBLUE CACA_LIGHTBLUE
     531#   define CUCUL_COLOR_LIGHTGREEN CACA_LIGHTGREEN
     532#   define CUCUL_COLOR_LIGHTCYAN CACA_LIGHTCYAN
     533#   define CUCUL_COLOR_LIGHTRED CACA_LIGHTRED
     534#   define CUCUL_COLOR_LIGHTMAGENTA CACA_LIGHTMAGENTA
     535#   define CUCUL_COLOR_YELLOW CACA_YELLOW
     536#   define CUCUL_COLOR_WHITE CACA_YELLOW
     537#   define CUCUL_COLOR_DEFAULT CACA_DEFAULT
     538#   define CUCUL_COLOR_TRANSPARENT CACA_TRANSPARENT
     539#endif
     540
    204541#ifdef __cplusplus
    205542}
  • libcaca/trunk/caca/caca.pc.in

    r729 r2821  
    77Description: Colour ASCII-Art library
    88Version: @VERSION@
    9 Requires: cucul = @VERSION@
     9Requires: caca = @VERSION@
    1010Conflicts:
    11 Libs: -L${libdir} -lcaca -lcucul
     11Libs: -L${libdir} -lcaca -lcaca
    1212Cflags: -I${includedir}
  • libcaca/trunk/caca/caca0.c

    r2299 r2821  
    2828
    2929/* These variables are needed to emulate old non-thread safe behaviour */
    30 cucul_canvas_t *__caca0_cv = NULL;
     30caca_canvas_t *__caca0_cv = NULL;
    3131caca_display_t *__caca0_dp = NULL;
    32 unsigned char __caca0_fg = CUCUL_LIGHTGRAY;
    33 unsigned char __caca0_bg = CUCUL_BLACK;
     32unsigned char __caca0_fg = CACA_LIGHTGRAY;
     33unsigned char __caca0_bg = CACA_BLACK;
    3434char __caca0_utf8[2] = " ";
    3535
     
    4242void __caca0_set_feature(int);
    4343char const *__caca0_get_feature_name(int);
    44 cucul_canvas_t *__caca0_load_sprite(char const *);
    45 cucul_dither_t *__caca0_create_bitmap(unsigned int, unsigned int,
     44caca_canvas_t *__caca0_load_sprite(char const *);
     45caca_dither_t *__caca0_create_bitmap(unsigned int, unsigned int,
    4646          unsigned int, unsigned int, unsigned long int, unsigned long int,
    4747          unsigned long int, unsigned long int);
    48 void __caca0_free_bitmap(cucul_dither_t *);
     48void __caca0_free_bitmap(caca_dither_t *);
    4949extern char const *__caca0_get_color_name(unsigned char);
    5050
     
    5252int __caca0_init(void)
    5353{
    54     __caca0_cv = cucul_create_canvas(0, 0);
     54    __caca0_cv = caca_create_canvas(0, 0);
    5555    if(!__caca0_cv)
    5656        return -1;
     
    5858    if(!__caca0_dp)
    5959    {
    60         cucul_free_canvas(__caca0_cv);
     60        caca_free_canvas(__caca0_cv);
    6161        __caca0_cv = NULL;
    6262        return -1;
    6363    }
    64     __caca0_fg = CUCUL_LIGHTGRAY;
    65     __caca0_bg = CUCUL_BLACK;
     64    __caca0_fg = CACA_LIGHTGRAY;
     65    __caca0_bg = CACA_BLACK;
    6666    return 0;
    6767}
     
    7171    caca_free_display(__caca0_dp);
    7272    __caca0_dp = NULL;
    73     cucul_free_canvas(__caca0_cv);
     73    caca_free_canvas(__caca0_cv);
    7474    __caca0_cv = NULL;
    7575}
     
    145145};
    146146
    147 static cucul_dither_t **bitmaps = NULL;
     147static caca_dither_t **bitmaps = NULL;
    148148static unsigned int nbitmaps = 0;
    149149
     
    173173            background = feature;
    174174            for(i = 0; i < nbitmaps; i++)
    175                 cucul_set_dither_color(bitmaps[i], features[feature]);
     175                caca_set_dither_color(bitmaps[i], features[feature]);
    176176            break;
    177177
     
    180180            antialiasing = feature;
    181181            for(i = 0; i < nbitmaps; i++)
    182                 cucul_set_dither_antialias(bitmaps[i], features[feature]);
     182                caca_set_dither_antialias(bitmaps[i], features[feature]);
    183183            break;
    184184
     
    187187            dithering = feature;
    188188            for(i = 0; i < nbitmaps; i++)
    189                 cucul_set_dither_algorithm(bitmaps[i], features[feature]);
     189                caca_set_dither_algorithm(bitmaps[i], features[feature]);
    190190            break;
    191191    }
     
    212212}
    213213
    214 cucul_canvas_t *__caca0_load_sprite(char const *file)
    215 {
    216     cucul_canvas_t *cv;
    217 
    218     cv = cucul_create_canvas(0, 0);;
    219     if(cucul_import_file(cv, file, "") < 0)
    220     {
    221         cucul_free_canvas(cv);
     214caca_canvas_t *__caca0_load_sprite(char const *file)
     215{
     216    caca_canvas_t *cv;
     217
     218    cv = caca_create_canvas(0, 0);;
     219    if(caca_import_file(cv, file, "") < 0)
     220    {
     221        caca_free_canvas(cv);
    222222        return NULL;
    223223    }
     
    226226}
    227227
    228 cucul_dither_t *__caca0_create_bitmap(unsigned int bpp, unsigned int w,
     228caca_dither_t *__caca0_create_bitmap(unsigned int bpp, unsigned int w,
    229229                                      unsigned int h, unsigned int pitch,
    230230                                      unsigned long int r, unsigned long int g,
    231231                                      unsigned long int b, unsigned long int a)
    232232{
    233     cucul_dither_t *d;
    234 
    235     d = cucul_create_dither(bpp, w, h, pitch, r, g, b, a);
     233    caca_dither_t *d;
     234
     235    d = caca_create_dither(bpp, w, h, pitch, r, g, b, a);
    236236    if(!d)
    237237        return NULL;
    238238
    239     cucul_set_dither_color(d, features[background]);
    240     cucul_set_dither_antialias(d, features[antialiasing]);
    241     cucul_set_dither_algorithm(d, features[dithering]);
     239    caca_set_dither_color(d, features[background]);
     240    caca_set_dither_antialias(d, features[antialiasing]);
     241    caca_set_dither_algorithm(d, features[dithering]);
    242242
    243243    /* Store bitmap in our list */
    244244    nbitmaps++;
    245     bitmaps = realloc(bitmaps, nbitmaps * (sizeof(cucul_dither_t *)));
     245    bitmaps = realloc(bitmaps, nbitmaps * (sizeof(caca_dither_t *)));
    246246    bitmaps[nbitmaps - 1] = d;
    247247
     
    249249}
    250250
    251 void __caca0_free_bitmap(cucul_dither_t *d)
     251void __caca0_free_bitmap(caca_dither_t *d)
    252252{
    253253    unsigned int i, found = 0;
    254254
    255     cucul_free_dither(d);
     255    caca_free_dither(d);
    256256
    257257    /* Remove bitmap from our list */
  • libcaca/trunk/caca/caca0.h

    r1462 r2821  
    3636extern void __caca0_set_feature(int);
    3737extern char const *__caca0_get_feature_name(int);
    38 extern cucul_canvas_t *__caca0_load_sprite(char const *);
    39 extern cucul_dither_t *__caca0_create_bitmap(unsigned int, unsigned int,
     38extern caca_canvas_t *__caca0_load_sprite(char const *);
     39extern caca_dither_t *__caca0_create_bitmap(unsigned int, unsigned int,
    4040          unsigned int, unsigned int, unsigned long int, unsigned long int,
    4141          unsigned long int, unsigned long int);
    42 extern void __caca0_free_bitmap(cucul_dither_t *);
     42extern void __caca0_free_bitmap(caca_dither_t *);
    4343extern char const *__caca0_get_color_name(unsigned char);
    4444
    4545/* These variables are needed to emulate old non-thread safe behaviour */
    46 extern cucul_canvas_t *__caca0_cv;
     46extern caca_canvas_t *__caca0_cv;
    4747extern caca_display_t *__caca0_dp;
    4848extern unsigned char __caca0_fg;
     
    5252enum caca_color
    5353{
    54     CACA_COLOR_BLACK = CUCUL_BLACK,
    55     CACA_COLOR_BLUE = CUCUL_BLUE,
    56     CACA_COLOR_GREEN = CUCUL_GREEN,
    57     CACA_COLOR_CYAN = CUCUL_CYAN,
    58     CACA_COLOR_RED = CUCUL_RED,
    59     CACA_COLOR_MAGENTA = CUCUL_MAGENTA,
    60     CACA_COLOR_BROWN = CUCUL_BROWN,
    61     CACA_COLOR_LIGHTGRAY = CUCUL_LIGHTGRAY,
    62     CACA_COLOR_DARKGRAY = CUCUL_DARKGRAY,
    63     CACA_COLOR_LIGHTBLUE = CUCUL_LIGHTBLUE,
    64     CACA_COLOR_LIGHTGREEN = CUCUL_LIGHTGREEN,
    65     CACA_COLOR_LIGHTCYAN = CUCUL_LIGHTCYAN,
    66     CACA_COLOR_LIGHTRED = CUCUL_LIGHTRED,
    67     CACA_COLOR_LIGHTMAGENTA = CUCUL_LIGHTMAGENTA,
    68     CACA_COLOR_YELLOW = CUCUL_YELLOW,
    69     CACA_COLOR_WHITE = CUCUL_WHITE,
     54    CACA_COLOR_BLACK = CACA_BLACK,
     55    CACA_COLOR_BLUE = CACA_BLUE,
     56    CACA_COLOR_GREEN = CACA_GREEN,
     57    CACA_COLOR_CYAN = CACA_CYAN,
     58    CACA_COLOR_RED = CACA_RED,
     59    CACA_COLOR_MAGENTA = CACA_MAGENTA,
     60    CACA_COLOR_BROWN = CACA_BROWN,
     61    CACA_COLOR_LIGHTGRAY = CACA_LIGHTGRAY,
     62    CACA_COLOR_DARKGRAY = CACA_DARKGRAY,
     63    CACA_COLOR_LIGHTBLUE = CACA_LIGHTBLUE,
     64    CACA_COLOR_LIGHTGREEN = CACA_LIGHTGREEN,
     65    CACA_COLOR_LIGHTCYAN = CACA_LIGHTCYAN,
     66    CACA_COLOR_LIGHTRED = CACA_LIGHTRED,
     67    CACA_COLOR_LIGHTMAGENTA = CACA_LIGHTMAGENTA,
     68    CACA_COLOR_YELLOW = CACA_YELLOW,
     69    CACA_COLOR_WHITE = CACA_WHITE,
    7070};
    7171
     
    118118#define caca_get_feature_name __caca0_get_feature_name
    119119#define caca_get_rendertime() caca_get_display_time(__caca0_dp)
    120 #define caca_get_width() cucul_get_canvas_width(__caca0_cv)
    121 #define caca_get_height() cucul_get_canvas_height(__caca0_cv)
     120#define caca_get_width() caca_get_canvas_width(__caca0_cv)
     121#define caca_get_height() caca_get_canvas_height(__caca0_cv)
    122122#define caca_set_window_title(s) caca_set_display_title(__caca0_dp, s)
    123123#define caca_get_window_width() caca_get_display_width(__caca0_dp)
     
    132132
    133133#define caca_set_color(x, y) \
    134     (__caca0_fg = (x), __caca0_bg = (y), cucul_set_color_ansi(__caca0_cv, x, y))
     134    (__caca0_fg = (x), __caca0_bg = (y), caca_set_color_ansi(__caca0_cv, x, y))
    135135#define caca_get_fg_color() __caca0_fg
    136136#define caca_get_bg_color() __caca0_bg
    137137#define caca_get_color_name __caca0_get_color_name
    138 #define caca_putchar(x, y, c) cucul_put_char(__caca0_cv, x, y, c)
    139 #define caca_putstr(x, y, s) cucul_put_str(__caca0_cv, x, y, s)
    140 #define caca_printf(x, y, f, z...) cucul_printf(__caca0_cv, x, y, f, ##z)
    141 #define caca_clear() cucul_clear_canvas(__caca0_cv)
     138#define caca_putchar(x, y, c) caca_put_char(__caca0_cv, x, y, c)
     139#define caca_putstr(x, y, s) caca_put_str(__caca0_cv, x, y, s)
     140#define caca_printf(x, y, f, z...) caca_printf(__caca0_cv, x, y, f, ##z)
     141#define caca_clear() caca_clear_canvas(__caca0_cv)
    142142
    143143#define caca_draw_line(x, y, z, t, c) \
    144     cucul_draw_line(__caca0_cv, x, y, z, t, c)
     144    caca_draw_line(__caca0_cv, x, y, z, t, c)
    145145#define caca_draw_polyline(x, y, z, c) \
    146     cucul_draw_polyline(__caca0_cv, x, y, z, c)
     146    caca_draw_polyline(__caca0_cv, x, y, z, c)
    147147#define caca_draw_thin_line(x, y, z, t) \
    148     cucul_draw_thin_line(__caca0_cv, x, y, z, t)
     148    caca_draw_thin_line(__caca0_cv, x, y, z, t)
    149149#define caca_draw_thin_polyline(x, y, z) \
    150     cucul_draw_thin_polyline(__caca0_cv, x, y, z)
     150    caca_draw_thin_polyline(__caca0_cv, x, y, z)
    151151#define caca_draw_circle(x, y, z, c) \
    152     cucul_draw_circle(__caca0_cv, x, y, z, c)
     152    caca_draw_circle(__caca0_cv, x, y, z, c)
    153153#define caca_draw_ellipse(x, y, z, t, c) \
    154     cucul_draw_ellipse(__caca0_cv, x, y, z, t, c)
     154    caca_draw_ellipse(__caca0_cv, x, y, z, t, c)
    155155#define caca_draw_thin_ellipse(x, y, z, t) \
    156     cucul_draw_thin_ellipse(__caca0_cv, x, y, z, t)
     156    caca_draw_thin_ellipse(__caca0_cv, x, y, z, t)
    157157#define caca_fill_ellipse(x, y, z, t, c) \
    158     cucul_fill_ellipse(__caca0_cv, x, y, z, t, c)
     158    caca_fill_ellipse(__caca0_cv, x, y, z, t, c)
    159159#define caca_draw_box(x, y, z, t, c) \
    160     cucul_draw_box(__caca0_cv, x, y, z, t, c)
     160    caca_draw_box(__caca0_cv, x, y, z, t, c)
    161161#define caca_draw_thin_box(x, y, z, t) \
    162     cucul_draw_thin_box(__caca0_cv, x, y, z, t)
     162    caca_draw_thin_box(__caca0_cv, x, y, z, t)
    163163#define caca_fill_box(x, y, z, t, c) \
    164     cucul_fill_box(__caca0_cv, x, y, z, t, c)
     164    caca_fill_box(__caca0_cv, x, y, z, t, c)
    165165#define caca_draw_triangle(x, y, z, t, u, v, c) \
    166     cucul_draw_triangle(__caca0_cv, x, y, z, t, u, v, c)
     166    caca_draw_triangle(__caca0_cv, x, y, z, t, u, v, c)
    167167#define caca_draw_thin_triangle(x, y, z, t, u, v) \
    168     cucul_draw_thin_triangle(__caca0_cv, x, y, z, t, u, v)
     168    caca_draw_thin_triangle(__caca0_cv, x, y, z, t, u, v)
    169169#define caca_fill_triangle(x, y, z, t, u, v, c) \
    170     cucul_fill_triangle(__caca0_cv, x, y, z, t, u, v, c)
     170    caca_fill_triangle(__caca0_cv, x, y, z, t, u, v, c)
    171171
    172 #define caca_rand(a, b) cucul_rand(a, (b)+1)
     172#define caca_rand(a, b) caca_rand(a, (b)+1)
    173173#define caca_sqrt __caca0_sqrt
    174174
    175 #define caca_sprite cucul_canvas
     175#define caca_sprite caca_canvas
    176176#define caca_load_sprite __caca0_load_sprite
    177177#define caca_get_sprite_frames(c) 1
    178 #define caca_get_sprite_width(c, f) cucul_get_canvas_width(c)
    179 #define caca_get_sprite_height(c, f) cucul_get_canvas_height(c)
     178#define caca_get_sprite_width(c, f) caca_get_canvas_width(c)
     179#define caca_get_sprite_height(c, f) caca_get_canvas_height(c)
    180180#define caca_get_sprite_dx(c, f) 0
    181181#define caca_get_sprite_dx(c, f) 0
    182 #define caca_draw_sprite(x, y, c, f) cucul_blit(__caca0_cv, x, y, c, NULL)
    183 #define caca_free_sprite cucul_free_canvas
     182#define caca_draw_sprite(x, y, c, f) caca_blit(__caca0_cv, x, y, c, NULL)
     183#define caca_free_sprite caca_free_canvas
    184184
    185 #define caca_bitmap cucul_dither
     185#define caca_bitmap caca_dither
    186186#define caca_create_bitmap __caca0_create_bitmap
    187 #define caca_set_bitmap_palette cucul_set_dither_palette
     187#define caca_set_bitmap_palette caca_set_dither_palette
    188188#define caca_draw_bitmap(x, y, z, t, b, p) \
    189     cucul_dither_bitmap(__caca0_cv, x, y, z, t, b, p)
     189    caca_dither_bitmap(__caca0_cv, x, y, z, t, b, p)
    190190#define caca_free_bitmap __caca0_free_bitmap
    191191
  • libcaca/trunk/caca/caca_internals.h

    r2305 r2821  
    2020typedef struct caca_timer caca_timer_t;
    2121typedef struct caca_privevent caca_privevent_t;
     22typedef struct caca_figfont caca_figfont_t;
    2223
    2324#if !defined(_DOXYGEN_SKIP_ME)
    2425#   define EVENTBUF_LEN 10
    2526#endif
     27
     28struct caca_frame
     29{
     30    /* Frame size */
     31    int width, height;
     32
     33    /* Cell information */
     34    uint32_t *chars;
     35    uint32_t *attrs;
     36
     37    /* Painting context */
     38    int x, y;
     39    int handlex, handley;
     40    uint32_t curattr;
     41
     42    /* Frame name */
     43    char *name;
     44};
     45
     46struct caca_canvas
     47{
     48    /* XXX: look at caca_set_canvas_boundaries() before adding anything
     49     * to this structure. The function is quite hacky. */
     50
     51    /* Frame information */
     52    int frame, framecount;
     53    struct caca_frame *frames;
     54
     55    /* Canvas management */
     56    int refcount;
     57    int autoinc;
     58    int (*resize_callback)(void *);
     59    void *resize_data;
     60
     61    /* Shortcut to the active frame information */
     62    int width, height;
     63    uint32_t *chars;
     64    uint32_t *attrs;
     65    uint32_t curattr;
     66
     67    /* FIGfont management */
     68    caca_figfont_t *ff;
     69};
    2670
    2771/* Graphics driver */
     
    105149struct caca_display
    106150{
    107     /* A link to our cucul canvas */
    108     cucul_canvas_t *cv;
     151    /* A link to our caca canvas */
     152    caca_canvas_t *cv;
    109153    int autorelease;
    110154
     
    169213};
    170214
     215/* Colour functions */
     216extern uint32_t _caca_attr_to_rgb24fg(uint32_t);
     217extern uint32_t _caca_attr_to_rgb24bg(uint32_t);
     218
     219/* Frames functions */
     220extern void _caca_save_frame_info(caca_canvas_t *);
     221extern void _caca_load_frame_info(caca_canvas_t *);
     222
    171223/* Internal timer functions */
    172224extern void _caca_sleep(int);
  • libcaca/trunk/caca/caca_types.h.in

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  libcaca       Colour ASCII-Art library
    44 *  Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
     
    1717 */
    1818
    19 #ifndef __CUCUL_TYPES_H__
    20 #define __CUCUL_TYPES_H__
     19#ifndef __CACA_TYPES_H__
     20#define __CACA_TYPES_H__
    2121
    22 #ifndef CUCUL_TYPES
    23 #   define CUCUL_TYPES @CUCUL_TYPES@
     22#ifndef CACA_TYPES
     23#   define CACA_TYPES @CACA_TYPES@
    2424#endif
    2525
    2626/* mode 1: standard <stdint.h> header is present, just include it */
    27 #if CUCUL_TYPES == 1
     27#if CACA_TYPES == 1
    2828#   include <stdint.h>
    2929#   include <unistd.h>
    3030
    3131/* mode 2: standard <inttypes.h> header is present, just include it */
    32 #elif CUCUL_TYPES == 2
     32#elif CACA_TYPES == 2
    3333#   include <inttypes.h>
    3434#   include <unistd.h>
     
    3636/* mode 3: <windows.h> indicates Win32, only (u)intptr_t is present
    3737 * FIXME: Win64 probably doesn't work that way */
    38 #elif CUCUL_TYPES == 3
     38#elif CACA_TYPES == 3
    3939#include <windows.h>
    4040
     
    5656 * have no idea what other typedefs have already been made. */
    5757#else
    58 typedef signed char _cucul_int8_t;
    59 typedef signed short _cucul_int16_t;
    60 typedef signed long int _cucul_int32_t;
    61 typedef signed long long int _cucul_int64_t;
     58typedef signed char _caca_int8_t;
     59typedef signed short _caca_int16_t;
     60typedef signed long int _caca_int32_t;
     61typedef signed long long int _caca_int64_t;
    6262#   undef int8_t
    63 #   define int8_t _cucul_int8_t
     63#   define int8_t _caca_int8_t
    6464#   undef int16_t
    65 #   define int16_t _cucul_int16_t
     65#   define int16_t _caca_int16_t
    6666#   undef int32_t
    67 #   define int32_t _cucul_int32_t
     67#   define int32_t _caca_int32_t
    6868#   undef int64_t
    69 #   define int64_t _cucul_int64_t
     69#   define int64_t _caca_int64_t
    7070
    71 typedef unsigned char _cucul_uint8_t;
    72 typedef unsigned short _cucul_uint16_t;
    73 typedef unsigned long int _cucul_uint32_t;
    74 typedef unsigned long long int _cucul_uint64_t;
     71typedef unsigned char _caca_uint8_t;
     72typedef unsigned short _caca_uint16_t;
     73typedef unsigned long int _caca_uint32_t;
     74typedef unsigned long long int _caca_uint64_t;
    7575#   undef uint8_t
    76 #   define uint8_t _cucul_uint8_t
     76#   define uint8_t _caca_uint8_t
    7777#   undef uint16_t
    78 #   define uint16_t _cucul_uint16_t
     78#   define uint16_t _caca_uint16_t
    7979#   undef uint32_t
    80 #   define uint32_t _cucul_uint32_t
     80#   define uint32_t _caca_uint32_t
    8181#   undef uint64_t
    82 #   define uint64_t _cucul_uint64_t
     82#   define uint64_t _caca_uint64_t
    8383
    84 typedef long int _cucul_intptr_t;
    85 typedef unsigned long int _cucul_uintptr_t;
     84typedef long int _caca_intptr_t;
     85typedef unsigned long int _caca_uintptr_t;
    8686#   undef intptr_t
    87 #   define intptr_t _cucul_intptr_t
     87#   define intptr_t _caca_intptr_t
    8888#   undef uintptr_t
    89 #   define uintptr_t _cucul_uintptr_t
     89#   define uintptr_t _caca_uintptr_t
    9090
    91 typedef int _cucul_ssize_t;
    92 typedef unsigned int _cucul_size_t;
     91typedef int _caca_ssize_t;
     92typedef unsigned int _caca_size_t;
    9393#   undef ssize_t
    94 #   define ssize_t _cucul_ssize_t
     94#   define ssize_t _caca_ssize_t
    9595#   undef size_t
    96 #   define size_t _cucul_size_t
     96#   define size_t _caca_size_t
    9797
    9898#endif
    9999
    100 #endif /* __CUCUL_TYPES_H__ */
     100#endif /* __CACA_TYPES_H__ */
    101101
  • libcaca/trunk/caca/canvas.c

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
    44 *                All Rights Reserved
     
    1414
    1515/*
    16  *  This file contains the main functions used by \e libcucul applications
     16 *  This file contains the main functions used by \e libcaca applications
    1717 *  to initialise a drawing context.
    1818 */
     
    3131#endif
    3232
    33 #include "cucul.h"
    34 #include "cucul_internals.h"
    35 
    36 static int cucul_resize(cucul_canvas_t *, int, int);
    37 
    38 /** \brief Initialise a \e libcucul canvas.
    39  *
    40  *  Initialise internal \e libcucul structures and the backend that will
     33#include "caca.h"
     34#include "caca_internals.h"
     35
     36static int caca_resize(caca_canvas_t *, int, int);
     37
     38/** \brief Initialise a \e libcaca canvas.
     39 *
     40 *  Initialise internal \e libcaca structures and the backend that will
    4141 *  be used for subsequent graphical operations. It must be the first
    42  *  \e libcucul function to be called in a function. cucul_free_canvas()
     42 *  \e libcaca function to be called in a function. caca_free_canvas()
    4343 *  should be called at the end of the program to free all allocated resources.
    4444 *
     
    5252 *  \param width The desired canvas width
    5353 *  \param height The desired canvas height
    54  *  \return A libcucul canvas handle upon success, NULL if an error occurred.
    55  */
    56 cucul_canvas_t * cucul_create_canvas(int width, int height)
    57 {
    58     cucul_canvas_t *cv;
     54 *  \return A libcaca canvas handle upon success, NULL if an error occurred.
     55 */
     56caca_canvas_t * caca_create_canvas(int width, int height)
     57{
     58    caca_canvas_t *cv;
    5959
    6060    if(width < 0 || height < 0)
     
    6464    }
    6565
    66     cv = malloc(sizeof(cucul_canvas_t));
     66    cv = malloc(sizeof(caca_canvas_t));
    6767
    6868    if(!cv)
     
    7676    cv->frame = 0;
    7777    cv->framecount = 1;
    78     cv->frames = malloc(sizeof(struct cucul_frame));
     78    cv->frames = malloc(sizeof(struct caca_frame));
    7979    if(!cv->frames)
    8080    {
     
    9191    cv->frames[0].name = strdup("frame#00000000");
    9292
    93     _cucul_load_frame_info(cv);
    94     cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
     93    _caca_load_frame_info(cv);
     94    caca_set_color_ansi(cv, CACA_DEFAULT, CACA_TRANSPARENT);
    9595
    9696    cv->ff = NULL;
    9797
    98     if(cucul_resize(cv, width, height) < 0)
     98    if(caca_resize(cv, width, height) < 0)
    9999    {
    100100        int saved_errno = geterrno();
     
    117117 *  Lock a canvas to prevent it from being resized. If non-NULL,
    118118 *  the \e callback function pointer will be called upon each
    119  *  \e cucul_set_canvas_size call and if the returned value is zero, the
     119 *  \e caca_set_canvas_size call and if the returned value is zero, the
    120120 *  canvas resize request will be denied.
    121121 *
     
    126126 *  - \c EBUSY The canvas is already being managed.
    127127 *
    128  *  \param cv A libcucul canvas.
     128 *  \param cv A libcaca canvas.
    129129 *  \param callback An optional callback function pointer.
    130130 *  \param p The argument to be passed to \e callback.
    131131 *  \return 0 in case of success, -1 if an error occurred.
    132132 */
    133 int cucul_manage_canvas(cucul_canvas_t *cv, int (*callback)(void *), void *p)
     133int caca_manage_canvas(caca_canvas_t *cv, int (*callback)(void *), void *p)
    134134{
    135135    if(cv->refcount)
     
    148148/** \brief Unmanage a canvas.
    149149 *
    150  *  Unlock a canvas previously locked by cucul_manage_canvas(). For safety
     150 *  Unlock a canvas previously locked by caca_manage_canvas(). For safety
    151151 *  reasons, the callback and callback data arguments must be the same as for
    152  *  the cucul_manage_canvas() call.
     152 *  the caca_manage_canvas() call.
    153153 *
    154154 *  This function is only useful for display drivers such as the \e libcaca
     
    159159 *              not match.
    160160 *
    161  *  \param cv A libcucul canvas.
     161 *  \param cv A libcaca canvas.
    162162 *  \param callback The \e callback argument previously passed to
    163                     cucul_manage_canvas().
    164  *  \param p The \e p argument previously passed to cucul_manage_canvas().
     163                    caca_manage_canvas().
     164 *  \param p The \e p argument previously passed to caca_manage_canvas().
    165165 *  \return 0 in case of success, -1 if an error occurred.
    166166 */
    167 int cucul_unmanage_canvas(cucul_canvas_t *cv, int (*callback)(void *), void *p)
     167int caca_unmanage_canvas(caca_canvas_t *cv, int (*callback)(void *), void *p)
    168168{
    169169    if(!cv->refcount
     
    205205 *    happens, the canvas handle becomes invalid and should not be used.
    206206 *
    207  *  \param cv A libcucul canvas.
     207 *  \param cv A libcaca canvas.
    208208 *  \param width The desired canvas width.
    209209 *  \param height The desired canvas height.
    210210 *  \return 0 in case of success, -1 if an error occurred.
    211211 */
    212 int cucul_set_canvas_size(cucul_canvas_t *cv, int width, int height)
     212int caca_set_canvas_size(caca_canvas_t *cv, int width, int height)
    213213{
    214214    if(width < 0 || height < 0)
     
    225225    }
    226226
    227     return cucul_resize(cv, width, height);
     227    return caca_resize(cv, width, height);
    228228}
    229229
     
    234234 *  This function never fails.
    235235 *
    236  *  \param cv A libcucul canvas.
     236 *  \param cv A libcaca canvas.
    237237 *  \return The canvas width.
    238238 */
    239 int cucul_get_canvas_width(cucul_canvas_t const *cv)
     239int caca_get_canvas_width(caca_canvas_t const *cv)
    240240{
    241241    return cv->width;
     
    248248 *  This function never fails.
    249249 *
    250  *  \param cv A libcucul canvas.
     250 *  \param cv A libcaca canvas.
    251251 *  \return The canvas height.
    252252 */
    253 int cucul_get_canvas_height(cucul_canvas_t const *cv)
     253int caca_get_canvas_height(caca_canvas_t const *cv)
    254254{
    255255    return cv->height;
     
    260260 *  Return the current canvas' internal character array. The array elements
    261261 *  consist in native endian 32-bit Unicode values as returned by
    262  *  cucul_get_char().
     262 *  caca_get_char().
    263263 *
    264264 *  This function is only useful for display drivers such as the \e libcaca
     
    267267 *  This function never fails.
    268268 *
    269  *  \param cv A libcucul canvas.
     269 *  \param cv A libcaca canvas.
    270270 *  \return The canvas character array.
    271271 */
    272 uint8_t const * cucul_get_canvas_chars(cucul_canvas_t const *cv)
     272uint8_t const * caca_get_canvas_chars(caca_canvas_t const *cv)
    273273{
    274274    return (uint8_t const *)cv->chars;
     
    279279 *  Returns the current canvas' internal attribute array. The array elements
    280280 *  consist in native endian 32-bit attribute values as returned by
    281  *  cucul_get_attr().
     281 *  caca_get_attr().
    282282 *
    283283 *  This function is only useful for display drivers such as the \e libcaca
     
    286286 *  This function never fails.
    287287 *
    288  *  \param cv A libcucul canvas.
     288 *  \param cv A libcaca canvas.
    289289 *  \return The canvas attribute array.
    290290 */
    291 uint8_t const * cucul_get_canvas_attrs(cucul_canvas_t const *cv)
     291uint8_t const * caca_get_canvas_attrs(caca_canvas_t const *cv)
    292292{
    293293    return (uint8_t const *)cv->attrs;
    294294}
    295295
    296 /** \brief Uninitialise \e libcucul.
    297  *
    298  *  Free all resources allocated by cucul_create_canvas(). After
    299  *  this function has been called, no other \e libcucul functions may be
    300  *  used unless a new call to cucul_create_canvas() is done.
     296/** \brief Uninitialise \e libcaca.
     297 *
     298 *  Free all resources allocated by caca_create_canvas(). After
     299 *  this function has been called, no other \e libcaca functions may be
     300 *  used unless a new call to caca_create_canvas() is done.
    301301 *
    302302 *  If an error occurs, -1 is returned and \b errno is set accordingly:
    303303 *  - \c EBUSY The canvas is in use by a display driver and cannot be freed.
    304304 *
    305  *  \param cv A libcucul canvas.
     305 *  \param cv A libcaca canvas.
    306306 *  \return 0 in case of success, -1 if an error occurred.
    307307 */
    308 int cucul_free_canvas(cucul_canvas_t *cv)
     308int caca_free_canvas(caca_canvas_t *cv)
    309309{
    310310    int f;
     
    323323    }
    324324
    325     cucul_canvas_set_figfont(cv, NULL);
     325    caca_canvas_set_figfont(cv, NULL);
    326326
    327327    free(cv->frames);
     
    342342 *  (inclusive).
    343343 */
    344 int cucul_rand(int min, int max)
     344int caca_rand(int min, int max)
    345345{
    346346    static int need_init = 1;
     
    355355}
    356356
    357 /** \brief Return the \e libcucul version.
    358  *
    359  *  Return a read-only string with the \e libcucul version information.
    360  *
    361  *  This function never fails.
    362  *
    363  *  \return The \e libcucul version information.
    364  */
    365 char const * cucul_get_version(void)
    366 {
    367     return VERSION;
    368 }
    369357
    370358/*
     
    372360 */
    373361
    374 int cucul_resize(cucul_canvas_t *cv, int width, int height)
     362int caca_resize(caca_canvas_t *cv, int width, int height)
    375363{
    376364    int x, y, f, old_width, old_height, new_size, old_size;
     
    380368    old_size = old_width * old_height;
    381369
    382     _cucul_save_frame_info(cv);
     370    _caca_save_frame_info(cv);
    383371
    384372    cv->width = width;
     
    508496
    509497    /* Reset the current frame shortcuts */
    510     _cucul_load_frame_info(cv);
     498    _caca_load_frame_info(cv);
    511499
    512500    return 0;
  • libcaca/trunk/caca/charset.c

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2002-2007 Sam Hocevar <sam@zoy.org>
    44 *                2007 Ben Wiley Sittler <bsittler@gmail.com>
     
    2525#endif
    2626
    27 #include "cucul.h"
    28 #include "cucul_internals.h"
     27#include "caca.h"
     28#include "caca_internals.h"
    2929
    3030/*
     
    112112 *  is incomplete.
    113113 */
    114 uint32_t cucul_utf8_to_utf32(char const *s, size_t *bytes)
     114uint32_t caca_utf8_to_utf32(char const *s, size_t *bytes)
    115115{
    116116    int todo = trailing[(int)(unsigned char)*s];
     
    151151 *  \return The number of bytes written.
    152152 */
    153 size_t cucul_utf32_to_utf8(char *buf, uint32_t ch)
     153size_t caca_utf32_to_utf8(char *buf, uint32_t ch)
    154154{
    155155    static const uint8_t mark[7] =
     
    191191 *  \return The corresponding CP437 character, or "?" if not representable.
    192192 */
    193 uint8_t cucul_utf32_to_cp437(uint32_t ch)
     193uint8_t caca_utf32_to_cp437(uint32_t ch)
    194194{
    195195    unsigned int i;
     
    223223 *  \return The corresponding UTF-32 character, or zero if not representable.
    224224 */
    225 uint32_t cucul_cp437_to_utf32(uint8_t ch)
     225uint32_t caca_cp437_to_utf32(uint8_t ch)
    226226{
    227227    if(ch > 0x7f)
     
    249249 *  equivalent if found, or "?" if not representable.
    250250 */
    251 char cucul_utf32_to_ascii(uint32_t ch)
     251char caca_utf32_to_ascii(uint32_t ch)
    252252{
    253253    /* Standard ASCII */
     
    388388 *  \return 1 if the character is fullwidth, 0 otherwise.
    389389 */
    390 int cucul_utf32_is_fullwidth(uint32_t ch)
     390int caca_utf32_is_fullwidth(uint32_t ch)
    391391{
    392392    if(ch < 0x2e80) /* Standard stuff */
  • libcaca/trunk/caca/conic.c

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
    44 *                All Rights Reserved
     
    2424#endif
    2525
    26 #include "cucul.h"
    27 #include "cucul_internals.h"
    28 
    29 static void ellipsepoints(cucul_canvas_t *, int, int, int, int, uint32_t, int);
     26#include "caca.h"
     27#include "caca_internals.h"
     28
     29static void ellipsepoints(caca_canvas_t *, int, int, int, int, uint32_t, int);
    3030
    3131/** \brief Draw a circle on the canvas using the given character.
     
    3333 *  This function never fails.
    3434 *
    35  *  \param cv The handle to the libcucul canvas.
     35 *  \param cv The handle to the libcaca canvas.
    3636 *  \param x Center X coordinate.
    3737 *  \param y Center Y coordinate.
     
    4040 *  \return This function always returns 0.
    4141 */
    42 int cucul_draw_circle(cucul_canvas_t *cv, int x, int y, int r, uint32_t ch)
     42int caca_draw_circle(caca_canvas_t *cv, int x, int y, int r, uint32_t ch)
    4343{
    4444    int test, dx, dy;
     
    6060 *  This function never fails.
    6161 *
    62  *  \param cv The handle to the libcucul canvas.
     62 *  \param cv The handle to the libcaca canvas.
    6363 *  \param xo Center X coordinate.
    6464 *  \param yo Center Y coordinate.
     
    6868 *  \return This function always returns 0.
    6969 */
    70 int cucul_fill_ellipse(cucul_canvas_t *cv, int xo, int yo, int a, int b,
     70int caca_fill_ellipse(caca_canvas_t *cv, int xo, int yo, int a, int b,
    7171                       uint32_t ch)
    7272{
     
    8585        {
    8686            d1 += b*b*(2*x*1) + a*a*(-2*y+2);
    87             cucul_draw_line(cv, xo - x, yo - y, xo + x, yo - y, ch);
    88             cucul_draw_line(cv, xo - x, yo + y, xo + x, yo + y, ch);
     87            caca_draw_line(cv, xo - x, yo - y, xo + x, yo - y, ch);
     88            caca_draw_line(cv, xo - x, yo + y, xo + x, yo + y, ch);
    8989            y--;
    9090        }
     
    9292    }
    9393
    94     cucul_draw_line(cv, xo - x, yo - y, xo + x, yo - y, ch);
    95     cucul_draw_line(cv, xo - x, yo + y, xo + x, yo + y, ch);
     94    caca_draw_line(cv, xo - x, yo - y, xo + x, yo - y, ch);
     95    caca_draw_line(cv, xo - x, yo + y, xo + x, yo + y, ch);
    9696
    9797    d2 = b*b*(x+0.5)*(x+0.5) + a*a*(y-1)*(y-1) - a*a*b*b;
     
    109109
    110110        y--;
    111         cucul_draw_line(cv, xo - x, yo - y, xo + x, yo - y, ch);
    112         cucul_draw_line(cv, xo - x, yo + y, xo + x, yo + y, ch);
     111        caca_draw_line(cv, xo - x, yo - y, xo + x, yo - y, ch);
     112        caca_draw_line(cv, xo - x, yo + y, xo + x, yo + y, ch);
    113113    }
    114114
     
    120120 *  This function never fails.
    121121 *
    122  *  \param cv The handle to the libcucul canvas.
     122 *  \param cv The handle to the libcaca canvas.
    123123 *  \param xo Center X coordinate.
    124124 *  \param yo Center Y coordinate.
     
    128128 *  \return This function always returns 0.
    129129 */
    130 int cucul_draw_ellipse(cucul_canvas_t *cv, int xo, int yo, int a, int b,
     130int caca_draw_ellipse(caca_canvas_t *cv, int xo, int yo, int a, int b,
    131131                       uint32_t ch)
    132132{
     
    177177 *  This function never fails.
    178178 *
    179  *  \param cv The handle to the libcucul canvas.
     179 *  \param cv The handle to the libcaca canvas.
    180180 *  \param xo Center X coordinate.
    181181 *  \param yo Center Y coordinate.
     
    184184 *  \return This function always returns 0.
    185185 */
    186 int cucul_draw_thin_ellipse(cucul_canvas_t *cv, int xo, int yo, int a, int b)
     186int caca_draw_thin_ellipse(caca_canvas_t *cv, int xo, int yo, int a, int b)
    187187{
    188188    /* FIXME: this is not correct */
     
    235235}
    236236
    237 static void ellipsepoints(cucul_canvas_t *cv, int xo, int yo, int x, int y,
     237static void ellipsepoints(caca_canvas_t *cv, int xo, int yo, int x, int y,
    238238                          uint32_t ch, int thin)
    239239{
     
    269269
    270270        }
    271         cucul_put_char(cv, xo + x, yo + y, c);
     271        caca_put_char(cv, xo + x, yo + y, c);
    272272    }
    273273    if((b & (0x2|0x4)) == (0x2|0x4)) {
     
    291291
    292292        }
    293         cucul_put_char(cv, xo - x, yo + y, c);
     293        caca_put_char(cv, xo - x, yo + y, c);
    294294    }
    295295
     
    315315
    316316        }
    317         cucul_put_char(cv, xo + x, yo - y, c);
     317        caca_put_char(cv, xo + x, yo - y, c);
    318318    }
    319319
     
    338338
    339339        }
    340         cucul_put_char(cv, xo - x, yo - y, c);
    341     }
    342 
    343        
    344 }
    345 
     340        caca_put_char(cv, xo - x, yo - y, c);
     341    }
     342
     343       
     344}
     345
  • libcaca/trunk/caca/dither.c

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
    44 *                All Rights Reserved
     
    2929#endif
    3030
    31 #include "cucul.h"
    32 #include "cucul_internals.h"
     31#include "caca.h"
     32#include "caca_internals.h"
    3333
    3434#define CP437 0
     
    116116};
    117117
    118 struct cucul_dither
     118struct caca_dither
    119119{
    120120    int bpp, has_palette, has_alpha;
     
    123123    int rright, gright, bright, aright;
    124124    int rleft, gleft, bleft, aleft;
    125     void (*get_hsv)(cucul_dither_t *, char *, int, int);
     125    void (*get_hsv)(caca_dither_t *, char *, int, int);
    126126    int red[256], green[256], blue[256], alpha[256];
    127127
     
    173173static float gammapow(float x, float y);
    174174
    175 static void get_rgba_default(cucul_dither_t const *, uint8_t *, int, int,
     175static void get_rgba_default(caca_dither_t const *, uint8_t *, int, int,
    176176                             unsigned int *);
    177177static int init_lookup(void);
     
    243243 *  pitch) and pixel mask values. If the depth is 8 bits per pixel, the mask
    244244 *  values are ignored and the colour palette should be set using the
    245  *  cucul_set_dither_palette() function. For depths greater than 8 bits per
     245 *  caca_set_dither_palette() function. For depths greater than 8 bits per
    246246 *  pixel, a zero alpha mask causes the alpha values to be ignored.
    247247 *
     
    261261 *  \return Dither object upon success, NULL if an error occurred.
    262262 */
    263 cucul_dither_t *cucul_create_dither(int bpp, int w, int h, int pitch,
     263caca_dither_t *caca_create_dither(int bpp, int w, int h, int pitch,
    264264                                    uint32_t rmask, uint32_t gmask,
    265265                                    uint32_t bmask, uint32_t amask)
    266266{
    267     cucul_dither_t *d;
     267    caca_dither_t *d;
    268268    int i;
    269269
     
    275275    }
    276276
    277     d = malloc(sizeof(cucul_dither_t));
     277    d = malloc(sizeof(caca_dither_t));
    278278    if(!d)
    279279    {
     
    372372 *  \return 0 in case of success, -1 if an error occurred.
    373373 */
    374 int cucul_set_dither_palette(cucul_dither_t *d,
     374int caca_set_dither_palette(caca_dither_t *d,
    375375                             uint32_t red[], uint32_t green[],
    376376                             uint32_t blue[], uint32_t alpha[])
     
    421421 *  \return 0 in case of success, -1 if an error occurred.
    422422 */
    423 int cucul_set_dither_brightness(cucul_dither_t *d, float brightness)
     423int caca_set_dither_brightness(caca_dither_t *d, float brightness)
    424424{
    425425    /* FIXME */
     
    438438 *  \return Brightness value.
    439439 */
    440 float cucul_get_dither_brightness(cucul_dither_t const *d)
     440float caca_get_dither_brightness(caca_dither_t const *d)
    441441{
    442442    return d->brightness;
     
    455455 *  \return 0 in case of success, -1 if an error occurred.
    456456 */
    457 int cucul_set_dither_gamma(cucul_dither_t *d, float gamma)
     457int caca_set_dither_gamma(caca_dither_t *d, float gamma)
    458458{
    459459    /* FIXME: we don't need 4096 calls to gammapow(), we could just compute
     
    490490 *  \return Gamma value.
    491491 */
    492 float cucul_get_dither_gamma(cucul_dither_t const *d)
     492float caca_get_dither_gamma(caca_dither_t const *d)
    493493{
    494494    return d->gamma;
     
    506506 *  \return 0 in case of success, -1 if an error occurred.
    507507 */
    508 int cucul_set_dither_contrast(cucul_dither_t *d, float contrast)
     508int caca_set_dither_contrast(caca_dither_t *d, float contrast)
    509509{
    510510    /* FIXME */
     
    523523 *  \return Contrast value.
    524524 */
    525 float cucul_get_dither_contrast(cucul_dither_t const *d)
     525float caca_get_dither_contrast(caca_dither_t const *d)
    526526{
    527527    return d->contrast;
     
    544544 *  \return 0 in case of success, -1 if an error occurred.
    545545 */
    546 int cucul_set_dither_antialias(cucul_dither_t *d, char const *str)
     546int caca_set_dither_antialias(caca_dither_t *d, char const *str)
    547547{
    548548    if(!strcasecmp(str, "none"))
     
    570570 *  list is a NULL-terminated array of strings, interleaving a string
    571571 *  containing the internal value for the antialiasing method to be used with
    572  *  cucul_set_dither_antialias(), and a string containing the natural
     572 *  caca_set_dither_antialias(), and a string containing the natural
    573573 *  language description for that antialiasing method.
    574574 *
     
    579579 */
    580580char const * const *
    581     cucul_get_dither_antialias_list(cucul_dither_t const *d)
     581    caca_get_dither_antialias_list(caca_dither_t const *d)
    582582{
    583583    static char const * const list[] =
     
    600600 *  \return A static string.
    601601 */
    602 char const * cucul_get_dither_antialias(cucul_dither_t const *d)
     602char const * caca_get_dither_antialias(caca_dither_t const *d)
    603603{
    604604    return d->antialias_name;
     
    628628 *  \return 0 in case of success, -1 if an error occurred.
    629629 */
    630 int cucul_set_dither_color(cucul_dither_t *d, char const *str)
     630int caca_set_dither_color(caca_dither_t *d, char const *str)
    631631{
    632632    if(!strcasecmp(str, "mono"))
     
    679679 *  is a NULL-terminated array of strings, interleaving a string containing
    680680 *  the internal value for the colour mode, to be used with
    681  *  cucul_set_dither_color(), and a string containing the natural
     681 *  caca_set_dither_color(), and a string containing the natural
    682682 *  language description for that colour mode.
    683683 *
     
    688688 */
    689689char const * const *
    690     cucul_get_dither_color_list(cucul_dither_t const *d)
     690    caca_get_dither_color_list(caca_dither_t const *d)
    691691{
    692692    static char const * const list[] =
     
    714714 *  \return A static string.
    715715 */
    716 char const * cucul_get_dither_color(cucul_dither_t const *d)
     716char const * caca_get_dither_color(caca_dither_t const *d)
    717717{
    718718    return d->color_name;
     
    739739 *  \return 0 in case of success, -1 if an error occurred.
    740740 */
    741 int cucul_set_dither_charset(cucul_dither_t *d, char const *str)
     741int caca_set_dither_charset(caca_dither_t *d, char const *str)
    742742{
    743743    if(!strcasecmp(str, "shades"))
     
    773773 *  is a NULL-terminated array of strings, interleaving a string containing
    774774 *  the internal value for the character set, to be used with
    775  *  cucul_set_dither_charset(), and a string containing the natural
     775 *  caca_set_dither_charset(), and a string containing the natural
    776776 *  language description for that character set.
    777777 *
     
    781781 *  \return An array of strings.
    782782 */
    783 char const * const * cucul_get_dither_charset_list(cucul_dither_t const *d)
     783char const * const * caca_get_dither_charset_list(caca_dither_t const *d)
    784784{
    785785    static char const * const list[] =
     
    803803 *  \return A static string.
    804804 */
    805 char const * cucul_get_dither_charset(cucul_dither_t const *d)
     805char const * caca_get_dither_charset(caca_dither_t const *d)
    806806{
    807807    return d->glyph_name;
     
    828828 *  \return 0 in case of success, -1 if an error occurred.
    829829 */
    830 int cucul_set_dither_algorithm(cucul_dither_t *d, char const *str)
     830int caca_set_dither_algorithm(caca_dither_t *d, char const *str)
    831831{
    832832    if(!strcasecmp(str, "none"))
     
    886886 *  list is a NULL-terminated array of strings, interleaving a string
    887887 *  containing the internal value for the dithering algorithm, to be used
    888  *  with cucul_set_dither_dithering(), and a string containing the natural
     888 *  with caca_set_dither_dithering(), and a string containing the natural
    889889 *  language description for that algorithm.
    890890 *
     
    894894 *  \return An array of strings.
    895895 */
    896 char const * const * cucul_get_dither_algorithm_list(cucul_dither_t const *d)
     896char const * const * caca_get_dither_algorithm_list(caca_dither_t const *d)
    897897{
    898898    static char const * const list[] =
     
    919919 *  \return A static string.
    920920 */
    921 char const * cucul_get_dither_algorithm(cucul_dither_t const *d)
     921char const * caca_get_dither_algorithm(caca_dither_t const *d)
    922922{
    923923    return d->algo_name;
     
    931931 *  This function never fails.
    932932 *
    933  *  \param cv A handle to the libcucul canvas.
     933 *  \param cv A handle to the libcaca canvas.
    934934 *  \param x X coordinate of the upper-left corner of the drawing area.
    935935 *  \param y Y coordinate of the upper-left corner of the drawing area.
     
    940940 *  \return This function always returns 0.
    941941 */
    942 int cucul_dither_bitmap(cucul_canvas_t *cv, int x, int y, int w, int h,
    943                         cucul_dither_t const *d, void *pixels)
     942int caca_dither_bitmap(caca_canvas_t *cv, int x, int y, int w, int h,
     943                        caca_dither_t const *d, void *pixels)
    944944{
    945945    int *floyd_steinberg, *fs_r, *fs_g, *fs_b;
     
    951951        return 0;
    952952
    953     savedattr = cucul_get_attr(cv, -1, -1);
     953    savedattr = caca_get_attr(cv, -1, -1);
    954954
    955955    x1 = x; x2 = x + w - 1;
     
    11281128            if(rgba[2] > lum) lum = rgba[2];
    11291129            outfg = outbg;
    1130             outbg = CUCUL_BLACK;
     1130            outbg = CACA_BLACK;
    11311131
    11321132            ch = lum * dchmax / 0x1000;
     
    11701170
    11711171        /* Now output the character */
    1172         cucul_set_color_ansi(cv, outfg, outbg);
    1173         cucul_put_char(cv, x, y, outch);
     1172        caca_set_color_ansi(cv, outfg, outbg);
     1173        caca_put_char(cv, x, y, outch);
    11741174
    11751175        d->increment_dither();
     
    11801180    free(floyd_steinberg);
    11811181
    1182     cucul_set_attr(cv, savedattr);
     1182    caca_set_attr(cv, savedattr);
    11831183
    11841184    return 0;
     
    11871187/** \brief Free the memory associated with a dither.
    11881188 *
    1189  *  Free the memory allocated by cucul_create_dither().
     1189 *  Free the memory allocated by caca_create_dither().
    11901190 *
    11911191 *  This function never fails.
     
    11941194 *  \return This function always returns 0.
    11951195 */
    1196 int cucul_free_dither(cucul_dither_t *d)
     1196int caca_free_dither(caca_dither_t *d)
    11971197{
    11981198    if(!d)
     
    12971297}
    12981298
    1299 static void get_rgba_default(cucul_dither_t const *d, uint8_t *pixels,
     1299static void get_rgba_default(caca_dither_t const *d, uint8_t *pixels,
    13001300                             int x, int y, unsigned int *rgba)
    13011301{
     
    14941494static int get_random_dither(void)
    14951495{
    1496     return cucul_rand(0x00, 0x100);
     1496    return caca_rand(0x00, 0x100);
    14971497}
    14981498
     
    15101510
    15111511    /* These ones are constant */
    1512     lookup_colors[0] = CUCUL_BLACK;
    1513     lookup_colors[1] = CUCUL_DARKGRAY;
    1514     lookup_colors[2] = CUCUL_LIGHTGRAY;
    1515     lookup_colors[3] = CUCUL_WHITE;
     1512    lookup_colors[0] = CACA_BLACK;
     1513    lookup_colors[1] = CACA_DARKGRAY;
     1514    lookup_colors[2] = CACA_LIGHTGRAY;
     1515    lookup_colors[3] = CACA_WHITE;
    15161516
    15171517    /* These ones will be overwritten */
    1518     lookup_colors[4] = CUCUL_MAGENTA;
    1519     lookup_colors[5] = CUCUL_LIGHTMAGENTA;
    1520     lookup_colors[6] = CUCUL_RED;
    1521     lookup_colors[7] = CUCUL_LIGHTRED;
     1518    lookup_colors[4] = CACA_MAGENTA;
     1519    lookup_colors[5] = CACA_LIGHTMAGENTA;
     1520    lookup_colors[6] = CACA_RED;
     1521    lookup_colors[7] = CACA_LIGHTRED;
    15221522
    15231523    for(v = 0; v < LOOKUP_VAL; v++)
  • libcaca/trunk/caca/driver_cocoa.m

    r2305 r2821  
    2424#import <Cocoa/Cocoa.h>
    2525
    26 #include "cucul.h"
     26#include "caca.h"
    2727#include "caca.h"
    2828#include "caca_internals.h"
     
    196196- (void)resizeIfNeeded:(caca_display_t *)dp
    197197{
    198     if(_w != cucul_get_canvas_width(dp->cv)
    199         || _h != cucul_get_canvas_height(dp->cv)
     198    if(_w != caca_get_canvas_width(dp->cv)
     199        || _h != caca_get_canvas_height(dp->cv)
    200200        || !_attrs || !_bkg_rects || !_bkg_colors)
    201201    {
    202202        debug_log(@"%s resize to %ux%u", _cmd, _w, _h);
    203203       
    204         _w = cucul_get_canvas_width(dp->cv);
    205         _h = cucul_get_canvas_height(dp->cv);
     204        _w = caca_get_canvas_width(dp->cv);
     205        _h = caca_get_canvas_height(dp->cv);
    206206
    207207        if(_attrs)
     
    217217        _bkg_colors = malloc(_w * _h * sizeof(NSColor*));
    218218
    219         [[self window] setContentSize: NSMakeSize(cucul_get_canvas_width(dp->cv) * _font_rect.size.width,
    220                                                   cucul_get_canvas_height(dp->cv) * _font_rect.size.height)];
     219        [[self window] setContentSize: NSMakeSize(caca_get_canvas_width(dp->cv) * _font_rect.size.width,
     220                                                  caca_get_canvas_height(dp->cv) * _font_rect.size.height)];
    221221    }
    222222}
     
    229229    {
    230230        _chars = _attrs + _w * _h;
    231         memcpy(_attrs, cucul_get_canvas_attrs(dp->cv),
     231        memcpy(_attrs, caca_get_canvas_attrs(dp->cv),
    232232               _w * _h * sizeof(uint32_t));
    233         memcpy(_chars, cucul_get_canvas_chars(dp->cv),
     233        memcpy(_chars, caca_get_canvas_chars(dp->cv),
    234234               _w * _h * sizeof(uint32_t));
    235235
     
    271271                NSColor* color = nil;
    272272#if USE_RGB12_FGBG
    273                 uint16_t bg = cucul_attr_to_rgb12_bg(*attrs);
     273                uint16_t bg = caca_attr_to_rgb12_bg(*attrs);
    274274                if(bg)
    275275                {
     
    289289#else
    290290                uint8_t argb[8];
    291                 cucul_attr_to_argb64(*attrs, argb);
     291                caca_attr_to_argb64(*attrs, argb);
    292292                color =  [NSColor colorWithCalibratedRed:((float)argb[1]) / 15.0
    293293                                  green:((float)argb[2]) / 15.0
     
    317317                continue;
    318318
    319             if(*chars == CUCUL_MAGIC_FULLWIDTH)
     319            if(*chars == CACA_MAGIC_FULLWIDTH)
    320320                continue;
    321321
     
    329329                    NSColor* color = nil;
    330330#if USE_RGB12_FGBG
    331                     uint16_t fg = cucul_attr_to_rgb12_fg(*attrs);
     331                    uint16_t fg = caca_attr_to_rgb12_fg(*attrs);
    332332#   ifdef PRECACHE_WHOLE_COLOR_TABLE
    333333                    color = _colorCache[fg];
     
    344344#else // USE_RGB12_FGBG
    345345                    uint8_t argb[8];
    346                     cucul_attr_to_argb64(*attrs, argb);
     346                    caca_attr_to_argb64(*attrs, argb);
    347347                    debug_log(@"x,y=[%d,%d] r,g,b back=[%u %u %u] front=[%u %u %u]",
    348348                              x, y, argb[1], argb[2], argb[3], argb[5], argb[6], argb[7]);
     
    355355                    if(color)
    356356                    {
    357                         NSMutableDictionary* attrDict = (*attrs & CUCUL_UNDERLINE) ?
     357                        NSMutableDictionary* attrDict = (*attrs & CACA_UNDERLINE) ?
    358358                                                        _attrDictUnderline : _attrDict;
    359359                        [attrDict setObject:color forKey:NSForegroundColorAttributeName];
     
    573573    NSRect fontRect = [font boundingRectForFont];
    574574    fontRect = NSMakeRect(0, 0, ceilf(fontRect.size.width), ceilf(fontRect.size.height));
    575     NSRect windowRect = NSMakeRect(20, 20, cucul_get_canvas_width(dp->cv) * fontRect.size.width,
    576                                            cucul_get_canvas_height(dp->cv) * fontRect.size.height);
     575    NSRect windowRect = NSMakeRect(20, 20, caca_get_canvas_width(dp->cv) * fontRect.size.width,
     576                                           caca_get_canvas_height(dp->cv) * fontRect.size.height);
    577577    convert_NSRect(&windowRect);
    578578
     
    827827static int cocoa_init_graphics(caca_display_t *dp)
    828828{
    829     int width = cucul_get_canvas_width(dp->cv);
    830     int height = cucul_get_canvas_height(dp->cv);
     829    int width = caca_get_canvas_width(dp->cv);
     830    int height = caca_get_canvas_height(dp->cv);
    831831
    832832    debug_log(@"%s dp->cv: %ux%u", __PRETTY_FUNCTION__, width, height);
     
    839839
    840840    dp->resize.allow = 1;
    841     cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32);
     841    caca_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32);
    842842    dp->resize.allow = 0;
    843843
     
    859859{
    860860    debug_log(@"%s dp->cv: %ux%u", __PRETTY_FUNCTION__,
    861               cucul_get_canvas_width(dp->cv), cucul_get_canvas_height(dp->cv));
     861              caca_get_canvas_width(dp->cv), caca_get_canvas_height(dp->cv));
    862862
    863863    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
     
    959959{
    960960    debug_log(@"%s", __PRETTY_FUNCTION__);
    961     dp->resize.w = cucul_get_canvas_width(dp->cv);
    962     dp->resize.h = cucul_get_canvas_height(dp->cv);
     961    dp->resize.w = caca_get_canvas_width(dp->cv);
     962    dp->resize.h = caca_get_canvas_height(dp->cv);
    963963}
    964964
  • libcaca/trunk/caca/driver_conio.c

    r2305 r2821  
    2929#include <stdlib.h>
    3030
    31 #include "cucul.h"
    3231#include "caca.h"
    3332#include "caca_internals.h"
     
    5857#   endif
    5958    dp->resize.allow = 1;
    60     cucul_set_canvas_size(dp->cv, dp->drv.p->ti.screenwidth,
     59    caca_set_canvas_size(dp->cv, dp->drv.p->ti.screenwidth,
    6160                                  dp->drv.p->ti.screenheight);
    6261    dp->resize.allow = 0;
     
    7069    textcolor((enum COLORS)WHITE);
    7170    textbackground((enum COLORS)BLACK);
    72     gotoxy(cucul_get_canvas_width(dp->cv), cucul_get_canvas_height(dp->cv));
     71    gotoxy(caca_get_canvas_width(dp->cv), caca_get_canvas_height(dp->cv));
    7372    cputs("\r\n");
    7473    _setcursortype(_NORMALCURSOR);
     
    8887{
    8988    /* Fallback to a 6x10 font */
    90     return cucul_get_canvas_width(dp->cv) * 6;
     89    return caca_get_canvas_width(dp->cv) * 6;
    9190}
    9291
     
    9493{
    9594    /* Fallback to a 6x10 font */
    96     return cucul_get_canvas_height(dp->cv) * 10;
     95    return caca_get_canvas_height(dp->cv) * 10;
    9796}
    9897
     
    10099{
    101100    char *screen = dp->drv.p->screen;
    102     uint32_t const *chars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
    103     uint32_t const *attrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
    104     int width = cucul_get_canvas_width(dp->cv);
    105     int height = cucul_get_canvas_height(dp->cv);
     101    uint32_t const *chars = (uint32_t const *)caca_get_canvas_chars(dp->cv);
     102    uint32_t const *attrs = (uint32_t const *)caca_get_canvas_attrs(dp->cv);
     103    int width = caca_get_canvas_width(dp->cv);
     104    int height = caca_get_canvas_height(dp->cv);
    106105    int n;
    107106
    108107    for(n = height * width; n--; )
    109108    {
    110         char ch = cucul_utf32_to_cp437(*chars++);
    111         if(n && *chars == CUCUL_MAGIC_FULLWIDTH)
     109        char ch = caca_utf32_to_cp437(*chars++);
     110        if(n && *chars == CACA_MAGIC_FULLWIDTH)
    112111        {
    113112            *screen++ = '[';
    114             *screen++ = cucul_attr_to_ansi(*attrs++);
     113            *screen++ = caca_attr_to_ansi(*attrs++);
    115114            ch = ']';
    116115            chars++;
     
    118117        }
    119118        *screen++ = ch;
    120         *screen++ = cucul_attr_to_ansi(*attrs++);
     119        *screen++ = caca_attr_to_ansi(*attrs++);
    121120    }
    122121#   if defined(SCREENUPDATE_IN_PC_H)
     
    130129{
    131130    /* We know nothing about our window */
    132     dp->resize.w = cucul_get_canvas_width(dp->cv);
    133     dp->resize.h = cucul_get_canvas_height(dp->cv);
     131    dp->resize.w = caca_get_canvas_width(dp->cv);
     132    dp->resize.h = caca_get_canvas_height(dp->cv);
    134133}
    135134
  • libcaca/trunk/caca/driver_gl.c

    r2305 r2821  
    3636#include <stdio.h>
    3737
    38 #include "cucul.h"
    3938#include "caca.h"
    4039#include "caca_internals.h"
     
    6665    int width, height;
    6766    int new_width, new_height;
    68     cucul_font_t *f;
     67    caca_font_t *f;
    6968    float font_width, font_height;
    7069    float incx, incy;
     
    8887    char *argv[2] = { "", NULL };
    8988    char const * const * fonts;
    90     int width = cucul_get_canvas_width(dp->cv);
    91     int height = cucul_get_canvas_height(dp->cv);
     89    int width = caca_get_canvas_width(dp->cv);
     90    int height = caca_get_canvas_height(dp->cv);
    9291    int argc = 1;
    9392
     
    103102
    104103    dp->resize.allow = 1;
    105     cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32);
     104    caca_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32);
    106105    dp->resize.allow = 0;
    107106
    108     /* Load a libcucul internal font */
    109     fonts = cucul_get_font_list();
     107    /* Load a libcaca internal font */
     108    fonts = caca_get_font_list();
    110109    if(fonts[0] == NULL)
    111110    {
    112         fprintf(stderr, "error: libcucul was compiled without any fonts\n");
     111        fprintf(stderr, "error: libcaca was compiled without any fonts\n");
    113112        return -1;
    114113    }
    115     dp->drv.p->f = cucul_load_font(fonts[0], 0);
     114    dp->drv.p->f = caca_load_font(fonts[0], 0);
    116115    if(dp->drv.p->f == NULL)
    117116    {
     
    120119    }
    121120
    122     dp->drv.p->font_width = cucul_get_font_width(dp->drv.p->f);
    123     dp->drv.p->font_height = cucul_get_font_height(dp->drv.p->f);
    124 
    125     dp->drv.p->width = cucul_get_canvas_width(dp->cv) * dp->drv.p->font_width;
    126     dp->drv.p->height = cucul_get_canvas_height(dp->cv) * dp->drv.p->font_height;
     121    dp->drv.p->font_width = caca_get_font_width(dp->drv.p->f);
     122    dp->drv.p->font_height = caca_get_font_height(dp->drv.p->f);
     123
     124    dp->drv.p->width = caca_get_canvas_width(dp->cv) * dp->drv.p->font_width;
     125    dp->drv.p->height = caca_get_canvas_height(dp->cv) * dp->drv.p->font_height;
    127126
    128127#ifdef HAVE_GLUTCLOSEFUNC
     
    193192    glutHideWindow();
    194193    glutDestroyWindow(dp->drv.p->window);
    195     cucul_free_font(dp->drv.p->f);
     194    caca_free_font(dp->drv.p->f);
    196195    free(dp->drv.p->txid);
    197196    free(dp->drv.p);
     
    217216static void gl_display(caca_display_t *dp)
    218217{
    219     uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
    220     uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
    221     int width = cucul_get_canvas_width(dp->cv);
     218    uint32_t const *cvchars = (uint32_t const *)caca_get_canvas_chars(dp->cv);
     219    uint32_t const *cvattrs = (uint32_t const *)caca_get_canvas_attrs(dp->cv);
     220    int width = caca_get_canvas_width(dp->cv);
    222221    int x, y, line;
    223222
     
    233232        for(x = 0; x < dp->drv.p->width; x += dp->drv.p->font_width)
    234233        {
    235             uint16_t bg = cucul_attr_to_rgb12_bg(*attrs++);
     234            uint16_t bg = caca_attr_to_rgb12_bg(*attrs++);
    236235
    237236            glColor4b(((bg & 0xf00) >> 8) * 8,
     
    267266            int i, b, fullwidth;
    268267
    269             fullwidth = cucul_utf32_is_fullwidth(ch);
     268            fullwidth = caca_utf32_is_fullwidth(ch);
    270269
    271270            for(b = 0, i = 0; dp->drv.p->blocks[i + 1]; i += 2)
     
    285284                                        - (uint32_t)dp->drv.p->blocks[i]]);
    286285
    287                 fg = cucul_attr_to_rgb12_fg(*attrs);
     286                fg = caca_attr_to_rgb12_fg(*attrs);
    288287                glColor3b(((fg & 0xf00) >> 8) * 8,
    289288                          ((fg & 0x0f0) >> 4) * 8,
     
    353352    {
    354353        ev->type = CACA_EVENT_RESIZE;
    355         ev->data.resize.w = cucul_get_canvas_width(dp->cv);
    356         ev->data.resize.h = cucul_get_canvas_height(dp->cv);
     354        ev->data.resize.w = caca_get_canvas_width(dp->cv);
     355        ev->data.resize.h = caca_get_canvas_height(dp->cv);
    357356        return 1;
    358357    }
     
    514513static void gl_compute_font(caca_display_t *dp)
    515514{
    516     cucul_canvas_t *cv;
     515    caca_canvas_t *cv;
    517516    uint32_t *image;
    518517    int i, b, w, h, x, y;
    519518
    520519    /* Count how many glyphs this font has */
    521     dp->drv.p->blocks = cucul_get_font_blocks(dp->drv.p->f);
     520    dp->drv.p->blocks = caca_get_font_blocks(dp->drv.p->f);
    522521
    523522    for(b = 0, i = 0; dp->drv.p->blocks[i + 1]; i += 2)
    524523        b += (int)(dp->drv.p->blocks[i + 1] - dp->drv.p->blocks[i]);
    525524
    526     /* Allocate a libcucul canvas and print all the glyphs on it */
    527     cv = cucul_create_canvas(2, b);
    528     cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK);
     525    /* Allocate a libcaca canvas and print all the glyphs on it */
     526    cv = caca_create_canvas(2, b);
     527    caca_set_color_ansi(cv, CACA_WHITE, CACA_BLACK);
    529528
    530529    for(b = 0, i = 0; dp->drv.p->blocks[i + 1]; i += 2)
     
    533532
    534533        for(j = 0; j < n; j++)
    535             cucul_put_char(cv, 0, b + j, dp->drv.p->blocks[i] + j);
     534            caca_put_char(cv, 0, b + j, dp->drv.p->blocks[i] + j);
    536535
    537536        b += n;
    538537    }
    539538
    540     /* Draw the cucul canvas onto an image buffer */
     539    /* Draw the caca canvas onto an image buffer */
    541540    image = malloc(b * dp->drv.p->font_height *
    542541                   2 * dp->drv.p->font_width * sizeof(uint32_t));
    543     cucul_render_canvas(cv, dp->drv.p->f, image, 2 * dp->drv.p->font_width,
     542    caca_render_canvas(cv, dp->drv.p->f, image, 2 * dp->drv.p->font_width,
    544543                        b * dp->drv.p->font_height, 8 * dp->drv.p->font_width);
    545     cucul_free_canvas(cv);
     544    caca_free_canvas(cv);
    546545
    547546    /* Convert all glyphs in the image buffer to GL textures */
     
    561560                                            * dp->drv.p->font_height);
    562561            int fullwidth =
    563                     cucul_utf32_is_fullwidth(dp->drv.p->blocks[i] + j);
     562                    caca_utf32_is_fullwidth(dp->drv.p->blocks[i] + j);
    564563
    565564            memset(tmp, 0, 16 * 8 * 16);
  • libcaca/trunk/caca/driver_ncurses.c

    r2305 r2821  
    5151#endif
    5252
    53 #include "cucul.h"
    5453#include "caca.h"
    5554#include "caca_internals.h"
     
    303302
    304303    dp->resize.allow = 1;
    305     cucul_set_canvas_size(dp->cv, COLS, LINES);
     304    caca_set_canvas_size(dp->cv, COLS, LINES);
    306305    dp->resize.allow = 0;
    307306
     
    336335{
    337336    /* Fallback to a 6x10 font */
    338     return cucul_get_canvas_width(dp->cv) * 6;
     337    return caca_get_canvas_width(dp->cv) * 6;
    339338}
    340339
     
    342341{
    343342    /* Fallback to a 6x10 font */
    344     return cucul_get_canvas_height(dp->cv) * 10;
     343    return caca_get_canvas_height(dp->cv) * 10;
    345344}
    346345
    347346static void ncurses_display(caca_display_t *dp)
    348347{
    349     uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
    350     uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
    351     int width = cucul_get_canvas_width(dp->cv);
    352     int height = cucul_get_canvas_height(dp->cv);
     348    uint32_t const *cvchars = (uint32_t const *)caca_get_canvas_chars(dp->cv);
     349    uint32_t const *cvattrs = (uint32_t const *)caca_get_canvas_attrs(dp->cv);
     350    int width = caca_get_canvas_width(dp->cv);
     351    int height = caca_get_canvas_height(dp->cv);
    353352    int x, y;
    354353
     
    358357        for(x = width; x--; )
    359358        {
    360             attrset(dp->drv.p->attr[cucul_attr_to_ansi(*cvattrs++)]);
     359            attrset(dp->drv.p->attr[caca_attr_to_ansi(*cvattrs++)]);
    361360            ncurses_write_utf32(*cvchars++);
    362361        }
    363362    }
    364363   
    365     x = cucul_get_cursor_x(dp->cv);
    366     y = cucul_get_cursor_y(dp->cv);
     364    x = caca_get_cursor_x(dp->cv);
     365    y = caca_get_cursor_y(dp->cv);
    367366    move(y, x);
    368367
     
    390389
    391390    /* Fallback */
    392     dp->resize.w = cucul_get_canvas_width(dp->cv);
    393     dp->resize.h = cucul_get_canvas_height(dp->cv);
     391    dp->resize.w = caca_get_canvas_width(dp->cv);
     392    dp->resize.h = caca_get_canvas_height(dp->cv);
    394393}
    395394
     
    433432
    434433        utf8[i] = '\0';
    435         utf32 = cucul_utf8_to_utf32(utf8, &bytes);
     434        utf32 = caca_utf8_to_utf32(utf8, &bytes);
    436435
    437436        while(i > bytes)
     
    616615#endif
    617616
    618     if(ch == CUCUL_MAGIC_FULLWIDTH)
     617    if(ch == CACA_MAGIC_FULLWIDTH)
    619618        return;
    620619
    621620#if defined HAVE_NCURSESW_NCURSES_H
    622     bytes = cucul_utf32_to_utf8(buf, ch);
     621    bytes = caca_utf32_to_utf8(buf, ch);
    623622    buf[bytes] = '\0';
    624623    addstr(buf);
     
    815814        }
    816815        addch(cch);
    817         if(cucul_utf32_is_fullwidth(ch))
     816        if(caca_utf32_is_fullwidth(ch))
    818817        {
    819818            addch(cch2);
  • libcaca/trunk/caca/driver_raw.c

    r2305 r2821  
    2424#include <stdlib.h>
    2525
    26 #include "cucul.h"
    2726#include "caca.h"
    2827#include "caca_internals.h"
     
    3029static int raw_init_graphics(caca_display_t *dp)
    3130{
    32     int width = cucul_get_canvas_width(dp->cv);
    33     int height = cucul_get_canvas_height(dp->cv);
     31    int width = caca_get_canvas_width(dp->cv);
     32    int height = caca_get_canvas_height(dp->cv);
    3433    char const *geometry;
    3534
     
    4140
    4241    dp->resize.allow = 1;
    43     cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 24);
     42    caca_set_canvas_size(dp->cv, width ? width : 80, height ? height : 24);
    4443    dp->resize.allow = 0;
    4544
     
    7271    size_t len;
    7372
    74     buffer = cucul_export_memory(dp->cv, "caca", &len);
     73    buffer = caca_export_memory(dp->cv, "caca", &len);
    7574    if(!buffer)
    7675        return;
  • libcaca/trunk/caca/driver_slang.c

    r2305 r2821  
    3434#endif
    3535
    36 #include "cucul.h"
    3736#include "caca.h"
    3837#include "caca_internals.h"
     
    178177
    179178    dp->resize.allow = 1;
    180     cucul_set_canvas_size(dp->cv, SLtt_Screen_Cols, SLtt_Screen_Rows);
     179    caca_set_canvas_size(dp->cv, SLtt_Screen_Cols, SLtt_Screen_Rows);
    181180    dp->resize.allow = 0;
    182181
     
    211210{
    212211    /* Fallback to a 6x10 font */
    213     return cucul_get_canvas_width(dp->cv) * 6;
     212    return caca_get_canvas_width(dp->cv) * 6;
    214213}
    215214
     
    217216{
    218217    /* Fallback to a 6x10 font */
    219     return cucul_get_canvas_height(dp->cv) * 10;
     218    return caca_get_canvas_height(dp->cv) * 10;
    220219}
    221220
    222221static void slang_display(caca_display_t *dp)
    223222{
    224     uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
    225     uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
    226     int width = cucul_get_canvas_width(dp->cv);
    227     int height = cucul_get_canvas_height(dp->cv);
     223    uint32_t const *cvchars = (uint32_t const *)caca_get_canvas_chars(dp->cv);
     224    uint32_t const *cvattrs = (uint32_t const *)caca_get_canvas_attrs(dp->cv);
     225    int width = caca_get_canvas_width(dp->cv);
     226    int height = caca_get_canvas_height(dp->cv);
    228227    int x, y;
    229228
     
    242241             * bright backgrounds, it's just fucked up. */
    243242#if 0
    244             uint8_t fgcolor = cucul_attr_to_ansi_fg(*cvattrs);
    245             uint8_t bgcolor = cucul_attr_to_ansi_bg(*cvattrs);
     243            uint8_t fgcolor = caca_attr_to_ansi_fg(*cvattrs);
     244            uint8_t bgcolor = caca_attr_to_ansi_bg(*cvattrs);
    246245
    247246            if(fgcolor >= 0x10)
    248                 fgcolor = CUCUL_LIGHTGRAY;
     247                fgcolor = CACA_LIGHTGRAY;
    249248
    250249            if(bgcolor >= 0x10)
    251                 bgcolor = CUCUL_BLACK; /* FIXME: handle transparency */
     250                bgcolor = CACA_BLACK; /* FIXME: handle transparency */
    252251
    253252            if(fgcolor == bgcolor)
    254253            {
    255                 if(fgcolor == CUCUL_BLACK)
    256                     fgcolor = CUCUL_WHITE;
    257                 else if(fgcolor == CUCUL_WHITE
    258                          || fgcolor <= CUCUL_LIGHTGRAY)
    259                     fgcolor = CUCUL_BLACK;
     254                if(fgcolor == CACA_BLACK)
     255                    fgcolor = CACA_WHITE;
     256                else if(fgcolor == CACA_WHITE
     257                         || fgcolor <= CACA_LIGHTGRAY)
     258                    fgcolor = CACA_BLACK;
    260259                else
    261                     fgcolor = CUCUL_WHITE;
     260                    fgcolor = CACA_WHITE;
    262261                SLsmg_set_color(slang_assoc[fgcolor + 16 * bgcolor]);
    263262                SLsmg_write_char(' ');
     
    267266#endif
    268267            {
    269                 SLsmg_set_color(slang_assoc[cucul_attr_to_ansi(*cvattrs++)]);
     268                SLsmg_set_color(slang_assoc[caca_attr_to_ansi(*cvattrs++)]);
    270269                slang_write_utf32(ch);
    271270            }
    272271#else
    273             SLsmg_set_color(cucul_attr_to_ansi(*cvattrs++));
     272            SLsmg_set_color(caca_attr_to_ansi(*cvattrs++));
    274273            slang_write_utf32(ch);
    275274#endif
    276275        }
    277276    }
    278     SLsmg_gotorc(cucul_get_cursor_y(dp->cv), cucul_get_cursor_x(dp->cv));
     277    SLsmg_gotorc(caca_get_cursor_y(dp->cv), caca_get_cursor_x(dp->cv));
    279278    SLsmg_refresh();
    280279}
     
    286285    dp->resize.h = SLtt_Screen_Rows;
    287286
    288     if(dp->resize.w != cucul_get_canvas_width(dp->cv)
    289         || dp->resize.h != cucul_get_canvas_height(dp->cv))
     287    if(dp->resize.w != caca_get_canvas_width(dp->cv)
     288        || dp->resize.h != caca_get_canvas_height(dp->cv))
    290289        SLsmg_reinit_smg();
    291290}
     
    343342
    344343        utf8[i] = '\0';
    345         utf32 = cucul_utf8_to_utf32(utf8, &bytes);
     344        utf32 = caca_utf8_to_utf32(utf8, &bytes);
    346345
    347346        while(i > bytes)
     
    483482#endif
    484483
    485     if(ch == CUCUL_MAGIC_FULLWIDTH)
     484    if(ch == CACA_MAGIC_FULLWIDTH)
    486485        return;
    487486
    488487#ifdef HAVE_SLSMG_UTF8_ENABLE
    489     bytes = cucul_utf32_to_utf8(buf, ch);
     488    bytes = caca_utf32_to_utf8(buf, ch);
    490489    buf[bytes] = '\0';
    491490    SLsmg_write_string(buf);
    492491#else
    493     ascii = cucul_utf32_to_ascii(ch);
     492    ascii = caca_utf32_to_ascii(ch);
    494493    SLsmg_write_char(ascii);
    495     if(cucul_utf32_is_fullwidth(ch))
     494    if(caca_utf32_is_fullwidth(ch))
    496495        SLsmg_write_char(ascii);
    497496#endif
  • libcaca/trunk/caca/driver_vga.c

    r2305 r2821  
    2121#if defined(USE_VGA)
    2222
    23 #include "cucul.h"
    2423#include "caca.h"
    2524#include "caca_internals.h"
     
    7675    /* We don't have much choice */
    7776    dp->resize.allow = 1;
    78     cucul_set_canvas_size(dp->cv, 80, 25);
     77    caca_set_canvas_size(dp->cv, 80, 25);
    7978    dp->resize.allow = 0;
    8079
     
    117116{
    118117    char *screen = (char *)(intptr_t)0x000b8000;
    119     uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
    120     uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
    121     int width = cucul_get_canvas_width(dp->cv);
    122     int height = cucul_get_canvas_height(dp->cv);
     118    uint32_t const *cvchars = (uint32_t const *)caca_get_canvas_chars(dp->cv);
     119    uint32_t const *cvattrs = (uint32_t const *)caca_get_canvas_attrs(dp->cv);
     120    int width = caca_get_canvas_width(dp->cv);
     121    int height = caca_get_canvas_height(dp->cv);
    123122    int n;
    124123
    125124    for(n = height * width; n--; )
    126125    {
    127         char ch = cucul_utf32_to_cp437(*cvchars++);
    128         if(n && *cvchars == CUCUL_MAGIC_FULLWIDTH)
     126        char ch = caca_utf32_to_cp437(*cvchars++);
     127        if(n && *cvchars == CACA_MAGIC_FULLWIDTH)
    129128        {
    130129            *screen++ = '[';
    131             *screen++ = cucul_attr_to_ansi(*cvattrs++);
     130            *screen++ = caca_attr_to_ansi(*cvattrs++);
    132131            ch = ']';
    133132            cvchars++;
     
    135134        }
    136135        *screen++ = ch;
    137         *screen++ = cucul_attr_to_ansi(*cvattrs++);
     136        *screen++ = caca_attr_to_ansi(*cvattrs++);
    138137    }
    139138}
     
    142141{
    143142    /* We know nothing about our window */
    144     dp->resize.w = cucul_get_canvas_width(dp->cv);
    145     dp->resize.h = cucul_get_canvas_height(dp->cv);
     143    dp->resize.w = caca_get_canvas_width(dp->cv);
     144    dp->resize.h = caca_get_canvas_height(dp->cv);
    146145}
    147146
  • libcaca/trunk/caca/driver_win32.c

    r2305 r2821  
    2626#include <stdio.h>
    2727
    28 #include "cucul.h"
    2928#include "caca.h"
    3029#include "caca_internals.h"
     
    8382static int win32_init_graphics(caca_display_t *dp)
    8483{
    85     int width = cucul_get_canvas_width(dp->cv);
    86     int height = cucul_get_canvas_height(dp->cv);
     84    int width = caca_get_canvas_width(dp->cv);
     85    int height = caca_get_canvas_height(dp->cv);
    8786    CONSOLE_SCREEN_BUFFER_INFO csbi;
    8887    SMALL_RECT rect;
     
    123122    SetConsoleWindowInfo(dp->drv.p->screen, TRUE, &rect);
    124123
    125     /* Report our new size to libcucul */
     124    /* Report our new size to libcaca */
    126125    if(!GetConsoleScreenBufferInfo(dp->drv.p->screen, &csbi))
    127126        return -1;
    128127
    129128    dp->resize.allow = 1;
    130     cucul_set_canvas_size(dp->cv,
     129    caca_set_canvas_size(dp->cv,
    131130                          csbi.srWindow.Right - csbi.srWindow.Left + 1,
    132131                          csbi.srWindow.Bottom - csbi.srWindow.Top + 1);
    133     width = cucul_get_canvas_width(dp->cv);
    134     height = cucul_get_canvas_height(dp->cv);
     132    width = caca_get_canvas_width(dp->cv);
     133    height = caca_get_canvas_height(dp->cv);
    135134    dp->resize.allow = 0;
    136135
     
    181180
    182181    /* Fallback to a 6x10 font */
    183     return cucul_get_canvas_width(dp->cv) * 6;
     182    return caca_get_canvas_width(dp->cv) * 6;
    184183}
    185184
     
    189188
    190189    /* Fallback to a 6x10 font */
    191     return cucul_get_canvas_height(dp->cv) * 10;
     190    return caca_get_canvas_height(dp->cv) * 10;
    192191}
    193192
     
    197196    SMALL_RECT rect;
    198197    CHAR_INFO *buffer = dp->drv.p->buffer;
    199     uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
    200     uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
    201     int width = cucul_get_canvas_width(dp->cv);
    202     int height = cucul_get_canvas_height(dp->cv);
     198    uint32_t const *cvchars = (uint32_t const *)caca_get_canvas_chars(dp->cv);
     199    uint32_t const *cvattrs = (uint32_t const *)caca_get_canvas_attrs(dp->cv);
     200    int width = caca_get_canvas_width(dp->cv);
     201    int height = caca_get_canvas_height(dp->cv);
    203202    int n;
    204203
     
    207206    {
    208207        uint32_t ch = *cvchars++;
    209         uint8_t fg = cucul_attr_to_ansi_fg(*cvattrs);
    210         uint8_t bg = cucul_attr_to_ansi_bg(*cvattrs);
     208        uint8_t fg = caca_attr_to_ansi_fg(*cvattrs);
     209        uint8_t bg = caca_attr_to_ansi_bg(*cvattrs);
    211210
    212211#if 0
     
    216215            dp->drv.p->buffer[i].Char.AsciiChar = ' ';
    217216#else
    218         if(n && *cvchars == CUCUL_MAGIC_FULLWIDTH)
     217        if(n && *cvchars == CACA_MAGIC_FULLWIDTH)
    219218            ;
    220219        else if(ch > 0x00000020 && ch < 0x00010000)
     
    224223#endif
    225224
    226         buffer->Attributes = win32_fg_palette[fg < 0x10 ? fg : CUCUL_LIGHTGRAY]
    227                               | win32_bg_palette[bg < 0x10 ? bg : CUCUL_BLACK];
     225        buffer->Attributes = win32_fg_palette[fg < 0x10 ? fg : CACA_LIGHTGRAY]
     226                              | win32_bg_palette[bg < 0x10 ? bg : CACA_BLACK];
    228227        cvattrs++;
    229228        buffer++;
     
    247246{
    248247    /* FIXME: I don't know what to do here. */
    249     dp->resize.w = cucul_get_canvas_width(dp->cv);
    250     dp->resize.h = cucul_get_canvas_height(dp->cv);
     248    dp->resize.w = caca_get_canvas_width(dp->cv);
     249    dp->resize.h = caca_get_canvas_height(dp->cv);
    251250}
    252251
  • libcaca/trunk/caca/driver_x11.c

    r2305 r2821  
    3333#include <string.h>
    3434
    35 #include "cucul.h"
     35#include "caca.h"
    3636#include "caca.h"
    3737#include "caca_internals.h"
     
    7676    char const *fonts[] = { NULL, "8x13bold", "fixed" }, **parser;
    7777    char const *geometry;
    78     int width = cucul_get_canvas_width(dp->cv);
    79     int height = cucul_get_canvas_height(dp->cv);
     78    int width = caca_get_canvas_width(dp->cv);
     79    int height = caca_get_canvas_height(dp->cv);
    8080    int i;
    8181
     
    8989
    9090    dp->resize.allow = 1;
    91     cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32);
    92     width = cucul_get_canvas_width(dp->cv);
    93     height = cucul_get_canvas_height(dp->cv);
     91    caca_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32);
     92    width = caca_get_canvas_width(dp->cv);
     93    height = caca_get_canvas_height(dp->cv);
    9494    dp->resize.allow = 0;
    9595
     
    280280static int x11_get_display_width(caca_display_t const *dp)
    281281{
    282     return cucul_get_canvas_width(dp->cv) * dp->drv.p->font_width;
     282    return caca_get_canvas_width(dp->cv) * dp->drv.p->font_width;
    283283}
    284284
    285285static int x11_get_display_height(caca_display_t const *dp)
    286286{
    287     return cucul_get_canvas_height(dp->cv) * dp->drv.p->font_height;
     287    return caca_get_canvas_height(dp->cv) * dp->drv.p->font_height;
    288288}
    289289
    290290static void x11_display(caca_display_t *dp)
    291291{
    292     uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
    293     uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
    294     int width = cucul_get_canvas_width(dp->cv);
    295     int height = cucul_get_canvas_height(dp->cv);
     292    uint32_t const *cvchars = (uint32_t const *)caca_get_canvas_chars(dp->cv);
     293    uint32_t const *cvattrs = (uint32_t const *)caca_get_canvas_attrs(dp->cv);
     294    int width = caca_get_canvas_width(dp->cv);
     295    int height = caca_get_canvas_height(dp->cv);
    296296    int x, y, len;
    297297
     
    303303        {
    304304            uint32_t const *attrs = cvattrs + x + y * width;
    305             uint16_t bg = cucul_attr_to_rgb12_bg(*attrs);
     305            uint16_t bg = caca_attr_to_rgb12_bg(*attrs);
    306306
    307307            len = 1;
    308308            while(x + len < width
    309                    && cucul_attr_to_rgb12_bg(attrs[len]) == bg)
     309                   && caca_attr_to_rgb12_bg(attrs[len]) == bg)
    310310                len++;
    311311
     
    331331        {
    332332            XSetForeground(dp->drv.p->dpy, dp->drv.p->gc,
    333                            dp->drv.p->colors[cucul_attr_to_rgb12_fg(*attrs)]);
     333                           dp->drv.p->colors[caca_attr_to_rgb12_fg(*attrs)]);
    334334
    335335            x11_put_glyph(dp, x * dp->drv.p->font_width,
     
    345345        XSetForeground(dp->drv.p->dpy, dp->drv.p->gc,
    346346                       dp->drv.p->colors[0xfff]);
    347         x = cucul_get_cursor_x(dp->cv);
    348         y = cucul_get_cursor_y(dp->cv);
     347        x = caca_get_cursor_x(dp->cv);
     348        y = caca_get_cursor_y(dp->cv);
    349349        XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap, dp->drv.p->gc,
    350350                       x * dp->drv.p->font_width, y * dp->drv.p->font_height,
     
    379379static int x11_get_event(caca_display_t *dp, caca_privevent_t *ev)
    380380{
    381     int width = cucul_get_canvas_width(dp->cv);
    382     int height = cucul_get_canvas_height(dp->cv);
     381    int width = caca_get_canvas_width(dp->cv);
     382    int height = caca_get_canvas_height(dp->cv);
    383383    XEvent xevent;
    384384    char key;
     
    611611
    612612    /* Underline */
    613     if(attr & CUCUL_UNDERLINE)
     613    if(attr & CACA_UNDERLINE)
    614614        XFillRectangle(dpy, px, gc, x, y + h - 1, w, 1);
    615615
     
    618618        return;
    619619
    620     if(ch == CUCUL_MAGIC_FULLWIDTH)
     620    if(ch == CACA_MAGIC_FULLWIDTH)
    621621        return;
    622622
    623623    fw = w;
    624     if(cucul_utf32_is_fullwidth(ch))
     624    if(caca_utf32_is_fullwidth(ch))
    625625        fw *= 2;
    626626
    627627    /* We want to be able to print a few special Unicode characters
    628628     * such as the CP437 gradients and half blocks. For unknown
    629      * characters, print what cucul_utf32_to_ascii() returns. */
     629     * characters, print what caca_utf32_to_ascii() returns. */
    630630
    631631    if(ch >= 0x2500 && ch <= 0x256c && udlr[ch - 0x2500])
     
    772772    {
    773773        ch16.byte1 = 0;
    774         ch16.byte2 = cucul_utf32_to_ascii(ch);
     774        ch16.byte2 = caca_utf32_to_ascii(ch);
    775775    }
    776776
  • libcaca/trunk/caca/event.c

    r2305 r2821  
    2424#endif
    2525
    26 #include "cucul.h"
    2726#include "caca.h"
    2827#include "caca_internals.h"
     
    130129int caca_get_mouse_x(caca_display_t const *dp)
    131130{
    132     int width = cucul_get_canvas_width(dp->cv);
     131    int width = caca_get_canvas_width(dp->cv);
    133132
    134133    if(dp->mouse.x >= width)
     
    152151int caca_get_mouse_y(caca_display_t const *dp)
    153152{
    154     int height = cucul_get_canvas_height(dp->cv);
     153    int height = caca_get_canvas_height(dp->cv);
    155154
    156155    if(dp->mouse.y >= height)
     
    336335        _caca_handle_resize(dp);
    337336        ev->type = CACA_EVENT_RESIZE;
    338         ev->data.resize.w = cucul_get_canvas_width(dp->cv);
    339         ev->data.resize.h = cucul_get_canvas_height(dp->cv);
     337        ev->data.resize.w = caca_get_canvas_width(dp->cv);
     338        ev->data.resize.h = caca_get_canvas_height(dp->cv);
    340339        return 1;
    341340    }
  • libcaca/trunk/caca/export.c

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
    44 *                2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
     
    2626#endif
    2727
    28 #include "cucul.h"
    29 #include "cucul_internals.h"
     28#include "caca.h"
     29#include "caca_internals.h"
    3030
    3131static inline int sprintu32(char *s, uint32_t x)
     
    4545}
    4646
    47 static void *export_caca(cucul_canvas_t const *, size_t *);
    48 static void *export_ansi(cucul_canvas_t const *, size_t *);
    49 static void *export_utf8(cucul_canvas_t const *, size_t *, int);
    50 static void *export_html(cucul_canvas_t const *, size_t *);
    51 static void *export_html3(cucul_canvas_t const *, size_t *);
    52 static void *export_bbfr(cucul_canvas_t const *, size_t *);
    53 static void *export_irc(cucul_canvas_t const *, size_t *);
    54 static void *export_ps(cucul_canvas_t const *, size_t *);
    55 static void *export_svg(cucul_canvas_t const *, size_t *);
    56 static void *export_tga(cucul_canvas_t const *, size_t *);
     47static void *export_caca(caca_canvas_t const *, size_t *);
     48static void *export_ansi(caca_canvas_t const *, size_t *);
     49static void *export_utf8(caca_canvas_t const *, size_t *, int);
     50static void *export_html(caca_canvas_t const *, size_t *);
     51static void *export_html3(caca_canvas_t const *, size_t *);
     52static void *export_bbfr(caca_canvas_t const *, size_t *);
     53static void *export_irc(caca_canvas_t const *, size_t *);
     54static void *export_ps(caca_canvas_t const *, size_t *);
     55static void *export_svg(caca_canvas_t const *, size_t *);
     56static void *export_tga(caca_canvas_t const *, size_t *);
    5757
    5858/** \brief Export a canvas into a foreign format.
    5959 *
    60  *  This function exports a libcucul canvas into various foreign formats such
     60 *  This function exports a libcaca canvas into various foreign formats such
    6161 *  as ANSI art, HTML, IRC colours, etc. The returned pointer should be passed
    6262 *  to free() to release the allocated storage when it is no longer needed.
     
    7777 *  - \c ENOMEM Not enough memory to allocate output buffer.
    7878 *
    79  *  \param cv A libcucul canvas
     79 *  \param cv A libcaca canvas
    8080 *  \param format A string describing the requested output format.
    8181 *  \param bytes A pointer to a size_t where the number of allocated bytes
     
    8383 *  \return A pointer to the exported memory area, or NULL in case of error.
    8484 */
    85 void *cucul_export_memory(cucul_canvas_t const *cv, char const *format,
     85void *caca_export_memory(caca_canvas_t const *cv, char const *format,
    8686                          size_t *bytes)
    8787{
     
    127127 *  Return a list of available export formats. The list is a NULL-terminated
    128128 *  array of strings, interleaving a string containing the internal value for
    129  *  the export format, to be used with cucul_export_memory(), and a string
     129 *  the export format, to be used with caca_export_memory(), and a string
    130130 *  containing the natural language description for that export format.
    131131 *
     
    134134 *  \return An array of strings.
    135135 */
    136 char const * const * cucul_get_export_list(void)
     136char const * const * caca_get_export_list(void)
    137137{
    138138    static char const * const list[] =
     
    160160
    161161/* Generate a native libcaca canvas file. */
    162 static void *export_caca(cucul_canvas_t const *cv, size_t *bytes)
     162static void *export_caca(caca_canvas_t const *cv, size_t *bytes)
    163163{
    164164    char *data, *cur;
     
    213213
    214214/* Generate UTF-8 representation of current canvas. */
    215 static void *export_utf8(cucul_canvas_t const *cv, size_t *bytes,
     215static void *export_utf8(caca_canvas_t const *cv, size_t *bytes,
    216216                         int cr)
    217217{
     
    245245            uint8_t ansifg, ansibg, fg, bg;
    246246
    247             if(ch == CUCUL_MAGIC_FULLWIDTH)
     247            if(ch == CACA_MAGIC_FULLWIDTH)
    248248                continue;
    249249
    250             ansifg = cucul_attr_to_ansi_fg(attr);
    251             ansibg = cucul_attr_to_ansi_bg(attr);
     250            ansifg = caca_attr_to_ansi_fg(attr);
     251            ansibg = caca_attr_to_ansi_bg(attr);
    252252
    253253            fg = ansifg < 0x10 ? palette[ansifg] : 0x10;
     
    272272            }
    273273
    274             cur += cucul_utf32_to_utf8(cur, ch);
     274            cur += caca_utf32_to_utf8(cur, ch);
    275275
    276276            prevfg = fg;
     
    294294
    295295/* Generate ANSI representation of current canvas. */
    296 static void *export_ansi(cucul_canvas_t const *cv, size_t *bytes)
     296static void *export_ansi(caca_canvas_t const *cv, size_t *bytes)
    297297{
    298298    static uint8_t const palette[] =
     
    321321        for(x = 0; x < cv->width; x++)
    322322        {
    323             uint8_t ansifg = cucul_attr_to_ansi_fg(lineattr[x]);
    324             uint8_t ansibg = cucul_attr_to_ansi_bg(lineattr[x]);
    325             uint8_t fg = ansifg < 0x10 ? palette[ansifg] : CUCUL_LIGHTGRAY;
    326             uint8_t bg = ansibg < 0x10 ? palette[ansibg] : CUCUL_BLACK;
     323            uint8_t ansifg = caca_attr_to_ansi_fg(lineattr[x]);
     324            uint8_t ansibg = caca_attr_to_ansi_bg(lineattr[x]);
     325            uint8_t fg = ansifg < 0x10 ? palette[ansifg] : CACA_LIGHTGRAY;
     326            uint8_t bg = ansibg < 0x10 ? palette[ansibg] : CACA_BLACK;
    327327            uint32_t ch = linechar[x];
    328328
    329             if(ch == CUCUL_MAGIC_FULLWIDTH)
     329            if(ch == CACA_MAGIC_FULLWIDTH)
    330330                ch = '?';
    331331
     
    346346            }
    347347
    348             *cur++ = cucul_utf32_to_cp437(ch);
     348            *cur++ = caca_utf32_to_cp437(ch);
    349349
    350350            prevfg = fg;
     
    374374
    375375/* Generate HTML representation of current canvas. */
    376 static void *export_html(cucul_canvas_t const *cv, size_t *bytes)
     376static void *export_html(caca_canvas_t const *cv, size_t *bytes)
    377377{
    378378    char *data, *cur;
     
    391391    cur += sprintf(cur, "<html><head>\n");
    392392    cur += sprintf(cur, "<title>Generated by libcaca %s</title>\n",
    393                         cucul_get_version());
     393                        caca_get_version());
    394394    cur += sprintf(cur, "</head><body>\n");
    395395
     
    405405        {
    406406            cur += sprintf(cur, "<span style=\"");
    407             if(cucul_attr_to_ansi_fg(lineattr[x]) < 0x10)
     407            if(caca_attr_to_ansi_fg(lineattr[x]) < 0x10)
    408408                cur += sprintf(cur, ";color:#%.03x",
    409                                cucul_attr_to_rgb12_fg(lineattr[x]));
    410             if(cucul_attr_to_ansi_bg(lineattr[x]) < 0x10)
     409                               caca_attr_to_rgb12_fg(lineattr[x]));
     410            if(caca_attr_to_ansi_bg(lineattr[x]) < 0x10)
    411411                cur += sprintf(cur, ";background-color:#%.03x",
    412                                cucul_attr_to_rgb12_bg(lineattr[x]));
    413             if(lineattr[x] & CUCUL_BOLD)
     412                               caca_attr_to_rgb12_bg(lineattr[x]));
     413            if(lineattr[x] & CACA_BOLD)
    414414                cur += sprintf(cur, ";font-weight:bold");
    415             if(lineattr[x] & CUCUL_ITALICS)
     415            if(lineattr[x] & CACA_ITALICS)
    416416                cur += sprintf(cur, ";font-style:italic");
    417             if(lineattr[x] & CUCUL_UNDERLINE)
     417            if(lineattr[x] & CACA_UNDERLINE)
    418418                cur += sprintf(cur, ";text-decoration:underline");
    419             if(lineattr[x] & CUCUL_BLINK)
     419            if(lineattr[x] & CACA_BLINK)
    420420                cur += sprintf(cur, ";text-decoration:blink");
    421421            cur += sprintf(cur, "\">");
     
    425425                len++)
    426426            {
    427                 if(linechar[x + len] == CUCUL_MAGIC_FULLWIDTH)
     427                if(linechar[x + len] == CACA_MAGIC_FULLWIDTH)
    428428                    ;
    429429                else if(linechar[x + len] <= 0x00000020)
     
    456456 * will not work under gecko (mozilla rendering engine) unless you set a
    457457 * correct header. */
    458 static void *export_html3(cucul_canvas_t const *cv, size_t *bytes)
     458static void *export_html3(caca_canvas_t const *cv, size_t *bytes)
    459459{
    460460    char *data, *cur;
     
    493493            cur += sprintf(cur, "<td");
    494494
    495             if(cucul_attr_to_ansi_fg(lineattr[x]) < 0x10)
     495            if(caca_attr_to_ansi_fg(lineattr[x]) < 0x10)
    496496                cur += sprintf(cur, " bgcolor=#%.06lx", (unsigned long int)
    497                                _cucul_attr_to_rgb24bg(lineattr[x]));
     497                               _caca_attr_to_rgb24bg(lineattr[x]));
    498498
    499499            if(len > 1)
     
    502502            cur += sprintf(cur, ">");
    503503
    504             needfont = cucul_attr_to_ansi_bg(lineattr[x]) < 0x10;
     504            needfont = caca_attr_to_ansi_bg(lineattr[x]) < 0x10;
    505505
    506506            if(needfont)
    507507                cur += sprintf(cur, "<font color=#%.06lx>", (unsigned long int)
    508                                _cucul_attr_to_rgb24fg(lineattr[x]));
    509 
    510             if(lineattr[x] & CUCUL_BOLD)
     508                               _caca_attr_to_rgb24fg(lineattr[x]));
     509
     510            if(lineattr[x] & CACA_BOLD)
    511511                cur += sprintf(cur, "<b>");
    512             if(lineattr[x] & CUCUL_ITALICS)
     512            if(lineattr[x] & CACA_ITALICS)
    513513                cur += sprintf(cur, "<i>");
    514             if(lineattr[x] & CUCUL_UNDERLINE)
     514            if(lineattr[x] & CACA_UNDERLINE)
    515515                cur += sprintf(cur, "<u>");
    516             if(lineattr[x] & CUCUL_BLINK)
     516            if(lineattr[x] & CACA_BLINK)
    517517                cur += sprintf(cur, "<blink>");
    518518
    519519            for(i = 0; i < len; i++)
    520520            {
    521                 if(linechar[x + i] == CUCUL_MAGIC_FULLWIDTH)
     521                if(linechar[x + i] == CACA_MAGIC_FULLWIDTH)
    522522                    ;
    523523                else if(linechar[x + i] <= 0x00000020)
     
    529529            }
    530530
    531             if(lineattr[x] & CUCUL_BLINK)
     531            if(lineattr[x] & CACA_BLINK)
    532532                cur += sprintf(cur, "</blink>");
    533             if(lineattr[x] & CUCUL_UNDERLINE)
     533            if(lineattr[x] & CACA_UNDERLINE)
    534534                cur += sprintf(cur, "</u>");
    535             if(lineattr[x] & CUCUL_ITALICS)
     535            if(lineattr[x] & CACA_ITALICS)
    536536                cur += sprintf(cur, "</i>");
    537             if(lineattr[x] & CUCUL_BOLD)
     537            if(lineattr[x] & CACA_BOLD)
    538538                cur += sprintf(cur, "</b>");
    539539
     
    557557}
    558558
    559 static void *export_bbfr(cucul_canvas_t const *cv, size_t *bytes)
     559static void *export_bbfr(caca_canvas_t const *cv, size_t *bytes)
    560560{
    561561    char *data, *cur;
     
    595595                    len++;
    596596
    597             needback = cucul_attr_to_ansi_bg(lineattr[x]) < 0x10;
    598             needfront = cucul_attr_to_ansi_fg(lineattr[x]) < 0x10;
     597            needback = caca_attr_to_ansi_bg(lineattr[x]) < 0x10;
     598            needfront = caca_attr_to_ansi_fg(lineattr[x]) < 0x10;
    599599
    600600            if(needback)
    601601                cur += sprintf(cur, "[f=#%.06lx]", (unsigned long int)
    602                                _cucul_attr_to_rgb24bg(lineattr[x]));
     602                               _caca_attr_to_rgb24bg(lineattr[x]));
    603603
    604604            if(linechar[x] == ' ')
    605605                cur += sprintf(cur, "[c=#%.06lx]", (unsigned long int)
    606                                _cucul_attr_to_rgb24bg(lineattr[x]));
     606                               _caca_attr_to_rgb24bg(lineattr[x]));
    607607            else if(needfront)
    608608                cur += sprintf(cur, "[c=#%.06lx]", (unsigned long int)
    609                                _cucul_attr_to_rgb24fg(lineattr[x]));
    610 
    611             if(lineattr[x] & CUCUL_BOLD)
     609                               _caca_attr_to_rgb24fg(lineattr[x]));
     610
     611            if(lineattr[x] & CACA_BOLD)
    612612                cur += sprintf(cur, "[g]");
    613             if(lineattr[x] & CUCUL_ITALICS)
     613            if(lineattr[x] & CACA_ITALICS)
    614614                cur += sprintf(cur, "[i]");
    615             if(lineattr[x] & CUCUL_UNDERLINE)
     615            if(lineattr[x] & CACA_UNDERLINE)
    616616                cur += sprintf(cur, "[s]");
    617             if(lineattr[x] & CUCUL_BLINK)
     617            if(lineattr[x] & CACA_BLINK)
    618618                ; /* FIXME */
    619619
    620620            for(i = 0; i < len; i++)
    621621            {
    622                 if(linechar[x + i] == CUCUL_MAGIC_FULLWIDTH)
     622                if(linechar[x + i] == CACA_MAGIC_FULLWIDTH)
    623623                    ;
    624624                else if(linechar[x + i] == ' ')
    625625                    *cur++ = '_';
    626626                else
    627                     cur += cucul_utf32_to_utf8(cur, linechar[x + i]);
     627                    cur += caca_utf32_to_utf8(cur, linechar[x + i]);
    628628            }
    629629
    630             if(lineattr[x] & CUCUL_BLINK)
     630            if(lineattr[x] & CACA_BLINK)
    631631                ; /* FIXME */
    632             if(lineattr[x] & CUCUL_UNDERLINE)
     632            if(lineattr[x] & CACA_UNDERLINE)
    633633                cur += sprintf(cur, "[/s]");
    634             if(lineattr[x] & CUCUL_ITALICS)
     634            if(lineattr[x] & CACA_ITALICS)
    635635                cur += sprintf(cur, "[/i]");
    636             if(lineattr[x] & CUCUL_BOLD)
     636            if(lineattr[x] & CACA_BOLD)
    637637                cur += sprintf(cur, "[/g]");
    638638
     
    658658
    659659/* Export a text file with IRC colours */
    660 static void *export_irc(cucul_canvas_t const *cv, size_t *bytes)
     660static void *export_irc(caca_canvas_t const *cv, size_t *bytes)
    661661{
    662662    static uint8_t const palette[] =
     
    696696            uint8_t ansifg, ansibg, fg, bg;
    697697
    698             if(ch == CUCUL_MAGIC_FULLWIDTH)
     698            if(ch == CACA_MAGIC_FULLWIDTH)
    699699                continue;
    700700
    701             ansifg = cucul_attr_to_ansi_fg(attr);
    702             ansibg = cucul_attr_to_ansi_bg(attr);
     701            ansifg = caca_attr_to_ansi_fg(attr);
     702            ansibg = caca_attr_to_ansi_bg(attr);
    703703
    704704            fg = ansifg < 0x10 ? palette[ansifg] : 0x10;
     
    742742            }
    743743
    744             cur += cucul_utf32_to_utf8(cur, ch);
     744            cur += caca_utf32_to_utf8(cur, ch);
    745745            prevfg = fg;
    746746            prevbg = bg;
     
    765765
    766766/* Export a PostScript document. */
    767 static void *export_ps(cucul_canvas_t const *cv, size_t *bytes)
     767static void *export_ps(caca_canvas_t const *cv, size_t *bytes)
    768768{
    769769    static char const *ps_header =
     
    811811        {
    812812            uint8_t argb[8];
    813             cucul_attr_to_argb64(*lineattr++, argb);
     813            caca_attr_to_argb64(*lineattr++, argb);
    814814            cur += sprintf(cur, "1 0 translate\n %f %f %f csquare\n",
    815815                           (float)argb[1] * (1.0 / 0xf),
     
    835835            uint32_t ch = *linechar++;
    836836
    837             cucul_attr_to_argb64(*lineattr++, argb);
     837            caca_attr_to_argb64(*lineattr++, argb);
    838838
    839839            cur += sprintf(cur, "newpath\n");
     
    874874
    875875/* Export an SVG vector image */
    876 static void *export_svg(cucul_canvas_t const *cv, size_t *bytes)
     876static void *export_svg(caca_canvas_t const *cv, size_t *bytes)
    877877{
    878878    static char const svg_header[] =
     
    906906            cur += sprintf(cur, "<rect style=\"fill:#%.03x\" x=\"%d\" y=\"%d\""
    907907                                " width=\"6\" height=\"10\"/>\n",
    908                                 cucul_attr_to_rgb12_bg(*lineattr++),
     908                                caca_attr_to_rgb12_bg(*lineattr++),
    909909                                x * 6, y * 10);
    910910        }
     
    921921            uint32_t ch = *linechar++;
    922922
    923             if(ch == ' ' || ch == CUCUL_MAGIC_FULLWIDTH)
     923            if(ch == ' ' || ch == CACA_MAGIC_FULLWIDTH)
    924924            {
    925925                lineattr++;
     
    929929            cur += sprintf(cur, "<text style=\"fill:#%.03x\" "
    930930                                "x=\"%d\" y=\"%d\">",
    931                                 cucul_attr_to_rgb12_fg(*lineattr++),
     931                                caca_attr_to_rgb12_fg(*lineattr++),
    932932                                x * 6, (y * 10) + 8);
    933933
     
    935935                *cur++ = '?';
    936936            else if(ch > 0x0000007f)
    937                 cur += cucul_utf32_to_utf8(cur, ch);
     937                cur += caca_utf32_to_utf8(cur, ch);
    938938            else switch((uint8_t)ch)
    939939            {
     
    960960
    961961/* Export a TGA image */
    962 static void *export_tga(cucul_canvas_t const *cv, size_t *bytes)
     962static void *export_tga(caca_canvas_t const *cv, size_t *bytes)
    963963{
    964964    char const * const *fontlist;
    965965    char *data, *cur;
    966     cucul_font_t *f;
     966    caca_font_t *f;
    967967    int i, w, h;
    968968
    969     fontlist = cucul_get_font_list();
     969    fontlist = caca_get_font_list();
    970970    if(!fontlist[0])
    971971    {
     
    974974    }
    975975
    976     f = cucul_load_font(fontlist[0], 0);
    977 
    978     w = cucul_get_canvas_width(cv) * cucul_get_font_width(f);
    979     h = cucul_get_canvas_height(cv) * cucul_get_font_height(f);
     976    f = caca_load_font(fontlist[0], 0);
     977
     978    w = caca_get_canvas_width(cv) * caca_get_font_width(f);
     979    h = caca_get_canvas_height(cv) * caca_get_font_height(f);
    980980
    981981    *bytes = w * h * 4 + 18; /* 32 bpp + 18 bytes for the header */
     
    10031003
    10041004    /* Image Data */
    1005     cucul_render_canvas(cv, f, cur, w, h, 4 * w);
     1005    caca_render_canvas(cv, f, cur, w, h, 4 * w);
    10061006
    10071007    /* Swap bytes. What a waste of time. */
     
    10131013    }
    10141014
    1015     cucul_free_font(f);
     1015    caca_free_font(f);
    10161016
    10171017    return data;
  • libcaca/trunk/caca/figfont.c

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2006-2007 Sam Hocevar <sam@zoy.org>
    44 *                All Rights Reserved
     
    2929#endif
    3030
    31 #include "cucul.h"
    32 #include "cucul_internals.h"
    33 
    34 struct cucul_figfont
     31#include "caca.h"
     32#include "caca_internals.h"
     33
     34struct caca_figfont
    3535{
    3636    int term_width;
     
    4444    int print_direction, full_layout, codetag_count;
    4545    int glyphs;
    46     cucul_canvas_t *fontcv, *charcv;
     46    caca_canvas_t *fontcv, *charcv;
    4747    int *left, *right; /* Unused yet */
    4848    uint32_t *lookup;
     
    5050
    5151static uint32_t hsmush(uint32_t ch1, uint32_t ch2, int rule);
    52 static cucul_figfont_t * open_figfont(char const *);
    53 static int free_figfont(cucul_figfont_t *);
    54 
    55 int cucul_canvas_set_figfont(cucul_canvas_t *cv, char const *path)
    56 {
    57     cucul_figfont_t *ff = NULL;
     52static caca_figfont_t * open_figfont(char const *);
     53static int free_figfont(caca_figfont_t *);
     54
     55int caca_canvas_set_figfont(caca_canvas_t *cv, char const *path)
     56{
     57    caca_figfont_t *ff = NULL;
    5858
    5959    if(path)
     
    6666    if(cv->ff)
    6767    {
    68         cucul_free_canvas(cv->ff->charcv);
     68        caca_free_canvas(cv->ff->charcv);
    6969        free(cv->ff->left);
    7070        free(cv->ff->right);
     
    8585    ff->w = ff->h = 0;
    8686    ff->lines = 0;
    87     cucul_set_canvas_size(cv, 0, 0); /* XXX */
     87    caca_set_canvas_size(cv, 0, 0); /* XXX */
    8888
    8989    /* from TOIlet’s figlet.c */
     
    118118    }
    119119
    120     ff->charcv = cucul_create_canvas(ff->max_length - 2, ff->height);
     120    ff->charcv = caca_create_canvas(ff->max_length - 2, ff->height);
    121121
    122122    ff->left = malloc(ff->height * sizeof(int));
     
    128128}
    129129
    130 int cucul_put_figchar(cucul_canvas_t *cv, uint32_t ch)
    131 {
    132     cucul_figfont_t *ff = cv->ff;
     130int caca_put_figchar(caca_canvas_t *cv, uint32_t ch)
     131{
     132    caca_figfont_t *ff = cv->ff;
    133133    int c, w, h, x, y, overlap, extra, xleft, xright;
    134134
     
    155155    h = ff->height;
    156156
    157     cucul_set_canvas_handle(ff->fontcv, 0, c * ff->height);
    158     cucul_blit(ff->charcv, 0, 0, ff->fontcv, NULL);
     157    caca_set_canvas_handle(ff->fontcv, 0, c * ff->height);
     158    caca_blit(ff->charcv, 0, 0, ff->fontcv, NULL);
    159159
    160160    /* Check whether we reached the end of the screen */
     
    177177            /* Compute how much spaces we can eat from the new glyph */
    178178            for(xright = 0; xright < overlap; xright++)
    179                 if(cucul_get_char(ff->charcv, xright, y) != ' ')
     179                if(caca_get_char(ff->charcv, xright, y) != ' ')
    180180                    break;
    181181
    182182            /* Compute how much spaces we can eat from the previous glyph */
    183183            for(xleft = 0; xright + xleft < overlap && xleft < ff->x; xleft++)
    184                 if(cucul_get_char(cv, ff->x - 1 - xleft, ff->y + y) != ' ')
     184                if(caca_get_char(cv, ff->x - 1 - xleft, ff->y + y) != ' ')
    185185                    break;
    186186
     
    193193            {
    194194                if(xleft < ff->x &&
    195                     hsmush(cucul_get_char(cv, ff->x - 1 - xleft, ff->y + y),
    196                           cucul_get_char(ff->charcv, xright, y),
     195                    hsmush(caca_get_char(cv, ff->x - 1 - xleft, ff->y + y),
     196                          caca_get_char(ff->charcv, xright, y),
    197197                          ff->hsmushrule))
    198198                    xleft++;
     
    220220#if 0 /* deactivated for libcaca insertion */
    221221    if(attr)
    222         cucul_set_attr(cv, attr);
     222        caca_set_attr(cv, attr);
    223223#endif
    224     cucul_set_canvas_size(cv, ff->w, ff->h);
    225 
    226     /* Render our char (FIXME: create a rect-aware cucul_blit_canvas?) */
     224    caca_set_canvas_size(cv, ff->w, ff->h);
     225
     226    /* Render our char (FIXME: create a rect-aware caca_blit_canvas?) */
    227227    for(y = 0; y < h; y++)
    228228        for(x = 0; x < w; x++)
    229229    {
    230230        uint32_t ch1, ch2;
    231         //uint32_t tmpat = cucul_get_attr(ff->fontcv, x, y + c * ff->height);
    232         ch2 = cucul_get_char(ff->charcv, x, y);
     231        //uint32_t tmpat = caca_get_attr(ff->fontcv, x, y + c * ff->height);
     232        ch2 = caca_get_char(ff->charcv, x, y);
    233233        if(ch2 == ' ')
    234234            continue;
    235         ch1 = cucul_get_char(cv, ff->x + x - overlap, ff->y + y);
    236         /* FIXME: this could be changed to cucul_put_attr() when the
    237          * function is fixed in libcucul */
    238         //cucul_set_attr(cv, tmpat);
     235        ch1 = caca_get_char(cv, ff->x + x - overlap, ff->y + y);
     236        /* FIXME: this could be changed to caca_put_attr() when the
     237         * function is fixed in libcaca */
     238        //caca_set_attr(cv, tmpat);
    239239        if(ch1 == ' ' || ff->hmode != H_SMUSH)
    240             cucul_put_char(cv, ff->x + x - overlap, ff->y + y, ch2);
     240            caca_put_char(cv, ff->x + x - overlap, ff->y + y, ch2);
    241241        else
    242             cucul_put_char(cv, ff->x + x - overlap, ff->y + y,
     242            caca_put_char(cv, ff->x + x - overlap, ff->y + y,
    243243                           hsmush(ch1, ch2, ff->hsmushrule));
    244         //cucul_put_attr(cv, ff->x + x, ff->y + y, tmpat);
     244        //caca_put_attr(cv, ff->x + x, ff->y + y, tmpat);
    245245    }
    246246
     
    251251}
    252252
    253 int cucul_flush_figlet(cucul_canvas_t *cv)
    254 {
    255     cucul_figfont_t *ff = cv->ff;
     253int caca_flush_figlet(caca_canvas_t *cv)
     254{
     255    caca_figfont_t *ff = cv->ff;
    256256    int x, y;
    257257
    258258    //ff->torender = cv;
    259     //cucul_set_canvas_size(ff->torender, ff->w, ff->h);
    260     cucul_set_canvas_size(cv, ff->w, ff->h);
     259    //caca_set_canvas_size(ff->torender, ff->w, ff->h);
     260    caca_set_canvas_size(cv, ff->w, ff->h);
    261261
    262262    /* FIXME: do this somewhere else, or record hardblank positions */
    263263    for(y = 0; y < ff->h; y++)
    264264        for(x = 0; x < ff->w; x++)
    265             if(cucul_get_char(cv, x, y) == 0xa0)
    266             {
    267                 uint32_t attr = cucul_get_attr(cv, x, y);
    268                 cucul_put_char(cv, x, y, ' ');
    269                 cucul_put_attr(cv, x, y, attr);
     265            if(caca_get_char(cv, x, y) == 0xa0)
     266            {
     267                uint32_t attr = caca_get_attr(cv, x, y);
     268                caca_put_char(cv, x, y, ' ');
     269                caca_put_attr(cv, x, y, attr);
    270270            }
    271271
     
    273273    ff->w = ff->h = 0;
    274274
    275     //cv = cucul_create_canvas(1, 1); /* XXX */
     275    //cv = caca_create_canvas(1, 1); /* XXX */
    276276
    277277    /* from render.c */
    278     ff->lines += cucul_get_canvas_height(cv);
     278    ff->lines += caca_get_canvas_height(cv);
    279279
    280280    return 0;
     
    284284#define EXT_GLYPHS (STD_GLYPHS + 7)
    285285
    286 static cucul_figfont_t * open_figfont(char const *path)
     286static caca_figfont_t * open_figfont(char const *path)
    287287{
    288288    char altpath[2048];
    289289    char buf[2048];
    290290    char hardblank[10];
    291     cucul_figfont_t *ff;
     291    caca_figfont_t *ff;
    292292    char *data = NULL;
    293     cucul_file_t *f;
     293    caca_file_t *f;
    294294    int i, j, size, comment_lines;
    295295
    296     ff = malloc(sizeof(cucul_figfont_t));
     296    ff = malloc(sizeof(caca_figfont_t));
    297297    if(!ff)
    298298    {
     
    302302
    303303    /* Open font: if not found, try .tlf, then .flf */
    304     f = cucul_file_open(path, "r");
     304    f = caca_file_open(path, "r");
    305305#if !defined __KERNEL__ && defined HAVE_SNPRINTF
    306306
     
    313313        snprintf(altpath, 2047, "%s.tlf", path);
    314314        altpath[2047] = '\0';
    315         f = cucul_file_open(altpath, "r");
     315        f = caca_file_open(altpath, "r");
    316316    }
    317317    if(!f)
     
    319319        snprintf(altpath, 2047, "%s.flf", path);
    320320        altpath[2047] = '\0';
    321         f = cucul_file_open(altpath, "r");
     321        f = caca_file_open(altpath, "r");
    322322    }
    323323#endif
     
    333333    ff->full_layout = 0;
    334334    ff->codetag_count = 0;
    335     cucul_file_gets(f, buf, 2048);
     335    caca_file_gets(f, buf, 2048);
    336336    if(sscanf(buf, "%*[ft]lf2a%6s %u %u %u %i %u %u %u %u\n", hardblank,
    337337              &ff->height, &ff->baseline, &ff->max_length,
     
    340340    {
    341341        debug("figfont error: `%s' has invalid header: %s", path, buf);
    342         cucul_file_close(f);
     342        caca_file_close(f);
    343343        free(ff);
    344344        seterrno(EINVAL);
     
    352352        debug("figfont error: `%s' has invalid layout %i/%u",
    353353                path, ff->old_layout, ff->full_layout);
    354         cucul_file_close(f);
     354        caca_file_close(f);
    355355        free(ff);
    356356        seterrno(EINVAL);
     
    358358    }
    359359
    360     ff->hardblank = cucul_utf8_to_utf32(hardblank, NULL);
     360    ff->hardblank = caca_utf8_to_utf32(hardblank, NULL);
    361361
    362362    /* Skip comment lines */
    363363    for(i = 0; i < comment_lines; i++)
    364         cucul_file_gets(f, buf, 2048);
     364        caca_file_gets(f, buf, 2048);
    365365
    366366    /* Read mandatory characters (32-127, 196, 214, 220, 228, 246, 252, 223)
     
    369369    ff->lookup = NULL;
    370370
    371     for(i = 0, size = 0; !cucul_file_eof(f); ff->glyphs++)
     371    for(i = 0, size = 0; !caca_file_eof(f); ff->glyphs++)
    372372    {
    373373        if((ff->glyphs % 2048) == 0)
     
    386386        else
    387387        {
    388             if(cucul_file_gets(f, buf, 2048) == NULL)
     388            if(caca_file_gets(f, buf, 2048) == NULL)
    389389                break;
    390390
     
    397397            {
    398398                for(j = 0; j < ff->height; j++)
    399                     cucul_file_gets(f, buf, 2048);
     399                    caca_file_gets(f, buf, 2048);
    400400                continue;
    401401            }
     
    424424                data = realloc(data, size += 2048);
    425425
    426             cucul_file_gets(f, data + i, 2048);
     426            caca_file_gets(f, data + i, 2048);
    427427            i = (uintptr_t)strchr(data + i, 0) - (uintptr_t)data;
    428428        }
    429429    }
    430430
    431     cucul_file_close(f);
     431    caca_file_close(f);
    432432
    433433    if(ff->glyphs < EXT_GLYPHS)
     
    443443
    444444    /* Import buffer into canvas */
    445     ff->fontcv = cucul_create_canvas(0, 0);
    446     cucul_import_memory(ff->fontcv, data, i, "utf8");
     445    ff->fontcv = caca_create_canvas(0, 0);
     446    caca_import_memory(ff->fontcv, data, i, "utf8");
    447447    free(data);
    448448
     
    455455        for(i = ff->max_length; i--;)
    456456        {
    457             ch = cucul_get_char(ff->fontcv, i, j);
     457            ch = caca_get_char(ff->fontcv, i, j);
    458458
    459459            /* Replace hardblanks with U+00A0 NO-BREAK SPACE */
    460460            if(ch == ff->hardblank)
    461                 cucul_put_char(ff->fontcv, i, j, ch = 0xa0);
     461                caca_put_char(ff->fontcv, i, j, ch = 0xa0);
    462462
    463463            if(oldch && ch != oldch)
     
    467467            }
    468468            else if(oldch && ch == oldch)
    469                 cucul_put_char(ff->fontcv, i, j, ' ');
     469                caca_put_char(ff->fontcv, i, j, ' ');
    470470            else if(ch != ' ')
    471471            {
    472472                oldch = ch;
    473                 cucul_put_char(ff->fontcv, i, j, ' ');
     473                caca_put_char(ff->fontcv, i, j, ' ');
    474474            }
    475475        }
     
    479479}
    480480
    481 int free_figfont(cucul_figfont_t *ff)
    482 {
    483     cucul_free_canvas(ff->fontcv);
     481int free_figfont(caca_figfont_t *ff)
     482{
     483    caca_free_canvas(ff->fontcv);
    484484    free(ff->lookup);
    485485    free(ff);
  • libcaca/trunk/caca/file.c

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2006-2007 Sam Hocevar <sam@zoy.org>
    44 *                All Rights Reserved
     
    3030#endif
    3131
    32 #include "cucul.h"
    33 #include "cucul_internals.h"
     32#include "caca.h"
     33#include "caca_internals.h"
    3434
    3535#if !defined __KERNEL__ && defined HAVE_ZLIB_H
    36 static int zipread(cucul_file_t *, void *, unsigned int);
     36static int zipread(caca_file_t *, void *, unsigned int);
    3737#endif
    3838
    3939#if !defined __KERNEL__
    40 struct cucul_file
     40struct caca_file
    4141{
    4242#   if defined HAVE_ZLIB_H
     
    5151#endif
    5252
    53 cucul_file_t *cucul_file_open(char const *path, const char *mode)
     53caca_file_t *caca_file_open(char const *path, const char *mode)
    5454{
    5555#if defined __KERNEL__
     
    5757    return NULL;
    5858#else
    59     cucul_file_t *fp = malloc(sizeof(*fp));
     59    caca_file_t *fp = malloc(sizeof(*fp));
    6060
    6161    fp->readonly = !!strchr(mode, 'r');
     
    126126}
    127127
    128 int cucul_file_close(cucul_file_t *fp)
     128int caca_file_close(caca_file_t *fp)
    129129{
    130130#if defined __KERNEL__
     
    144144}
    145145
    146 uint64_t cucul_file_tell(cucul_file_t *fp)
     146uint64_t caca_file_tell(caca_file_t *fp)
    147147{
    148148#if defined __KERNEL__
     
    158158}
    159159
    160 size_t cucul_file_read(cucul_file_t *fp, void *ptr, size_t size)
     160size_t caca_file_read(caca_file_t *fp, void *ptr, size_t size)
    161161{
    162162#if defined __KERNEL__
     
    172172}
    173173
    174 size_t cucul_file_write(cucul_file_t *fp, const void *ptr, size_t size)
     174size_t caca_file_write(caca_file_t *fp, const void *ptr, size_t size)
    175175{
    176176#if defined __KERNEL__
     
    195195}
    196196
    197 char *cucul_file_gets(cucul_file_t *fp, char *s, int size)
     197char *caca_file_gets(caca_file_t *fp, char *s, int size)
    198198{
    199199#if defined __KERNEL__
     
    229229}
    230230
    231 int cucul_file_eof(cucul_file_t *fp)
     231int caca_file_eof(caca_file_t *fp)
    232232{
    233233#if defined __KERNEL__
     
    241241
    242242#if !defined __KERNEL__ && defined HAVE_ZLIB_H
    243 static int zipread(cucul_file_t *fp, void *buf, unsigned int len)
     243static int zipread(caca_file_t *fp, void *buf, unsigned int len)
    244244{
    245245    unsigned int total_read = 0;
  • libcaca/trunk/caca/font.c

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
    44 *                All Rights Reserved
     
    2828#endif
    2929
    30 #include "cucul.h"
    31 #include "cucul_internals.h"
     30#include "caca.h"
     31#include "caca_internals.h"
    3232
    3333/* Internal fonts */
     
    5656};
    5757
    58 struct cucul_font
     58struct caca_font
    5959{
    6060    struct font_header header;
     
    9292 *
    9393 *  This function loads a font and returns a handle to its internal
    94  *  structure. The handle can then be used with cucul_render_canvas()
     94 *  structure. The handle can then be used with caca_render_canvas()
    9595 *  for bitmap output.
    9696 *
     
    100100 *  If \c size is non-zero, the \c size bytes of memory at address \c data
    101101 *  are loaded as a font. This memory are must not be freed by the calling
    102  *  program until the font handle has been freed with cucul_free_font().
     102 *  program until the font handle has been freed with caca_free_font().
    103103 *
    104104 *  If an error occurs, NULL is returned and \b errno is set accordingly:
     
    111111 *  \return A font handle or NULL in case of error.
    112112 */
    113 cucul_font_t *cucul_load_font(void const *data, size_t size)
    114 {
    115     cucul_font_t *f;
     113caca_font_t *caca_load_font(void const *data, size_t size)
     114{
     115    caca_font_t *f;
    116116    int i;
    117117
     
    119119    {
    120120        if(!strcasecmp(data, "Monospace 9"))
    121             return cucul_load_font((char *)&mono9_data, mono9_size);
     121            return caca_load_font((char *)&mono9_data, mono9_size);
    122122        if(!strcasecmp(data, "Monospace Bold 12"))
    123             return cucul_load_font((char *)&monobold12_data, monobold12_size);
     123            return caca_load_font((char *)&monobold12_data, monobold12_size);
    124124
    125125        seterrno(ENOENT);
     
    135135    }
    136136
    137     f = malloc(sizeof(cucul_font_t));
     137    f = malloc(sizeof(caca_font_t));
    138138    if(!f)
    139139    {
     
    302302 *  \return An array of strings.
    303303 */
    304 char const * const * cucul_get_font_list(void)
     304char const * const * caca_get_font_list(void)
    305305{
    306306    static char const * const list[] =
     
    321321 *  This function never fails.
    322322 *
    323  *  \param f The font, as returned by cucul_load_font()
     323 *  \param f The font, as returned by caca_load_font()
    324324 *  \return The standard glyph width.
    325325 */
    326 int cucul_get_font_width(cucul_font_t const *f)
     326int caca_get_font_width(caca_font_t const *f)
    327327{
    328328    return f->header.width;
     
    336336 *  This function never fails.
    337337 *
    338  *  \param f The font, as returned by cucul_load_font()
     338 *  \param f The font, as returned by caca_load_font()
    339339 *  \return The standard glyph height.
    340340 */
    341 int cucul_get_font_height(cucul_font_t const *f)
     341int caca_get_font_height(caca_font_t const *f)
    342342{
    343343    return f->header.height;
     
    361361 *  This function never fails.
    362362 *
    363  *  \param f The font, as returned by cucul_load_font()
     363 *  \param f The font, as returned by caca_load_font()
    364364 *  \return The list of Unicode blocks supported by the font.
    365365 */
    366 uint32_t const *cucul_get_font_blocks(cucul_font_t const *f)
     366uint32_t const *caca_get_font_blocks(caca_font_t const *f)
    367367{
    368368    return (uint32_t const *)f->user_block_list;
     
    371371/** \brief Free a font structure.
    372372 *
    373  *  This function frees all data allocated by cucul_load_font(). The
    374  *  font structure is no longer usable by other libcucul functions. Once
     373 *  This function frees all data allocated by caca_load_font(). The
     374 *  font structure is no longer usable by other libcaca functions. Once
    375375 *  this function has returned, the memory area that was given to
    376  *  cucul_load_font() can be freed.
     376 *  caca_load_font() can be freed.
    377377 *
    378378 *  This function never fails.
    379379 *
    380  *  \param f The font, as returned by cucul_load_font()
     380 *  \param f The font, as returned by caca_load_font()
    381381 *  \return This function always returns 0.
    382382 */
    383 int cucul_free_font(cucul_font_t *f)
     383int caca_free_font(caca_font_t *f)
    384384{
    385385    free(f->glyph_list);
     
    397397 *
    398398 *  The required image width can be computed using
    399  *  cucul_get_canvas_width() and cucul_get_font_width(). The required
    400  *  height can be computed using cucul_get_canvas_height() and
    401  *  cucul_get_font_height().
     399 *  caca_get_canvas_width() and caca_get_font_width(). The required
     400 *  height can be computed using caca_get_canvas_height() and
     401 *  caca_get_font_height().
    402402 *
    403403 *  Glyphs that do not fit in the image buffer are currently not rendered at
     
    408408 *
    409409 *  \param cv The canvas to render
    410  *  \param f The font, as returned by cucul_load_font()
     410 *  \param f The font, as returned by caca_load_font()
    411411 *  \param buf The image buffer
    412412 *  \param width The width (in pixels) of the image buffer
     
    415415 *  \return 0 in case of success, -1 if an error occurred.
    416416 */
    417 int cucul_render_canvas(cucul_canvas_t const *cv, cucul_font_t const *f,
     417int caca_render_canvas(caca_canvas_t const *cv, caca_font_t const *f,
    418418                        void *buf, int width, int height, int pitch)
    419419{
     
    472472                                + ch - f->block_list[b].start];
    473473
    474             cucul_attr_to_argb64(attr, argb);
     474            caca_attr_to_argb64(attr, argb);
    475475
    476476            /* Step 1: unpack glyph */
  • libcaca/trunk/caca/frame.c

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
    44 *                All Rights Reserved
     
    2525#endif
    2626
    27 #include "cucul.h"
    28 #include "cucul_internals.h"
     27#include "caca.h"
     28#include "caca_internals.h"
    2929
    3030/** \brief Get the number of frames in a canvas.
     
    3434 *  This function never fails.
    3535 *
    36  *  \param cv A libcucul canvas
     36 *  \param cv A libcaca canvas
    3737 *  \return The frame count
    3838 */
    39 int cucul_get_frame_count(cucul_canvas_t const *cv)
     39int caca_get_frame_count(caca_canvas_t const *cv)
    4040{
    4141    return cv->framecount;
     
    4646 *  Set the active canvas frame. All subsequent drawing operations will
    4747 *  be performed on that frame. The current painting context set by
    48  *  cucul_set_attr() is inherited.
     48 *  caca_set_attr() is inherited.
    4949 *
    5050 *  If the frame index is outside the canvas' frame range, nothing happens.
     
    5353 *  - \c EINVAL Requested frame is out of range.
    5454 *
    55  *  \param cv A libcucul canvas
     55 *  \param cv A libcaca canvas
    5656 *  \param id The canvas frame to activate
    5757 *  \return 0 in case of success, -1 if an error occurred.
    5858 */
    59 int cucul_set_frame(cucul_canvas_t *cv, int id)
     59int caca_set_frame(caca_canvas_t *cv, int id)
    6060{
    6161    if(id < 0 || id >= cv->framecount)
     
    6565    }
    6666
    67     _cucul_save_frame_info(cv);
     67    _caca_save_frame_info(cv);
    6868    cv->frame = id;
    69     _cucul_load_frame_info(cv);
     69    _caca_load_frame_info(cv);
    7070
    7171    return 0;
     
    7575 *
    7676 *  Return the current frame's name. The returned string is valid until
    77  *  the frame is deleted or cucul_set_frame_name() is called to change
     77 *  the frame is deleted or caca_set_frame_name() is called to change
    7878 *  the frame name again.
    7979 *
    8080 *  This function never fails.
    8181 *
    82  *  \param cv A libcucul canvas.
     82 *  \param cv A libcaca canvas.
    8383 *  \return The current frame's name.
    8484 */
    85 char const *cucul_get_frame_name(cucul_canvas_t const *cv)
     85char const *caca_get_frame_name(caca_canvas_t const *cv)
    8686{
    8787    return cv->frames[cv->frame].name;
     
    9797 *  - \c ENOMEM Not enough memory to allocate new frame.
    9898 *
    99  *  \param cv A libcucul canvas.
     99 *  \param cv A libcaca canvas.
    100100 *  \param name The name to give to the current frame.
    101101 *  \return 0 in case of success, -1 if an error occurred.
    102102 */
    103 int cucul_set_frame_name(cucul_canvas_t *cv, char const *name)
     103int caca_set_frame_name(caca_canvas_t *cv, char const *name)
    104104{
    105105    char *newname = strdup(name);
     
    134134 *  - \c ENOMEM Not enough memory to allocate new frame.
    135135 *
    136  *  \param cv A libcucul canvas
     136 *  \param cv A libcaca canvas
    137137 *  \param id The index where to insert the new frame
    138138 *  \return 0 in case of success, -1 if an error occurred.
    139139 */
    140 int cucul_create_frame(cucul_canvas_t *cv, int id)
     140int caca_create_frame(caca_canvas_t *cv, int id)
    141141{
    142142    int size = cv->width * cv->height;
     
    150150    cv->framecount++;
    151151    cv->frames = realloc(cv->frames,
    152                          sizeof(struct cucul_frame) * cv->framecount);
     152                         sizeof(struct caca_frame) * cv->framecount);
    153153
    154154    for(f = cv->framecount - 1; f > id; f--)
     
    194194 *    last frame of the canvas.
    195195 *
    196  *  \param cv A libcucul canvas
     196 *  \param cv A libcaca canvas
    197197 *  \param id The index of the frame to delete
    198198 *  \return 0 in case of success, -1 if an error occurred.
    199199 */
    200 int cucul_free_frame(cucul_canvas_t *cv, int id)
     200int caca_free_frame(caca_canvas_t *cv, int id)
    201201{
    202202    int f;
     
    223223    cv->framecount--;
    224224    cv->frames = realloc(cv->frames,
    225                          sizeof(struct cucul_frame) * cv->framecount);
     225                         sizeof(struct caca_frame) * cv->framecount);
    226226
    227227    if(cv->frame > id)
     
    230230    {
    231231        cv->frame = 0;
    232         _cucul_load_frame_info(cv);
     232        _caca_load_frame_info(cv);
    233233    }
    234234
     
    240240 */
    241241
    242 void _cucul_save_frame_info(cucul_canvas_t *cv)
     242void _caca_save_frame_info(caca_canvas_t *cv)
    243243{
    244244    cv->frames[cv->frame].width = cv->width;
     
    248248}
    249249
    250 void _cucul_load_frame_info(cucul_canvas_t *cv)
     250void _caca_load_frame_info(caca_canvas_t *cv)
    251251{
    252252    cv->width = cv->frames[cv->frame].width;
  • libcaca/trunk/caca/graphics.c

    r2305 r2821  
    2525#endif
    2626
    27 #include "cucul.h"
    2827#include "caca.h"
    2928#include "caca_internals.h"
     
    242241    dp->drv.handle_resize(dp);
    243242
    244     /* Tell libcucul we changed size */
    245     if(dp->resize.w != cucul_get_canvas_width(dp->cv)
    246         || dp->resize.h != cucul_get_canvas_height(dp->cv))
     243    /* Tell libcaca we changed size */
     244    if(dp->resize.w != caca_get_canvas_width(dp->cv)
     245        || dp->resize.h != caca_get_canvas_height(dp->cv))
    247246    {
    248247        dp->resize.allow = 1;
    249         cucul_set_canvas_size(dp->cv, dp->resize.w, dp->resize.h);
     248        caca_set_canvas_size(dp->cv, dp->resize.w, dp->resize.h);
    250249        dp->resize.allow = 0;
    251250    }
  • libcaca/trunk/caca/import.c

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
    44 *                All Rights Reserved
     
    2424#endif
    2525
    26 #include "cucul.h"
    27 #include "cucul_internals.h"
     26#include "caca.h"
     27#include "caca_internals.h"
    2828
    2929static inline uint32_t sscanu32(void const *s)
     
    5252};
    5353
    54 static ssize_t import_caca(cucul_canvas_t *, void const *, size_t);
    55 static ssize_t import_text(cucul_canvas_t *, void const *, size_t);
    56 static ssize_t import_ansi(cucul_canvas_t *, void const *, size_t, int);
    57 
    58 static void ansi_parse_grcm(cucul_canvas_t *, struct import *,
     54static ssize_t import_caca(caca_canvas_t *, void const *, size_t);
     55static ssize_t import_text(caca_canvas_t *, void const *, size_t);
     56static ssize_t import_ansi(caca_canvas_t *, void const *, size_t, int);
     57
     58static void ansi_parse_grcm(caca_canvas_t *, struct import *,
    5959                            unsigned int, unsigned int const *);
    6060
    6161/** \brief Import a memory buffer into a canvas
    6262 *
    63  *  Import a memory buffer into the given libcucul canvas's current
     63 *  Import a memory buffer into the given libcaca canvas's current
    6464 *  frame. The current frame is resized accordingly and its contents are
    6565 *  replaced with the imported data.
     
    7979 *  - \c EINVAL Invalid format requested.
    8080 *
    81  *  \param cv A libcucul canvas in which to import the file.
     81 *  \param cv A libcaca canvas in which to import the file.
    8282 *  \param data A memory area containing the data to be loaded into the canvas.
    8383 *  \param len The size in bytes of the memory area.
     
    8686 *  or -1 if an error occurred.
    8787 */
    88 ssize_t cucul_import_memory(cucul_canvas_t *cv, void const *data,
     88ssize_t caca_import_memory(caca_canvas_t *cv, void const *data,
    8989                            size_t len, char const *format)
    9090{
     
    124124/** \brief Import a file into a canvas
    125125 *
    126  *  Import a file into the given libcucul canvas's current frame. The
     126 *  Import a file into the given libcaca canvas's current frame. The
    127127 *  current frame is resized accordingly and its contents are replaced
    128128 *  with the imported data.
     
    142142 *  - \c ENOMEM Not enough memory to allocate canvas.
    143143 *  - \c EINVAL Invalid format requested.
    144  *  cucul_import_file() may also fail and set \b errno for any of the
     144 *  caca_import_file() may also fail and set \b errno for any of the
    145145 *  errors specified for the routine fopen().
    146146 *
    147  *  \param cv A libcucul canvas in which to import the file.
     147 *  \param cv A libcaca canvas in which to import the file.
    148148 *  \param filename The name of the file to load.
    149149 *  \param format A string describing the input format.
     
    151151 *  or -1 if an error occurred.
    152152 */
    153 ssize_t cucul_import_file(cucul_canvas_t *cv, char const *filename,
     153ssize_t caca_import_file(caca_canvas_t *cv, char const *filename,
    154154                          char const *format)
    155155{
     
    158158    return -1;
    159159#else
    160     cucul_file_t *f;
     160    caca_file_t *f;
    161161    char *data = NULL;
    162162    ssize_t size = 0;
    163163    int ret;
    164164
    165     f = cucul_file_open(filename, "rb");
     165    f = caca_file_open(filename, "rb");
    166166    if(!f)
    167167        return -1; /* fopen already set errno */
    168168
    169     while(!cucul_file_eof(f))
     169    while(!caca_file_eof(f))
    170170    {
    171171        data = realloc(data, size + 1024);
    172172        if(!data)
    173173        {
    174             cucul_file_close(f);
     174            caca_file_close(f);
    175175            seterrno(ENOMEM);
    176176            return -1;
    177177        }
    178178
    179         ret = cucul_file_read(f, data + size, 1024);
     179        ret = caca_file_read(f, data + size, 1024);
    180180        if(ret >= 0)
    181181            size += ret;
    182182    }
    183     cucul_file_close(f);
    184 
    185     ret = cucul_import_memory(cv, data, size, format);
     183    caca_file_close(f);
     184
     185    ret = caca_import_memory(cv, data, size, format);
    186186    free(data);
    187187
     
    194194 *  Return a list of available import formats. The list is a NULL-terminated
    195195 *  array of strings, interleaving a string containing the internal value for
    196  *  the import format, to be used with cucul_import_canvas(), and a string
     196 *  the import format, to be used with caca_import_canvas(), and a string
    197197 *  containing the natural language description for that import format.
    198198 *
     
    201201 *  \return An array of strings.
    202202 */
    203 char const * const * cucul_get_import_list(void)
     203char const * const * caca_get_import_list(void)
    204204{
    205205    static char const * const list[] =
     
    220220 */
    221221
    222 static ssize_t import_caca(cucul_canvas_t *cv, void const *data, size_t size)
     222static ssize_t import_caca(caca_canvas_t *cv, void const *data, size_t size)
    223223{
    224224    uint8_t const *buf = (uint8_t const *)data;
     
    285285    }
    286286
    287     cucul_set_canvas_size(cv, 0, 0);
    288     cucul_set_canvas_size(cv, xmax - xmin, ymax - ymin);
    289 
    290     for (f = cucul_get_frame_count(cv); f--; )
    291     {
    292         cucul_free_frame(cv, f);
     287    caca_set_canvas_size(cv, 0, 0);
     288    caca_set_canvas_size(cv, xmax - xmin, ymax - ymin);
     289
     290    for (f = caca_get_frame_count(cv); f--; )
     291    {
     292        caca_free_frame(cv, f);
    293293    }
    294294
     
    299299        width = sscanu32(buf + 4 + 16 + f * 32);
    300300        height = sscanu32(buf + 4 + 16 + f * 32 + 4);
    301         cucul_create_frame(cv, f);
    302         cucul_set_frame(cv, f);
     301        caca_create_frame(cv, f);
     302        caca_set_frame(cv, f);
    303303
    304304        cv->curattr = sscanu32(buf + 4 + 16 + f * 32 + 12);
     
    315315            int y = (n / width) - cv->frames[f].handley - ymin;
    316316
    317             cucul_put_char(cv, x, y, sscanu32(buf + 4 + control_size
     317            caca_put_char(cv, x, y, sscanu32(buf + 4 + control_size
    318318                                               + offset + 8 * n));
    319             cucul_put_attr(cv, x, y, sscanu32(buf + 4 + control_size
     319            caca_put_attr(cv, x, y, sscanu32(buf + 4 + control_size
    320320                                               + offset + 8 * n + 4));
    321321        }
     
    328328    }
    329329
    330     cucul_set_frame(cv, 0);
     330    caca_set_frame(cv, 0);
    331331
    332332    return 4 + control_size + data_size;
     
    337337}
    338338
    339 static ssize_t import_text(cucul_canvas_t *cv, void const *data, size_t size)
     339static ssize_t import_text(caca_canvas_t *cv, void const *data, size_t size)
    340340{
    341341    char const *text = (char const *)data;
    342342    unsigned int width = 0, height = 0, x = 0, y = 0, i;
    343343
    344     cucul_set_canvas_size(cv, width, height);
     344    caca_set_canvas_size(cv, width, height);
    345345
    346346    for(i = 0; i < size; i++)
     
    366366                height = y + 1;
    367367
    368             cucul_set_canvas_size(cv, width, height);
    369         }
    370 
    371         cucul_put_char(cv, x, y, ch);
     368            caca_set_canvas_size(cv, width, height);
     369        }
     370
     371        caca_put_char(cv, x, y, ch);
    372372        x++;
    373373    }
    374374
    375375    if(y > height)
    376         cucul_set_canvas_size(cv, width, height = y);
     376        caca_set_canvas_size(cv, width, height = y);
    377377
    378378    return size;
    379379}
    380380
    381 static ssize_t import_ansi(cucul_canvas_t *cv, void const *data,
     381static ssize_t import_ansi(caca_canvas_t *cv, void const *data,
    382382                           size_t size, int utf8)
    383383{
     
    400400    else
    401401    {
    402         cucul_set_canvas_size(cv, width = 80, height = 0);
     402        caca_set_canvas_size(cv, width = 80, height = 0);
    403403        growx = 0;
    404404        growy = 1;