Browse Source

* Rename cucul_put*() into cucul_put_*(). Updated all code to reflect that.

tags/v0.99.beta14
Sam Hocevar sam 19 years ago
parent
commit
3243101ff0
30 changed files with 187 additions and 169 deletions
  1. +2
    -2
      caca/caca0.h
  2. +1
    -1
      caca/driver_gl.c
  3. +1
    -1
      cucul/attr.c
  4. +17
    -17
      cucul/box.c
  5. +7
    -7
      cucul/canvas.c
  6. +4
    -4
      cucul/conic.c
  7. +10
    -6
      cucul/cucul.h
  8. +1
    -1
      cucul/dither.c
  9. +3
    -3
      cucul/import.c
  10. +14
    -0
      cucul/legacy.c
  11. +8
    -8
      cucul/line.c
  12. +1
    -1
      cucul/triangle.c
  13. +3
    -3
      src/aafire.c
  14. +6
    -6
      src/cacademo.c
  15. +7
    -7
      src/cacaview.c
  16. +1
    -1
      test/blit.c
  17. +7
    -7
      test/colors.c
  18. +19
    -19
      test/demo.c
  19. +1
    -1
      test/dithering.c
  20. +1
    -1
      test/event.c
  21. +10
    -10
      test/export.c
  22. +3
    -3
      test/font.c
  23. +1
    -1
      test/font2tga.c
  24. +1
    -1
      test/frames.c
  25. +6
    -6
      test/fullwidth.c
  26. +3
    -3
      test/input.c
  27. +4
    -4
      test/spritedit.c
  28. +13
    -13
      test/transform.c
  29. +2
    -2
      test/truecolor.c
  30. +30
    -30
      test/unicode.c

+ 2
- 2
caca/caca0.h View File

@@ -134,8 +134,8 @@ enum caca_feature
#define caca_get_fg_color() __caca0_fg #define caca_get_fg_color() __caca0_fg
#define caca_get_bg_color() __caca0_bg #define caca_get_bg_color() __caca0_bg
#define caca_get_color_name __caca0_get_color_name #define caca_get_color_name __caca0_get_color_name
#define caca_putchar(x, y, c) cucul_putchar(__caca0_cv, x, y, c)
#define caca_putstr(x, y, s) cucul_putstr(__caca0_cv, x, y, s)
#define caca_putchar(x, y, c) cucul_put_char(__caca0_cv, x, y, c)
#define caca_putstr(x, y, s) cucul_put_str(__caca0_cv, x, y, s)
#define caca_printf(x, y, f, z...) cucul_printf(__caca0_cv, x, y, f, ##z) #define caca_printf(x, y, f, z...) cucul_printf(__caca0_cv, x, y, f, ##z)
#define caca_clear() cucul_clear_canvas(__caca0_cv) #define caca_clear() cucul_clear_canvas(__caca0_cv)




+ 1
- 1
caca/driver_gl.c View File

@@ -519,7 +519,7 @@ static void gl_compute_font(caca_display_t *dp)
int j, n = (int)(dp->drv.p->blocks[i + 1] - dp->drv.p->blocks[i]); int j, n = (int)(dp->drv.p->blocks[i + 1] - dp->drv.p->blocks[i]);


for(j = 0; j < n; j++) for(j = 0; j < n; j++)
cucul_putchar(cv, 0, b + j, dp->drv.p->blocks[i] + j);
cucul_put_char(cv, 0, b + j, dp->drv.p->blocks[i] + j);


b += n; b += n;
} }


+ 1
- 1
cucul/attr.c View File

@@ -125,7 +125,7 @@ int cucul_set_attr(cucul_canvas_t *cv, unsigned long int attr)
* \param attr The requested attribute value. * \param attr The requested attribute value.
* \return 0 in case of success, -1 if an error occurred. * \return 0 in case of success, -1 if an error occurred.
*/ */
int cucul_putattr(cucul_canvas_t *cv, int x, int y, unsigned long int attr)
int cucul_put_attr(cucul_canvas_t *cv, int x, int y, unsigned long int attr)
{ {
uint32_t *curattr, *curchar; uint32_t *curattr, *curchar;




+ 17
- 17
cucul/box.c View File

@@ -84,25 +84,25 @@ int cucul_draw_thin_box(cucul_canvas_t *cv, int x1, int y1, int x2, int y2)
/* Draw edges */ /* Draw edges */
if(y1 >= 0) if(y1 >= 0)
for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++)
cucul_putchar(cv, x, y1, '-');
cucul_put_char(cv, x, y1, '-');


if(y2 <= ymax) if(y2 <= ymax)
for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++)
cucul_putchar(cv, x, y2, '-');
cucul_put_char(cv, x, y2, '-');


if(x1 >= 0) if(x1 >= 0)
for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++)
cucul_putchar(cv, x1, y, '|');
cucul_put_char(cv, x1, y, '|');


if(x2 <= xmax) if(x2 <= xmax)
for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++)
cucul_putchar(cv, x2, y, '|');
cucul_put_char(cv, x2, y, '|');


/* Draw corners */ /* Draw corners */
cucul_putchar(cv, x1, y1, ',');
cucul_putchar(cv, x1, y2, '`');
cucul_putchar(cv, x2, y1, '.');
cucul_putchar(cv, x2, y2, '\'');
cucul_put_char(cv, x1, y1, ',');
cucul_put_char(cv, x1, y2, '`');
cucul_put_char(cv, x2, y1, '.');
cucul_put_char(cv, x2, y2, '\'');


return 0; return 0;
} }
@@ -143,25 +143,25 @@ int cucul_draw_cp437_box(cucul_canvas_t *cv, int x1, int y1, int x2, int y2)
/* Draw edges */ /* Draw edges */
if(y1 >= 0) if(y1 >= 0)
for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++)
cucul_putchar(cv, x, y1, 0x2500); /* ─ */
cucul_put_char(cv, x, y1, 0x2500); /* ─ */


if(y2 <= ymax) if(y2 <= ymax)
for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++)
cucul_putchar(cv, x, y2, 0x2500); /* ─ */
cucul_put_char(cv, x, y2, 0x2500); /* ─ */


if(x1 >= 0) if(x1 >= 0)
for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++)
cucul_putchar(cv, x1, y, 0x2502); /* │ */
cucul_put_char(cv, x1, y, 0x2502); /* │ */


if(x2 <= xmax) if(x2 <= xmax)
for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++)
cucul_putchar(cv, x2, y, 0x2502); /* │ */
cucul_put_char(cv, x2, y, 0x2502); /* │ */


/* Draw corners */ /* Draw corners */
cucul_putchar(cv, x1, y1, 0x250c); /* ┌ */
cucul_putchar(cv, x1, y2, 0x2514); /* └ */
cucul_putchar(cv, x2, y1, 0x2510); /* ┐ */
cucul_putchar(cv, x2, y2, 0x2518); /* ┘ */
cucul_put_char(cv, x1, y1, 0x250c); /* ┌ */
cucul_put_char(cv, x1, y2, 0x2514); /* └ */
cucul_put_char(cv, x2, y1, 0x2510); /* ┐ */
cucul_put_char(cv, x2, y2, 0x2518); /* ┘ */


return 0; return 0;
} }
@@ -208,7 +208,7 @@ int cucul_fill_box(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,


for(y = y1; y <= y2; y++) for(y = y1; y <= y2; y++)
for(x = x1; x <= x2; x++) for(x = x1; x <= x2; x++)
cucul_putchar(cv, x, y, ch);
cucul_put_char(cv, x, y, ch);


return 0; return 0;
} }


+ 7
- 7
cucul/canvas.c View File

@@ -102,7 +102,7 @@ int cucul_get_cursor_y(cucul_canvas_t *cv)
* *
* The behaviour when printing non-printable characters or invalid UTF-32 * The behaviour when printing non-printable characters or invalid UTF-32
* characters is undefined. To print a sequence of bytes forming an UTF-8 * characters is undefined. To print a sequence of bytes forming an UTF-8
* character instead of an UTF-32 character, use the cucul_putstr() function.
* character instead of an UTF-32 character, use the cucul_put_str() function.
* *
* This function never fails. * This function never fails.
* *
@@ -112,7 +112,7 @@ int cucul_get_cursor_y(cucul_canvas_t *cv)
* \param ch The character to print. * \param ch The character to print.
* \return This function always returns 0. * \return This function always returns 0.
*/ */
int cucul_putchar(cucul_canvas_t *cv, int x, int y, unsigned long int ch)
int cucul_put_char(cucul_canvas_t *cv, int x, int y, unsigned long int ch)
{ {
uint32_t *curchar, *curattr, attr; uint32_t *curchar, *curattr, attr;
int fullwidth; int fullwidth;
@@ -194,7 +194,7 @@ int cucul_putchar(cucul_canvas_t *cv, int x, int y, unsigned long int ch)
* \param y Y coordinate. * \param y Y coordinate.
* \return This function always returns 0. * \return This function always returns 0.
*/ */
unsigned long int cucul_getchar(cucul_canvas_t *cv, int x, int y)
unsigned long int cucul_get_char(cucul_canvas_t *cv, int x, int y)
{ {
if(x < 0 || x >= (int)cv->width || y < 0 || y >= (int)cv->height) if(x < 0 || x >= (int)cv->width || y < 0 || y >= (int)cv->height)
return ' '; return ' ';
@@ -209,7 +209,7 @@ unsigned long int cucul_getchar(cucul_canvas_t *cv, int x, int y)
* canvas boundaries (eg. a negative Y coordinate) and the string will * canvas boundaries (eg. a negative Y coordinate) and the string will
* be cropped accordingly if it is too long. * be cropped accordingly if it is too long.
* *
* See cucul_putchar() for more information on how fullwidth characters
* See cucul_put_char() for more information on how fullwidth characters
* are handled when overwriting each other or at the canvas' boundaries. * are handled when overwriting each other or at the canvas' boundaries.
* *
* This function never fails. * This function never fails.
@@ -220,7 +220,7 @@ unsigned long int cucul_getchar(cucul_canvas_t *cv, int x, int y)
* \param s The string to print. * \param s The string to print.
* \return This function always returns 0. * \return This function always returns 0.
*/ */
int cucul_putstr(cucul_canvas_t *cv, int x, int y, char const *s)
int cucul_put_str(cucul_canvas_t *cv, int x, int y, char const *s)
{ {
unsigned int read; unsigned int read;


@@ -236,7 +236,7 @@ int cucul_putstr(cucul_canvas_t *cv, int x, int y, char const *s)
while(*s && x < (int)cv->width) while(*s && x < (int)cv->width)
{ {
uint32_t ch = cucul_utf8_to_utf32(s, &read); uint32_t ch = cucul_utf8_to_utf32(s, &read);
cucul_putchar(cv, x, y, ch);
cucul_put_char(cv, x, y, ch);
x += cucul_utf32_is_fullwidth(ch) ? 2 : 1; x += cucul_utf32_is_fullwidth(ch) ? 2 : 1;
s += read; s += read;
} }
@@ -282,7 +282,7 @@ int cucul_printf(cucul_canvas_t *cv, int x, int y, char const *format, ...)
buf[cv->width - x] = '\0'; buf[cv->width - x] = '\0';
va_end(args); va_end(args);


cucul_putstr(cv, x, y, buf);
cucul_put_str(cv, x, y, buf);


if(buf != tmp) if(buf != tmp)
free(buf); free(buf);


+ 4
- 4
cucul/conic.c View File

@@ -244,15 +244,15 @@ static void ellipsepoints(cucul_canvas_t *cv, int xo, int yo, int x, int y,
b |= 0x8; b |= 0x8;


if((b & (0x1|0x4)) == (0x1|0x4)) if((b & (0x1|0x4)) == (0x1|0x4))
cucul_putchar(cv, xo + x, yo + y, ch);
cucul_put_char(cv, xo + x, yo + y, ch);


if((b & (0x2|0x4)) == (0x2|0x4)) if((b & (0x2|0x4)) == (0x2|0x4))
cucul_putchar(cv, xo - x, yo + y, ch);
cucul_put_char(cv, xo - x, yo + y, ch);


if((b & (0x1|0x8)) == (0x1|0x8)) if((b & (0x1|0x8)) == (0x1|0x8))
cucul_putchar(cv, xo + x, yo - y, ch);
cucul_put_char(cv, xo + x, yo - y, ch);


if((b & (0x2|0x8)) == (0x2|0x8)) if((b & (0x2|0x8)) == (0x2|0x8))
cucul_putchar(cv, xo - x, yo - y, ch);
cucul_put_char(cv, xo - x, yo - y, ch);
} }



+ 10
- 6
cucul/cucul.h View File

@@ -92,14 +92,14 @@ int cucul_rand(int, int);
int cucul_gotoxy(cucul_canvas_t *, int, int); int cucul_gotoxy(cucul_canvas_t *, int, int);
int cucul_get_cursor_x(cucul_canvas_t *); int cucul_get_cursor_x(cucul_canvas_t *);
int cucul_get_cursor_y(cucul_canvas_t *); int cucul_get_cursor_y(cucul_canvas_t *);
int cucul_put_char(cucul_canvas_t *, int, int, unsigned long int);
unsigned long int cucul_get_char(cucul_canvas_t *, int, int);
int cucul_put_str(cucul_canvas_t *, int, int, char const *);
unsigned long int cucul_get_attr(cucul_canvas_t *, int, int); unsigned long int cucul_get_attr(cucul_canvas_t *, int, int);
int cucul_set_attr(cucul_canvas_t *, unsigned long int); int cucul_set_attr(cucul_canvas_t *, unsigned long int);
int cucul_putattr(cucul_canvas_t *, int, int, unsigned long int);
int cucul_put_attr(cucul_canvas_t *, int, int, unsigned long int);
int cucul_set_color_ansi(cucul_canvas_t *, unsigned char, unsigned char); int cucul_set_color_ansi(cucul_canvas_t *, unsigned char, unsigned char);
int cucul_set_color_argb(cucul_canvas_t *, unsigned int, unsigned int); int cucul_set_color_argb(cucul_canvas_t *, unsigned int, unsigned int);
int cucul_putchar(cucul_canvas_t *, int, int, unsigned long int);
unsigned long int cucul_getchar(cucul_canvas_t *, int, int);
int cucul_putstr(cucul_canvas_t *, int, int, char const *);
int cucul_printf(cucul_canvas_t *, int, int, char const *, ...); int cucul_printf(cucul_canvas_t *, int, int, char const *, ...);
int cucul_clear_canvas(cucul_canvas_t *); int cucul_clear_canvas(cucul_canvas_t *);
int cucul_set_canvas_handle(cucul_canvas_t *, int, int); int cucul_set_canvas_handle(cucul_canvas_t *, int, int);
@@ -254,10 +254,14 @@ char const * const * cucul_get_export_list(void);
# else # else
# define CUCUL_DEPRECATED # define CUCUL_DEPRECATED
# endif # endif
int cucul_putchar(cucul_canvas_t *, int, int,
unsigned long int) CUCUL_DEPRECATED;
int cucul_putstr(cucul_canvas_t *, int, int,
char const *) CUCUL_DEPRECATED;
int cucul_set_color(cucul_canvas_t *, unsigned char, int cucul_set_color(cucul_canvas_t *, unsigned char,
unsigned char) CUCUL_DEPRECATED;
unsigned char) CUCUL_DEPRECATED;
int cucul_set_truecolor(cucul_canvas_t *, unsigned int, int cucul_set_truecolor(cucul_canvas_t *, unsigned int,
unsigned int) CUCUL_DEPRECATED;
unsigned int) CUCUL_DEPRECATED;
cucul_buffer_t *cucul_load_memory(void *, cucul_buffer_t *cucul_load_memory(void *,
unsigned long int) CUCUL_DEPRECATED; unsigned long int) CUCUL_DEPRECATED;
cucul_buffer_t *cucul_load_file(char const *) CUCUL_DEPRECATED; cucul_buffer_t *cucul_load_file(char const *) CUCUL_DEPRECATED;


+ 1
- 1
cucul/dither.c View File

@@ -1054,7 +1054,7 @@ int cucul_dither_bitmap(cucul_canvas_t *cv, int x, int y, int w, int h,


/* Now output the character */ /* Now output the character */
cucul_set_color_ansi(cv, outfg, outbg); cucul_set_color_ansi(cv, outfg, outbg);
cucul_putchar(cv, x, y, outch);
cucul_put_char(cv, x, y, outch);


d->increment_dither(); d->increment_dither();
} }


+ 3
- 3
cucul/import.c View File

@@ -332,7 +332,7 @@ static long int import_text(cucul_canvas_t *cv,
cucul_set_canvas_size(cv, width, height); cucul_set_canvas_size(cv, width, height);
} }


cucul_putchar(cv, x, y, ch);
cucul_put_char(cv, x, y, ch);
x++; x++;
} }


@@ -481,7 +481,7 @@ static long int import_ansi(cucul_canvas_t *cv,
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
cucul_set_canvas_size(cv, width = 80, height); cucul_set_canvas_size(cv, width = 80, height);
for(j = x; j < 80; j++) for(j = x; j < 80; j++)
cucul_putchar(cv, j, y, ' ');
cucul_put_char(cv, j, y, ' ');
x = 80; x = 80;
break; break;
case 'm': /* SGR - Select Graphic Rendition */ case 'm': /* SGR - Select Graphic Rendition */
@@ -540,7 +540,7 @@ static long int import_ansi(cucul_canvas_t *cv,


/* Now paste our character */ /* Now paste our character */
cucul_set_color_ansi(cv, grcm.efg, grcm.ebg); cucul_set_color_ansi(cv, grcm.efg, grcm.ebg);
cucul_putchar(cv, x, y, ch);
cucul_put_char(cv, x, y, ch);
x += wch; x += wch;
} }




+ 14
- 0
cucul/legacy.c View File

@@ -31,6 +31,20 @@
#include "cucul.h" #include "cucul.h"
#include "cucul_internals.h" #include "cucul_internals.h"


/*
* Functions from canvas.c
*/

int cucul_putchar(cucul_canvas_t *cv, int x, int y, unsigned long int ch)
{
return cucul_put_char(cv, x, y, ch);
}

int cucul_putstr(cucul_canvas_t *cv, int x, int y, char const *s)
{
return cucul_put_str(cv, x, y, s);
}

/* /*
* Functions from color.c * Functions from color.c
*/ */


+ 8
- 8
cucul/line.c View File

@@ -260,7 +260,7 @@ static void draw_solid_line(cucul_canvas_t *cv, struct line* s)


for(; dx>=0; dx--) for(; dx>=0; dx--)
{ {
cucul_putchar(cv, x1, y1, s->ch);
cucul_put_char(cv, x1, y1, s->ch);
if(delta > 0) if(delta > 0)
{ {
x1 += xinc; x1 += xinc;
@@ -282,7 +282,7 @@ static void draw_solid_line(cucul_canvas_t *cv, struct line* s)


for(; dy >= 0; dy--) for(; dy >= 0; dy--)
{ {
cucul_putchar(cv, x1, y1, s->ch);
cucul_put_char(cv, x1, y1, s->ch);
if(delta > 0) if(delta > 0)
{ {
x1 += xinc; x1 += xinc;
@@ -347,7 +347,7 @@ static void draw_thin_line(cucul_canvas_t *cv, struct line* s)
{ {
if(delta > 0) if(delta > 0)
{ {
cucul_putchar(cv, x1, y1, charmapy[1]);
cucul_put_char(cv, x1, y1, charmapy[1]);
x1++; x1++;
y1 += yinc; y1 += yinc;
delta += dpru; delta += dpru;
@@ -356,9 +356,9 @@ static void draw_thin_line(cucul_canvas_t *cv, struct line* s)
else else
{ {
if(prev) if(prev)
cucul_putchar(cv, x1, y1, charmapy[0]);
cucul_put_char(cv, x1, y1, charmapy[0]);
else else
cucul_putchar(cv, x1, y1, '-');
cucul_put_char(cv, x1, y1, '-');
x1++; x1++;
delta += dpr; delta += dpr;
prev = 0; prev = 0;
@@ -375,15 +375,15 @@ static void draw_thin_line(cucul_canvas_t *cv, struct line* s)
{ {
if(delta > 0) if(delta > 0)
{ {
cucul_putchar(cv, x1, y1, charmapx[0]);
cucul_putchar(cv, x1 + 1, y1, charmapx[1]);
cucul_put_char(cv, x1, y1, charmapx[0]);
cucul_put_char(cv, x1 + 1, y1, charmapx[1]);
x1++; x1++;
y1 += yinc; y1 += yinc;
delta += dpru; delta += dpru;
} }
else else
{ {
cucul_putchar(cv, x1, y1, '|');
cucul_put_char(cv, x1, y1, '|');
y1 += yinc; y1 += yinc;
delta += dpr; delta += dpr;
} }


+ 1
- 1
cucul/triangle.c View File

@@ -146,7 +146,7 @@ int cucul_fill_triangle(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,
xmax = xx2 + 1 < (int)cv->width ? xx2 + 1 : (int)cv->width; xmax = xx2 + 1 < (int)cv->width ? xx2 + 1 : (int)cv->width;


for(x = xmin; x < xmax; x++) for(x = xmin; x < xmax; x++)
cucul_putchar(cv, x, y, ch);
cucul_put_char(cv, x, y, ch);


xa += y < y2 ? sl21 : sl32; xa += y < y2 ? sl21 : sl32;
xb += sl31; xb += sl31;


+ 3
- 3
src/aafire.c View File

@@ -242,9 +242,9 @@ paused:
cucul_get_canvas_height(cv), cucul_dither, bitmap); cucul_get_canvas_height(cv), cucul_dither, bitmap);
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
if (sloop < 100) if (sloop < 100)
cucul_putstr(cv, cucul_get_canvas_width(cv) - 30,
cucul_get_canvas_height(cv) - 2,
" -=[ Powered by libcaca ]=- ");
cucul_put_str(cv, cucul_get_canvas_width(cv) - 30,
cucul_get_canvas_height(cv) - 2,
" -=[ Powered by libcaca ]=- ");
caca_refresh_display(dp); caca_refresh_display(dp);
/*XSIZ = caca_get_width() * 2; /*XSIZ = caca_get_width() * 2;


+ 6
- 6
src/cacademo.c View File

@@ -171,9 +171,9 @@ paused:


cucul_set_color_ansi(frontcv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(frontcv, CUCUL_WHITE, CUCUL_BLUE);
if(frame < 100) if(frame < 100)
cucul_putstr(frontcv, cucul_get_canvas_width(frontcv) - 30,
cucul_get_canvas_height(frontcv) - 2,
" -=[ Powered by libcaca ]=- ");
cucul_put_str(frontcv, cucul_get_canvas_width(frontcv) - 30,
cucul_get_canvas_height(frontcv) - 2,
" -=[ Powered by libcaca ]=- ");
caca_refresh_display(dp); caca_refresh_display(dp);
} }
end: end:
@@ -695,7 +695,7 @@ void langton(enum action action, cucul_canvas_t *cv)
cucul_set_color_ansi(cv, CUCUL_WHITE, p >> 4); cucul_set_color_ansi(cv, CUCUL_WHITE, p >> 4);
else else
cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_BLACK); cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_BLACK);
cucul_putchar(cv, x, y, gradient[p & 0x0f]);
cucul_put_char(cv, x, y, gradient[p & 0x0f]);
} }
} }
break; break;
@@ -782,8 +782,8 @@ void matrix(enum action action, cucul_canvas_t *cv)
fg = CUCUL_DARKGRAY; fg = CUCUL_DARKGRAY;
cucul_set_color_ansi(cv, fg, CUCUL_BLACK); cucul_set_color_ansi(cv, fg, CUCUL_BLACK);


cucul_putchar(cv, x, y - j,
drop[i].str[(y - j) % drop[i].len]);
cucul_put_char(cv, x, y - j,
drop[i].str[(y - j) % drop[i].len]);
} }
} }
break; break;


+ 7
- 7
src/cacaview.c View File

@@ -305,7 +305,7 @@ int main(int argc, char **argv)
sprintf(buffer, " Loading `%s'... ", list[current]); sprintf(buffer, " Loading `%s'... ", list[current]);
buffer[ww] = '\0'; buffer[ww] = '\0';
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
cucul_putstr(cv, (ww - strlen(buffer)) / 2, wh / 2, buffer);
cucul_put_str(cv, (ww - strlen(buffer)) / 2, wh / 2, buffer);
caca_refresh_display(dp); caca_refresh_display(dp);
ww = cucul_get_canvas_width(cv); ww = cucul_get_canvas_width(cv);
wh = cucul_get_canvas_height(cv); wh = cucul_get_canvas_height(cv);
@@ -350,7 +350,7 @@ int main(int argc, char **argv)
sprintf(buffer, ERROR_STRING, list[current]); sprintf(buffer, ERROR_STRING, list[current]);
buffer[ww] = '\0'; buffer[ww] = '\0';
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
cucul_putstr(cv, (ww - strlen(buffer)) / 2, wh / 2, buffer);
cucul_put_str(cv, (ww - strlen(buffer)) / 2, wh / 2, buffer);
free(buffer); free(buffer);
} }
else else
@@ -421,9 +421,9 @@ static void print_status(void)
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
cucul_draw_line(cv, 0, 0, ww - 1, 0, ' '); cucul_draw_line(cv, 0, 0, ww - 1, 0, ' ');
cucul_draw_line(cv, 0, wh - 2, ww - 1, wh - 2, '-'); cucul_draw_line(cv, 0, wh - 2, ww - 1, wh - 2, '-');
cucul_putstr(cv, 0, 0, "q:Quit np:Next/Prev +-x:Zoom gG:Gamma "
"hjkl:Move d:Dither a:Antialias");
cucul_putstr(cv, ww - strlen("?:Help"), 0, "?:Help");
cucul_put_str(cv, 0, 0, "q:Quit np:Next/Prev +-x:Zoom gG:Gamma "
"hjkl:Move d:Dither a:Antialias");
cucul_put_str(cv, ww - strlen("?:Help"), 0, "?:Help");
cucul_printf(cv, 3, wh - 2, "cacaview %s", VERSION); cucul_printf(cv, 3, wh - 2, "cacaview %s", VERSION);
cucul_printf(cv, ww - 30, wh - 2, "(gamma: %#.3g)", GAMMA(g)); cucul_printf(cv, ww - 30, wh - 2, "(gamma: %#.3g)", GAMMA(g));
cucul_printf(cv, ww - 14, wh - 2, "(zoom: %s%i)", zoom > 0 ? "+" : "", zoom); cucul_printf(cv, ww - 14, wh - 2, "(zoom: %s%i)", zoom > 0 ? "+" : "", zoom);
@@ -459,7 +459,7 @@ static void print_help(int x, int y)
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);


for(i = 0; help[i]; i++) for(i = 0; help[i]; i++)
cucul_putstr(cv, x, y + i, help[i]);
cucul_put_str(cv, x, y + i, help[i]);
} }


static void set_zoom(int new_zoom) static void set_zoom(int new_zoom)
@@ -520,7 +520,7 @@ static void draw_checkers(int x, int y, int w, int h)
cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_DARKGRAY); cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_DARKGRAY);
else else
cucul_set_color_ansi(cv, CUCUL_DARKGRAY, CUCUL_LIGHTGRAY); cucul_set_color_ansi(cv, CUCUL_DARKGRAY, CUCUL_LIGHTGRAY);
cucul_putchar(cv, xn, yn, ' ');
cucul_put_char(cv, xn, yn, ' ');
} }
} }



+ 1
- 1
test/blit.c View File

@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
cucul_get_canvas_height(sprite) / 2); cucul_get_canvas_height(sprite) / 2);


cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
cucul_putstr(cv, 0, 0, "Centered sprite");
cucul_put_str(cv, 0, 0, "Centered sprite");


cucul_blit(cv, cucul_get_canvas_width(cv) / 2, cucul_blit(cv, cucul_get_canvas_width(cv) / 2,
cucul_get_canvas_height(cv) / 2, sprite, NULL); cucul_get_canvas_height(cv) / 2, sprite, NULL);


+ 7
- 7
test/colors.c View File

@@ -44,21 +44,21 @@ int main(int argc, char **argv)
for(j = 0; j < 16; j++) for(j = 0; j < 16; j++)
{ {
cucul_set_color_ansi(cv, i, j); cucul_set_color_ansi(cv, i, j);
cucul_putstr(cv, (j >= 8 ? 13 : 12) + j * 4, i + (i >= 8 ? 3 : 2),
"Aaホ");
cucul_put_str(cv, (j >= 8 ? 13 : 12) + j * 4, i + (i >= 8 ? 3 : 2),
"Aaホ");
} }
} }


cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
cucul_putstr(cv, 3, 20, "This is bold This is blink This is italics This is underline");
cucul_put_str(cv, 3, 20, "This is bold This is blink This is italics This is underline");
cucul_set_attr(cv, CUCUL_BOLD); cucul_set_attr(cv, CUCUL_BOLD);
cucul_putstr(cv, 3 + 8, 20, "bold");
cucul_put_str(cv, 3 + 8, 20, "bold");
cucul_set_attr(cv, CUCUL_BLINK); cucul_set_attr(cv, CUCUL_BLINK);
cucul_putstr(cv, 3 + 24, 20, "blink");
cucul_put_str(cv, 3 + 24, 20, "blink");
cucul_set_attr(cv, CUCUL_ITALICS); cucul_set_attr(cv, CUCUL_ITALICS);
cucul_putstr(cv, 3 + 41, 20, "italics");
cucul_put_str(cv, 3 + 41, 20, "italics");
cucul_set_attr(cv, CUCUL_UNDERLINE); cucul_set_attr(cv, CUCUL_UNDERLINE);
cucul_putstr(cv, 3 + 60, 20, "underline");
cucul_put_str(cv, 3 + 60, 20, "underline");


caca_refresh_display(dp); caca_refresh_display(dp);
caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1); caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);


+ 19
- 19
test/demo.c View File

@@ -168,8 +168,8 @@ int main(int argc, char **argv)
if(mouse && !demo) if(mouse && !demo)
{ {
cucul_set_color_ansi(cv, CUCUL_RED, CUCUL_BLACK); cucul_set_color_ansi(cv, CUCUL_RED, CUCUL_BLACK);
cucul_putstr(cv, xmouse, ymouse, ".");
cucul_putstr(cv, xmouse, ymouse + 1, "|\\");
cucul_put_str(cv, xmouse, ymouse, ".");
cucul_put_str(cv, xmouse, ymouse + 1, "|\\");
} }
caca_refresh_display(dp); caca_refresh_display(dp);
mouse = menu = 0; mouse = menu = 0;
@@ -208,24 +208,24 @@ static void display_menu(void)
cucul_clear_canvas(cv); cucul_clear_canvas(cv);
cucul_draw_thin_box(cv, 1, 1, xo, yo); cucul_draw_thin_box(cv, 1, 1, xo, yo);


cucul_putstr(cv, (xo - strlen("libcaca demo")) / 2, 3, "libcaca demo");
cucul_putstr(cv, (xo - strlen("==============")) / 2, 4, "==============");
cucul_putstr(cv, 4, 6, "demos:");
cucul_putstr(cv, 4, 7, "'f': full");
cucul_putstr(cv, 4, 8, "'1': dots");
cucul_putstr(cv, 4, 9, "'2': lines");
cucul_putstr(cv, 4, 10, "'3': boxes");
cucul_putstr(cv, 4, 11, "'4': triangles");
cucul_putstr(cv, 4, 12, "'5': ellipses");
cucul_putstr(cv, 4, 13, "'c': colour");
cucul_putstr(cv, 4, 14, "'r': render");
cucul_put_str(cv, (xo - strlen("libcaca demo")) / 2, 3, "libcaca demo");
cucul_put_str(cv, (xo - strlen("==============")) / 2, 4, "==============");
cucul_put_str(cv, 4, 6, "demos:");
cucul_put_str(cv, 4, 7, "'f': full");
cucul_put_str(cv, 4, 8, "'1': dots");
cucul_put_str(cv, 4, 9, "'2': lines");
cucul_put_str(cv, 4, 10, "'3': boxes");
cucul_put_str(cv, 4, 11, "'4': triangles");
cucul_put_str(cv, 4, 12, "'5': ellipses");
cucul_put_str(cv, 4, 13, "'c': colour");
cucul_put_str(cv, 4, 14, "'r': render");
#if 0 #if 0
if(sprite) if(sprite)
cucul_putstr(cv, 4, 15, "'s': sprites");
cucul_put_str(cv, 4, 15, "'s': sprites");
#endif #endif


cucul_putstr(cv, 4, 16, "settings:");
cucul_put_str(cv, 4, 16, "settings:");
cucul_printf(cv, 4, 17, "'o': outline: %s", cucul_printf(cv, 4, 17, "'o': outline: %s",
outline == 0 ? "none" : outline == 1 ? "solid" : "thin"); outline == 0 ? "none" : outline == 1 ? "solid" : "thin");
cucul_printf(cv, 4, 18, "'b': drawing boundaries: %s", cucul_printf(cv, 4, 18, "'b': drawing boundaries: %s",
@@ -233,7 +233,7 @@ static void display_menu(void)
//cucul_printf(cv, 4, 19, "'d': dithering (%s)", //cucul_printf(cv, 4, 19, "'d': dithering (%s)",
// cucul_get_feature_name(dithering)); // cucul_get_feature_name(dithering));


cucul_putstr(cv, 4, yo - 2, "'q': quit");
cucul_put_str(cv, 4, yo - 2, "'q': quit");


caca_refresh_display(dp); caca_refresh_display(dp);
} }
@@ -325,7 +325,7 @@ static void demo_all(void)
{ {
int delta = cucul_rand(-5, 6); int delta = cucul_rand(-5, 6);
cucul_set_color_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16)); cucul_set_color_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16));
cucul_putchar(cv, cucul_get_canvas_width(cv) / 2
cucul_put_char(cv, cucul_get_canvas_width(cv) / 2
+ cos(0.02*j) * (delta + cucul_get_canvas_width(cv) / 4), + cos(0.02*j) * (delta + cucul_get_canvas_width(cv) / 4),
cucul_get_canvas_height(cv) / 2 cucul_get_canvas_height(cv) / 2
+ sin(0.02*j) * (delta + cucul_get_canvas_height(cv) / 3), + sin(0.02*j) * (delta + cucul_get_canvas_height(cv) / 3),
@@ -354,7 +354,7 @@ static void demo_dots(void)
{ {
/* Putpixel */ /* Putpixel */
cucul_set_color_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16)); cucul_set_color_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16));
cucul_putchar(cv, cucul_rand(0, xmax), cucul_rand(0, ymax),
cucul_put_char(cv, cucul_rand(0, xmax), cucul_rand(0, ymax),
chars[cucul_rand(0, 9)]); chars[cucul_rand(0, 9)]);
} }
} }


+ 1
- 1
test/dithering.c View File

@@ -118,7 +118,7 @@ int main(int argc, char *argv[])
ch = density[dista * 2 * 13 / (dista + distb)]; ch = density[dista * 2 * 13 / (dista + distb)];
cucul_set_color_ansi(cv, points[nearb], points[neara]); cucul_set_color_ansi(cv, points[nearb], points[neara]);


cucul_putchar(cv, x * cucul_get_canvas_width(cv) / 100,
cucul_put_char(cv, x * cucul_get_canvas_width(cv) / 100,
(100 - y) * cucul_get_canvas_height(cv) / 100, ch); (100 - y) * cucul_get_canvas_height(cv) / 100, ch);
} }




+ 1
- 1
test/event.c View File

@@ -45,7 +45,7 @@ int main(int argc, char **argv)
cucul_draw_line(cv, 0, 0, cucul_get_canvas_width(cv) - 1, 0, ' '); cucul_draw_line(cv, 0, 0, cucul_get_canvas_width(cv) - 1, 0, ' ');


cucul_draw_line(cv, 0, h, cucul_get_canvas_width(cv) - 1, h, ' '); cucul_draw_line(cv, 0, h, cucul_get_canvas_width(cv) - 1, h, ' ');
cucul_putstr(cv, 0, h, "type \"quit\" to exit");
cucul_put_str(cv, 0, h, "type \"quit\" to exit");


caca_refresh_display(dp); caca_refresh_display(dp);




+ 10
- 10
test/export.c View File

@@ -114,28 +114,28 @@ int main(int argc, char *argv[])
cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_WHITE); cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_WHITE);
cucul_fill_ellipse(cv, WIDTH / 2, HEIGHT / 2, cucul_fill_ellipse(cv, WIDTH / 2, HEIGHT / 2,
WIDTH / 4, HEIGHT / 4, ' '); WIDTH / 4, HEIGHT / 4, ' ');
cucul_putstr(cv, WIDTH / 2 - 5, HEIGHT / 2 - 5, "(\") \\o/ <&>");
cucul_putstr(cv, WIDTH / 2 - 8, HEIGHT / 2 - 3, "[<><><><> <>--<>]");
cucul_putstr(cv, WIDTH / 2 - 8, HEIGHT / 2 - 2, "[ドラゴン ボーレ]");
cucul_putstr(cv, WIDTH / 2 - 7, HEIGHT / 2 + 2, "äβç ░▒▓█▓▒░ ΔЗҒ");
cucul_put_str(cv, WIDTH / 2 - 5, HEIGHT / 2 - 5, "(\") \\o/ <&>");
cucul_put_str(cv, WIDTH / 2 - 8, HEIGHT / 2 - 3, "[<><><><> <>--<>]");
cucul_put_str(cv, WIDTH / 2 - 8, HEIGHT / 2 - 2, "[ドラゴン ボーレ]");
cucul_put_str(cv, WIDTH / 2 - 7, HEIGHT / 2 + 2, "äβç ░▒▓█▓▒░ ΔЗҒ");


cucul_set_attr(cv, CUCUL_BOLD); cucul_set_attr(cv, CUCUL_BOLD);
cucul_putstr(cv, WIDTH / 2 - 16, HEIGHT / 2 + 3, "Bold");
cucul_put_str(cv, WIDTH / 2 - 16, HEIGHT / 2 + 3, "Bold");
cucul_set_attr(cv, CUCUL_BLINK); cucul_set_attr(cv, CUCUL_BLINK);
cucul_putstr(cv, WIDTH / 2 - 9, HEIGHT / 2 + 3, "Blink");
cucul_put_str(cv, WIDTH / 2 - 9, HEIGHT / 2 + 3, "Blink");
cucul_set_attr(cv, CUCUL_ITALICS); cucul_set_attr(cv, CUCUL_ITALICS);
cucul_putstr(cv, WIDTH / 2 - 1, HEIGHT / 2 + 3, "Italics");
cucul_put_str(cv, WIDTH / 2 - 1, HEIGHT / 2 + 3, "Italics");
cucul_set_attr(cv, CUCUL_UNDERLINE); cucul_set_attr(cv, CUCUL_UNDERLINE);
cucul_putstr(cv, WIDTH / 2 + 8, HEIGHT / 2 + 3, "Underline");
cucul_put_str(cv, WIDTH / 2 + 8, HEIGHT / 2 + 3, "Underline");
cucul_set_attr(cv, 0); cucul_set_attr(cv, 0);


cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_LIGHTBLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_LIGHTBLUE);
cucul_putstr(cv, WIDTH / 2 - 7, HEIGHT / 2, " LIBCACA ");
cucul_put_str(cv, WIDTH / 2 - 7, HEIGHT / 2, " LIBCACA ");


for(x = 0; x < 16; x++) for(x = 0; x < 16; x++)
{ {
cucul_set_color_argb(cv, 0xff00 | x, 0xf00f | (x << 4)); cucul_set_color_argb(cv, 0xff00 | x, 0xf00f | (x << 4));
cucul_putstr(cv, WIDTH / 2 - 7 + x, HEIGHT / 2 + 5, "#");
cucul_put_str(cv, WIDTH / 2 - 7 + x, HEIGHT / 2 + 5, "#");
} }
} }




+ 3
- 3
test/font.c View File

@@ -46,11 +46,11 @@ int main(int argc, char *argv[])


/* Draw stuff on our canvas */ /* Draw stuff on our canvas */
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK);
cucul_putstr(cv, 0, 0, "ABcde");
cucul_put_str(cv, 0, 0, "ABcde");
cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_BLACK); cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_BLACK);
cucul_putstr(cv, 5, 0, "\\o/");
cucul_put_str(cv, 5, 0, "\\o/");
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
cucul_putstr(cv, 0, 1, "&$âøÿØ?!");
cucul_put_str(cv, 0, 1, "&$âøÿØ?!");


/* Load a libcucul internal font */ /* Load a libcucul internal font */
fonts = cucul_get_font_list(); fonts = cucul_get_font_list();


+ 1
- 1
test/font2tga.c View File

@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
{ {
for(j = blocks[i]; j < blocks[i + 1]; j++) for(j = blocks[i]; j < blocks[i + 1]; j++)
{ {
cucul_putchar(cv, x, y, j);
cucul_put_char(cv, x, y, j);


if(++x == WIDTH) if(++x == WIDTH)
{ {


+ 1
- 1
test/frames.c View File

@@ -51,7 +51,7 @@ int main(int argc, char *argv[])
cucul_set_color_ansi(cv, CUCUL_WHITE, frame); cucul_set_color_ansi(cv, CUCUL_WHITE, frame);
cucul_fill_box(cv, 0, 0, 40, 15, ':'); cucul_fill_box(cv, 0, 0, 40, 15, ':');
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
cucul_putstr(cv, frame * 5 / 2, frame, "カカ");
cucul_put_str(cv, frame * 5 / 2, frame, "カカ");
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
} }




+ 6
- 6
test/fullwidth.c View File

@@ -43,9 +43,9 @@ int main(int argc, char *argv[])
for(i = 0; i < 10; i++) for(i = 0; i < 10; i++)
{ {
cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE);
cucul_putstr(caca, 0, i, CACA);
cucul_put_str(caca, 0, i, CACA);
cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_RED); cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_RED);
cucul_putchar(caca, i - 2, i, 'x');
cucul_put_char(caca, i - 2, i, 'x');
} }


cucul_blit(cv, 1, 1, caca, NULL); cucul_blit(cv, 1, 1, caca, NULL);
@@ -54,20 +54,20 @@ int main(int argc, char *argv[])
for(i = 0; i < 10; i++) for(i = 0; i < 10; i++)
{ {
cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE);
cucul_putstr(caca, 0, i, CACA);
cucul_put_str(caca, 0, i, CACA);
cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_GREEN); cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_GREEN);
cucul_putstr(caca, i - 2, i, "ホ");
cucul_put_str(caca, i - 2, i, "ホ");
} }


cucul_blit(cv, 15, 1, caca, NULL); cucul_blit(cv, 15, 1, caca, NULL);


/* Line of canvas */ /* Line of canvas */
cucul_set_color_ansi(line, CUCUL_WHITE, CUCUL_MAGENTA); cucul_set_color_ansi(line, CUCUL_WHITE, CUCUL_MAGENTA);
cucul_putstr(line, 0, 0, "ほ");
cucul_put_str(line, 0, 0, "ほ");
for(i = 0; i < 10; i++) for(i = 0; i < 10; i++)
{ {
cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE);
cucul_putstr(caca, 0, i, CACA);
cucul_put_str(caca, 0, i, CACA);
cucul_blit(caca, i - 2, i, line, NULL); cucul_blit(caca, i - 2, i, line, NULL);
} }




+ 3
- 3
test/input.c View File

@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
dp = caca_create_display(cv); dp = caca_create_display(cv);


cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
cucul_putstr(cv, 1, 1, "Text entries - press tab to cycle");
cucul_put_str(cv, 1, 1, "Text entries - press tab to cycle");


for(i = 0; i < TEXT_ENTRIES; i++) for(i = 0; i < TEXT_ENTRIES; i++)
{ {
@@ -69,14 +69,14 @@ int main(int argc, char *argv[])


for(j = 0; j < size; j++) for(j = 0; j < size; j++)
{ {
cucul_putchar(cv, 2 + j, 3 * i + 4,
cucul_put_char(cv, 2 + j, 3 * i + 4,
entries[i].buffer[start + j]); entries[i].buffer[start + j]);
} }
} }


/* Put the cursor on the active textentry */ /* Put the cursor on the active textentry */
cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_LIGHTRED); cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_LIGHTRED);
cucul_putchar(cv, 2 + entries[e].cursor, 3 * e + 4, ' ');
cucul_put_char(cv, 2 + entries[e].cursor, 3 * e + 4, ' ');


caca_refresh_display(dp); caca_refresh_display(dp);




+ 4
- 4
test/spritedit.c View File

@@ -108,17 +108,17 @@ int main(int argc, char **argv)
cucul_draw_thin_box(cv, 0, 0, cucul_get_canvas_width(cv) - 1, cucul_draw_thin_box(cv, 0, 0, cucul_get_canvas_width(cv) - 1,
cucul_get_canvas_height(cv) - 1); cucul_get_canvas_height(cv) - 1);


cucul_putstr(cv, 3, 0, "[ Sprite editor for libcaca ]");
cucul_put_str(cv, 3, 0, "[ Sprite editor for libcaca ]");


sprintf(buf, "sprite `%s'", argv[1]); sprintf(buf, "sprite `%s'", argv[1]);
cucul_putstr(cv, 3, 2, buf);
cucul_put_str(cv, 3, 2, buf);
sprintf(buf, "frame %i/%i", frame, cucul_get_sprite_frames(sprite) - 1); sprintf(buf, "frame %i/%i", frame, cucul_get_sprite_frames(sprite) - 1);
cucul_putstr(cv, 3, 3, buf);
cucul_put_str(cv, 3, 3, buf);


/* Crosshair */ /* Crosshair */
cucul_draw_thin_line(cv, 57, 2, 57, 18); cucul_draw_thin_line(cv, 57, 2, 57, 18);
cucul_draw_thin_line(cv, 37, 10, 77, 10); cucul_draw_thin_line(cv, 37, 10, 77, 10);
cucul_putchar(cv, 57, 10, '+');
cucul_put_char(cv, 57, 10, '+');


/* Boxed sprite */ /* Boxed sprite */
xa = -1 - cucul_get_sprite_dx(sprite, frame); xa = -1 - cucul_get_sprite_dx(sprite, frame);


+ 13
- 13
test/transform.c View File

@@ -60,38 +60,38 @@ int main(int argc, char *argv[])
cucul_blit(image, 30, 1, sprite, NULL); cucul_blit(image, 30, 1, sprite, NULL);


cucul_set_color_ansi(image, CUCUL_LIGHTCYAN, CUCUL_BLACK); cucul_set_color_ansi(image, CUCUL_LIGHTCYAN, CUCUL_BLACK);
cucul_putstr(image, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
cucul_put_str(image, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
cucul_set_color_ansi(image, CUCUL_LIGHTRED, CUCUL_BLACK); cucul_set_color_ansi(image, CUCUL_LIGHTRED, CUCUL_BLACK);
cucul_putchar(image, 38, 1, '|');
cucul_put_char(image, 38, 1, '|');


cucul_set_color_ansi(image, CUCUL_YELLOW, CUCUL_BLACK); cucul_set_color_ansi(image, CUCUL_YELLOW, CUCUL_BLACK);
cucul_putstr(image, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
cucul_put_str(image, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");


cucul_set_color_ansi(image, CUCUL_WHITE, CUCUL_LIGHTRED); cucul_set_color_ansi(image, CUCUL_WHITE, CUCUL_LIGHTRED);
cucul_putstr(image, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
cucul_putstr(image, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
cucul_put_str(image, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
cucul_put_str(image, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
cucul_set_color_ansi(image, CUCUL_BLACK, CUCUL_LIGHTRED); cucul_set_color_ansi(image, CUCUL_BLACK, CUCUL_LIGHTRED);
cucul_putstr(image, 4, 3, "▓▒░");
cucul_putstr(image, 4, 4, "▓▒░");
cucul_putstr(image, 24, 3, "░▒▓");
cucul_putstr(image, 24, 4, "░▒▓");
cucul_put_str(image, 4, 3, "▓▒░");
cucul_put_str(image, 4, 4, "▓▒░");
cucul_put_str(image, 24, 3, "░▒▓");
cucul_put_str(image, 24, 4, "░▒▓");


/* Blit the transformed canvas onto the main canvas */ /* Blit the transformed canvas onto the main canvas */
cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
cucul_putstr(cv, 0, 0, "normal");
cucul_put_str(cv, 0, 0, "normal");
cucul_blit(cv, 10, 0, image, NULL); cucul_blit(cv, 10, 0, image, NULL);


cucul_putstr(cv, 0, 6, "flip");
cucul_put_str(cv, 0, 6, "flip");
cucul_blit(tmp, 0, 0, image, NULL); cucul_blit(tmp, 0, 0, image, NULL);
cucul_flip(tmp); cucul_flip(tmp);
cucul_blit(cv, 10, 6, tmp, NULL); cucul_blit(cv, 10, 6, tmp, NULL);


cucul_putstr(cv, 0, 12, "flop");
cucul_put_str(cv, 0, 12, "flop");
cucul_blit(tmp, 0, 0, image, NULL); cucul_blit(tmp, 0, 0, image, NULL);
cucul_flop(tmp); cucul_flop(tmp);
cucul_blit(cv, 10, 12, tmp, NULL); cucul_blit(cv, 10, 12, tmp, NULL);


cucul_putstr(cv, 0, 18, "rotate");
cucul_put_str(cv, 0, 18, "rotate");
cucul_blit(tmp, 0, 0, image, NULL); cucul_blit(tmp, 0, 0, image, NULL);
cucul_rotate(tmp); cucul_rotate(tmp);
cucul_blit(cv, 10, 18, tmp, NULL); cucul_blit(cv, 10, 18, tmp, NULL);


+ 2
- 2
test/truecolor.c View File

@@ -41,11 +41,11 @@ int main(int argc, char *argv[])
uint16_t fgcolor = 0xf000 | ((15 - y) << 4) | ((15 - x) << 8); uint16_t fgcolor = 0xf000 | ((15 - y) << 4) | ((15 - x) << 8);


cucul_set_color_argb(cv, fgcolor, bgcolor); cucul_set_color_argb(cv, fgcolor, bgcolor);
cucul_putstr(cv, x * 2, y, "CA");
cucul_put_str(cv, x * 2, y, "CA");
} }


cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_LIGHTBLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_LIGHTBLUE);
cucul_putstr(cv, 2, 1, " truecolor libcaca ");
cucul_put_str(cv, 2, 1, " truecolor libcaca ");


caca_refresh_display(dp); caca_refresh_display(dp);




+ 30
- 30
test/unicode.c View File

@@ -33,56 +33,56 @@ int main(int argc, char *argv[])
dp = caca_create_display(cv); dp = caca_create_display(cv);


cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
cucul_putstr(cv, 1, 1, "Basic Unicode support");
cucul_put_str(cv, 1, 1, "Basic Unicode support");


cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
cucul_putstr(cv, 1, 2, "This is ASCII: | abc DEF 123 !@# |");
cucul_putstr(cv, 1, 3, "This is Unicode: | äßç δεφ ☺♥♀ ╞╬╗ |");
cucul_putstr(cv, 1, 4, "And this is, too: | ἀβϛ ΔЗҒ ᚴᛒᛯ ♩♔✈ |");
cucul_put_str(cv, 1, 2, "This is ASCII: | abc DEF 123 !@# |");
cucul_put_str(cv, 1, 3, "This is Unicode: | äßç δεφ ☺♥♀ ╞╬╗ |");
cucul_put_str(cv, 1, 4, "And this is, too: | ἀβϛ ΔЗҒ ᚴᛒᛯ ♩♔✈ |");


cucul_putstr(cv, 1, 5, "If the three lines do not have the same length, there is a bug somewhere.");
cucul_put_str(cv, 1, 5, "If the three lines do not have the same length, there is a bug somewhere.");


cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
cucul_putstr(cv, 1, 7, "Gradient glyphs");
cucul_put_str(cv, 1, 7, "Gradient glyphs");


cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
cucul_putstr(cv, 31, 8, " 0%");
cucul_putstr(cv, 31, 9, " 25%");
cucul_putstr(cv, 31, 10, " 50%");
cucul_putstr(cv, 31, 11, " 75%");
cucul_putstr(cv, 31, 12, "100%");
cucul_put_str(cv, 31, 8, " 0%");
cucul_put_str(cv, 31, 9, " 25%");
cucul_put_str(cv, 31, 10, " 50%");
cucul_put_str(cv, 31, 11, " 75%");
cucul_put_str(cv, 31, 12, "100%");


cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_LIGHTGREEN); cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_LIGHTGREEN);
cucul_putstr(cv, 1, 8, " ");
cucul_putstr(cv, 1, 9, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
cucul_putstr(cv, 1, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");
cucul_putstr(cv, 1, 11, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
cucul_putstr(cv, 1, 12, "█████████████████████████████");
cucul_put_str(cv, 1, 8, " ");
cucul_put_str(cv, 1, 9, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
cucul_put_str(cv, 1, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");
cucul_put_str(cv, 1, 11, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
cucul_put_str(cv, 1, 12, "█████████████████████████████");


cucul_set_color_ansi(cv, CUCUL_LIGHTGREEN, CUCUL_LIGHTRED); cucul_set_color_ansi(cv, CUCUL_LIGHTGREEN, CUCUL_LIGHTRED);
cucul_putstr(cv, 36, 8, "█████████████████████████████");
cucul_putstr(cv, 36, 9, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
cucul_putstr(cv, 36, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");
cucul_putstr(cv, 36, 11, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
cucul_putstr(cv, 36, 12, " ");
cucul_put_str(cv, 36, 8, "█████████████████████████████");
cucul_put_str(cv, 36, 9, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
cucul_put_str(cv, 36, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");
cucul_put_str(cv, 36, 11, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
cucul_put_str(cv, 36, 12, " ");


cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
cucul_putstr(cv, 1, 14, "Double width characters");
cucul_put_str(cv, 1, 14, "Double width characters");


cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_TRANSPARENT); cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_TRANSPARENT);
cucul_putstr(cv, 1, 15, "| ドラゴン ボーレ |");
cucul_put_str(cv, 1, 15, "| ドラゴン ボーレ |");
cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
cucul_putstr(cv, 1, 16, "| ()()()() ()()() |");
cucul_put_str(cv, 1, 16, "| ()()()() ()()() |");
cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_TRANSPARENT); cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_TRANSPARENT);
cucul_putstr(cv, 1, 17, "| ドラゴン");
cucul_putstr(cv, 12, 17, "ボーレ |");
cucul_put_str(cv, 1, 17, "| ドラゴン");
cucul_put_str(cv, 12, 17, "ボーレ |");


cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
cucul_putstr(cv, 1, 18, "If the three lines do not have the same length, there is a bug somewhere.");
cucul_put_str(cv, 1, 18, "If the three lines do not have the same length, there is a bug somewhere.");


cucul_putstr(cv, 1, 20, "CP437 glyphs: ☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ◙ ♂ ♀ ♪ ♫ ☼ ► ◄ ↕ ‼ ¶ § ▬ ↨ ↑ ↓ → ← ∟ ↔ ▲ ▼");
cucul_putstr(cv, 1, 21, "more CP437: α ß Γ π Σ σ µ τ Φ Θ Ω δ ∞ φ ε ∩ ≡ ± ≥ ≤ ⌠ ⌡ ÷ ≈ ° ∙ · √ ⁿ ² ■");
cucul_putstr(cv, 1, 22, "drawing blocks: ███ ▓▓▓ ▒▒▒ ░░░ ▀ ▄ ▌ ▐ █ ▖ ▗ ▘ ▝ ▚ ▞ ▙ ▛ ▜ ▟");
cucul_put_str(cv, 1, 20, "CP437 glyphs: ☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ◙ ♂ ♀ ♪ ♫ ☼ ► ◄ ↕ ‼ ¶ § ▬ ↨ ↑ ↓ → ← ∟ ↔ ▲ ▼");
cucul_put_str(cv, 1, 21, "more CP437: α ß Γ π Σ σ µ τ Φ Θ Ω δ ∞ φ ε ∩ ≡ ± ≥ ≤ ⌠ ⌡ ÷ ≈ ° ∙ · √ ⁿ ² ■");
cucul_put_str(cv, 1, 22, "drawing blocks: ███ ▓▓▓ ▒▒▒ ░░░ ▀ ▄ ▌ ▐ █ ▖ ▗ ▘ ▝ ▚ ▞ ▙ ▛ ▜ ▟");


caca_refresh_display(dp); caca_refresh_display(dp);




Loading…
Cancel
Save