Changeset 2821 for libcaca/trunk/caca
- Timestamp:
- Sep 27, 2008, 3:12:46 PM (13 years ago)
- Location:
- libcaca/trunk/caca
- Files:
-
- 18 edited
- 20 copied
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/Makefile.am
r2517 r2821 1 1 # $Id$ 2 2 3 EXTRA_DIST = caca .pc.in4 DISTCLEANFILES = caca .pc3 EXTRA_DIST = caca_types.h.in caca.pc.in mono9.data monobold12.data 4 DISTCLEANFILES = caca_types.h caca.pc 5 5 6 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/cucul -I../cucul \ 7 -DPLUGINDIR=\"$(plugindir)\" 6 AM_CPPFLAGS = -I$(top_srcdir) -DPLUGINDIR=\"$(plugindir)\" 8 7 9 8 pkgconfig_DATA = caca.pc 10 9 pkgconfigdir = $(libdir)/pkgconfig 11 10 12 include_HEADERS = caca.h caca 0.h11 include_HEADERS = caca.h caca_types.h caca0.h 13 12 14 13 lib_LTLIBRARIES = libcaca.la … … 17 16 caca.c \ 18 17 caca.h \ 18 caca_types.h \ 19 19 caca_internals.h \ 20 20 caca0.c \ 21 21 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 \ 22 39 graphics.c \ 23 40 event.c \ … … 32 49 $(extra_source) \ 33 50 $(NULL) 51 libcaca_la_DEPENDENCIES = \ 52 mono9.data \ 53 monobold12.data \ 54 $(NULL) 34 55 libcaca_la_CPPFLAGS = $(AM_CPPFLAGS) @CACA_CFLAGS@ 35 56 libcaca_la_LDFLAGS = -no-undefined -version-number @LT_VERSION@ 36 libcaca_la_LIBADD = ../cucul/libcucul.la @CACA_LIBS@57 libcaca_la_LIBADD = @CACA_LIBS@ $(ZLIB_LIBS) 37 58 38 59 if USE_PLUGINS … … 43 64 libx11_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) $(X11_CFLAGS) 44 65 libx11_plugin_la_LDFLAGS = -no-undefined -module -no-version 45 libx11_plugin_la_LIBADD = libcaca.la ../cucul/libcucul.la$(X11_LIBS)66 libx11_plugin_la_LIBADD = libcaca.la $(X11_LIBS) 46 67 47 68 libgl_plugin_la_SOURCES = driver_gl.c 48 69 libgl_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) $(GL_CFLAGS) #$(FTGL_CFLAGS) 49 70 libgl_plugin_la_LDFLAGS = -no-undefined -module -no-version 50 libgl_plugin_la_LIBADD = libcaca.la ../cucul/libcucul.la$(GL_LIBS) #$(FTGL_LIBS)71 libgl_plugin_la_LIBADD = libcaca.la $(GL_LIBS) #$(FTGL_LIBS) 51 72 else 52 73 extra_source = driver_x11.c driver_gl.c -
libcaca/trunk/caca/attr.c
r2819 r2821 1 1 /* 2 * libc ucul Canvas for ultrafast compositing of Unicode letters2 * libcaca Colour ASCII-Art library 3 3 * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 20 20 #include "config.h" 21 21 22 #include "c ucul.h"23 #include "c ucul_internals.h"22 #include "caca.h" 23 #include "caca_internals.h" 24 24 25 25 static uint8_t nearest_ansi(uint16_t); … … 43 43 /** \brief Get the text attribute at the given coordinates. 44 44 * 45 * Get the internal \e libc uculattribute value of the character at the45 * Get the internal \e libcaca attribute value of the character at the 46 46 * given coordinates. The attribute value has 32 significant bits, 47 47 * organised as follows from MSB to LSB: … … 61 61 * This function never fails. 62 62 * 63 * \param cv A handle to the libc uculcanvas.63 * \param cv A handle to the libcaca canvas. 64 64 * \param x X coordinate. 65 65 * \param y Y coordinate. 66 66 * \return The requested attribute. 67 67 */ 68 uint32_t c ucul_get_attr(cucul_canvas_t const *cv, int x, int y)68 uint32_t caca_get_attr(caca_canvas_t const *cv, int x, int y) 69 69 { 70 70 if(x < 0 || x >= (int)cv->width || y < 0 || y >= (int)cv->height) … … 83 83 * 84 84 * The value of \e attr is either: 85 * - a 32-bit integer as returned by c ucul_get_attr(), in which case it85 * - a 32-bit integer as returned by caca_get_attr(), in which case it 86 86 * also contains colour information, 87 * - a combination (bitwise OR) of style values (\e C UCUL_UNDERLINE,88 * \e C UCUL_BLINK, \e CUCUL_BOLD and \e CUCUL_ITALICS), in which case87 * - a combination (bitwise OR) of style values (\e CACA_UNDERLINE, 88 * \e CACA_BLINK, \e CACA_BOLD and \e CACA_ITALICS), in which case 89 89 * setting the attribute does not modify the current colour information. 90 90 * 91 * To retrieve the current attribute value, use c ucul_get_attr(-1,-1).91 * To retrieve the current attribute value, use caca_get_attr(-1,-1). 92 92 * 93 93 * This function never fails. 94 94 * 95 * \param cv A handle to the libc uculcanvas.95 * \param cv A handle to the libcaca canvas. 96 96 * \param attr The requested attribute value. 97 97 * \return This function always returns 0. 98 98 */ 99 int c ucul_set_attr(cucul_canvas_t *cv, uint32_t attr)99 int caca_set_attr(caca_canvas_t *cv, uint32_t attr) 100 100 { 101 101 if(attr < 0x00000010) … … 114 114 * 115 115 * The value of \e attr is either: 116 * - a 32-bit integer as returned by c ucul_get_attr(), in which case it116 * - a 32-bit integer as returned by caca_get_attr(), in which case it 117 117 * also contains colour information, 118 * - a combination (bitwise OR) of style values (\e C UCUL_UNDERLINE,119 * \e C UCUL_BLINK, \e CUCUL_BOLD and \e CUCUL_ITALICS), in which case118 * - a combination (bitwise OR) of style values (\e CACA_UNDERLINE, 119 * \e CACA_BLINK, \e CACA_BOLD and \e CACA_ITALICS), in which case 120 120 * setting the attribute does not modify the current colour information. 121 121 * 122 122 * This function never fails. 123 123 * 124 * \param cv A handle to the libc uculcanvas.124 * \param cv A handle to the libcaca canvas. 125 125 * \param x X coordinate. 126 126 * \param y Y coordinate. … … 128 128 * \return This function always returns 0. 129 129 */ 130 int c ucul_put_attr(cucul_canvas_t *cv, int x, int y, uint32_t attr)130 int caca_put_attr(caca_canvas_t *cv, int x, int y, uint32_t attr) 131 131 { 132 132 uint32_t *curattr, *curchar; … … 143 143 curattr[0] = attr; 144 144 145 if(x && curchar[0] == C UCUL_MAGIC_FULLWIDTH)145 if(x && curchar[0] == CACA_MAGIC_FULLWIDTH) 146 146 curattr[-1] = curattr[0]; 147 else if(x + 1 < (int)cv->width && curchar[1] == C UCUL_MAGIC_FULLWIDTH)147 else if(x + 1 < (int)cv->width && curchar[1] == CACA_MAGIC_FULLWIDTH) 148 148 curattr[1] = curattr[0]; 149 149 … … 157 157 * will use these attributes. 158 158 * 159 * Color values are those defined in c ucul.h, such as CUCUL_RED160 * or C UCUL_TRANSPARENT.159 * Color values are those defined in caca.h, such as CACA_RED 160 * or CACA_TRANSPARENT. 161 161 * 162 162 * If an error occurs, 0 is returned and \b errno is set accordingly: 163 163 * - \c EINVAL At least one of the colour values is invalid. 164 164 * 165 * \param cv A handle to the libc uculcanvas.165 * \param cv A handle to the libcaca canvas. 166 166 * \param fg The requested ANSI foreground colour. 167 167 * \param bg The requested ANSI background colour. 168 168 * \return 0 in case of success, -1 if an error occurred. 169 169 */ 170 int c ucul_set_color_ansi(cucul_canvas_t *cv, uint8_t fg, uint8_t bg)170 int caca_set_color_ansi(caca_canvas_t *cv, uint8_t fg, uint8_t bg) 171 171 { 172 172 uint32_t attr; … … 196 196 * This function never fails. 197 197 * 198 * \param cv A handle to the libc uculcanvas.198 * \param cv A handle to the libcaca canvas. 199 199 * \param fg The requested ARGB foreground colour. 200 200 * \param bg The requested ARGB background colour. 201 201 * \return This function always returns 0. 202 202 */ 203 int c ucul_set_color_argb(cucul_canvas_t *cv, uint16_t fg, uint16_t bg)203 int caca_set_color_argb(caca_canvas_t *cv, uint16_t fg, uint16_t bg) 204 204 { 205 205 uint32_t attr; … … 227 227 * 228 228 * If the attribute has ARGB colours, the nearest colour is used. Special 229 * attributes such as \e C UCUL_DEFAULT and \e CUCUL_TRANSPARENT are not230 * handled and are both replaced with \e C UCUL_LIGHTGRAY for the foreground231 * colour and \e C UCUL_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. 232 232 * 233 233 * This function never fails. If the attribute value is outside the expected … … 237 237 * \return The corresponding DOS ANSI value. 238 238 */ 239 uint8_t c ucul_attr_to_ansi(uint32_t attr)239 uint8_t caca_attr_to_ansi(uint32_t attr) 240 240 { 241 241 uint8_t fg = nearest_ansi((attr >> 4) & 0x3fff); 242 242 uint8_t bg = nearest_ansi(attr >> 18); 243 243 244 return (fg < 0x10 ? fg : C UCUL_LIGHTGRAY)245 | ((bg < 0x10 ? bg : C UCUL_BLACK) << 4);244 return (fg < 0x10 ? fg : CACA_LIGHTGRAY) 245 | ((bg < 0x10 ? bg : CACA_BLACK) << 4); 246 246 } 247 247 … … 249 249 * 250 250 * Get the ANSI foreground colour value for a given attribute. The returned 251 * value is either one of the \e C UCUL_RED, \e CUCUL_BLACK etc. predefined252 * colours, or the special value \e C UCUL_DEFAULT meaning the media's253 * default foreground value, or the special value \e C UCUL_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. 254 254 * 255 255 * If the attribute has ARGB colours, the nearest colour is returned. … … 261 261 * \return The corresponding ANSI foreground value. 262 262 */ 263 uint8_t c ucul_attr_to_ansi_fg(uint32_t attr)263 uint8_t caca_attr_to_ansi_fg(uint32_t attr) 264 264 { 265 265 return nearest_ansi(((uint16_t)attr >> 4) & 0x3fff); … … 269 269 * 270 270 * Get the ANSI background colour value for a given attribute. The returned 271 * value is either one of the \e C UCUL_RED, \e CUCUL_BLACK etc. predefined272 * colours, or the special value \e C UCUL_DEFAULT meaning the media's273 * default background value, or the special value \e C UCUL_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. 274 274 * 275 275 * If the attribute has ARGB colours, the nearest colour is returned. … … 281 281 * \return The corresponding ANSI background value. 282 282 */ 283 uint8_t c ucul_attr_to_ansi_bg(uint32_t attr)283 uint8_t caca_attr_to_ansi_bg(uint32_t attr) 284 284 { 285 285 return nearest_ansi(attr >> 18); … … 301 301 * \return The corresponding 12-bit RGB foreground value. 302 302 */ 303 uint16_t c ucul_attr_to_rgb12_fg(uint32_t attr)303 uint16_t caca_attr_to_rgb12_fg(uint32_t attr) 304 304 { 305 305 uint16_t fg = (attr >> 4) & 0x3fff; … … 308 308 return ansitab16[fg ^ 0x40] & 0x0fff; 309 309 310 if(fg == (C UCUL_DEFAULT | 0x40))311 return ansitab16[C UCUL_LIGHTGRAY] & 0x0fff;312 313 if(fg == (C UCUL_TRANSPARENT | 0x40))314 return ansitab16[C UCUL_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; 315 315 316 316 return (fg << 1) & 0x0fff; … … 332 332 * \return The corresponding 12-bit RGB background value. 333 333 */ 334 uint16_t c ucul_attr_to_rgb12_bg(uint32_t attr)334 uint16_t caca_attr_to_rgb12_bg(uint32_t attr) 335 335 { 336 336 uint16_t bg = attr >> 18; … … 339 339 return ansitab16[bg ^ 0x40] & 0x0fff; 340 340 341 if(bg == (C UCUL_DEFAULT | 0x40))342 return ansitab16[C UCUL_BLACK] & 0x0fff;343 344 if(bg == (C UCUL_TRANSPARENT | 0x40))345 return ansitab16[C UCUL_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; 346 346 347 347 return (bg << 1) & 0x0fff; … … 367 367 * \param argb An array of 8-bit integers. 368 368 */ 369 void c ucul_attr_to_argb64(uint32_t attr, uint8_t argb[8])369 void caca_attr_to_argb64(uint32_t attr, uint8_t argb[8]) 370 370 { 371 371 uint16_t fg = (attr >> 4) & 0x3fff; … … 374 374 if(bg < (0x10 | 0x40)) 375 375 bg = ansitab16[bg ^ 0x40]; 376 else if(bg == (C UCUL_DEFAULT | 0x40))377 bg = ansitab16[C UCUL_BLACK];378 else if(bg == (C UCUL_TRANSPARENT | 0x40))376 else if(bg == (CACA_DEFAULT | 0x40)) 377 bg = ansitab16[CACA_BLACK]; 378 else if(bg == (CACA_TRANSPARENT | 0x40)) 379 379 bg = 0x0fff; 380 380 else … … 388 388 if(fg < (0x10 | 0x40)) 389 389 fg = ansitab16[fg ^ 0x40]; 390 else if(fg == (C UCUL_DEFAULT | 0x40))391 fg = ansitab16[C UCUL_LIGHTGRAY];392 else if(fg == (C UCUL_TRANSPARENT | 0x40))390 else if(fg == (CACA_DEFAULT | 0x40)) 391 fg = ansitab16[CACA_LIGHTGRAY]; 392 else if(fg == (CACA_TRANSPARENT | 0x40)) 393 393 fg = 0x0fff; 394 394 else … … 412 412 return argb14 ^ 0x40; 413 413 414 if(argb14 == (C UCUL_DEFAULT | 0x40) || argb14 == (CUCUL_TRANSPARENT | 0x40))414 if(argb14 == (CACA_DEFAULT | 0x40) || argb14 == (CACA_TRANSPARENT | 0x40)) 415 415 return argb14 ^ 0x40; 416 416 417 417 if(argb14 < 0x0fff) /* too transparent */ 418 return C UCUL_TRANSPARENT;419 420 best = C UCUL_DEFAULT;418 return CACA_TRANSPARENT; 419 420 best = CACA_DEFAULT; 421 421 dist = 0x3fff; 422 422 for(i = 0; i < 16; i++) … … 452 452 | ((uint32_t)(i & 0x00f) * 0x000011)) 453 453 454 uint32_t _c ucul_attr_to_rgb24fg(uint32_t attr)455 { 456 return RGB12TO24(c ucul_attr_to_rgb12_fg(attr));457 } 458 459 uint32_t _c ucul_attr_to_rgb24bg(uint32_t attr)460 { 461 return RGB12TO24(c ucul_attr_to_rgb12_bg(attr));462 } 463 454 uint32_t _caca_attr_to_rgb24fg(uint32_t attr) 455 { 456 return RGB12TO24(caca_attr_to_rgb12_fg(attr)); 457 } 458 459 uint32_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 1 1 /* 2 * libc ucul Canvas for ultrafast compositing of Unicode letters2 * libcaca Colour ASCII-Art library 3 3 * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 23 23 #endif 24 24 25 #include "c ucul.h"26 #include "c ucul_internals.h"25 #include "caca.h" 26 #include "caca_internals.h" 27 27 28 28 /** \brief Draw a box on the canvas using the given character. … … 30 30 * This function never fails. 31 31 * 32 * \param cv The handle to the libc uculcanvas.32 * \param cv The handle to the libcaca canvas. 33 33 * \param x X coordinate of the upper-left corner of the box. 34 34 * \param y Y coordinate of the upper-left corner of the box. … … 38 38 * \return This function always returns 0. 39 39 */ 40 int c ucul_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 c ucul_draw_line(cv, x, y, x, y2, ch);46 c ucul_draw_line(cv, x, y2, x2, y2, ch);47 c ucul_draw_line(cv, x2, y2, x2, y, ch);48 c ucul_draw_line(cv, x2, y, x, y, ch);40 int 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); 49 49 50 50 return 0; … … 55 55 * This function never fails. 56 56 * 57 * \param cv The handle to the libc uculcanvas.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 c ucul_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 */ 64 int caca_draw_thin_box(caca_canvas_t *cv, int x, int y, int w, int h) 65 65 { 66 66 int i, j, xmax, ymax; … … 90 90 if(y >= 0) 91 91 for(i = x < 0 ? 1 : x + 1; i < x2 && i < xmax; i++) 92 c ucul_put_char(cv, i, y, '-');92 caca_put_char(cv, i, y, '-'); 93 93 94 94 if(y2 <= ymax) 95 95 for(i = x < 0 ? 1 : x + 1; i < x2 && i < xmax; i++) 96 c ucul_put_char(cv, i, y2, '-');96 caca_put_char(cv, i, y2, '-'); 97 97 98 98 if(x >= 0) 99 99 for(j = y < 0 ? 1 : y + 1; j < y2 && j < ymax; j++) 100 c ucul_put_char(cv, x, j, '|');100 caca_put_char(cv, x, j, '|'); 101 101 102 102 if(x2 <= xmax) 103 103 for(j = y < 0 ? 1 : y + 1; j < y2 && j < ymax; j++) 104 c ucul_put_char(cv, x2, j, '|');104 caca_put_char(cv, x2, j, '|'); 105 105 106 106 /* Draw corners */ 107 c ucul_put_char(cv, x, y, ',');108 c ucul_put_char(cv, x, y2, '`');109 c ucul_put_char(cv, x2, y, '.');110 c ucul_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, '\''); 111 111 112 112 return 0; … … 117 117 * This function never fails. 118 118 * 119 * \param cv The handle to the libc uculcanvas.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 c ucul_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 */ 126 int caca_draw_cp437_box(caca_canvas_t *cv, int x, int y, int w, int h) 127 127 { 128 128 int i, j, xmax, ymax; … … 152 152 if(y >= 0) 153 153 for(i = x < 0 ? 1 : x + 1; i < x2 && i < xmax; i++) 154 c ucul_put_char(cv, i, y, 0x2500); /* ─ */154 caca_put_char(cv, i, y, 0x2500); /* ─ */ 155 155 156 156 if(y2 <= ymax) 157 157 for(i = x < 0 ? 1 : x + 1; i < x2 && i < xmax; i++) 158 c ucul_put_char(cv, i, y2, 0x2500); /* ─ */158 caca_put_char(cv, i, y2, 0x2500); /* ─ */ 159 159 160 160 if(x >= 0) 161 161 for(j = y < 0 ? 1 : y + 1; j < y2 && j < ymax; j++) 162 c ucul_put_char(cv, x, j, 0x2502); /* │ */162 caca_put_char(cv, x, j, 0x2502); /* │ */ 163 163 164 164 if(x2 <= xmax) 165 165 for(j = y < 0 ? 1 : y + 1; j < y2 && j < ymax; j++) 166 c ucul_put_char(cv, x2, j, 0x2502); /* │ */166 caca_put_char(cv, x2, j, 0x2502); /* │ */ 167 167 168 168 /* Draw corners */ 169 c ucul_put_char(cv, x, y, 0x250c); /* ┌ */170 c ucul_put_char(cv, x, y2, 0x2514); /* └ */171 c ucul_put_char(cv, x2, y, 0x2510); /* ┐ */172 c ucul_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); /* ┘ */ 173 173 174 174 return 0; … … 179 179 * This function never fails. 180 180 * 181 * \param cv The handle to the libc uculcanvas.181 * \param cv The handle to the libcaca canvas. 182 182 * \param x X coordinate of the upper-left corner of the box. 183 183 * \param y Y coordinate of the upper-left corner of the box. … … 187 187 * \return This function always returns 0. 188 188 */ 189 int c ucul_fill_box(cucul_canvas_t *cv, int x, int y, int w, int h,189 int caca_fill_box(caca_canvas_t *cv, int x, int y, int w, int h, 190 190 uint32_t ch) 191 191 { … … 220 220 for(j = y; j <= y2; j++) 221 221 for(i = x; i <= x2; i++) 222 c ucul_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 32 32 #endif 33 33 34 #include "cucul.h"35 34 #include "caca.h" 36 35 #include "caca_internals.h" … … 49 48 #endif 50 49 51 /** \brief Attach a caca graphical context to a c uculcanvas.50 /** \brief Attach a caca graphical context to a caca canvas. 52 51 * 53 52 * Create a graphical context using device-dependent features (ncurses for 54 53 * terminals, an X11 window, a DOS command window...) that attaches to a 55 * libc ucul canvas. Everything that gets drawn in the libcuculcanvas can54 * libcaca canvas. Everything that gets drawn in the libcaca canvas can 56 55 * then be displayed by the libcaca driver. 57 56 * 58 * If no c uculcanvas is provided, a new one is created. Its handle can be57 * If no caca canvas is provided, a new one is created. Its handle can be 59 58 * retrieved using caca_get_canvas() and it is automatically destroyed when 60 59 * caca_free_display() is called. … … 66 65 * - \c ENODEV Graphical device could not be initialised. 67 66 * 68 * \param cv The c uculcanvas or NULL to create a canvas automatically.67 * \param cv The caca canvas or NULL to create a canvas automatically. 69 68 * \return The caca graphical context or NULL if an error occurred. 70 69 */ 71 caca_display_t * caca_create_display(c ucul_canvas_t *cv)70 caca_display_t * caca_create_display(caca_canvas_t *cv) 72 71 { 73 72 return caca_create_display_with_driver(cv, NULL); 74 73 } 75 74 76 /** \brief Attach a specific caca graphical context to a c uculcanvas.75 /** \brief Attach a specific caca graphical context to a caca canvas. 77 76 * 78 77 * Create a graphical context using device-dependent features (ncurses for 79 78 * terminals, an X11 window, a DOS command window...) that attaches to a 80 * libc ucul canvas. Everything that gets drawn in the libcuculcanvas can79 * libcaca canvas. Everything that gets drawn in the libcaca canvas can 81 80 * then be displayed by the libcaca driver. 82 81 * 83 * If no c uculcanvas is provided, a new one is created. Its handle can be82 * If no caca canvas is provided, a new one is created. Its handle can be 84 83 * retrieved using caca_get_canvas() and it is automatically destroyed when 85 84 * caca_free_display() is called. … … 94 93 * - \c ENODEV Graphical device could not be initialised. 95 94 * 96 * \param cv The c uculcanvas or NULL to create a canvas automatically.95 * \param cv The caca canvas or NULL to create a canvas automatically. 97 96 * \param driver A string describing the desired output driver or NULL to 98 97 * choose the best driver automatically. 99 98 * \return The caca graphical context or NULL if an error occurred. 100 99 */ 101 caca_display_t * caca_create_display_with_driver(c ucul_canvas_t *cv,100 caca_display_t * caca_create_display_with_driver(caca_canvas_t *cv, 102 101 char const *driver) 103 102 { … … 112 111 if((dp->autorelease = (cv == NULL))) 113 112 { 114 cv = c ucul_create_canvas(0, 0);113 cv = caca_create_canvas(0, 0); 115 114 } 116 115 117 116 dp->cv = cv; 118 117 119 if(c ucul_manage_canvas(cv, (int (*)(void *))caca_can_resize, (void *)dp))118 if(caca_manage_canvas(cv, (int (*)(void *))caca_can_resize, (void *)dp)) 120 119 { 121 120 if(dp->autorelease) 122 c ucul_free_canvas(dp->cv);121 caca_free_canvas(dp->cv); 123 122 free(dp); 124 123 seterrno(EBUSY); … … 128 127 if(caca_install_driver(dp, driver)) 129 128 { 130 c ucul_unmanage_canvas(cv, (int (*)(void *))caca_can_resize, (void *)dp);129 caca_unmanage_canvas(cv, (int (*)(void *))caca_can_resize, (void *)dp); 131 130 if(dp->autorelease) 132 c ucul_free_canvas(dp->cv);131 caca_free_canvas(dp->cv); 133 132 free(dp); 134 133 seterrno(ENODEV); … … 224 223 } 225 224 226 /** \brief Detach a caca graphical context from a c uculbackend context.227 * 228 * Detach a graphical context from its c uculbackend and destroy it. The229 * libc uculcanvas continues to exist and other graphical contexts can be225 /** \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 230 229 * attached to it afterwards. 231 230 * 232 * If the c uculcanvas was automatically created by caca_create_display(),231 * If the caca canvas was automatically created by caca_create_display(), 233 232 * it is automatically destroyed and any handle to it becomes invalid. 234 233 * … … 241 240 { 242 241 caca_uninstall_driver(dp); 243 c ucul_unmanage_canvas(dp->cv, (int (*)(void *))caca_can_resize, (void *)dp);242 caca_unmanage_canvas(dp->cv, (int (*)(void *))caca_can_resize, (void *)dp); 244 243 if(dp->autorelease) 245 c ucul_free_canvas(dp->cv);244 caca_free_canvas(dp->cv); 246 245 free(dp); 247 246 … … 251 250 /** \brief Get the canvas attached to a caca graphical context. 252 251 * 253 * Return a handle on the \e c ucul_canvas_t object that was either attached252 * Return a handle on the \e caca_canvas_t object that was either attached 254 253 * or created by caca_create_display(). 255 254 * … … 257 256 * 258 257 * \param dp The libcaca graphical context. 259 * \return The libc uculcanvas.260 */ 261 c ucul_canvas_t * caca_get_canvas(caca_display_t *dp)258 * \return The libcaca canvas. 259 */ 260 caca_canvas_t * caca_get_canvas(caca_display_t *dp) 262 261 { 263 262 return dp->cv; … … 331 330 332 331 /* Mouse position */ 333 dp->mouse.x = c ucul_get_canvas_width(dp->cv) / 2;334 dp->mouse.y = c ucul_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; 335 334 336 335 /* Resize events */ -
libcaca/trunk/caca/caca.h
r2305 r2821 25 25 #define __CACA_H__ 26 26 27 #include <c ucul.h>27 #include <caca_types.h> 28 28 29 29 #undef __extern … … 43 43 #endif 44 44 45 /** \e libcaca canvas */ 46 typedef struct caca_canvas caca_canvas_t; 47 /** dither structure */ 48 typedef struct caca_dither caca_dither_t; 49 /** font structure */ 50 typedef struct caca_font caca_font_t; 51 /** file handle structure */ 52 typedef struct caca_file caca_file_t; 45 53 /** \e libcaca display context */ 46 54 typedef struct caca_display caca_display_t; 47 55 /** \e libcaca event structure */ 48 56 typedef 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 /* @} */ 49 87 50 88 /** \brief User event type enumeration. … … 159 197 /** \defgroup libcaca libcaca basic functions 160 198 * 161 * These functions provide the basic \e libcaca routines for driver199 * These functions provide the basic \e libcaca routines for library 162 200 * initialisation, system information retrieval and configuration. 163 201 * 164 202 * @{ */ 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 *, 167 434 char const *); 168 435 __extern char const * const * caca_get_display_driver_list(void); … … 170 437 __extern int caca_set_display_driver(caca_display_t *, char const *); 171 438 __extern int caca_free_display(caca_display_t *); 172 __extern c ucul_canvas_t * caca_get_canvas(caca_display_t *);439 __extern caca_canvas_t * caca_get_canvas(caca_display_t *); 173 440 __extern int caca_refresh_display(caca_display_t *); 174 441 __extern int caca_set_display_time(caca_display_t *, int); … … 179 446 __extern int caca_set_mouse(caca_display_t *, int); 180 447 __extern int caca_set_cursor(caca_display_t *, int); 181 __extern char const * caca_get_version(void);182 448 /* @} */ 183 449 … … 202 468 /* @} */ 203 469 470 #if !defined(_DOXYGEN_SKIP_ME) 471 /* Legacy stuff from beta versions, will probably disappear in 1.0 */ 472 typedef 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 204 541 #ifdef __cplusplus 205 542 } -
libcaca/trunk/caca/caca.pc.in
r729 r2821 7 7 Description: Colour ASCII-Art library 8 8 Version: @VERSION@ 9 Requires: c ucul= @VERSION@9 Requires: caca = @VERSION@ 10 10 Conflicts: 11 Libs: -L${libdir} -lcaca -lc ucul11 Libs: -L${libdir} -lcaca -lcaca 12 12 Cflags: -I${includedir} -
libcaca/trunk/caca/caca0.c
r2299 r2821 28 28 29 29 /* These variables are needed to emulate old non-thread safe behaviour */ 30 c ucul_canvas_t *__caca0_cv = NULL;30 caca_canvas_t *__caca0_cv = NULL; 31 31 caca_display_t *__caca0_dp = NULL; 32 unsigned char __caca0_fg = C UCUL_LIGHTGRAY;33 unsigned char __caca0_bg = C UCUL_BLACK;32 unsigned char __caca0_fg = CACA_LIGHTGRAY; 33 unsigned char __caca0_bg = CACA_BLACK; 34 34 char __caca0_utf8[2] = " "; 35 35 … … 42 42 void __caca0_set_feature(int); 43 43 char const *__caca0_get_feature_name(int); 44 c ucul_canvas_t *__caca0_load_sprite(char const *);45 c ucul_dither_t *__caca0_create_bitmap(unsigned int, unsigned int,44 caca_canvas_t *__caca0_load_sprite(char const *); 45 caca_dither_t *__caca0_create_bitmap(unsigned int, unsigned int, 46 46 unsigned int, unsigned int, unsigned long int, unsigned long int, 47 47 unsigned long int, unsigned long int); 48 void __caca0_free_bitmap(c ucul_dither_t *);48 void __caca0_free_bitmap(caca_dither_t *); 49 49 extern char const *__caca0_get_color_name(unsigned char); 50 50 … … 52 52 int __caca0_init(void) 53 53 { 54 __caca0_cv = c ucul_create_canvas(0, 0);54 __caca0_cv = caca_create_canvas(0, 0); 55 55 if(!__caca0_cv) 56 56 return -1; … … 58 58 if(!__caca0_dp) 59 59 { 60 c ucul_free_canvas(__caca0_cv);60 caca_free_canvas(__caca0_cv); 61 61 __caca0_cv = NULL; 62 62 return -1; 63 63 } 64 __caca0_fg = C UCUL_LIGHTGRAY;65 __caca0_bg = C UCUL_BLACK;64 __caca0_fg = CACA_LIGHTGRAY; 65 __caca0_bg = CACA_BLACK; 66 66 return 0; 67 67 } … … 71 71 caca_free_display(__caca0_dp); 72 72 __caca0_dp = NULL; 73 c ucul_free_canvas(__caca0_cv);73 caca_free_canvas(__caca0_cv); 74 74 __caca0_cv = NULL; 75 75 } … … 145 145 }; 146 146 147 static c ucul_dither_t **bitmaps = NULL;147 static caca_dither_t **bitmaps = NULL; 148 148 static unsigned int nbitmaps = 0; 149 149 … … 173 173 background = feature; 174 174 for(i = 0; i < nbitmaps; i++) 175 c ucul_set_dither_color(bitmaps[i], features[feature]);175 caca_set_dither_color(bitmaps[i], features[feature]); 176 176 break; 177 177 … … 180 180 antialiasing = feature; 181 181 for(i = 0; i < nbitmaps; i++) 182 c ucul_set_dither_antialias(bitmaps[i], features[feature]);182 caca_set_dither_antialias(bitmaps[i], features[feature]); 183 183 break; 184 184 … … 187 187 dithering = feature; 188 188 for(i = 0; i < nbitmaps; i++) 189 c ucul_set_dither_algorithm(bitmaps[i], features[feature]);189 caca_set_dither_algorithm(bitmaps[i], features[feature]); 190 190 break; 191 191 } … … 212 212 } 213 213 214 c ucul_canvas_t *__caca0_load_sprite(char const *file)215 { 216 c ucul_canvas_t *cv;217 218 cv = c ucul_create_canvas(0, 0);;219 if(c ucul_import_file(cv, file, "") < 0)220 { 221 c ucul_free_canvas(cv);214 caca_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); 222 222 return NULL; 223 223 } … … 226 226 } 227 227 228 c ucul_dither_t *__caca0_create_bitmap(unsigned int bpp, unsigned int w,228 caca_dither_t *__caca0_create_bitmap(unsigned int bpp, unsigned int w, 229 229 unsigned int h, unsigned int pitch, 230 230 unsigned long int r, unsigned long int g, 231 231 unsigned long int b, unsigned long int a) 232 232 { 233 c ucul_dither_t *d;234 235 d = c ucul_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); 236 236 if(!d) 237 237 return NULL; 238 238 239 c ucul_set_dither_color(d, features[background]);240 c ucul_set_dither_antialias(d, features[antialiasing]);241 c ucul_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]); 242 242 243 243 /* Store bitmap in our list */ 244 244 nbitmaps++; 245 bitmaps = realloc(bitmaps, nbitmaps * (sizeof(c ucul_dither_t *)));245 bitmaps = realloc(bitmaps, nbitmaps * (sizeof(caca_dither_t *))); 246 246 bitmaps[nbitmaps - 1] = d; 247 247 … … 249 249 } 250 250 251 void __caca0_free_bitmap(c ucul_dither_t *d)251 void __caca0_free_bitmap(caca_dither_t *d) 252 252 { 253 253 unsigned int i, found = 0; 254 254 255 c ucul_free_dither(d);255 caca_free_dither(d); 256 256 257 257 /* Remove bitmap from our list */ -
libcaca/trunk/caca/caca0.h
r1462 r2821 36 36 extern void __caca0_set_feature(int); 37 37 extern char const *__caca0_get_feature_name(int); 38 extern c ucul_canvas_t *__caca0_load_sprite(char const *);39 extern c ucul_dither_t *__caca0_create_bitmap(unsigned int, unsigned int,38 extern caca_canvas_t *__caca0_load_sprite(char const *); 39 extern caca_dither_t *__caca0_create_bitmap(unsigned int, unsigned int, 40 40 unsigned int, unsigned int, unsigned long int, unsigned long int, 41 41 unsigned long int, unsigned long int); 42 extern void __caca0_free_bitmap(c ucul_dither_t *);42 extern void __caca0_free_bitmap(caca_dither_t *); 43 43 extern char const *__caca0_get_color_name(unsigned char); 44 44 45 45 /* These variables are needed to emulate old non-thread safe behaviour */ 46 extern c ucul_canvas_t *__caca0_cv;46 extern caca_canvas_t *__caca0_cv; 47 47 extern caca_display_t *__caca0_dp; 48 48 extern unsigned char __caca0_fg; … … 52 52 enum caca_color 53 53 { 54 CACA_COLOR_BLACK = C UCUL_BLACK,55 CACA_COLOR_BLUE = C UCUL_BLUE,56 CACA_COLOR_GREEN = C UCUL_GREEN,57 CACA_COLOR_CYAN = C UCUL_CYAN,58 CACA_COLOR_RED = C UCUL_RED,59 CACA_COLOR_MAGENTA = C UCUL_MAGENTA,60 CACA_COLOR_BROWN = C UCUL_BROWN,61 CACA_COLOR_LIGHTGRAY = C UCUL_LIGHTGRAY,62 CACA_COLOR_DARKGRAY = C UCUL_DARKGRAY,63 CACA_COLOR_LIGHTBLUE = C UCUL_LIGHTBLUE,64 CACA_COLOR_LIGHTGREEN = C UCUL_LIGHTGREEN,65 CACA_COLOR_LIGHTCYAN = C UCUL_LIGHTCYAN,66 CACA_COLOR_LIGHTRED = C UCUL_LIGHTRED,67 CACA_COLOR_LIGHTMAGENTA = C UCUL_LIGHTMAGENTA,68 CACA_COLOR_YELLOW = C UCUL_YELLOW,69 CACA_COLOR_WHITE = C UCUL_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, 70 70 }; 71 71 … … 118 118 #define caca_get_feature_name __caca0_get_feature_name 119 119 #define caca_get_rendertime() caca_get_display_time(__caca0_dp) 120 #define caca_get_width() c ucul_get_canvas_width(__caca0_cv)121 #define caca_get_height() c ucul_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) 122 122 #define caca_set_window_title(s) caca_set_display_title(__caca0_dp, s) 123 123 #define caca_get_window_width() caca_get_display_width(__caca0_dp) … … 132 132 133 133 #define caca_set_color(x, y) \ 134 (__caca0_fg = (x), __caca0_bg = (y), c ucul_set_color_ansi(__caca0_cv, x, y))134 (__caca0_fg = (x), __caca0_bg = (y), caca_set_color_ansi(__caca0_cv, x, y)) 135 135 #define caca_get_fg_color() __caca0_fg 136 136 #define caca_get_bg_color() __caca0_bg 137 137 #define caca_get_color_name __caca0_get_color_name 138 #define caca_putchar(x, y, c) c ucul_put_char(__caca0_cv, x, y, c)139 #define caca_putstr(x, y, s) c ucul_put_str(__caca0_cv, x, y, s)140 #define caca_printf(x, y, f, z...) c ucul_printf(__caca0_cv, x, y, f, ##z)141 #define caca_clear() c ucul_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) 142 142 143 143 #define caca_draw_line(x, y, z, t, c) \ 144 c ucul_draw_line(__caca0_cv, x, y, z, t, c)144 caca_draw_line(__caca0_cv, x, y, z, t, c) 145 145 #define caca_draw_polyline(x, y, z, c) \ 146 c ucul_draw_polyline(__caca0_cv, x, y, z, c)146 caca_draw_polyline(__caca0_cv, x, y, z, c) 147 147 #define caca_draw_thin_line(x, y, z, t) \ 148 c ucul_draw_thin_line(__caca0_cv, x, y, z, t)148 caca_draw_thin_line(__caca0_cv, x, y, z, t) 149 149 #define caca_draw_thin_polyline(x, y, z) \ 150 c ucul_draw_thin_polyline(__caca0_cv, x, y, z)150 caca_draw_thin_polyline(__caca0_cv, x, y, z) 151 151 #define caca_draw_circle(x, y, z, c) \ 152 c ucul_draw_circle(__caca0_cv, x, y, z, c)152 caca_draw_circle(__caca0_cv, x, y, z, c) 153 153 #define caca_draw_ellipse(x, y, z, t, c) \ 154 c ucul_draw_ellipse(__caca0_cv, x, y, z, t, c)154 caca_draw_ellipse(__caca0_cv, x, y, z, t, c) 155 155 #define caca_draw_thin_ellipse(x, y, z, t) \ 156 c ucul_draw_thin_ellipse(__caca0_cv, x, y, z, t)156 caca_draw_thin_ellipse(__caca0_cv, x, y, z, t) 157 157 #define caca_fill_ellipse(x, y, z, t, c) \ 158 c ucul_fill_ellipse(__caca0_cv, x, y, z, t, c)158 caca_fill_ellipse(__caca0_cv, x, y, z, t, c) 159 159 #define caca_draw_box(x, y, z, t, c) \ 160 c ucul_draw_box(__caca0_cv, x, y, z, t, c)160 caca_draw_box(__caca0_cv, x, y, z, t, c) 161 161 #define caca_draw_thin_box(x, y, z, t) \ 162 c ucul_draw_thin_box(__caca0_cv, x, y, z, t)162 caca_draw_thin_box(__caca0_cv, x, y, z, t) 163 163 #define caca_fill_box(x, y, z, t, c) \ 164 c ucul_fill_box(__caca0_cv, x, y, z, t, c)164 caca_fill_box(__caca0_cv, x, y, z, t, c) 165 165 #define caca_draw_triangle(x, y, z, t, u, v, c) \ 166 c ucul_draw_triangle(__caca0_cv, x, y, z, t, u, v, c)166 caca_draw_triangle(__caca0_cv, x, y, z, t, u, v, c) 167 167 #define caca_draw_thin_triangle(x, y, z, t, u, v) \ 168 c ucul_draw_thin_triangle(__caca0_cv, x, y, z, t, u, v)168 caca_draw_thin_triangle(__caca0_cv, x, y, z, t, u, v) 169 169 #define caca_fill_triangle(x, y, z, t, u, v, c) \ 170 c ucul_fill_triangle(__caca0_cv, x, y, z, t, u, v, c)170 caca_fill_triangle(__caca0_cv, x, y, z, t, u, v, c) 171 171 172 #define caca_rand(a, b) c ucul_rand(a, (b)+1)172 #define caca_rand(a, b) caca_rand(a, (b)+1) 173 173 #define caca_sqrt __caca0_sqrt 174 174 175 #define caca_sprite c ucul_canvas175 #define caca_sprite caca_canvas 176 176 #define caca_load_sprite __caca0_load_sprite 177 177 #define caca_get_sprite_frames(c) 1 178 #define caca_get_sprite_width(c, f) c ucul_get_canvas_width(c)179 #define caca_get_sprite_height(c, f) c ucul_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) 180 180 #define caca_get_sprite_dx(c, f) 0 181 181 #define caca_get_sprite_dx(c, f) 0 182 #define caca_draw_sprite(x, y, c, f) c ucul_blit(__caca0_cv, x, y, c, NULL)183 #define caca_free_sprite c ucul_free_canvas182 #define caca_draw_sprite(x, y, c, f) caca_blit(__caca0_cv, x, y, c, NULL) 183 #define caca_free_sprite caca_free_canvas 184 184 185 #define caca_bitmap c ucul_dither185 #define caca_bitmap caca_dither 186 186 #define caca_create_bitmap __caca0_create_bitmap 187 #define caca_set_bitmap_palette c ucul_set_dither_palette187 #define caca_set_bitmap_palette caca_set_dither_palette 188 188 #define caca_draw_bitmap(x, y, z, t, b, p) \ 189 c ucul_dither_bitmap(__caca0_cv, x, y, z, t, b, p)189 caca_dither_bitmap(__caca0_cv, x, y, z, t, b, p) 190 190 #define caca_free_bitmap __caca0_free_bitmap 191 191 -
libcaca/trunk/caca/caca_internals.h
r2305 r2821 20 20 typedef struct caca_timer caca_timer_t; 21 21 typedef struct caca_privevent caca_privevent_t; 22 typedef struct caca_figfont caca_figfont_t; 22 23 23 24 #if !defined(_DOXYGEN_SKIP_ME) 24 25 # define EVENTBUF_LEN 10 25 26 #endif 27 28 struct 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 46 struct 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 }; 26 70 27 71 /* Graphics driver */ … … 105 149 struct caca_display 106 150 { 107 /* A link to our c uculcanvas */108 c ucul_canvas_t *cv;151 /* A link to our caca canvas */ 152 caca_canvas_t *cv; 109 153 int autorelease; 110 154 … … 169 213 }; 170 214 215 /* Colour functions */ 216 extern uint32_t _caca_attr_to_rgb24fg(uint32_t); 217 extern uint32_t _caca_attr_to_rgb24bg(uint32_t); 218 219 /* Frames functions */ 220 extern void _caca_save_frame_info(caca_canvas_t *); 221 extern void _caca_load_frame_info(caca_canvas_t *); 222 171 223 /* Internal timer functions */ 172 224 extern void _caca_sleep(int); -
libcaca/trunk/caca/caca_types.h.in
r2819 r2821 1 1 /* 2 * libc ucul Canvas for ultrafast compositing of Unicode letters2 * libcaca Colour ASCII-Art library 3 3 * libcaca Colour ASCII-Art library 4 4 * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> … … 17 17 */ 18 18 19 #ifndef __C UCUL_TYPES_H__20 #define __C UCUL_TYPES_H__19 #ifndef __CACA_TYPES_H__ 20 #define __CACA_TYPES_H__ 21 21 22 #ifndef C UCUL_TYPES23 # define C UCUL_TYPES @CUCUL_TYPES@22 #ifndef CACA_TYPES 23 # define CACA_TYPES @CACA_TYPES@ 24 24 #endif 25 25 26 26 /* mode 1: standard <stdint.h> header is present, just include it */ 27 #if C UCUL_TYPES == 127 #if CACA_TYPES == 1 28 28 # include <stdint.h> 29 29 # include <unistd.h> 30 30 31 31 /* mode 2: standard <inttypes.h> header is present, just include it */ 32 #elif C UCUL_TYPES == 232 #elif CACA_TYPES == 2 33 33 # include <inttypes.h> 34 34 # include <unistd.h> … … 36 36 /* mode 3: <windows.h> indicates Win32, only (u)intptr_t is present 37 37 * FIXME: Win64 probably doesn't work that way */ 38 #elif C UCUL_TYPES == 338 #elif CACA_TYPES == 3 39 39 #include <windows.h> 40 40 … … 56 56 * have no idea what other typedefs have already been made. */ 57 57 #else 58 typedef signed char _c ucul_int8_t;59 typedef signed short _c ucul_int16_t;60 typedef signed long int _c ucul_int32_t;61 typedef signed long long int _c ucul_int64_t;58 typedef signed char _caca_int8_t; 59 typedef signed short _caca_int16_t; 60 typedef signed long int _caca_int32_t; 61 typedef signed long long int _caca_int64_t; 62 62 # undef int8_t 63 # define int8_t _c ucul_int8_t63 # define int8_t _caca_int8_t 64 64 # undef int16_t 65 # define int16_t _c ucul_int16_t65 # define int16_t _caca_int16_t 66 66 # undef int32_t 67 # define int32_t _c ucul_int32_t67 # define int32_t _caca_int32_t 68 68 # undef int64_t 69 # define int64_t _c ucul_int64_t69 # define int64_t _caca_int64_t 70 70 71 typedef unsigned char _c ucul_uint8_t;72 typedef unsigned short _c ucul_uint16_t;73 typedef unsigned long int _c ucul_uint32_t;74 typedef unsigned long long int _c ucul_uint64_t;71 typedef unsigned char _caca_uint8_t; 72 typedef unsigned short _caca_uint16_t; 73 typedef unsigned long int _caca_uint32_t; 74 typedef unsigned long long int _caca_uint64_t; 75 75 # undef uint8_t 76 # define uint8_t _c ucul_uint8_t76 # define uint8_t _caca_uint8_t 77 77 # undef uint16_t 78 # define uint16_t _c ucul_uint16_t78 # define uint16_t _caca_uint16_t 79 79 # undef uint32_t 80 # define uint32_t _c ucul_uint32_t80 # define uint32_t _caca_uint32_t 81 81 # undef uint64_t 82 # define uint64_t _c ucul_uint64_t82 # define uint64_t _caca_uint64_t 83 83 84 typedef long int _c ucul_intptr_t;85 typedef unsigned long int _c ucul_uintptr_t;84 typedef long int _caca_intptr_t; 85 typedef unsigned long int _caca_uintptr_t; 86 86 # undef intptr_t 87 # define intptr_t _c ucul_intptr_t87 # define intptr_t _caca_intptr_t 88 88 # undef uintptr_t 89 # define uintptr_t _c ucul_uintptr_t89 # define uintptr_t _caca_uintptr_t 90 90 91 typedef int _c ucul_ssize_t;92 typedef unsigned int _c ucul_size_t;91 typedef int _caca_ssize_t; 92 typedef unsigned int _caca_size_t; 93 93 # undef ssize_t 94 # define ssize_t _c ucul_ssize_t94 # define ssize_t _caca_ssize_t 95 95 # undef size_t 96 # define size_t _c ucul_size_t96 # define size_t _caca_size_t 97 97 98 98 #endif 99 99 100 #endif /* __C UCUL_TYPES_H__ */100 #endif /* __CACA_TYPES_H__ */ 101 101 -
libcaca/trunk/caca/canvas.c
r2819 r2821 1 1 /* 2 * libc ucul Canvas for ultrafast compositing of Unicode letters2 * libcaca Colour ASCII-Art library 3 3 * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 14 14 15 15 /* 16 * This file contains the main functions used by \e libc uculapplications16 * This file contains the main functions used by \e libcaca applications 17 17 * to initialise a drawing context. 18 18 */ … … 31 31 #endif 32 32 33 #include "c ucul.h"34 #include "c ucul_internals.h"35 36 static int c ucul_resize(cucul_canvas_t *, int, int);37 38 /** \brief Initialise a \e libc uculcanvas.39 * 40 * Initialise internal \e libc uculstructures and the backend that will33 #include "caca.h" 34 #include "caca_internals.h" 35 36 static 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 41 41 * be used for subsequent graphical operations. It must be the first 42 * \e libc ucul function to be called in a function. cucul_free_canvas()42 * \e libcaca function to be called in a function. caca_free_canvas() 43 43 * should be called at the end of the program to free all allocated resources. 44 44 * … … 52 52 * \param width The desired canvas width 53 53 * \param height The desired canvas height 54 * \return A libc uculcanvas handle upon success, NULL if an error occurred.55 */ 56 c ucul_canvas_t * cucul_create_canvas(int width, int height)57 { 58 c ucul_canvas_t *cv;54 * \return A libcaca canvas handle upon success, NULL if an error occurred. 55 */ 56 caca_canvas_t * caca_create_canvas(int width, int height) 57 { 58 caca_canvas_t *cv; 59 59 60 60 if(width < 0 || height < 0) … … 64 64 } 65 65 66 cv = malloc(sizeof(c ucul_canvas_t));66 cv = malloc(sizeof(caca_canvas_t)); 67 67 68 68 if(!cv) … … 76 76 cv->frame = 0; 77 77 cv->framecount = 1; 78 cv->frames = malloc(sizeof(struct c ucul_frame));78 cv->frames = malloc(sizeof(struct caca_frame)); 79 79 if(!cv->frames) 80 80 { … … 91 91 cv->frames[0].name = strdup("frame#00000000"); 92 92 93 _c ucul_load_frame_info(cv);94 c ucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);93 _caca_load_frame_info(cv); 94 caca_set_color_ansi(cv, CACA_DEFAULT, CACA_TRANSPARENT); 95 95 96 96 cv->ff = NULL; 97 97 98 if(c ucul_resize(cv, width, height) < 0)98 if(caca_resize(cv, width, height) < 0) 99 99 { 100 100 int saved_errno = geterrno(); … … 117 117 * Lock a canvas to prevent it from being resized. If non-NULL, 118 118 * the \e callback function pointer will be called upon each 119 * \e c ucul_set_canvas_size call and if the returned value is zero, the119 * \e caca_set_canvas_size call and if the returned value is zero, the 120 120 * canvas resize request will be denied. 121 121 * … … 126 126 * - \c EBUSY The canvas is already being managed. 127 127 * 128 * \param cv A libc uculcanvas.128 * \param cv A libcaca canvas. 129 129 * \param callback An optional callback function pointer. 130 130 * \param p The argument to be passed to \e callback. 131 131 * \return 0 in case of success, -1 if an error occurred. 132 132 */ 133 int c ucul_manage_canvas(cucul_canvas_t *cv, int (*callback)(void *), void *p)133 int caca_manage_canvas(caca_canvas_t *cv, int (*callback)(void *), void *p) 134 134 { 135 135 if(cv->refcount) … … 148 148 /** \brief Unmanage a canvas. 149 149 * 150 * Unlock a canvas previously locked by c ucul_manage_canvas(). For safety150 * Unlock a canvas previously locked by caca_manage_canvas(). For safety 151 151 * reasons, the callback and callback data arguments must be the same as for 152 * the c ucul_manage_canvas() call.152 * the caca_manage_canvas() call. 153 153 * 154 154 * This function is only useful for display drivers such as the \e libcaca … … 159 159 * not match. 160 160 * 161 * \param cv A libc uculcanvas.161 * \param cv A libcaca canvas. 162 162 * \param callback The \e callback argument previously passed to 163 c ucul_manage_canvas().164 * \param p The \e p argument previously passed to c ucul_manage_canvas().163 caca_manage_canvas(). 164 * \param p The \e p argument previously passed to caca_manage_canvas(). 165 165 * \return 0 in case of success, -1 if an error occurred. 166 166 */ 167 int c ucul_unmanage_canvas(cucul_canvas_t *cv, int (*callback)(void *), void *p)167 int caca_unmanage_canvas(caca_canvas_t *cv, int (*callback)(void *), void *p) 168 168 { 169 169 if(!cv->refcount … … 205 205 * happens, the canvas handle becomes invalid and should not be used. 206 206 * 207 * \param cv A libc uculcanvas.207 * \param cv A libcaca canvas. 208 208 * \param width The desired canvas width. 209 209 * \param height The desired canvas height. 210 210 * \return 0 in case of success, -1 if an error occurred. 211 211 */ 212 int c ucul_set_canvas_size(cucul_canvas_t *cv, int width, int height)212 int caca_set_canvas_size(caca_canvas_t *cv, int width, int height) 213 213 { 214 214 if(width < 0 || height < 0) … … 225 225 } 226 226 227 return c ucul_resize(cv, width, height);227 return caca_resize(cv, width, height); 228 228 } 229 229 … … 234 234 * This function never fails. 235 235 * 236 * \param cv A libc uculcanvas.236 * \param cv A libcaca canvas. 237 237 * \return The canvas width. 238 238 */ 239 int c ucul_get_canvas_width(cucul_canvas_t const *cv)239 int caca_get_canvas_width(caca_canvas_t const *cv) 240 240 { 241 241 return cv->width; … … 248 248 * This function never fails. 249 249 * 250 * \param cv A libc uculcanvas.250 * \param cv A libcaca canvas. 251 251 * \return The canvas height. 252 252 */ 253 int c ucul_get_canvas_height(cucul_canvas_t const *cv)253 int caca_get_canvas_height(caca_canvas_t const *cv) 254 254 { 255 255 return cv->height; … … 260 260 * Return the current canvas' internal character array. The array elements 261 261 * consist in native endian 32-bit Unicode values as returned by 262 * c ucul_get_char().262 * caca_get_char(). 263 263 * 264 264 * This function is only useful for display drivers such as the \e libcaca … … 267 267 * This function never fails. 268 268 * 269 * \param cv A libc uculcanvas.269 * \param cv A libcaca canvas. 270 270 * \return The canvas character array. 271 271 */ 272 uint8_t const * c ucul_get_canvas_chars(cucul_canvas_t const *cv)272 uint8_t const * caca_get_canvas_chars(caca_canvas_t const *cv) 273 273 { 274 274 return (uint8_t const *)cv->chars; … … 279 279 * Returns the current canvas' internal attribute array. The array elements 280 280 * consist in native endian 32-bit attribute values as returned by 281 * c ucul_get_attr().281 * caca_get_attr(). 282 282 * 283 283 * This function is only useful for display drivers such as the \e libcaca … … 286 286 * This function never fails. 287 287 * 288 * \param cv A libc uculcanvas.288 * \param cv A libcaca canvas. 289 289 * \return The canvas attribute array. 290 290 */ 291 uint8_t const * c ucul_get_canvas_attrs(cucul_canvas_t const *cv)291 uint8_t const * caca_get_canvas_attrs(caca_canvas_t const *cv) 292 292 { 293 293 return (uint8_t const *)cv->attrs; 294 294 } 295 295 296 /** \brief Uninitialise \e libc ucul.297 * 298 * Free all resources allocated by c ucul_create_canvas(). After299 * this function has been called, no other \e libc uculfunctions may be300 * used unless a new call to c ucul_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. 301 301 * 302 302 * If an error occurs, -1 is returned and \b errno is set accordingly: 303 303 * - \c EBUSY The canvas is in use by a display driver and cannot be freed. 304 304 * 305 * \param cv A libc uculcanvas.305 * \param cv A libcaca canvas. 306 306 * \return 0 in case of success, -1 if an error occurred. 307 307 */ 308 int c ucul_free_canvas(cucul_canvas_t *cv)308 int caca_free_canvas(caca_canvas_t *cv) 309 309 { 310 310 int f; … … 323 323 } 324 324 325 c ucul_canvas_set_figfont(cv, NULL);325 caca_canvas_set_figfont(cv, NULL); 326 326 327 327 free(cv->frames); … … 342 342 * (inclusive). 343 343 */ 344 int c ucul_rand(int min, int max)344 int caca_rand(int min, int max) 345 345 { 346 346 static int need_init = 1; … … 355 355 } 356 356 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 }369 357 370 358 /* … … 372 360 */ 373 361 374 int c ucul_resize(cucul_canvas_t *cv, int width, int height)362 int caca_resize(caca_canvas_t *cv, int width, int height) 375 363 { 376 364 int x, y, f, old_width, old_height, new_size, old_size; … … 380 368 old_size = old_width * old_height; 381 369 382 _c ucul_save_frame_info(cv);370 _caca_save_frame_info(cv); 383 371 384 372 cv->width = width; … … 508 496 509 497 /* Reset the current frame shortcuts */ 510 _c ucul_load_frame_info(cv);498 _caca_load_frame_info(cv); 511 499 512 500 return 0; -
libcaca/trunk/caca/charset.c
r2819 r2821 1 1 /* 2 * libc ucul Canvas for ultrafast compositing of Unicode letters2 * libcaca Colour ASCII-Art library 3 3 * Copyright (c) 2002-2007 Sam Hocevar <sam@zoy.org> 4 4 * 2007 Ben Wiley Sittler <bsittler@gmail.com> … … 25 25 #endif 26 26 27 #include "c ucul.h"28 #include "c ucul_internals.h"27 #include "caca.h" 28 #include "caca_internals.h" 29 29 30 30 /* … … 112 112 * is incomplete. 113 113 */ 114 uint32_t c ucul_utf8_to_utf32(char const *s, size_t *bytes)114 uint32_t caca_utf8_to_utf32(char const *s, size_t *bytes) 115 115 { 116 116 int todo = trailing[(int)(unsigned char)*s]; … … 151 151 * \return The number of bytes written. 152 152 */ 153 size_t c ucul_utf32_to_utf8(char *buf, uint32_t ch)153 size_t caca_utf32_to_utf8(char *buf, uint32_t ch) 154 154 { 155 155 static const uint8_t mark[7] = … … 191 191 * \return The corresponding CP437 character, or "?" if not representable. 192 192 */ 193 uint8_t c ucul_utf32_to_cp437(uint32_t ch)193 uint8_t caca_utf32_to_cp437(uint32_t ch) 194 194 { 195 195 unsigned int i; … … 223 223 * \return The corresponding UTF-32 character, or zero if not representable. 224 224 */ 225 uint32_t c ucul_cp437_to_utf32(uint8_t ch)225 uint32_t caca_cp437_to_utf32(uint8_t ch) 226 226 { 227 227 if(ch > 0x7f) … … 249 249 * equivalent if found, or "?" if not representable. 250 250 */ 251 char c ucul_utf32_to_ascii(uint32_t ch)251 char caca_utf32_to_ascii(uint32_t ch) 252 252 { 253 253 /* Standard ASCII */ … … 388 388 * \return 1 if the character is fullwidth, 0 otherwise. 389 389 */ 390 int c ucul_utf32_is_fullwidth(uint32_t ch)390 int caca_utf32_is_fullwidth(uint32_t ch) 391 391 { 392 392 if(ch < 0x2e80) /* Standard stuff */ -
libcaca/trunk/caca/conic.c
r2819 r2821 1 1 /* 2 * libc ucul Canvas for ultrafast compositing of Unicode letters2 * libcaca Colour ASCII-Art library 3 3 * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 24 24 #endif 25 25 26 #include "c ucul.h"27 #include "c ucul_internals.h"28 29 static void ellipsepoints(c ucul_canvas_t *, int, int, int, int, uint32_t, int);26 #include "caca.h" 27 #include "caca_internals.h" 28 29 static void ellipsepoints(caca_canvas_t *, int, int, int, int, uint32_t, int); 30 30 31 31 /** \brief Draw a circle on the canvas using the given character. … … 33 33 * This function never fails. 34 34 * 35 * \param cv The handle to the libc uculcanvas.35 * \param cv The handle to the libcaca canvas. 36 36 * \param x Center X coordinate. 37 37 * \param y Center Y coordinate. … … 40 40 * \return This function always returns 0. 41 41 */ 42 int c ucul_draw_circle(cucul_canvas_t *cv, int x, int y, int r, uint32_t ch)42 int caca_draw_circle(caca_canvas_t *cv, int x, int y, int r, uint32_t ch) 43 43 { 44 44 int test, dx, dy; … … 60 60 * This function never fails. 61 61 * 62 * \param cv The handle to the libc uculcanvas.62 * \param cv The handle to the libcaca canvas. 63 63 * \param xo Center X coordinate. 64 64 * \param yo Center Y coordinate. … … 68 68 * \return This function always returns 0. 69 69 */ 70 int c ucul_fill_ellipse(cucul_canvas_t *cv, int xo, int yo, int a, int b,70 int caca_fill_ellipse(caca_canvas_t *cv, int xo, int yo, int a, int b, 71 71 uint32_t ch) 72 72 { … … 85 85 { 86 86 d1 += b*b*(2*x*1) + a*a*(-2*y+2); 87 c ucul_draw_line(cv, xo - x, yo - y, xo + x, yo - y, ch);88 c ucul_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); 89 89 y--; 90 90 } … … 92 92 } 93 93 94 c ucul_draw_line(cv, xo - x, yo - y, xo + x, yo - y, ch);95 c ucul_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); 96 96 97 97 d2 = b*b*(x+0.5)*(x+0.5) + a*a*(y-1)*(y-1) - a*a*b*b; … … 109 109 110 110 y--; 111 c ucul_draw_line(cv, xo - x, yo - y, xo + x, yo - y, ch);112 c ucul_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); 113 113 } 114 114 … … 120 120 * This function never fails. 121 121 * 122 * \param cv The handle to the libc uculcanvas.122 * \param cv The handle to the libcaca canvas. 123 123 * \param xo Center X coordinate. 124 124 * \param yo Center Y coordinate. … … 128 128 * \return This function always returns 0. 129 129 */ 130 int c ucul_draw_ellipse(cucul_canvas_t *cv, int xo, int yo, int a, int b,130 int caca_draw_ellipse(caca_canvas_t *cv, int xo, int yo, int a, int b, 131 131 uint32_t ch) 132 132 { … … 177 177 * This function never fails. 178 178 * 179 * \param cv The handle to the libc uculcanvas.179 * \param cv The handle to the libcaca canvas. 180 180 * \param xo Center X coordinate. 181 181 * \param yo Center Y coordinate. … … 184 184 * \return This function always returns 0. 185 185 */ 186 int c ucul_draw_thin_ellipse(cucul_canvas_t *cv, int xo, int yo, int a, int b)186 int caca_draw_thin_ellipse(caca_canvas_t *cv, int xo, int yo, int a, int b) 187 187 { 188 188 /* FIXME: this is not correct */ … … 235 235 } 236 236 237 static void ellipsepoints(c ucul_canvas_t *cv, int xo, int yo, int x, int y,237 static void ellipsepoints(caca_canvas_t *cv, int xo, int yo, int x, int y, 238 238 uint32_t ch, int thin) 239 239 { … … 269 269 270 270 } 271 c ucul_put_char(cv, xo + x, yo + y, c);271 caca_put_char(cv, xo + x, yo + y, c); 272 272 } 273 273 if((b & (0x2|0x4)) == (0x2|0x4)) { … … 291 291 292 292 } 293 c ucul_put_char(cv, xo - x, yo + y, c);293 caca_put_char(cv, xo - x, yo + y, c); 294 294 } 295 295 … … 315 315 316 316 } 317 c ucul_put_char(cv, xo + x, yo - y, c);317 caca_put_char(cv, xo + x, yo - y, c); 318 318 } 319 319 … … 338 338 339 339 } 340 c ucul_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 1 1 /* 2 * libc ucul Canvas for ultrafast compositing of Unicode letters2 * libcaca Colour ASCII-Art library 3 3 * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 29 29 #endif 30 30 31 #include "c ucul.h"32 #include "c ucul_internals.h"31 #include "caca.h" 32 #include "caca_internals.h" 33 33 34 34 #define CP437 0 … … 116 116 }; 117 117 118 struct c ucul_dither118 struct caca_dither 119 119 { 120 120 int bpp, has_palette, has_alpha; … … 123 123 int rright, gright, bright, aright; 124 124 int rleft, gleft, bleft, aleft; 125 void (*get_hsv)(c ucul_dither_t *, char *, int, int);125 void (*get_hsv)(caca_dither_t *, char *, int, int); 126 126 int red[256], green[256], blue[256], alpha[256]; 127 127 … … 173 173 static float gammapow(float x, float y); 174 174 175 static void get_rgba_default(c ucul_dither_t const *, uint8_t *, int, int,175 static void get_rgba_default(caca_dither_t const *, uint8_t *, int, int, 176 176 unsigned int *); 177 177 static int init_lookup(void); … … 243 243 * pitch) and pixel mask values. If the depth is 8 bits per pixel, the mask 244 244 * values are ignored and the colour palette should be set using the 245 * c ucul_set_dither_palette() function. For depths greater than 8 bits per245 * caca_set_dither_palette() function. For depths greater than 8 bits per 246 246 * pixel, a zero alpha mask causes the alpha values to be ignored. 247 247 * … … 261 261 * \return Dither object upon success, NULL if an error occurred. 262 262 */ 263 c ucul_dither_t *cucul_create_dither(int bpp, int w, int h, int pitch,263 caca_dither_t *caca_create_dither(int bpp, int w, int h, int pitch, 264 264 uint32_t rmask, uint32_t gmask, 265 265 uint32_t bmask, uint32_t amask) 266 266 { 267 c ucul_dither_t *d;267 caca_dither_t *d; 268 268 int i; 269 269 … … 275 275 } 276 276 277 d = malloc(sizeof(c ucul_dither_t));277 d = malloc(sizeof(caca_dither_t)); 278 278 if(!d) 279 279 { … … 372 372 * \return 0 in case of success, -1 if an error occurred. 373 373 */ 374 int c ucul_set_dither_palette(cucul_dither_t *d,374 int caca_set_dither_palette(caca_dither_t *d, 375 375 uint32_t red[], uint32_t green[], 376 376 uint32_t blue[], uint32_t alpha[]) … … 421 421 * \return 0 in case of success, -1 if an error occurred. 422 422 */ 423 int c ucul_set_dither_brightness(cucul_dither_t *d, float brightness)423 int caca_set_dither_brightness(caca_dither_t *d, float brightness) 424 424 { 425 425 /* FIXME */ … … 438 438 * \return Brightness value. 439 439 */ 440 float c ucul_get_dither_brightness(cucul_dither_t const *d)440 float caca_get_dither_brightness(caca_dither_t const *d) 441 441 { 442 442 return d->brightness; … … 455 455 * \return 0 in case of success, -1 if an error occurred. 456 456 */ 457 int c ucul_set_dither_gamma(cucul_dither_t *d, float gamma)457 int caca_set_dither_gamma(caca_dither_t *d, float gamma) 458 458 { 459 459 /* FIXME: we don't need 4096 calls to gammapow(), we could just compute … … 490 490 * \return Gamma value. 491 491 */ 492 float c ucul_get_dither_gamma(cucul_dither_t const *d)492 float caca_get_dither_gamma(caca_dither_t const *d) 493 493 { 494 494 return d->gamma; … … 506 506 * \return 0 in case of success, -1 if an error occurred. 507 507 */ 508 int c ucul_set_dither_contrast(cucul_dither_t *d, float contrast)508 int caca_set_dither_contrast(caca_dither_t *d, float contrast) 509 509 { 510 510 /* FIXME */ … … 523 523 * \return Contrast value. 524 524 */ 525 float c ucul_get_dither_contrast(cucul_dither_t const *d)525 float caca_get_dither_contrast(caca_dither_t const *d) 526 526 { 527 527 return d->contrast; … … 544 544 * \return 0 in case of success, -1 if an error occurred. 545 545 */ 546 int c ucul_set_dither_antialias(cucul_dither_t *d, char const *str)546 int caca_set_dither_antialias(caca_dither_t *d, char const *str) 547 547 { 548 548 if(!strcasecmp(str, "none")) … … 570 570 * list is a NULL-terminated array of strings, interleaving a string 571 571 * containing the internal value for the antialiasing method to be used with 572 * c ucul_set_dither_antialias(), and a string containing the natural572 * caca_set_dither_antialias(), and a string containing the natural 573 573 * language description for that antialiasing method. 574 574 * … … 579 579 */ 580 580 char const * const * 581 c ucul_get_dither_antialias_list(cucul_dither_t const *d)581 caca_get_dither_antialias_list(caca_dither_t const *d) 582 582 { 583 583 static char const * const list[] = … … 600 600 * \return A static string. 601 601 */ 602 char const * c ucul_get_dither_antialias(cucul_dither_t const *d)602 char const * caca_get_dither_antialias(caca_dither_t const *d) 603 603 { 604 604 return d->antialias_name; … … 628 628 * \return 0 in case of success, -1 if an error occurred. 629 629 */ 630 int c ucul_set_dither_color(cucul_dither_t *d, char const *str)630 int caca_set_dither_color(caca_dither_t *d, char const *str) 631 631 { 632 632 if(!strcasecmp(str, "mono")) … … 679 679 * is a NULL-terminated array of strings, interleaving a string containing 680 680 * the internal value for the colour mode, to be used with 681 * c ucul_set_dither_color(), and a string containing the natural681 * caca_set_dither_color(), and a string containing the natural 682 682 * language description for that colour mode. 683 683 * … … 688 688 */ 689 689 char const * const * 690 c ucul_get_dither_color_list(cucul_dither_t const *d)690 caca_get_dither_color_list(caca_dither_t const *d) 691 691 { 692 692 static char const * const list[] = … … 714 714 * \return A static string. 715 715 */ 716 char const * c ucul_get_dither_color(cucul_dither_t const *d)716 char const * caca_get_dither_color(caca_dither_t const *d) 717 717 { 718 718 return d->color_name; … … 739 739 * \return 0 in case of success, -1 if an error occurred. 740 740 */ 741 int c ucul_set_dither_charset(cucul_dither_t *d, char const *str)741 int caca_set_dither_charset(caca_dither_t *d, char const *str) 742 742 { 743 743 if(!strcasecmp(str, "shades")) … … 773 773 * is a NULL-terminated array of strings, interleaving a string containing 774 774 * the internal value for the character set, to be used with 775 * c ucul_set_dither_charset(), and a string containing the natural775 * caca_set_dither_charset(), and a string containing the natural 776 776 * language description for that character set. 777 777 * … … 781 781 * \return An array of strings. 782 782 */ 783 char const * const * c ucul_get_dither_charset_list(cucul_dither_t const *d)783 char const * const * caca_get_dither_charset_list(caca_dither_t const *d) 784 784 { 785 785 static char const * const list[] = … … 803 803 * \return A static string. 804 804 */ 805 char const * c ucul_get_dither_charset(cucul_dither_t const *d)805 char const * caca_get_dither_charset(caca_dither_t const *d) 806 806 { 807 807 return d->glyph_name; … … 828 828 * \return 0 in case of success, -1 if an error occurred. 829 829 */ 830 int c ucul_set_dither_algorithm(cucul_dither_t *d, char const *str)830 int caca_set_dither_algorithm(caca_dither_t *d, char const *str) 831 831 { 832 832 if(!strcasecmp(str, "none")) … … 886 886 * list is a NULL-terminated array of strings, interleaving a string 887 887 * containing the internal value for the dithering algorithm, to be used 888 * with c ucul_set_dither_dithering(), and a string containing the natural888 * with caca_set_dither_dithering(), and a string containing the natural 889 889 * language description for that algorithm. 890 890 * … … 894 894 * \return An array of strings. 895 895 */ 896 char const * const * c ucul_get_dither_algorithm_list(cucul_dither_t const *d)896 char const * const * caca_get_dither_algorithm_list(caca_dither_t const *d) 897 897 { 898 898 static char const * const list[] = … … 919 919 * \return A static string. 920 920 */ 921 char const * c ucul_get_dither_algorithm(cucul_dither_t const *d)921 char const * caca_get_dither_algorithm(caca_dither_t const *d) 922 922 { 923 923 return d->algo_name; … … 931 931 * This function never fails. 932 932 * 933 * \param cv A handle to the libc uculcanvas.933 * \param cv A handle to the libcaca canvas. 934 934 * \param x X coordinate of the upper-left corner of the drawing area. 935 935 * \param y Y coordinate of the upper-left corner of the drawing area. … … 940 940 * \return This function always returns 0. 941 941 */ 942 int c ucul_dither_bitmap(cucul_canvas_t *cv, int x, int y, int w, int h,943 c ucul_dither_t const *d, void *pixels)942 int caca_dither_bitmap(caca_canvas_t *cv, int x, int y, int w, int h, 943 caca_dither_t const *d, void *pixels) 944 944 { 945 945 int *floyd_steinberg, *fs_r, *fs_g, *fs_b; … … 951 951 return 0; 952 952 953 savedattr = c ucul_get_attr(cv, -1, -1);953 savedattr = caca_get_attr(cv, -1, -1); 954 954 955 955 x1 = x; x2 = x + w - 1; … … 1128 1128 if(rgba[2] > lum) lum = rgba[2]; 1129 1129 outfg = outbg; 1130 outbg = C UCUL_BLACK;1130 outbg = CACA_BLACK; 1131 1131 1132 1132 ch = lum * dchmax / 0x1000; … … 1170 1170 1171 1171 /* Now output the character */ 1172 c ucul_set_color_ansi(cv, outfg, outbg);1173 c ucul_put_char(cv, x, y, outch);1172 caca_set_color_ansi(cv, outfg, outbg); 1173 caca_put_char(cv, x, y, outch); 1174 1174 1175 1175 d->increment_dither(); … … 1180 1180 free(floyd_steinberg); 1181 1181 1182 c ucul_set_attr(cv, savedattr);1182 caca_set_attr(cv, savedattr); 1183 1183 1184 1184 return 0; … … 1187 1187 /** \brief Free the memory associated with a dither. 1188 1188 * 1189 * Free the memory allocated by c ucul_create_dither().1189 * Free the memory allocated by caca_create_dither(). 1190 1190 * 1191 1191 * This function never fails. … … 1194 1194 * \return This function always returns 0. 1195 1195 */ 1196 int c ucul_free_dither(cucul_dither_t *d)1196 int caca_free_dither(caca_dither_t *d) 1197 1197 { 1198 1198 if(!d) … … 1297 1297 } 1298 1298 1299 static void get_rgba_default(c ucul_dither_t const *d, uint8_t *pixels,1299 static void get_rgba_default(caca_dither_t const *d, uint8_t *pixels, 1300 1300 int x, int y, unsigned int *rgba) 1301 1301 { … … 1494 1494 static int get_random_dither(void) 1495 1495 { 1496 return c ucul_rand(0x00, 0x100);1496 return caca_rand(0x00, 0x100); 1497 1497 } 1498 1498 … … 1510 1510 1511 1511 /* These ones are constant */ 1512 lookup_colors[0] = C UCUL_BLACK;1513 lookup_colors[1] = C UCUL_DARKGRAY;1514 lookup_colors[2] = C UCUL_LIGHTGRAY;1515 lookup_colors[3] = C UCUL_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; 1516 1516 1517 1517 /* These ones will be overwritten */ 1518 lookup_colors[4] = C UCUL_MAGENTA;1519 lookup_colors[5] = C UCUL_LIGHTMAGENTA;1520 lookup_colors[6] = C UCUL_RED;1521 lookup_colors[7] = C UCUL_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; 1522 1522 1523 1523 for(v = 0; v < LOOKUP_VAL; v++) -
libcaca/trunk/caca/driver_cocoa.m
r2305 r2821 24 24 #import <Cocoa/Cocoa.h> 25 25 26 #include "c ucul.h"26 #include "caca.h" 27 27 #include "caca.h" 28 28 #include "caca_internals.h" … … 196 196 - (void)resizeIfNeeded:(caca_display_t *)dp 197 197 { 198 if(_w != c ucul_get_canvas_width(dp->cv)199 || _h != c ucul_get_canvas_height(dp->cv)198 if(_w != caca_get_canvas_width(dp->cv) 199 || _h != caca_get_canvas_height(dp->cv) 200 200 || !_attrs || !_bkg_rects || !_bkg_colors) 201 201 { 202 202 debug_log(@"%s resize to %ux%u", _cmd, _w, _h); 203 203 204 _w = c ucul_get_canvas_width(dp->cv);205 _h = c ucul_get_canvas_height(dp->cv);204 _w = caca_get_canvas_width(dp->cv); 205 _h = caca_get_canvas_height(dp->cv); 206 206 207 207 if(_attrs) … … 217 217 _bkg_colors = malloc(_w * _h * sizeof(NSColor*)); 218 218 219 [[self window] setContentSize: NSMakeSize(c ucul_get_canvas_width(dp->cv) * _font_rect.size.width,220 c ucul_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)]; 221 221 } 222 222 } … … 229 229 { 230 230 _chars = _attrs + _w * _h; 231 memcpy(_attrs, c ucul_get_canvas_attrs(dp->cv),231 memcpy(_attrs, caca_get_canvas_attrs(dp->cv), 232 232 _w * _h * sizeof(uint32_t)); 233 memcpy(_chars, c ucul_get_canvas_chars(dp->cv),233 memcpy(_chars, caca_get_canvas_chars(dp->cv), 234 234 _w * _h * sizeof(uint32_t)); 235 235 … … 271 271 NSColor* color = nil; 272 272 #if USE_RGB12_FGBG 273 uint16_t bg = c ucul_attr_to_rgb12_bg(*attrs);273 uint16_t bg = caca_attr_to_rgb12_bg(*attrs); 274 274 if(bg) 275 275 { … … 289 289 #else 290 290 uint8_t argb[8]; 291 c ucul_attr_to_argb64(*attrs, argb);291 caca_attr_to_argb64(*attrs, argb); 292 292 color = [NSColor colorWithCalibratedRed:((float)argb[1]) / 15.0 293 293 green:((float)argb[2]) / 15.0 … … 317 317 continue; 318 318 319 if(*chars == C UCUL_MAGIC_FULLWIDTH)319 if(*chars == CACA_MAGIC_FULLWIDTH) 320 320 continue; 321 321 … … 329 329 NSColor* color = nil; 330 330 #if USE_RGB12_FGBG 331 uint16_t fg = c ucul_attr_to_rgb12_fg(*attrs);331 uint16_t fg = caca_attr_to_rgb12_fg(*attrs); 332 332 # ifdef PRECACHE_WHOLE_COLOR_TABLE 333 333 color = _colorCache[fg]; … … 344 344 #else // USE_RGB12_FGBG 345 345 uint8_t argb[8]; 346 c ucul_attr_to_argb64(*attrs, argb);346 caca_attr_to_argb64(*attrs, argb); 347 347 debug_log(@"x,y=[%d,%d] r,g,b back=[%u %u %u] front=[%u %u %u]", 348 348 x, y, argb[1], argb[2], argb[3], argb[5], argb[6], argb[7]); … … 355 355 if(color) 356 356 { 357 NSMutableDictionary* attrDict = (*attrs & C UCUL_UNDERLINE) ?357 NSMutableDictionary* attrDict = (*attrs & CACA_UNDERLINE) ? 358 358 _attrDictUnderline : _attrDict; 359 359 [attrDict setObject:color forKey:NSForegroundColorAttributeName]; … … 573 573 NSRect fontRect = [font boundingRectForFont]; 574 574 fontRect = NSMakeRect(0, 0, ceilf(fontRect.size.width), ceilf(fontRect.size.height)); 575 NSRect windowRect = NSMakeRect(20, 20, c ucul_get_canvas_width(dp->cv) * fontRect.size.width,576 c ucul_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); 577 577 convert_NSRect(&windowRect); 578 578 … … 827 827 static int cocoa_init_graphics(caca_display_t *dp) 828 828 { 829 int width = c ucul_get_canvas_width(dp->cv);830 int height = c ucul_get_canvas_height(dp->cv);829 int width = caca_get_canvas_width(dp->cv); 830 int height = caca_get_canvas_height(dp->cv); 831 831 832 832 debug_log(@"%s dp->cv: %ux%u", __PRETTY_FUNCTION__, width, height); … … 839 839 840 840 dp->resize.allow = 1; 841 c ucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32);841 caca_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32); 842 842 dp->resize.allow = 0; 843 843 … … 859 859 { 860 860 debug_log(@"%s dp->cv: %ux%u", __PRETTY_FUNCTION__, 861 c ucul_get_canvas_width(dp->cv), cucul_get_canvas_height(dp->cv));861 caca_get_canvas_width(dp->cv), caca_get_canvas_height(dp->cv)); 862 862 863 863 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; … … 959 959 { 960 960 debug_log(@"%s", __PRETTY_FUNCTION__); 961 dp->resize.w = c ucul_get_canvas_width(dp->cv);962 dp->resize.h = c ucul_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); 963 963 } 964 964 -
libcaca/trunk/caca/driver_conio.c
r2305 r2821 29 29 #include <stdlib.h> 30 30 31 #include "cucul.h"32 31 #include "caca.h" 33 32 #include "caca_internals.h" … … 58 57 # endif 59 58 dp->resize.allow = 1; 60 c ucul_set_canvas_size(dp->cv, dp->drv.p->ti.screenwidth,59 caca_set_canvas_size(dp->cv, dp->drv.p->ti.screenwidth, 61 60 dp->drv.p->ti.screenheight); 62 61 dp->resize.allow = 0; … … 70 69 textcolor((enum COLORS)WHITE); 71 70 textbackground((enum COLORS)BLACK); 72 gotoxy(c ucul_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)); 73 72 cputs("\r\n"); 74 73 _setcursortype(_NORMALCURSOR); … … 88 87 { 89 88 /* Fallback to a 6x10 font */ 90 return c ucul_get_canvas_width(dp->cv) * 6;89 return caca_get_canvas_width(dp->cv) * 6; 91 90 } 92 91 … … 94 93 { 95 94 /* Fallback to a 6x10 font */ 96 return c ucul_get_canvas_height(dp->cv) * 10;95 return caca_get_canvas_height(dp->cv) * 10; 97 96 } 98 97 … … 100 99 { 101 100 char *screen = dp->drv.p->screen; 102 uint32_t const *chars = (uint32_t const *)c ucul_get_canvas_chars(dp->cv);103 uint32_t const *attrs = (uint32_t const *)c ucul_get_canvas_attrs(dp->cv);104 int width = c ucul_get_canvas_width(dp->cv);105 int height = c ucul_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); 106 105 int n; 107 106 108 107 for(n = height * width; n--; ) 109 108 { 110 char ch = c ucul_utf32_to_cp437(*chars++);111 if(n && *chars == C UCUL_MAGIC_FULLWIDTH)109 char ch = caca_utf32_to_cp437(*chars++); 110 if(n && *chars == CACA_MAGIC_FULLWIDTH) 112 111 { 113 112 *screen++ = '['; 114 *screen++ = c ucul_attr_to_ansi(*attrs++);113 *screen++ = caca_attr_to_ansi(*attrs++); 115 114 ch = ']'; 116 115 chars++; … … 118 117 } 119 118 *screen++ = ch; 120 *screen++ = c ucul_attr_to_ansi(*attrs++);119 *screen++ = caca_attr_to_ansi(*attrs++); 121 120 } 122 121 # if defined(SCREENUPDATE_IN_PC_H) … … 130 129 { 131 130 /* We know nothing about our window */ 132 dp->resize.w = c ucul_get_canvas_width(dp->cv);133 dp->resize.h = c ucul_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); 134 133 } 135 134 -
libcaca/trunk/caca/driver_gl.c
r2305 r2821 36 36 #include <stdio.h> 37 37 38 #include "cucul.h"39 38 #include "caca.h" 40 39 #include "caca_internals.h" … … 66 65 int width, height; 67 66 int new_width, new_height; 68 c ucul_font_t *f;67 caca_font_t *f; 69 68 float font_width, font_height; 70 69 float incx, incy; … … 88 87 char *argv[2] = { "", NULL }; 89 88 char const * const * fonts; 90 int width = c ucul_get_canvas_width(dp->cv);91 int height = c ucul_get_canvas_height(dp->cv);89 int width = caca_get_canvas_width(dp->cv); 90 int height = caca_get_canvas_height(dp->cv); 92 91 int argc = 1; 93 92 … … 103 102 104 103 dp->resize.allow = 1; 105 c ucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32);104 caca_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32); 106 105 dp->resize.allow = 0; 107 106 108 /* Load a libc uculinternal font */109 fonts = c ucul_get_font_list();107 /* Load a libcaca internal font */ 108 fonts = caca_get_font_list(); 110 109 if(fonts[0] == NULL) 111 110 { 112 fprintf(stderr, "error: libc uculwas compiled without any fonts\n");111 fprintf(stderr, "error: libcaca was compiled without any fonts\n"); 113 112 return -1; 114 113 } 115 dp->drv.p->f = c ucul_load_font(fonts[0], 0);114 dp->drv.p->f = caca_load_font(fonts[0], 0); 116 115 if(dp->drv.p->f == NULL) 117 116 { … … 120 119 } 121 120 122 dp->drv.p->font_width = c ucul_get_font_width(dp->drv.p->f);123 dp->drv.p->font_height = c ucul_get_font_height(dp->drv.p->f);124 125 dp->drv.p->width = c ucul_get_canvas_width(dp->cv) * dp->drv.p->font_width;126 dp->drv.p->height = c ucul_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; 127 126 128 127 #ifdef HAVE_GLUTCLOSEFUNC … … 193 192 glutHideWindow(); 194 193 glutDestroyWindow(dp->drv.p->window); 195 c ucul_free_font(dp->drv.p->f);194 caca_free_font(dp->drv.p->f); 196 195 free(dp->drv.p->txid); 197 196 free(dp->drv.p); … … 217 216 static void gl_display(caca_display_t *dp) 218 217 { 219 uint32_t const *cvchars = (uint32_t const *)c ucul_get_canvas_chars(dp->cv);220 uint32_t const *cvattrs = (uint32_t const *)c ucul_get_canvas_attrs(dp->cv);221 int width = c ucul_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); 222 221 int x, y, line; 223 222 … … 233 232 for(x = 0; x < dp->drv.p->width; x += dp->drv.p->font_width) 234 233 { 235 uint16_t bg = c ucul_attr_to_rgb12_bg(*attrs++);234 uint16_t bg = caca_attr_to_rgb12_bg(*attrs++); 236 235 237 236 glColor4b(((bg & 0xf00) >> 8) * 8, … … 267 266 int i, b, fullwidth; 268 267 269 fullwidth = c ucul_utf32_is_fullwidth(ch);268 fullwidth = caca_utf32_is_fullwidth(ch); 270 269 271 270 for(b = 0, i = 0; dp->drv.p->blocks[i + 1]; i += 2) … … 285 284 - (uint32_t)dp->drv.p->blocks[i]]); 286 285 287 fg = c ucul_attr_to_rgb12_fg(*attrs);286 fg = caca_attr_to_rgb12_fg(*attrs); 288 287 glColor3b(((fg & 0xf00) >> 8) * 8, 289 288 ((fg & 0x0f0) >> 4) * 8, … … 353 352 { 354 353 ev->type = CACA_EVENT_RESIZE; 355 ev->data.resize.w = c ucul_get_canvas_width(dp->cv);356 ev->data.resize.h = c ucul_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); 357 356 return 1; 358 357 } … … 514 513 static void gl_compute_font(caca_display_t *dp) 515 514 { 516 c ucul_canvas_t *cv;515 caca_canvas_t *cv; 517 516 uint32_t *image; 518 517 int i, b, w, h, x, y; 519 518 520 519 /* Count how many glyphs this font has */ 521 dp->drv.p->blocks = c ucul_get_font_blocks(dp->drv.p->f);520 dp->drv.p->blocks = caca_get_font_blocks(dp->drv.p->f); 522 521 523 522 for(b = 0, i = 0; dp->drv.p->blocks[i + 1]; i += 2) 524 523 b += (int)(dp->drv.p->blocks[i + 1] - dp->drv.p->blocks[i]); 525 524 526 /* Allocate a libc uculcanvas and print all the glyphs on it */527 cv = c ucul_create_canvas(2, b);528 c ucul_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); 529 528 530 529 for(b = 0, i = 0; dp->drv.p->blocks[i + 1]; i += 2) … … 533 532 534 533 for(j = 0; j < n; j++) 535 c ucul_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); 536 535 537 536 b += n; 538 537 } 539 538 540 /* Draw the c uculcanvas onto an image buffer */539 /* Draw the caca canvas onto an image buffer */ 541 540 image = malloc(b * dp->drv.p->font_height * 542 541 2 * dp->drv.p->font_width * sizeof(uint32_t)); 543 c ucul_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, 544 543 b * dp->drv.p->font_height, 8 * dp->drv.p->font_width); 545 c ucul_free_canvas(cv);544 caca_free_canvas(cv); 546 545 547 546 /* Convert all glyphs in the image buffer to GL textures */ … … 561 560 * dp->drv.p->font_height); 562 561 int fullwidth = 563 c ucul_utf32_is_fullwidth(dp->drv.p->blocks[i] + j);562 caca_utf32_is_fullwidth(dp->drv.p->blocks[i] + j); 564 563 565 564 memset(tmp, 0, 16 * 8 * 16); -
libcaca/trunk/caca/driver_ncurses.c
r2305 r2821 51 51 #endif 52 52 53 #include "cucul.h"54 53 #include "caca.h" 55 54 #include "caca_internals.h" … … 303 302 304 303 dp->resize.allow = 1; 305 c ucul_set_canvas_size(dp->cv, COLS, LINES);304 caca_set_canvas_size(dp->cv, COLS, LINES); 306 305 dp->resize.allow = 0; 307 306 … … 336 335 { 337 336 /* Fallback to a 6x10 font */ 338 return c ucul_get_canvas_width(dp->cv) * 6;337 return caca_get_canvas_width(dp->cv) * 6; 339 338 } 340 339 … … 342 341 { 343 342 /* Fallback to a 6x10 font */ 344 return c ucul_get_canvas_height(dp->cv) * 10;343 return caca_get_canvas_height(dp->cv) * 10; 345 344 } 346 345 347 346 static void ncurses_display(caca_display_t *dp) 348 347 { 349 uint32_t const *cvchars = (uint32_t const *)c ucul_get_canvas_chars(dp->cv);350 uint32_t const *cvattrs = (uint32_t const *)c ucul_get_canvas_attrs(dp->cv);351 int width = c ucul_get_canvas_width(dp->cv);352 int height = c ucul_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); 353 352 int x, y; 354 353 … … 358 357 for(x = width; x--; ) 359 358 { 360 attrset(dp->drv.p->attr[c ucul_attr_to_ansi(*cvattrs++)]);359 attrset(dp->drv.p->attr[caca_attr_to_ansi(*cvattrs++)]); 361 360 ncurses_write_utf32(*cvchars++); 362 361 } 363 362 } 364 363 365 x = c ucul_get_cursor_x(dp->cv);366 y = c ucul_get_cursor_y(dp->cv);364 x = caca_get_cursor_x(dp->cv); 365 y = caca_get_cursor_y(dp->cv); 367 366 move(y, x); 368 367 … … 390 389 391 390 /* Fallback */ 392 dp->resize.w = c ucul_get_canvas_width(dp->cv);393 dp->resize.h = c ucul_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); 394 393 } 395 394 … … 433 432 434 433 utf8[i] = '\0'; 435 utf32 = c ucul_utf8_to_utf32(utf8, &bytes);434 utf32 = caca_utf8_to_utf32(utf8, &bytes); 436 435 437 436 while(i > bytes) … … 616 615 #endif 617 616 618 if(ch == C UCUL_MAGIC_FULLWIDTH)617 if(ch == CACA_MAGIC_FULLWIDTH) 619 618 return; 620 619 621 620 #if defined HAVE_NCURSESW_NCURSES_H 622 bytes = c ucul_utf32_to_utf8(buf, ch);621 bytes = caca_utf32_to_utf8(buf, ch); 623 622 buf[bytes] = '\0'; 624 623 addstr(buf); … … 815 814 } 816 815 addch(cch); 817 if(c ucul_utf32_is_fullwidth(ch))816 if(caca_utf32_is_fullwidth(ch)) 818 817 { 819 818 addch(cch2); -
libcaca/trunk/caca/driver_raw.c
r2305 r2821 24 24 #include <stdlib.h> 25 25 26 #include "cucul.h"27 26 #include "caca.h" 28 27 #include "caca_internals.h" … … 30 29 static int raw_init_graphics(caca_display_t *dp) 31 30 { 32 int width = c ucul_get_canvas_width(dp->cv);33 int height = c ucul_get_canvas_height(dp->cv);31 int width = caca_get_canvas_width(dp->cv); 32 int height = caca_get_canvas_height(dp->cv); 34 33 char const *geometry; 35 34 … … 41 40 42 41 dp->resize.allow = 1; 43 c ucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 24);42 caca_set_canvas_size(dp->cv, width ? width : 80, height ? height : 24); 44 43 dp->resize.allow = 0; 45 44 … … 72 71 size_t len; 73 72 74 buffer = c ucul_export_memory(dp->cv, "caca", &len);73 buffer = caca_export_memory(dp->cv, "caca", &len); 75 74 if(!buffer) 76 75 return; -
libcaca/trunk/caca/driver_slang.c
r2305 r2821 34 34 #endif 35 35 36 #include "cucul.h"37 36 #include "caca.h" 38 37 #include "caca_internals.h" … … 178 177 179 178 dp->resize.allow = 1; 180 c ucul_set_canvas_size(dp->cv, SLtt_Screen_Cols, SLtt_Screen_Rows);179 caca_set_canvas_size(dp->cv, SLtt_Screen_Cols, SLtt_Screen_Rows); 181 180 dp->resize.allow = 0; 182 181 … … 211 210 { 212 211 /* Fallback to a 6x10 font */ 213 return c ucul_get_canvas_width(dp->cv) * 6;212 return caca_get_canvas_width(dp->cv) * 6; 214 213 } 215 214 … … 217 216 { 218 217 /* Fallback to a 6x10 font */ 219 return c ucul_get_canvas_height(dp->cv) * 10;218 return caca_get_canvas_height(dp->cv) * 10; 220 219 } 221 220 222 221 static void slang_display(caca_display_t *dp) 223 222 { 224 uint32_t const *cvchars = (uint32_t const *)c ucul_get_canvas_chars(dp->cv);225 uint32_t const *cvattrs = (uint32_t const *)c ucul_get_canvas_attrs(dp->cv);226 int width = c ucul_get_canvas_width(dp->cv);227 int height = c ucul_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); 228 227 int x, y; 229 228 … … 242 241 * bright backgrounds, it's just fucked up. */ 243 242 #if 0 244 uint8_t fgcolor = c ucul_attr_to_ansi_fg(*cvattrs);245 uint8_t bgcolor = c ucul_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); 246 245 247 246 if(fgcolor >= 0x10) 248 fgcolor = C UCUL_LIGHTGRAY;247 fgcolor = CACA_LIGHTGRAY; 249 248 250 249 if(bgcolor >= 0x10) 251 bgcolor = C UCUL_BLACK; /* FIXME: handle transparency */250 bgcolor = CACA_BLACK; /* FIXME: handle transparency */ 252 251 253 252 if(fgcolor == bgcolor) 254 253 { 255 if(fgcolor == C UCUL_BLACK)256 fgcolor = C UCUL_WHITE;257 else if(fgcolor == C UCUL_WHITE258 || fgcolor <= C UCUL_LIGHTGRAY)259 fgcolor = C UCUL_BLACK;254 if(fgcolor == CACA_BLACK) 255 fgcolor = CACA_WHITE; 256 else if(fgcolor == CACA_WHITE 257 || fgcolor <= CACA_LIGHTGRAY) 258 fgcolor = CACA_BLACK; 260 259 else 261 fgcolor = C UCUL_WHITE;260 fgcolor = CACA_WHITE; 262 261 SLsmg_set_color(slang_assoc[fgcolor + 16 * bgcolor]); 263 262 SLsmg_write_char(' '); … … 267 266 #endif 268 267 { 269 SLsmg_set_color(slang_assoc[c ucul_attr_to_ansi(*cvattrs++)]);268 SLsmg_set_color(slang_assoc[caca_attr_to_ansi(*cvattrs++)]); 270 269 slang_write_utf32(ch); 271 270 } 272 271 #else 273 SLsmg_set_color(c ucul_attr_to_ansi(*cvattrs++));272 SLsmg_set_color(caca_attr_to_ansi(*cvattrs++)); 274 273 slang_write_utf32(ch); 275 274 #endif 276 275 } 277 276 } 278 SLsmg_gotorc(c ucul_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)); 279 278 SLsmg_refresh(); 280 279 } … … 286 285 dp->resize.h = SLtt_Screen_Rows; 287 286 288 if(dp->resize.w != c ucul_get_canvas_width(dp->cv)289 || dp->resize.h != c ucul_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)) 290 289 SLsmg_reinit_smg(); 291 290 } … … 343 342 344 343 utf8[i] = '\0'; 345 utf32 = c ucul_utf8_to_utf32(utf8, &bytes);344 utf32 = caca_utf8_to_utf32(utf8, &bytes); 346 345 347 346 while(i > bytes) … … 483 482 #endif 484 483 485 if(ch == C UCUL_MAGIC_FULLWIDTH)484 if(ch == CACA_MAGIC_FULLWIDTH) 486 485 return; 487 486 488 487 #ifdef HAVE_SLSMG_UTF8_ENABLE 489 bytes = c ucul_utf32_to_utf8(buf, ch);488 bytes = caca_utf32_to_utf8(buf, ch); 490 489 buf[bytes] = '\0'; 491 490 SLsmg_write_string(buf); 492 491 #else 493 ascii = c ucul_utf32_to_ascii(ch);492 ascii = caca_utf32_to_ascii(ch); 494 493 SLsmg_write_char(ascii); 495 if(c ucul_utf32_is_fullwidth(ch))494 if(caca_utf32_is_fullwidth(ch)) 496 495 SLsmg_write_char(ascii); 497 496 #endif -
libcaca/trunk/caca/driver_vga.c
r2305 r2821 21 21 #if defined(USE_VGA) 22 22 23 #include "cucul.h"24 23 #include "caca.h" 25 24 #include "caca_internals.h" … … 76 75 /* We don't have much choice */ 77 76 dp->resize.allow = 1; 78 c ucul_set_canvas_size(dp->cv, 80, 25);77 caca_set_canvas_size(dp->cv, 80, 25); 79 78 dp->resize.allow = 0; 80 79 … … 117 116 { 118 117 char *screen = (char *)(intptr_t)0x000b8000; 119 uint32_t const *cvchars = (uint32_t const *)c ucul_get_canvas_chars(dp->cv);120 uint32_t const *cvattrs = (uint32_t const *)c ucul_get_canvas_attrs(dp->cv);121 int width = c ucul_get_canvas_width(dp->cv);122 int height = c ucul_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); 123 122 int n; 124 123 125 124 for(n = height * width; n--; ) 126 125 { 127 char ch = c ucul_utf32_to_cp437(*cvchars++);128 if(n && *cvchars == C UCUL_MAGIC_FULLWIDTH)126 char ch = caca_utf32_to_cp437(*cvchars++); 127 if(n && *cvchars == CACA_MAGIC_FULLWIDTH) 129 128 { 130 129 *screen++ = '['; 131 *screen++ = c ucul_attr_to_ansi(*cvattrs++);130 *screen++ = caca_attr_to_ansi(*cvattrs++); 132 131 ch = ']'; 133 132 cvchars++; … … 135 134 } 136 135 *screen++ = ch; 137 *screen++ = c ucul_attr_to_ansi(*cvattrs++);136 *screen++ = caca_attr_to_ansi(*cvattrs++); 138 137 } 139 138 } … … 142 141 { 143 142 /* We know nothing about our window */ 144 dp->resize.w = c ucul_get_canvas_width(dp->cv);145 dp->resize.h = c ucul_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); 146 145 } 147 146 -
libcaca/trunk/caca/driver_win32.c
r2305 r2821 26 26 #include <stdio.h> 27 27 28 #include "cucul.h"29 28 #include "caca.h" 30 29 #include "caca_internals.h" … … 83 82 static int win32_init_graphics(caca_display_t *dp) 84 83 { 85 int width = c ucul_get_canvas_width(dp->cv);86 int height = c ucul_get_canvas_height(dp->cv);84 int width = caca_get_canvas_width(dp->cv); 85 int height = caca_get_canvas_height(dp->cv); 87 86 CONSOLE_SCREEN_BUFFER_INFO csbi; 88 87 SMALL_RECT rect; … … 123 122 SetConsoleWindowInfo(dp->drv.p->screen, TRUE, &rect); 124 123 125 /* Report our new size to libc ucul*/124 /* Report our new size to libcaca */ 126 125 if(!GetConsoleScreenBufferInfo(dp->drv.p->screen, &csbi)) 127 126 return -1; 128 127 129 128 dp->resize.allow = 1; 130 c ucul_set_canvas_size(dp->cv,129 caca_set_canvas_size(dp->cv, 131 130 csbi.srWindow.Right - csbi.srWindow.Left + 1, 132 131 csbi.srWindow.Bottom - csbi.srWindow.Top + 1); 133 width = c ucul_get_canvas_width(dp->cv);134 height = c ucul_get_canvas_height(dp->cv);132 width = caca_get_canvas_width(dp->cv); 133 height = caca_get_canvas_height(dp->cv); 135 134 dp->resize.allow = 0; 136 135 … … 181 180 182 181 /* Fallback to a 6x10 font */ 183 return c ucul_get_canvas_width(dp->cv) * 6;182 return caca_get_canvas_width(dp->cv) * 6; 184 183 } 185 184 … … 189 188 190 189 /* Fallback to a 6x10 font */ 191 return c ucul_get_canvas_height(dp->cv) * 10;190 return caca_get_canvas_height(dp->cv) * 10; 192 191 } 193 192 … … 197 196 SMALL_RECT rect; 198 197 CHAR_INFO *buffer = dp->drv.p->buffer; 199 uint32_t const *cvchars = (uint32_t const *)c ucul_get_canvas_chars(dp->cv);200 uint32_t const *cvattrs = (uint32_t const *)c ucul_get_canvas_attrs(dp->cv);201 int width = c ucul_get_canvas_width(dp->cv);202 int height = c ucul_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); 203 202 int n; 204 203 … … 207 206 { 208 207 uint32_t ch = *cvchars++; 209 uint8_t fg = c ucul_attr_to_ansi_fg(*cvattrs);210 uint8_t bg = c ucul_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); 211 210 212 211 #if 0 … … 216 215 dp->drv.p->buffer[i].Char.AsciiChar = ' '; 217 216 #else 218 if(n && *cvchars == C UCUL_MAGIC_FULLWIDTH)217 if(n && *cvchars == CACA_MAGIC_FULLWIDTH) 219 218 ; 220 219 else if(ch > 0x00000020 && ch < 0x00010000) … … 224 223 #endif 225 224 226 buffer->Attributes = win32_fg_palette[fg < 0x10 ? fg : C UCUL_LIGHTGRAY]227 | win32_bg_palette[bg < 0x10 ? bg : C UCUL_BLACK];225 buffer->Attributes = win32_fg_palette[fg < 0x10 ? fg : CACA_LIGHTGRAY] 226 | win32_bg_palette[bg < 0x10 ? bg : CACA_BLACK]; 228 227 cvattrs++; 229 228 buffer++; … … 247 246 { 248 247 /* FIXME: I don't know what to do here. */ 249 dp->resize.w = c ucul_get_canvas_width(dp->cv);250 dp->resize.h = c ucul_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); 251 250 } 252 251 -
libcaca/trunk/caca/driver_x11.c
r2305 r2821 33 33 #include <string.h> 34 34 35 #include "c ucul.h"35 #include "caca.h" 36 36 #include "caca.h" 37 37 #include "caca_internals.h" … … 76 76 char const *fonts[] = { NULL, "8x13bold", "fixed" }, **parser; 77 77 char const *geometry; 78 int width = c ucul_get_canvas_width(dp->cv);79 int height = c ucul_get_canvas_height(dp->cv);78 int width = caca_get_canvas_width(dp->cv); 79 int height = caca_get_canvas_height(dp->cv); 80 80 int i; 81 81 … … 89 89 90 90 dp->resize.allow = 1; 91 c ucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32);92 width = c ucul_get_canvas_width(dp->cv);93 height = c ucul_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); 94 94 dp->resize.allow = 0; 95 95 … … 280 280 static int x11_get_display_width(caca_display_t const *dp) 281 281 { 282 return c ucul_get_canvas_width(dp->cv) * dp->drv.p->font_width;282 return caca_get_canvas_width(dp->cv) * dp->drv.p->font_width; 283 283 } 284 284 285 285 static int x11_get_display_height(caca_display_t const *dp) 286 286 { 287 return c ucul_get_canvas_height(dp->cv) * dp->drv.p->font_height;287 return caca_get_canvas_height(dp->cv) * dp->drv.p->font_height; 288 288 } 289 289 290 290 static void x11_display(caca_display_t *dp) 291 291 { 292 uint32_t const *cvchars = (uint32_t const *)c ucul_get_canvas_chars(dp->cv);293 uint32_t const *cvattrs = (uint32_t const *)c ucul_get_canvas_attrs(dp->cv);294 int width = c ucul_get_canvas_width(dp->cv);295 int height = c ucul_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); 296 296 int x, y, len; 297 297 … … 303 303 { 304 304 uint32_t const *attrs = cvattrs + x + y * width; 305 uint16_t bg = c ucul_attr_to_rgb12_bg(*attrs);305 uint16_t bg = caca_attr_to_rgb12_bg(*attrs); 306 306 307 307 len = 1; 308 308 while(x + len < width 309 && c ucul_attr_to_rgb12_bg(attrs[len]) == bg)309 && caca_attr_to_rgb12_bg(attrs[len]) == bg) 310 310 len++; 311 311 … … 331 331 { 332 332 XSetForeground(dp->drv.p->dpy, dp->drv.p->gc, 333 dp->drv.p->colors[c ucul_attr_to_rgb12_fg(*attrs)]);333 dp->drv.p->colors[caca_attr_to_rgb12_fg(*attrs)]); 334 334 335 335 x11_put_glyph(dp, x * dp->drv.p->font_width, … … 345 345 XSetForeground(dp->drv.p->dpy, dp->drv.p->gc, 346 346 dp->drv.p->colors[0xfff]); 347 x = c ucul_get_cursor_x(dp->cv);348 y = c ucul_get_cursor_y(dp->cv);347 x = caca_get_cursor_x(dp->cv); 348 y = caca_get_cursor_y(dp->cv); 349 349 XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap, dp->drv.p->gc, 350 350 x * dp->drv.p->font_width, y * dp->drv.p->font_height, … … 379 379 static int x11_get_event(caca_display_t *dp, caca_privevent_t *ev) 380 380 { 381 int width = c ucul_get_canvas_width(dp->cv);382 int height = c ucul_get_canvas_height(dp->cv);381 int width = caca_get_canvas_width(dp->cv); 382 int height = caca_get_canvas_height(dp->cv); 383 383 XEvent xevent; 384 384 char key; … … 611 611 612 612 /* Underline */ 613 if(attr & C UCUL_UNDERLINE)613 if(attr & CACA_UNDERLINE) 614 614 XFillRectangle(dpy, px, gc, x, y + h - 1, w, 1); 615 615 … … 618 618 return; 619 619 620 if(ch == C UCUL_MAGIC_FULLWIDTH)620 if(ch == CACA_MAGIC_FULLWIDTH) 621 621 return; 622 622 623 623 fw = w; 624 if(c ucul_utf32_is_fullwidth(ch))624 if(caca_utf32_is_fullwidth(ch)) 625 625 fw *= 2; 626 626 627 627 /* We want to be able to print a few special Unicode characters 628 628 * such as the CP437 gradients and half blocks. For unknown 629 * characters, print what c ucul_utf32_to_ascii() returns. */629 * characters, print what caca_utf32_to_ascii() returns. */ 630 630 631 631 if(ch >= 0x2500 && ch <= 0x256c && udlr[ch - 0x2500]) … … 772 772 { 773 773 ch16.byte1 = 0; 774 ch16.byte2 = c ucul_utf32_to_ascii(ch);774 ch16.byte2 = caca_utf32_to_ascii(ch); 775 775 } 776 776 -
libcaca/trunk/caca/event.c
r2305 r2821 24 24 #endif 25 25 26 #include "cucul.h"27 26 #include "caca.h" 28 27 #include "caca_internals.h" … … 130 129 int caca_get_mouse_x(caca_display_t const *dp) 131 130 { 132 int width = c ucul_get_canvas_width(dp->cv);131 int width = caca_get_canvas_width(dp->cv); 133 132 134 133 if(dp->mouse.x >= width) … … 152 151 int caca_get_mouse_y(caca_display_t const *dp) 153 152 { 154 int height = c ucul_get_canvas_height(dp->cv);153 int height = caca_get_canvas_height(dp->cv); 155 154 156 155 if(dp->mouse.y >= height) … … 336 335 _caca_handle_resize(dp); 337 336 ev->type = CACA_EVENT_RESIZE; 338 ev->data.resize.w = c ucul_get_canvas_width(dp->cv);339 ev->data.resize.h = c ucul_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); 340 339 return 1; 341 340 } -
libcaca/trunk/caca/export.c
r2819 r2821 1 1 /* 2 * libc ucul Canvas for ultrafast compositing of Unicode letters2 * libcaca Colour ASCII-Art library 3 3 * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> 4 4 * 2006 Jean-Yves Lamoureux <jylam@lnxscene.org> … … 26 26 #endif 27 27 28 #include "c ucul.h"29 #include "c ucul_internals.h"28 #include "caca.h" 29 #include "caca_internals.h" 30 30 31 31 static inline int sprintu32(char *s, uint32_t x) … … 45 45 } 46 46 47 static void *export_caca(c ucul_canvas_t const *, size_t *);48 static void *export_ansi(c ucul_canvas_t const *, size_t *);49 static void *export_utf8(c ucul_canvas_t const *, size_t *, int);50 static void *export_html(c ucul_canvas_t const *, size_t *);51 static void *export_html3(c ucul_canvas_t const *, size_t *);52 static void *export_bbfr(c ucul_canvas_t const *, size_t *);53 static void *export_irc(c ucul_canvas_t const *, size_t *);54 static void *export_ps(c ucul_canvas_t const *, size_t *);55 static void *export_svg(c ucul_canvas_t const *, size_t *);56 static void *export_tga(c ucul_canvas_t const *, size_t *);47 static void *export_caca(caca_canvas_t const *, size_t *); 48 static void *export_ansi(caca_canvas_t const *, size_t *); 49 static void *export_utf8(caca_canvas_t const *, size_t *, int); 50 static void *export_html(caca_canvas_t const *, size_t *); 51 static void *export_html3(caca_canvas_t const *, size_t *); 52 static void *export_bbfr(caca_canvas_t const *, size_t *); 53 static void *export_irc(caca_canvas_t const *, size_t *); 54 static void *export_ps(caca_canvas_t const *, size_t *); 55 static void *export_svg(caca_canvas_t const *, size_t *); 56 static void *export_tga(caca_canvas_t const *, size_t *); 57 57 58 58 /** \brief Export a canvas into a foreign format. 59 59 * 60 * This function exports a libc uculcanvas into various foreign formats such60 * This function exports a libcaca canvas into various foreign formats such 61 61 * as ANSI art, HTML, IRC colours, etc. The returned pointer should be passed 62 62 * to free() to release the allocated storage when it is no longer needed. … … 77 77 * - \c ENOMEM Not enough memory to allocate output buffer. 78 78 * 79 * \param cv A libc uculcanvas79 * \param cv A libcaca canvas 80 80 * \param format A string describing the requested output format. 81 81 * \param bytes A pointer to a size_t where the number of allocated bytes … … 83 83 * \return A pointer to the exported memory area, or NULL in case of error. 84 84 */ 85 void *c ucul_export_memory(cucul_canvas_t const *cv, char const *format,85 void *caca_export_memory(caca_canvas_t const *cv, char const *format, 86 86 size_t *bytes) 87 87 { … … 127 127 * Return a list of available export formats. The list is a NULL-terminated 128 128 * array of strings, interleaving a string containing the internal value for 129 * the export format, to be used with c ucul_export_memory(), and a string129 * the export format, to be used with caca_export_memory(), and a string 130 130 * containing the natural language description for that export format. 131 131 * … … 134 134 * \return An array of strings. 135 135 */ 136 char const * const * c ucul_get_export_list(void)136 char const * const * caca_get_export_list(void) 137 137 { 138 138 static char const * const list[] = … … 160 160 161 161 /* Generate a native libcaca canvas file. */ 162 static void *export_caca(c ucul_canvas_t const *cv, size_t *bytes)162 static void *export_caca(caca_canvas_t const *cv, size_t *bytes) 163 163 { 164 164 char *data, *cur; … … 213 213 214 214 /* Generate UTF-8 representation of current canvas. */ 215 static void *export_utf8(c ucul_canvas_t const *cv, size_t *bytes,215 static void *export_utf8(caca_canvas_t const *cv, size_t *bytes, 216 216 int cr) 217 217 { … … 245 245 uint8_t ansifg, ansibg, fg, bg; 246 246 247 if(ch == C UCUL_MAGIC_FULLWIDTH)247 if(ch == CACA_MAGIC_FULLWIDTH) 248 248 continue; 249 249 250 ansifg = c ucul_attr_to_ansi_fg(attr);251 ansibg = c ucul_attr_to_ansi_bg(attr);250 ansifg = caca_attr_to_ansi_fg(attr); 251 ansibg = caca_attr_to_ansi_bg(attr); 252 252 253 253 fg = ansifg < 0x10 ? palette[ansifg] : 0x10; … … 272 272 } 273 273 274 cur += c ucul_utf32_to_utf8(cur, ch);274 cur += caca_utf32_to_utf8(cur, ch); 275 275 276 276 prevfg = fg; … … 294 294 295 295 /* Generate ANSI representation of current canvas. */ 296 static void *export_ansi(c ucul_canvas_t const *cv, size_t *bytes)296 static void *export_ansi(caca_canvas_t const *cv, size_t *bytes) 297 297 { 298 298 static uint8_t const palette[] = … … 321 321 for(x = 0; x < cv->width; x++) 322 322 { 323 uint8_t ansifg = c ucul_attr_to_ansi_fg(lineattr[x]);324 uint8_t ansibg = c ucul_attr_to_ansi_bg(lineattr[x]);325 uint8_t fg = ansifg < 0x10 ? palette[ansifg] : C UCUL_LIGHTGRAY;326 uint8_t bg = ansibg < 0x10 ? palette[ansibg] : C UCUL_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; 327 327 uint32_t ch = linechar[x]; 328 328 329 if(ch == C UCUL_MAGIC_FULLWIDTH)329 if(ch == CACA_MAGIC_FULLWIDTH) 330 330 ch = '?'; 331 331 … … 346 346 } 347 347 348 *cur++ = c ucul_utf32_to_cp437(ch);348 *cur++ = caca_utf32_to_cp437(ch); 349 349 350 350 prevfg = fg; … … 374 374 375 375 /* Generate HTML representation of current canvas. */ 376 static void *export_html(c ucul_canvas_t const *cv, size_t *bytes)376 static void *export_html(caca_canvas_t const *cv, size_t *bytes) 377 377 { 378 378 char *data, *cur; … … 391 391 cur += sprintf(cur, "<html><head>\n"); 392 392 cur += sprintf(cur, "<title>Generated by libcaca %s</title>\n", 393 c ucul_get_version());393 caca_get_version()); 394 394 cur += sprintf(cur, "</head><body>\n"); 395 395 … … 405 405 { 406 406 cur += sprintf(cur, "<span style=\""); 407 if(c ucul_attr_to_ansi_fg(lineattr[x]) < 0x10)407 if(caca_attr_to_ansi_fg(lineattr[x]) < 0x10) 408 408 cur += sprintf(cur, ";color:#%.03x", 409 c ucul_attr_to_rgb12_fg(lineattr[x]));410 if(c ucul_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) 411 411 cur += sprintf(cur, ";background-color:#%.03x", 412 c ucul_attr_to_rgb12_bg(lineattr[x]));413 if(lineattr[x] & C UCUL_BOLD)412 caca_attr_to_rgb12_bg(lineattr[x])); 413 if(lineattr[x] & CACA_BOLD) 414 414 cur += sprintf(cur, ";font-weight:bold"); 415 if(lineattr[x] & C UCUL_ITALICS)415 if(lineattr[x] & CACA_ITALICS) 416 416 cur += sprintf(cur, ";font-style:italic"); 417 if(lineattr[x] & C UCUL_UNDERLINE)417 if(lineattr[x] & CACA_UNDERLINE) 418 418 cur += sprintf(cur, ";text-decoration:underline"); 419 if(lineattr[x] & C UCUL_BLINK)419 if(lineattr[x] & CACA_BLINK) 420 420 cur += sprintf(cur, ";text-decoration:blink"); 421 421 cur += sprintf(cur, "\">"); … … 425 425 len++) 426 426 { 427 if(linechar[x + len] == C UCUL_MAGIC_FULLWIDTH)427 if(linechar[x + len] == CACA_MAGIC_FULLWIDTH) 428 428 ; 429 429 else if(linechar[x + len] <= 0x00000020) … … 456 456 * will not work under gecko (mozilla rendering engine) unless you set a 457 457 * correct header. */ 458 static void *export_html3(c ucul_canvas_t const *cv, size_t *bytes)458 static void *export_html3(caca_canvas_t const *cv, size_t *bytes) 459 459 { 460 460 char *data, *cur; … … 493 493 cur += sprintf(cur, "<td"); 494 494 495 if(c ucul_attr_to_ansi_fg(lineattr[x]) < 0x10)495 if(caca_attr_to_ansi_fg(lineattr[x]) < 0x10) 496 496 cur += sprintf(cur, " bgcolor=#%.06lx", (unsigned long int) 497 _c ucul_attr_to_rgb24bg(lineattr[x]));497 _caca_attr_to_rgb24bg(lineattr[x])); 498 498 499 499 if(len > 1) … … 502 502 cur += sprintf(cur, ">"); 503 503 504 needfont = c ucul_attr_to_ansi_bg(lineattr[x]) < 0x10;504 needfont = caca_attr_to_ansi_bg(lineattr[x]) < 0x10; 505 505 506 506 if(needfont) 507 507 cur += sprintf(cur, "<font color=#%.06lx>", (unsigned long int) 508 _c ucul_attr_to_rgb24fg(lineattr[x]));509 510 if(lineattr[x] & C UCUL_BOLD)508 _caca_attr_to_rgb24fg(lineattr[x])); 509 510 if(lineattr[x] & CACA_BOLD) 511 511 cur += sprintf(cur, "<b>"); 512 if(lineattr[x] & C UCUL_ITALICS)512 if(lineattr[x] & CACA_ITALICS) 513 513 cur += sprintf(cur, "<i>"); 514 if(lineattr[x] & C UCUL_UNDERLINE)514 if(lineattr[x] & CACA_UNDERLINE) 515 515 cur += sprintf(cur, "<u>"); 516 if(lineattr[x] & C UCUL_BLINK)516 if(lineattr[x] & CACA_BLINK) 517 517 cur += sprintf(cur, "<blink>"); 518 518 519 519 for(i = 0; i < len; i++) 520 520 { 521 if(linechar[x + i] == C UCUL_MAGIC_FULLWIDTH)521 if(linechar[x + i] == CACA_MAGIC_FULLWIDTH) 522 522 ; 523 523 else if(linechar[x + i] <= 0x00000020) … … 529 529 } 530 530 531 if(lineattr[x] & C UCUL_BLINK)531 if(lineattr[x] & CACA_BLINK) 532 532 cur += sprintf(cur, "</blink>"); 533 if(lineattr[x] & C UCUL_UNDERLINE)533 if(lineattr[x] & CACA_UNDERLINE) 534 534 cur += sprintf(cur, "</u>"); 535 if(lineattr[x] & C UCUL_ITALICS)535 if(lineattr[x] & CACA_ITALICS) 536 536 cur += sprintf(cur, "</i>"); 537 if(lineattr[x] & C UCUL_BOLD)537 if(lineattr[x] & CACA_BOLD) 538 538 cur += sprintf(cur, "</b>"); 539 539 … … 557 557 } 558 558 559 static void *export_bbfr(c ucul_canvas_t const *cv, size_t *bytes)559 static void *export_bbfr(caca_canvas_t const *cv, size_t *bytes) 560 560 { 561 561 char *data, *cur; … … 595 595 len++; 596 596 597 needback = c ucul_attr_to_ansi_bg(lineattr[x]) < 0x10;598 needfront = c ucul_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; 599 599 600 600 if(needback) 601 601 cur += sprintf(cur, "[f=#%.06lx]", (unsigned long int) 602 _c ucul_attr_to_rgb24bg(lineattr[x]));602 _caca_attr_to_rgb24bg(lineattr[x])); 603 603 604 604 if(linechar[x] == ' ') 605 605 cur += sprintf(cur, "[c=#%.06lx]", (unsigned long int) 606 _c ucul_attr_to_rgb24bg(lineattr[x]));606 _caca_attr_to_rgb24bg(lineattr[x])); 607 607 else if(needfront) 608 608 cur += sprintf(cur, "[c=#%.06lx]", (unsigned long int) 609 _c ucul_attr_to_rgb24fg(lineattr[x]));610 611 if(lineattr[x] & C UCUL_BOLD)609 _caca_attr_to_rgb24fg(lineattr[x])); 610 611 if(lineattr[x] & CACA_BOLD) 612 612 cur += sprintf(cur, "[g]"); 613 if(lineattr[x] & C UCUL_ITALICS)613 if(lineattr[x] & CACA_ITALICS) 614 614 cur += sprintf(cur, "[i]"); 615 if(lineattr[x] & C UCUL_UNDERLINE)615 if(lineattr[x] & CACA_UNDERLINE) 616 616 cur += sprintf(cur, "[s]"); 617 if(lineattr[x] & C UCUL_BLINK)617 if(lineattr[x] & CACA_BLINK) 618 618 ; /* FIXME */ 619 619 620 620 for(i = 0; i < len; i++) 621 621 { 622 if(linechar[x + i] == C UCUL_MAGIC_FULLWIDTH)622 if(linechar[x + i] == CACA_MAGIC_FULLWIDTH) 623 623 ; 624 624 else if(linechar[x + i] == ' ') 625 625 *cur++ = '_'; 626 626 else 627 cur += c ucul_utf32_to_utf8(cur, linechar[x + i]);627 cur += caca_utf32_to_utf8(cur, linechar[x + i]); 628 628 } 629 629 630 if(lineattr[x] & C UCUL_BLINK)630 if(lineattr[x] & CACA_BLINK) 631 631 ; /* FIXME */ 632 if(lineattr[x] & C UCUL_UNDERLINE)632 if(lineattr[x] & CACA_UNDERLINE) 633 633 cur += sprintf(cur, "[/s]"); 634 if(lineattr[x] & C UCUL_ITALICS)634 if(lineattr[x] & CACA_ITALICS) 635 635 cur += sprintf(cur, "[/i]"); 636 if(lineattr[x] & C UCUL_BOLD)636 if(lineattr[x] & CACA_BOLD) 637 637 cur += sprintf(cur, "[/g]"); 638 638 … … 658 658 659 659 /* Export a text file with IRC colours */ 660 static void *export_irc(c ucul_canvas_t const *cv, size_t *bytes)660 static void *export_irc(caca_canvas_t const *cv, size_t *bytes) 661 661 { 662 662 static uint8_t const palette[] = … … 696 696 uint8_t ansifg, ansibg, fg, bg; 697 697 698 if(ch == C UCUL_MAGIC_FULLWIDTH)698 if(ch == CACA_MAGIC_FULLWIDTH) 699 699 continue; 700 700 701 ansifg = c ucul_attr_to_ansi_fg(attr);702 ansibg = c ucul_attr_to_ansi_bg(attr);701 ansifg = caca_attr_to_ansi_fg(attr); 702 ansibg = caca_attr_to_ansi_bg(attr); 703 703 704 704 fg = ansifg < 0x10 ? palette[ansifg] : 0x10; … … 742 742 } 743 743 744 cur += c ucul_utf32_to_utf8(cur, ch);744 cur += caca_utf32_to_utf8(cur, ch); 745 745 prevfg = fg; 746 746 prevbg = bg; … … 765 765 766 766 /* Export a PostScript document. */ 767 static void *export_ps(c ucul_canvas_t const *cv, size_t *bytes)767 static void *export_ps(caca_canvas_t const *cv, size_t *bytes) 768 768 { 769 769 static char const *ps_header = … … 811 811 { 812 812 uint8_t argb[8]; 813 c ucul_attr_to_argb64(*lineattr++, argb);813 caca_attr_to_argb64(*lineattr++, argb); 814 814 cur += sprintf(cur, "1 0 translate\n %f %f %f csquare\n", 815 815 (float)argb[1] * (1.0 / 0xf), … … 835 835 uint32_t ch = *linechar++; 836 836 837 c ucul_attr_to_argb64(*lineattr++, argb);837 caca_attr_to_argb64(*lineattr++, argb); 838 838 839 839 cur += sprintf(cur, "newpath\n"); … … 874 874 875 875 /* Export an SVG vector image */ 876 static void *export_svg(c ucul_canvas_t const *cv, size_t *bytes)876 static void *export_svg(caca_canvas_t const *cv, size_t *bytes) 877 877 { 878 878 static char const svg_header[] = … … 906 906 cur += sprintf(cur, "<rect style=\"fill:#%.03x\" x=\"%d\" y=\"%d\"" 907 907 " width=\"6\" height=\"10\"/>\n", 908 c ucul_attr_to_rgb12_bg(*lineattr++),908 caca_attr_to_rgb12_bg(*lineattr++), 909 909 x * 6, y * 10); 910 910 } … … 921 921 uint32_t ch = *linechar++; 922 922 923 if(ch == ' ' || ch == C UCUL_MAGIC_FULLWIDTH)923 if(ch == ' ' || ch == CACA_MAGIC_FULLWIDTH) 924 924 { 925 925 lineattr++; … … 929 929 cur += sprintf(cur, "<text style=\"fill:#%.03x\" " 930 930 "x=\"%d\" y=\"%d\">", 931 c ucul_attr_to_rgb12_fg(*lineattr++),931 caca_attr_to_rgb12_fg(*lineattr++), 932 932 x * 6, (y * 10) + 8); 933 933 … … 935 935 *cur++ = '?'; 936 936 else if(ch > 0x0000007f) 937 cur += c ucul_utf32_to_utf8(cur, ch);937 cur += caca_utf32_to_utf8(cur, ch); 938 938 else switch((uint8_t)ch) 939 939 { … … 960 960 961 961 /* Export a TGA image */ 962 static void *export_tga(c ucul_canvas_t const *cv, size_t *bytes)962 static void *export_tga(caca_canvas_t const *cv, size_t *bytes) 963 963 { 964 964 char const * const *fontlist; 965 965 char *data, *cur; 966 c ucul_font_t *f;966 caca_font_t *f; 967 967 int i, w, h; 968 968 969 fontlist = c ucul_get_font_list();969 fontlist = caca_get_font_list(); 970 970 if(!fontlist[0]) 971 971 { … … 974 974 } 975 975 976 f = c ucul_load_font(fontlist[0], 0);977 978 w = c ucul_get_canvas_width(cv) * cucul_get_font_width(f);979 h = c ucul_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); 980 980 981 981 *bytes = w * h * 4 + 18; /* 32 bpp + 18 bytes for the header */ … … 1003 1003 1004 1004 /* Image Data */ 1005 c ucul_render_canvas(cv, f, cur, w, h, 4 * w);1005 caca_render_canvas(cv, f, cur, w, h, 4 * w); 1006 1006 1007 1007 /* Swap bytes. What a waste of time. */ … … 1013 1013 } 1014 1014 1015 c ucul_free_font(f);1015 caca_free_font(f); 1016 1016 1017 1017 return data; -
libcaca/trunk/caca/figfont.c
r2819 r2821 1 1 /* 2 * libc ucul Canvas for ultrafast compositing of Unicode letters2 * libcaca Colour ASCII-Art library 3 3 * Copyright (c) 2006-2007 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 29 29 #endif 30 30 31 #include "c ucul.h"32 #include "c ucul_internals.h"33 34 struct c ucul_figfont31 #include "caca.h" 32 #include "caca_internals.h" 33 34 struct caca_figfont 35 35 { 36 36 int term_width; … … 44 44 int print_direction, full_layout, codetag_count; 45 45 int glyphs; 46 c ucul_canvas_t *fontcv, *charcv;46 caca_canvas_t *fontcv, *charcv; 47 47 int *left, *right; /* Unused yet */ 48 48 uint32_t *lookup; … … 50 50 51 51 static uint32_t hsmush(uint32_t ch1, uint32_t ch2, int rule); 52 static c ucul_figfont_t * open_figfont(char const *);53 static int free_figfont(c ucul_figfont_t *);54 55 int c ucul_canvas_set_figfont(cucul_canvas_t *cv, char const *path)56 { 57 c ucul_figfont_t *ff = NULL;52 static caca_figfont_t * open_figfont(char const *); 53 static int free_figfont(caca_figfont_t *); 54 55 int caca_canvas_set_figfont(caca_canvas_t *cv, char const *path) 56 { 57 caca_figfont_t *ff = NULL; 58 58 59 59 if(path) … … 66 66 if(cv->ff) 67 67 { 68 c ucul_free_canvas(cv->ff->charcv);68 caca_free_canvas(cv->ff->charcv); 69 69 free(cv->ff->left); 70 70 free(cv->ff->right); … … 85 85 ff->w = ff->h = 0; 86 86 ff->lines = 0; 87 c ucul_set_canvas_size(cv, 0, 0); /* XXX */87 caca_set_canvas_size(cv, 0, 0); /* XXX */ 88 88 89 89 /* from TOIlet’s figlet.c */ … … 118 118 } 119 119 120 ff->charcv = c ucul_create_canvas(ff->max_length - 2, ff->height);120 ff->charcv = caca_create_canvas(ff->max_length - 2, ff->height); 121 121 122 122 ff->left = malloc(ff->height * sizeof(int)); … … 128 128 } 129 129 130 int c ucul_put_figchar(cucul_canvas_t *cv, uint32_t ch)131 { 132 c ucul_figfont_t *ff = cv->ff;130 int caca_put_figchar(caca_canvas_t *cv, uint32_t ch) 131 { 132 caca_figfont_t *ff = cv->ff; 133 133 int c, w, h, x, y, overlap, extra, xleft, xright; 134 134 … … 155 155 h = ff->height; 156 156 157 c ucul_set_canvas_handle(ff->fontcv, 0, c * ff->height);158 c ucul_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); 159 159 160 160 /* Check whether we reached the end of the screen */ … … 177 177 /* Compute how much spaces we can eat from the new glyph */ 178 178 for(xright = 0; xright < overlap; xright++) 179 if(c ucul_get_char(ff->charcv, xright, y) != ' ')179 if(caca_get_char(ff->charcv, xright, y) != ' ') 180 180 break; 181 181 182 182 /* Compute how much spaces we can eat from the previous glyph */ 183 183 for(xleft = 0; xright + xleft < overlap && xleft < ff->x; xleft++) 184 if(c ucul_get_char(cv, ff->x - 1 - xleft, ff->y + y) != ' ')184 if(caca_get_char(cv, ff->x - 1 - xleft, ff->y + y) != ' ') 185 185 break; 186 186 … … 193 193 { 194 194 if(xleft < ff->x && 195 hsmush(c ucul_get_char(cv, ff->x - 1 - xleft, ff->y + y),196 c ucul_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), 197 197 ff->hsmushrule)) 198 198 xleft++; … … 220 220 #if 0 /* deactivated for libcaca insertion */ 221 221 if(attr) 222 c ucul_set_attr(cv, attr);222 caca_set_attr(cv, attr); 223 223 #endif 224 c ucul_set_canvas_size(cv, ff->w, ff->h);225 226 /* Render our char (FIXME: create a rect-aware c ucul_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?) */ 227 227 for(y = 0; y < h; y++) 228 228 for(x = 0; x < w; x++) 229 229 { 230 230 uint32_t ch1, ch2; 231 //uint32_t tmpat = c ucul_get_attr(ff->fontcv, x, y + c * ff->height);232 ch2 = c ucul_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); 233 233 if(ch2 == ' ') 234 234 continue; 235 ch1 = c ucul_get_char(cv, ff->x + x - overlap, ff->y + y);236 /* FIXME: this could be changed to c ucul_put_attr() when the237 * function is fixed in libc ucul*/238 //c ucul_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); 239 239 if(ch1 == ' ' || ff->hmode != H_SMUSH) 240 c ucul_put_char(cv, ff->x + x - overlap, ff->y + y, ch2);240 caca_put_char(cv, ff->x + x - overlap, ff->y + y, ch2); 241 241 else 242 c ucul_put_char(cv, ff->x + x - overlap, ff->y + y,242 caca_put_char(cv, ff->x + x - overlap, ff->y + y, 243 243 hsmush(ch1, ch2, ff->hsmushrule)); 244 //c ucul_put_attr(cv, ff->x + x, ff->y + y, tmpat);244 //caca_put_attr(cv, ff->x + x, ff->y + y, tmpat); 245 245 } 246 246 … … 251 251 } 252 252 253 int c ucul_flush_figlet(cucul_canvas_t *cv)254 { 255 c ucul_figfont_t *ff = cv->ff;253 int caca_flush_figlet(caca_canvas_t *cv) 254 { 255 caca_figfont_t *ff = cv->ff; 256 256 int x, y; 257 257 258 258 //ff->torender = cv; 259 //c ucul_set_canvas_size(ff->torender, ff->w, ff->h);260 c ucul_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); 261 261 262 262 /* FIXME: do this somewhere else, or record hardblank positions */ 263 263 for(y = 0; y < ff->h; y++) 264 264 for(x = 0; x < ff->w; x++) 265 if(c ucul_get_char(cv, x, y) == 0xa0)266 { 267 uint32_t attr = c ucul_get_attr(cv, x, y);268 c ucul_put_char(cv, x, y, ' ');269 c ucul_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); 270 270 } 271 271 … … 273 273 ff->w = ff->h = 0; 274 274 275 //cv = c ucul_create_canvas(1, 1); /* XXX */275 //cv = caca_create_canvas(1, 1); /* XXX */ 276 276 277 277 /* from render.c */ 278 ff->lines += c ucul_get_canvas_height(cv);278 ff->lines += caca_get_canvas_height(cv); 279 279 280 280 return 0; … … 284 284 #define EXT_GLYPHS (STD_GLYPHS + 7) 285 285 286 static c ucul_figfont_t * open_figfont(char const *path)286 static caca_figfont_t * open_figfont(char const *path) 287 287 { 288 288 char altpath[2048]; 289 289 char buf[2048]; 290 290 char hardblank[10]; 291 c ucul_figfont_t *ff;291 caca_figfont_t *ff; 292 292 char *data = NULL; 293 c ucul_file_t *f;293 caca_file_t *f; 294 294 int i, j, size, comment_lines; 295 295 296 ff = malloc(sizeof(c ucul_figfont_t));296 ff = malloc(sizeof(caca_figfont_t)); 297 297 if(!ff) 298 298 { … … 302 302 303 303 /* Open font: if not found, try .tlf, then .flf */ 304 f = c ucul_file_open(path, "r");304 f = caca_file_open(path, "r"); 305 305 #if !defined __KERNEL__ && defined HAVE_SNPRINTF 306 306 … … 313 313 snprintf(altpath, 2047, "%s.tlf", path); 314 314 altpath[2047] = '\0'; 315 f = c ucul_file_open(altpath, "r");315 f = caca_file_open(altpath, "r"); 316 316 } 317 317 if(!f) … … 319 319 snprintf(altpath, 2047, "%s.flf", path); 320 320 altpath[2047] = '\0'; 321 f = c ucul_file_open(altpath, "r");321 f = caca_file_open(altpath, "r"); 322 322 } 323 323 #endif … … 333 333 ff->full_layout = 0; 334 334 ff->codetag_count = 0; 335 c ucul_file_gets(f, buf, 2048);335 caca_file_gets(f, buf, 2048); 336 336 if(sscanf(buf, "%*[ft]lf2a%6s %u %u %u %i %u %u %u %u\n", hardblank, 337 337 &ff->height, &ff->baseline, &ff->max_length, … … 340 340 { 341 341 debug("figfont error: `%s' has invalid header: %s", path, buf); 342 c ucul_file_close(f);342 caca_file_close(f); 343 343 free(ff); 344 344 seterrno(EINVAL); … … 352 352 debug("figfont error: `%s' has invalid layout %i/%u", 353 353 path, ff->old_layout, ff->full_layout); 354 c ucul_file_close(f);354 caca_file_close(f); 355 355 free(ff); 356 356 seterrno(EINVAL); … … 358 358 } 359 359 360 ff->hardblank = c ucul_utf8_to_utf32(hardblank, NULL);360 ff->hardblank = caca_utf8_to_utf32(hardblank, NULL); 361 361 362 362 /* Skip comment lines */ 363 363 for(i = 0; i < comment_lines; i++) 364 c ucul_file_gets(f, buf, 2048);364 caca_file_gets(f, buf, 2048); 365 365 366 366 /* Read mandatory characters (32-127, 196, 214, 220, 228, 246, 252, 223) … … 369 369 ff->lookup = NULL; 370 370 371 for(i = 0, size = 0; !c ucul_file_eof(f); ff->glyphs++)371 for(i = 0, size = 0; !caca_file_eof(f); ff->glyphs++) 372 372 { 373 373 if((ff->glyphs % 2048) == 0) … … 386 386 else 387 387 { 388 if(c ucul_file_gets(f, buf, 2048) == NULL)388 if(caca_file_gets(f, buf, 2048) == NULL) 389 389 break; 390 390 … … 397 397 { 398 398 for(j = 0; j < ff->height; j++) 399 c ucul_file_gets(f, buf, 2048);399 caca_file_gets(f, buf, 2048); 400 400 continue; 401 401 } … … 424 424 data = realloc(data, size += 2048); 425 425 426 c ucul_file_gets(f, data + i, 2048);426 caca_file_gets(f, data + i, 2048); 427 427 i = (uintptr_t)strchr(data + i, 0) - (uintptr_t)data; 428 428 } 429 429 } 430 430 431 c ucul_file_close(f);431 caca_file_close(f); 432 432 433 433 if(ff->glyphs < EXT_GLYPHS) … … 443 443 444 444 /* Import buffer into canvas */ 445 ff->fontcv = c ucul_create_canvas(0, 0);446 c ucul_import_memory(ff->fontcv, data, i, "utf8");445 ff->fontcv = caca_create_canvas(0, 0); 446 caca_import_memory(ff->fontcv, data, i, "utf8"); 447 447 free(data); 448 448 … … 455 455 for(i = ff->max_length; i--;) 456 456 { 457 ch = c ucul_get_char(ff->fontcv, i, j);457 ch = caca_get_char(ff->fontcv, i, j); 458 458 459 459 /* Replace hardblanks with U+00A0 NO-BREAK SPACE */ 460 460 if(ch == ff->hardblank) 461 c ucul_put_char(ff->fontcv, i, j, ch = 0xa0);461 caca_put_char(ff->fontcv, i, j, ch = 0xa0); 462 462 463 463 if(oldch && ch != oldch) … … 467 467 } 468 468 else if(oldch && ch == oldch) 469 c ucul_put_char(ff->fontcv, i, j, ' ');469 caca_put_char(ff->fontcv, i, j, ' '); 470 470 else if(ch != ' ') 471 471 { 472 472 oldch = ch; 473 c ucul_put_char(ff->fontcv, i, j, ' ');473 caca_put_char(ff->fontcv, i, j, ' '); 474 474 } 475 475 } … … 479 479 } 480 480 481 int free_figfont(c ucul_figfont_t *ff)482 { 483 c ucul_free_canvas(ff->fontcv);481 int free_figfont(caca_figfont_t *ff) 482 { 483 caca_free_canvas(ff->fontcv); 484 484 free(ff->lookup); 485 485 free(ff); -
libcaca/trunk/caca/file.c
r2819 r2821 1 1 /* 2 * libc ucul Canvas for ultrafast compositing of Unicode letters2 * libcaca Colour ASCII-Art library 3 3 * Copyright (c) 2006-2007 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 30 30 #endif 31 31 32 #include "c ucul.h"33 #include "c ucul_internals.h"32 #include "caca.h" 33 #include "caca_internals.h" 34 34 35 35 #if !defined __KERNEL__ && defined HAVE_ZLIB_H 36 static int zipread(c ucul_file_t *, void *, unsigned int);36 static int zipread(caca_file_t *, void *, unsigned int); 37 37 #endif 38 38 39 39 #if !defined __KERNEL__ 40 struct c ucul_file40 struct caca_file 41 41 { 42 42 # if defined HAVE_ZLIB_H … … 51 51 #endif 52 52 53 c ucul_file_t *cucul_file_open(char const *path, const char *mode)53 caca_file_t *caca_file_open(char const *path, const char *mode) 54 54 { 55 55 #if defined __KERNEL__ … … 57 57 return NULL; 58 58 #else 59 c ucul_file_t *fp = malloc(sizeof(*fp));59 caca_file_t *fp = malloc(sizeof(*fp)); 60 60 61 61 fp->readonly = !!strchr(mode, 'r'); … … 126 126 } 127 127 128 int c ucul_file_close(cucul_file_t *fp)128 int caca_file_close(caca_file_t *fp) 129 129 { 130 130 #if defined __KERNEL__ … … 144 144 } 145 145 146 uint64_t c ucul_file_tell(cucul_file_t *fp)146 uint64_t caca_file_tell(caca_file_t *fp) 147 147 { 148 148 #if defined __KERNEL__ … … 158 158 } 159 159 160 size_t c ucul_file_read(cucul_file_t *fp, void *ptr, size_t size)160 size_t caca_file_read(caca_file_t *fp, void *ptr, size_t size) 161 161 { 162 162 #if defined __KERNEL__ … … 172 172 } 173 173 174 size_t c ucul_file_write(cucul_file_t *fp, const void *ptr, size_t size)174 size_t caca_file_write(caca_file_t *fp, const void *ptr, size_t size) 175 175 { 176 176 #if defined __KERNEL__ … … 195 195 } 196 196 197 char *c ucul_file_gets(cucul_file_t *fp, char *s, int size)197 char *caca_file_gets(caca_file_t *fp, char *s, int size) 198 198 { 199 199 #if defined __KERNEL__ … … 229 229 } 230 230 231 int c ucul_file_eof(cucul_file_t *fp)231 int caca_file_eof(caca_file_t *fp) 232 232 { 233 233 #if defined __KERNEL__ … … 241 241 242 242 #if !defined __KERNEL__ && defined HAVE_ZLIB_H 243 static int zipread(c ucul_file_t *fp, void *buf, unsigned int len)243 static int zipread(caca_file_t *fp, void *buf, unsigned int len) 244 244 { 245 245 unsigned int total_read = 0; -
libcaca/trunk/caca/font.c
r2819 r2821 1 1 /* 2 * libc ucul Canvas for ultrafast compositing of Unicode letters2 * libcaca Colour ASCII-Art library 3 3 * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 28 28 #endif 29 29 30 #include "c ucul.h"31 #include "c ucul_internals.h"30 #include "caca.h" 31 #include "caca_internals.h" 32 32 33 33 /* Internal fonts */ … … 56 56 }; 57 57 58 struct c ucul_font58 struct caca_font 59 59 { 60 60 struct font_header header; … … 92 92 * 93 93 * This function loads a font and returns a handle to its internal 94 * structure. The handle can then be used with c ucul_render_canvas()94 * structure. The handle can then be used with caca_render_canvas() 95 95 * for bitmap output. 96 96 * … … 100 100 * If \c size is non-zero, the \c size bytes of memory at address \c data 101 101 * 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 c ucul_free_font().102 * program until the font handle has been freed with caca_free_font(). 103 103 * 104 104 * If an error occurs, NULL is returned and \b errno is set accordingly: … … 111 111 * \return A font handle or NULL in case of error. 112 112 */ 113 c ucul_font_t *cucul_load_font(void const *data, size_t size)114 { 115 c ucul_font_t *f;113 caca_font_t *caca_load_font(void const *data, size_t size) 114 { 115 caca_font_t *f; 116 116 int i; 117 117 … … 119 119 { 120 120 if(!strcasecmp(data, "Monospace 9")) 121 return c ucul_load_font((char *)&mono9_data, mono9_size);121 return caca_load_font((char *)&mono9_data, mono9_size); 122 122 if(!strcasecmp(data, "Monospace Bold 12")) 123 return c ucul_load_font((char *)&monobold12_data, monobold12_size);123 return caca_load_font((char *)&monobold12_data, monobold12_size); 124 124 125 125 seterrno(ENOENT); … … 135 135 } 136 136 137 f = malloc(sizeof(c ucul_font_t));137 f = malloc(sizeof(caca_font_t)); 138 138 if(!f) 139 139 { … … 302 302 * \return An array of strings. 303 303 */ 304 char const * const * c ucul_get_font_list(void)304 char const * const * caca_get_font_list(void) 305 305 { 306 306 static char const * const list[] = … … 321 321 * This function never fails. 322 322 * 323 * \param f The font, as returned by c ucul_load_font()323 * \param f The font, as returned by caca_load_font() 324 324 * \return The standard glyph width. 325 325 */ 326 int c ucul_get_font_width(cucul_font_t const *f)326 int caca_get_font_width(caca_font_t const *f) 327 327 { 328 328 return f->header.width; … … 336 336 * This function never fails. 337 337 * 338 * \param f The font, as returned by c ucul_load_font()338 * \param f The font, as returned by caca_load_font() 339 339 * \return The standard glyph height. 340 340 */ 341 int c ucul_get_font_height(cucul_font_t const *f)341 int caca_get_font_height(caca_font_t const *f) 342 342 { 343 343 return f->header.height; … … 361 361 * This function never fails. 362 362 * 363 * \param f The font, as returned by c ucul_load_font()363 * \param f The font, as returned by caca_load_font() 364 364 * \return The list of Unicode blocks supported by the font. 365 365 */ 366 uint32_t const *c ucul_get_font_blocks(cucul_font_t const *f)366 uint32_t const *caca_get_font_blocks(caca_font_t const *f) 367 367 { 368 368 return (uint32_t const *)f->user_block_list; … … 371 371 /** \brief Free a font structure. 372 372 * 373 * This function frees all data allocated by c ucul_load_font(). The374 * font structure is no longer usable by other libc uculfunctions. Once373 * This function frees all data allocated by caca_load_font(). The 374 * font structure is no longer usable by other libcaca functions. Once 375 375 * this function has returned, the memory area that was given to 376 * c ucul_load_font() can be freed.376 * caca_load_font() can be freed. 377 377 * 378 378 * This function never fails. 379 379 * 380 * \param f The font, as returned by c ucul_load_font()380 * \param f The font, as returned by caca_load_font() 381 381 * \return This function always returns 0. 382 382 */ 383 int c ucul_free_font(cucul_font_t *f)383 int caca_free_font(caca_font_t *f) 384 384 { 385 385 free(f->glyph_list); … … 397 397 * 398 398 * The required image width can be computed using 399 * c ucul_get_canvas_width() and cucul_get_font_width(). The required400 * height can be computed using c ucul_get_canvas_height() and401 * c ucul_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(). 402 402 * 403 403 * Glyphs that do not fit in the image buffer are currently not rendered at … … 408 408 * 409 409 * \param cv The canvas to render 410 * \param f The font, as returned by c ucul_load_font()410 * \param f The font, as returned by caca_load_font() 411 411 * \param buf The image buffer 412 412 * \param width The width (in pixels) of the image buffer … … 415 415 * \return 0 in case of success, -1 if an error occurred. 416 416 */ 417 int c ucul_render_canvas(cucul_canvas_t const *cv, cucul_font_t const *f,417 int caca_render_canvas(caca_canvas_t const *cv, caca_font_t const *f, 418 418 void *buf, int width, int height, int pitch) 419 419 { … … 472 472 + ch - f->block_list[b].start]; 473 473 474 c ucul_attr_to_argb64(attr, argb);474 caca_attr_to_argb64(attr, argb); 475 475 476 476 /* Step 1: unpack glyph */ -
libcaca/trunk/caca/frame.c
r2819 r2821 1 1 /* 2 * libc ucul Canvas for ultrafast compositing of Unicode letters2 * libcaca Colour ASCII-Art library 3 3 * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 25 25 #endif 26 26 27 #include "c ucul.h"28 #include "c ucul_internals.h"27 #include "caca.h" 28 #include "caca_internals.h" 29 29 30 30 /** \brief Get the number of frames in a canvas. … … 34 34 * This function never fails. 35 35 * 36 * \param cv A libc uculcanvas36 * \param cv A libcaca canvas 37 37 * \return The frame count 38 38 */ 39 int c ucul_get_frame_count(cucul_canvas_t const *cv)39 int caca_get_frame_count(caca_canvas_t const *cv) 40 40 { 41 41 return cv->framecount; … … 46 46 * Set the active canvas frame. All subsequent drawing operations will 47 47 * be performed on that frame. The current painting context set by 48 * c ucul_set_attr() is inherited.48 * caca_set_attr() is inherited. 49 49 * 50 50 * If the frame index is outside the canvas' frame range, nothing happens. … … 53 53 * - \c EINVAL Requested frame is out of range. 54 54 * 55 * \param cv A libc uculcanvas55 * \param cv A libcaca canvas 56 56 * \param id The canvas frame to activate 57 57 * \return 0 in case of success, -1 if an error occurred. 58 58 */ 59 int c ucul_set_frame(cucul_canvas_t *cv, int id)59 int caca_set_frame(caca_canvas_t *cv, int id) 60 60 { 61 61 if(id < 0 || id >= cv->framecount) … … 65 65 } 66 66 67 _c ucul_save_frame_info(cv);67 _caca_save_frame_info(cv); 68 68 cv->frame = id; 69 _c ucul_load_frame_info(cv);69 _caca_load_frame_info(cv); 70 70 71 71 return 0; … … 75 75 * 76 76 * Return the current frame's name. The returned string is valid until 77 * the frame is deleted or c ucul_set_frame_name() is called to change77 * the frame is deleted or caca_set_frame_name() is called to change 78 78 * the frame name again. 79 79 * 80 80 * This function never fails. 81 81 * 82 * \param cv A libc uculcanvas.82 * \param cv A libcaca canvas. 83 83 * \return The current frame's name. 84 84 */ 85 char const *c ucul_get_frame_name(cucul_canvas_t const *cv)85 char const *caca_get_frame_name(caca_canvas_t const *cv) 86 86 { 87 87 return cv->frames[cv->frame].name; … … 97 97 * - \c ENOMEM Not enough memory to allocate new frame. 98 98 * 99 * \param cv A libc uculcanvas.99 * \param cv A libcaca canvas. 100 100 * \param name The name to give to the current frame. 101 101 * \return 0 in case of success, -1 if an error occurred. 102 102 */ 103 int c ucul_set_frame_name(cucul_canvas_t *cv, char const *name)103 int caca_set_frame_name(caca_canvas_t *cv, char const *name) 104 104 { 105 105 char *newname = strdup(name); … … 134 134 * - \c ENOMEM Not enough memory to allocate new frame. 135 135 * 136 * \param cv A libc uculcanvas136 * \param cv A libcaca canvas 137 137 * \param id The index where to insert the new frame 138 138 * \return 0 in case of success, -1 if an error occurred. 139 139 */ 140 int c ucul_create_frame(cucul_canvas_t *cv, int id)140 int caca_create_frame(caca_canvas_t *cv, int id) 141 141 { 142 142 int size = cv->width * cv->height; … … 150 150 cv->framecount++; 151 151 cv->frames = realloc(cv->frames, 152 sizeof(struct c ucul_frame) * cv->framecount);152 sizeof(struct caca_frame) * cv->framecount); 153 153 154 154 for(f = cv->framecount - 1; f > id; f--) … … 194 194 * last frame of the canvas. 195 195 * 196 * \param cv A libc uculcanvas196 * \param cv A libcaca canvas 197 197 * \param id The index of the frame to delete 198 198 * \return 0 in case of success, -1 if an error occurred. 199 199 */ 200 int c ucul_free_frame(cucul_canvas_t *cv, int id)200 int caca_free_frame(caca_canvas_t *cv, int id) 201 201 { 202 202 int f; … … 223 223 cv->framecount--; 224 224 cv->frames = realloc(cv->frames, 225 sizeof(struct c ucul_frame) * cv->framecount);225 sizeof(struct caca_frame) * cv->framecount); 226 226 227 227 if(cv->frame > id) … … 230 230 { 231 231 cv->frame = 0; 232 _c ucul_load_frame_info(cv);232 _caca_load_frame_info(cv); 233 233 } 234 234 … … 240 240 */ 241 241 242 void _c ucul_save_frame_info(cucul_canvas_t *cv)242 void _caca_save_frame_info(caca_canvas_t *cv) 243 243 { 244 244 cv->frames[cv->frame].width = cv->width; … … 248 248 } 249 249 250 void _c ucul_load_frame_info(cucul_canvas_t *cv)250 void _caca_load_frame_info(caca_canvas_t *cv) 251 251 { 252 252 cv->width = cv->frames[cv->frame].width; -
libcaca/trunk/caca/graphics.c
r2305 r2821 25 25 #endif 26 26 27 #include "cucul.h"28 27 #include "caca.h" 29 28 #include "caca_internals.h" … … 242 241 dp->drv.handle_resize(dp); 243 242 244 /* Tell libc uculwe changed size */245 if(dp->resize.w != c ucul_get_canvas_width(dp->cv)246 || dp->resize.h != c ucul_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)) 247 246 { 248 247 dp->resize.allow = 1; 249 c ucul_set_canvas_size(dp->cv, dp->resize.w, dp->resize.h);248 caca_set_canvas_size(dp->cv, dp->resize.w, dp->resize.h); 250 249 dp->resize.allow = 0; 251 250 } -
libcaca/trunk/caca/import.c
r2819 r2821 1 1 /* 2 * libc ucul Canvas for ultrafast compositing of Unicode letters2 * libcaca Colour ASCII-Art library 3 3 * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 24 24 #endif 25 25 26 #include "c ucul.h"27 #include "c ucul_internals.h"26 #include "caca.h" 27 #include "caca_internals.h" 28 28 29 29 static inline uint32_t sscanu32(void const *s) … … 52 52 }; 53 53 54 static ssize_t import_caca(c ucul_canvas_t *, void const *, size_t);55 static ssize_t import_text(c ucul_canvas_t *, void const *, size_t);56 static ssize_t import_ansi(c ucul_canvas_t *, void const *, size_t, int);57 58 static void ansi_parse_grcm(c ucul_canvas_t *, struct import *,54 static ssize_t import_caca(caca_canvas_t *, void const *, size_t); 55 static ssize_t import_text(caca_canvas_t *, void const *, size_t); 56 static ssize_t import_ansi(caca_canvas_t *, void const *, size_t, int); 57 58 static void ansi_parse_grcm(caca_canvas_t *, struct import *, 59 59 unsigned int, unsigned int const *); 60 60 61 61 /** \brief Import a memory buffer into a canvas 62 62 * 63 * Import a memory buffer into the given libc uculcanvas's current63 * Import a memory buffer into the given libcaca canvas's current 64 64 * frame. The current frame is resized accordingly and its contents are 65 65 * replaced with the imported data. … … 79 79 * - \c EINVAL Invalid format requested. 80 80 * 81 * \param cv A libc uculcanvas in which to import the file.81 * \param cv A libcaca canvas in which to import the file. 82 82 * \param data A memory area containing the data to be loaded into the canvas. 83 83 * \param len The size in bytes of the memory area. … … 86 86 * or -1 if an error occurred. 87 87 */ 88 ssize_t c ucul_import_memory(cucul_canvas_t *cv, void const *data,88 ssize_t caca_import_memory(caca_canvas_t *cv, void const *data, 89 89 size_t len, char const *format) 90 90 { … … 124 124 /** \brief Import a file into a canvas 125 125 * 126 * Import a file into the given libc uculcanvas's current frame. The126 * Import a file into the given libcaca canvas's current frame. The 127 127 * current frame is resized accordingly and its contents are replaced 128 128 * with the imported data. … … 142 142 * - \c ENOMEM Not enough memory to allocate canvas. 143 143 * - \c EINVAL Invalid format requested. 144 * c ucul_import_file() may also fail and set \b errno for any of the144 * caca_import_file() may also fail and set \b errno for any of the 145 145 * errors specified for the routine fopen(). 146 146 * 147 * \param cv A libc uculcanvas in which to import the file.147 * \param cv A libcaca canvas in which to import the file. 148 148 * \param filename The name of the file to load. 149 149 * \param format A string describing the input format. … … 151 151 * or -1 if an error occurred. 152 152 */ 153 ssize_t c ucul_import_file(cucul_canvas_t *cv, char const *filename,153 ssize_t caca_import_file(caca_canvas_t *cv, char const *filename, 154 154 char const *format) 155 155 { … … 158 158 return -1; 159 159 #else 160 c ucul_file_t *f;160 caca_file_t *f; 161 161 char *data = NULL; 162 162 ssize_t size = 0; 163 163 int ret; 164 164 165 f = c ucul_file_open(filename, "rb");165 f = caca_file_open(filename, "rb"); 166 166 if(!f) 167 167 return -1; /* fopen already set errno */ 168 168 169 while(!c ucul_file_eof(f))169 while(!caca_file_eof(f)) 170 170 { 171 171 data = realloc(data, size + 1024); 172 172 if(!data) 173 173 { 174 c ucul_file_close(f);174 caca_file_close(f); 175 175 seterrno(ENOMEM); 176 176 return -1; 177 177 } 178 178 179 ret = c ucul_file_read(f, data + size, 1024);179 ret = caca_file_read(f, data + size, 1024); 180 180 if(ret >= 0) 181 181 size += ret; 182 182 } 183 c ucul_file_close(f);184 185 ret = c ucul_import_memory(cv, data, size, format);183 caca_file_close(f); 184 185 ret = caca_import_memory(cv, data, size, format); 186 186 free(data); 187 187 … … 194 194 * Return a list of available import formats. The list is a NULL-terminated 195 195 * array of strings, interleaving a string containing the internal value for 196 * the import format, to be used with c ucul_import_canvas(), and a string196 * the import format, to be used with caca_import_canvas(), and a string 197 197 * containing the natural language description for that import format. 198 198 * … … 201 201 * \return An array of strings. 202 202 */ 203 char const * const * c ucul_get_import_list(void)203 char const * const * caca_get_import_list(void) 204 204 { 205 205 static char const * const list[] = … … 220 220 */ 221 221 222 static ssize_t import_caca(c ucul_canvas_t *cv, void const *data, size_t size)222 static ssize_t import_caca(caca_canvas_t *cv, void const *data, size_t size) 223 223 { 224 224 uint8_t const *buf = (uint8_t const *)data; … … 285 285 } 286 286 287 c ucul_set_canvas_size(cv, 0, 0);288 c ucul_set_canvas_size(cv, xmax - xmin, ymax - ymin);289 290 for (f = c ucul_get_frame_count(cv); f--; )291 { 292 c ucul_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); 293 293 } 294 294 … … 299 299 width = sscanu32(buf + 4 + 16 + f * 32); 300 300 height = sscanu32(buf + 4 + 16 + f * 32 + 4); 301 c ucul_create_frame(cv, f);302 c ucul_set_frame(cv, f);301 caca_create_frame(cv, f); 302 caca_set_frame(cv, f); 303 303 304 304 cv->curattr = sscanu32(buf + 4 + 16 + f * 32 + 12); … … 315 315 int y = (n / width) - cv->frames[f].handley - ymin; 316 316 317 c ucul_put_char(cv, x, y, sscanu32(buf + 4 + control_size317 caca_put_char(cv, x, y, sscanu32(buf + 4 + control_size 318 318 + offset + 8 * n)); 319 c ucul_put_attr(cv, x, y, sscanu32(buf + 4 + control_size319 caca_put_attr(cv, x, y, sscanu32(buf + 4 + control_size 320 320 + offset + 8 * n + 4)); 321 321 } … … 328 328 } 329 329 330 c ucul_set_frame(cv, 0);330 caca_set_frame(cv, 0); 331 331 332 332 return 4 + control_size + data_size; … … 337 337 } 338 338 339 static ssize_t import_text(c ucul_canvas_t *cv, void const *data, size_t size)339 static ssize_t import_text(caca_canvas_t *cv, void const *data, size_t size) 340 340 { 341 341 char const *text = (char const *)data; 342 342 unsigned int width = 0, height = 0, x = 0, y = 0, i; 343 343 344 c ucul_set_canvas_size(cv, width, height);344 caca_set_canvas_size(cv, width, height); 345 345 346 346 for(i = 0; i < size; i++) … … 366 366 height = y + 1; 367 367 368 c ucul_set_canvas_size(cv, width, height);369 } 370 371 c ucul_put_char(cv, x, y, ch);368 caca_set_canvas_size(cv, width, height); 369 } 370 371 caca_put_char(cv, x, y, ch); 372 372 x++; 373 373 } 374 374 375 375 if(y > height) 376 c ucul_set_canvas_size(cv, width, height = y);376 caca_set_canvas_size(cv, width, height = y); 377 377 378 378 return size; 379 379 } 380 380 381 static ssize_t import_ansi(c ucul_canvas_t *cv, void const *data,381 static ssize_t import_ansi(caca_canvas_t *cv, void const *data, 382 382 size_t size, int utf8) 383 383 { … … 400 400 else 401 401 { 402 c ucul_set_canvas_size(cv, width = 80, height = 0);402 caca_set_canvas_size(cv, width = 80, height = 0); 403 403 growx = 0; 404 404 growy = 1; … … 407 407 if(utf8) 408 408 { 409 im.dfg = C UCUL_DEFAULT;410 im.dbg = C UCUL_TRANSPARENT;409 im.dfg = CACA_DEFAULT; 410 im.dbg = CACA_TRANSPARENT; 411 411 } 412 412 else 413 413 { 414 im.dfg = C UCUL_LIGHTGRAY;415 im.dbg = C UCUL_BLACK;416 } 417 418 c ucul_set_color_ansi(cv, im.dfg, im.dbg);419 im.clearattr = c ucul_get_attr(cv, -1, -1);414 im.dfg = CACA_LIGHTGRAY; 415 im.dbg = CACA_BLACK; 416 } 417 418 caca_set_color_ansi(cv, im.dfg, im.dbg); 419 im.clearattr = caca_get_attr(cv, -1, -1); 420 420 421 421 ansi_parse_grcm(cv, &im, 1, &dummy); … … 555 555 break; 556 556 case 'J': /* ED (0x4a) - Erase In Page */ 557 savedattr = c ucul_get_attr(cv, -1, -1);558 c ucul_set_attr(cv, im.clearattr);557 savedattr = caca_get_attr(cv, -1, -1); 558 caca_set_attr(cv, im.clearattr); 559 559 if(!argc || argv[0] == 0) 560 560 { 561 c ucul_draw_line(cv, x, y, width, y, ' ');562 c ucul_fill_box(cv, 0, y + 1, width - 1, height - 1, ' ');561 caca_draw_line(cv, x, y, width, y, ' '); 562 caca_fill_box(cv, 0, y + 1, width - 1, height - 1, ' '); 563 563 } 564 564 else if(argv[0] == 1) 565 565 { 566 c ucul_fill_box(cv, 0, 0, width - 1, y - 1, ' ');567 c ucul_draw_line(cv, 0, y, x, y, ' ');566 caca_fill_box(cv, 0, 0, width - 1, y - 1, ' '); 567 caca_draw_line(cv, 0, y, x, y, ' '); 568 568 } 569 569 else if(argv[0] == 2) 570 570 //x = y = 0; 571 c ucul_fill_box(cv, 0, 0, width - 1, height - 1, ' ');572 c ucul_set_attr(cv, savedattr);571 caca_fill_box(cv, 0, 0, width - 1, height - 1, ' '); 572 caca_set_attr(cv, savedattr); 573 573 break; 574 574 case 'K': /* EL (0x4b) - Erase In Line */ 575 575 if(!argc || argv[0] == 0) 576 c ucul_draw_line(cv, x, y, width, y, ' ');576 caca_draw_line(cv, x, y, width, y, ' '); 577 577 else if(argv[0] == 1) 578 c ucul_draw_line(cv, 0, y, x, y, ' ');578 caca_draw_line(cv, 0, y, x, y, ' '); 579 579 else if(argv[0] == 2) 580 580 if((unsigned int)x < width) 581 c ucul_draw_line(cv, x, y, width - 1, y, ' ');581 caca_draw_line(cv, x, y, width - 1, y, ' '); 582 582 //x = width; 583 583 break; … … 587 587 for(j = 0; (unsigned int)(j + argv[0]) < width; j++) 588 588 { 589 c ucul_put_char(cv, j, y,590 c ucul_get_char(cv, j + argv[0], y));591 c ucul_put_attr(cv, j, y,592 c ucul_get_attr(cv, j + argv[0], y));589 caca_put_char(cv, j, y, 590 caca_get_char(cv, j + argv[0], y)); 591 caca_put_attr(cv, j, y, 592 caca_get_attr(cv, j + argv[0], y)); 593 593 } 594 594 #if 0 595 savedattr = c ucul_get_attr(cv, -1, -1);596 c ucul_set_attr(cv, im.clearattr);595 savedattr = caca_get_attr(cv, -1, -1); 596 caca_set_attr(cv, im.clearattr); 597 597 for( ; (unsigned int)j < width; j++) 598 c ucul_put_char(cv, j, y, ' ');599 c ucul_set_attr(cv, savedattr);598 caca_put_char(cv, j, y, ' '); 599 caca_set_attr(cv, savedattr); 600 600 #endif 601 601 case 'X': /* ECH (0x58) - Erase Character */ 602 602 if(argc && argv[0]) 603 603 { 604 savedattr = c ucul_get_attr(cv, -1, -1);605 c ucul_set_attr(cv, im.clearattr);606 c ucul_draw_line(cv, x, y, x + argv[0] - 1, y, ' ');607 c ucul_set_attr(cv, savedattr);604 savedattr = caca_get_attr(cv, -1, -1); 605 caca_set_attr(cv, im.clearattr); 606 caca_draw_line(cv, x, y, x + argv[0] - 1, y, ' '); 607 caca_set_attr(cv, savedattr); 608 608 } 609 609 case 'd': /* VPA (0x64) - Line Position Absolute */ … … 684 684 685 685 if(i + 6 < size) 686 ch = c ucul_utf8_to_utf32((char const *)(buffer + i), &bytes);686 ch = caca_utf8_to_utf32((char const *)(buffer + i), &bytes); 687 687 else 688 688 { … … 691 691 memcpy(tmp, buffer + i, size - i); 692 692 tmp[size - i] = '\0'; 693 ch = c ucul_utf8_to_utf32(tmp, &bytes);693 ch = caca_utf8_to_utf32(tmp, &bytes); 694 694 } 695 695 … … 700 700 bytes = 1; 701 701 } 702 wch = c ucul_utf32_is_fullwidth(ch) ? 2 : 1;702 wch = caca_utf32_is_fullwidth(ch) ? 2 : 1; 703 703 skip += bytes - 1; 704 704 } 705 705 else 706 706 { 707 ch = c ucul_cp437_to_utf32(buffer[i]);707 ch = caca_cp437_to_utf32(buffer[i]); 708 708 wch = 1; 709 709 } … … 714 714 if(growx) 715 715 { 716 savedattr = c ucul_get_attr(cv, -1, -1);717 c ucul_set_attr(cv, im.clearattr);718 c ucul_set_canvas_size(cv, width = x + wch, height);719 c ucul_set_attr(cv, savedattr);716 savedattr = caca_get_attr(cv, -1, -1); 717 caca_set_attr(cv, im.clearattr); 718 caca_set_canvas_size(cv, width = x + wch, height); 719 caca_set_attr(cv, savedattr); 720 720 } 721 721 else … … 729 729 if((unsigned int)y >= height) 730 730 { 731 savedattr = c ucul_get_attr(cv, -1, -1);732 c ucul_set_attr(cv, im.clearattr);731 savedattr = caca_get_attr(cv, -1, -1); 732 caca_set_attr(cv, im.clearattr); 733 733 if(growy) 734 734 { 735 c ucul_set_canvas_size(cv, width, height = y + 1);735 caca_set_canvas_size(cv, width, height = y + 1); 736 736 } 737 737 else … … 746 746 cv->chars + (j + lines) * cv->width, cv->width * 4); 747 747 } 748 c ucul_fill_box(cv, 0, height - lines,748 caca_fill_box(cv, 0, height - lines, 749 749 cv->width - 1, height - 1, ' '); 750 750 y -= lines; 751 751 } 752 c ucul_set_attr(cv, savedattr);752 caca_set_attr(cv, savedattr); 753 753 } 754 754 … … 756 756 if(wch) 757 757 { 758 c ucul_put_char(cv, x, y, ch);758 caca_put_char(cv, x, y, ch);