@@ -51,10 +51,10 @@ if test "${ac_cv_have_tiocgwinsz}" = "yes"; then | |||
fi | |||
CUCUL="no" | |||
PKG_CHECK_MODULES(cucul, cucul >= 0.99.beta9, | |||
PKG_CHECK_MODULES(cucul, cucul >= 0.99.beta10, | |||
[CUCUL="yes"], | |||
[AC_MSG_RESULT(no) | |||
AC_MSG_ERROR([you need libcucul version 0.99.beta9 or later])]) | |||
AC_MSG_ERROR([you need libcucul version 0.99.beta10 or later])]) | |||
AC_MSG_CHECKING([for release date]) | |||
stamp="$(sed -ne 's/# \$Id: .*\(....-..-..\).*/\1/p;q' configure.ac)" | |||
@@ -6,5 +6,5 @@ CLEANFILES = toilet.1 | |||
man_MANS = toilet.1 | |||
toilet.1: toilet.1.in | |||
sed -e "s,@data""rootdir@,$(datarootdir),g" $(srcdir)/$^ > $@ | |||
sed -e "s,[@]datarootdir@,$(datarootdir),g" $(srcdir)/$^ > $@ | |||
@@ -96,8 +96,8 @@ static int feed_figlet(context_t *cx, uint32_t ch) | |||
for(y = 0; y < h; y++) | |||
for(x = 0; x < w; x++) | |||
{ | |||
uint32_t tmp = cucul_getchar(cx->image, x, y + c * cx->height); | |||
cucul_putchar(cx->cv, cx->x + x, cx->y + y, tmp); | |||
uint32_t tmp = cucul_get_char(cx->image, x, y + c * cx->height); | |||
cucul_put_char(cx->cv, cx->x + x, cx->y + y, tmp); | |||
} | |||
/* Advance cursor */ | |||
@@ -132,7 +132,6 @@ static int open_font(context_t *cx) | |||
char path[2048]; | |||
char buf[2048]; | |||
char hardblank[10]; | |||
cucul_buffer_t *b; | |||
TOIFILE *f; | |||
unsigned int i, j, size, comment_lines; | |||
@@ -249,18 +248,10 @@ static int open_font(context_t *cx) | |||
} | |||
/* Import buffer into canvas */ | |||
b = cucul_load_memory(data, i); | |||
cx->image = cucul_import_canvas(b, "utf8"); | |||
cucul_free_buffer(b); | |||
cx->image = cucul_create_canvas(0, 0); | |||
cucul_import_memory(cx->image, data, i, "utf8"); | |||
free(data); | |||
if(!cx->image) | |||
{ | |||
free(cx->lookup); | |||
fprintf(stderr, "libcucul could not load data in `%s'\n", path); | |||
return -1; | |||
} | |||
/* Remove EOL characters. For now we ignore hardblanks, don’t do any | |||
* smushing, nor any kind of error checking. */ | |||
for(j = 0; j < cx->height * cx->glyphs; j++) | |||
@@ -269,12 +260,12 @@ static int open_font(context_t *cx) | |||
for(i = cx->max_length; i--;) | |||
{ | |||
ch = cucul_getchar(cx->image, i, j); | |||
ch = cucul_get_char(cx->image, i, j); | |||
/* TODO: Replace hardblanks with U+00A0 NO-BREAK SPACE */ | |||
if(ch == cx->hardblank) | |||
cucul_putchar(cx->image, i, j, ch = ' '); | |||
//cucul_putchar(cx->image, i, j, ch = 0xa0); | |||
cucul_put_char(cx->image, i, j, ch = ' '); | |||
//cucul_put_char(cx->image, i, j, ch = 0xa0); | |||
if(oldch && ch != oldch) | |||
{ | |||
@@ -282,11 +273,11 @@ static int open_font(context_t *cx) | |||
cx->lookup[j / cx->height * 2 + 1] = i + 1; | |||
} | |||
else if(oldch && ch == oldch) | |||
cucul_putchar(cx->image, i, j, ' '); | |||
cucul_put_char(cx->image, i, j, ' '); | |||
else if(ch != ' ') | |||
{ | |||
oldch = ch; | |||
cucul_putchar(cx->image, i, j, ' '); | |||
cucul_put_char(cx->image, i, j, ' '); | |||
} | |||
} | |||
} | |||
@@ -130,7 +130,7 @@ static void filter_crop(context_t *cx) | |||
for(y = 0; y < h; y++) | |||
for(x = 0; x < w; x++) | |||
{ | |||
unsigned long int ch = cucul_getchar(cx->torender, x, y); | |||
unsigned long int ch = cucul_get_char(cx->torender, x, y); | |||
if(ch != (unsigned char)' ') | |||
{ | |||
if(x < xmin) | |||
@@ -166,7 +166,7 @@ static void filter_metal(context_t *cx) | |||
for(y = 0; y < h; y++) | |||
for(x = 0; x < w; x++) | |||
{ | |||
unsigned long int ch = cucul_getchar(cx->torender, x, y); | |||
unsigned long int ch = cucul_get_char(cx->torender, x, y); | |||
int i; | |||
if(ch == (unsigned char)' ') | |||
@@ -174,7 +174,7 @@ static void filter_metal(context_t *cx) | |||
i = ((cx->lines + y + x / 8) / 2) % 4; | |||
cucul_set_color_ansi(cx->torender, palette[i], CUCUL_TRANSPARENT); | |||
cucul_putchar(cx->torender, x, y, ch); | |||
cucul_put_char(cx->torender, x, y, ch); | |||
} | |||
} | |||
@@ -193,13 +193,13 @@ static void filter_gay(context_t *cx) | |||
for(y = 0; y < h; y++) | |||
for(x = 0; x < w; x++) | |||
{ | |||
unsigned long int ch = cucul_getchar(cx->torender, x, y); | |||
unsigned long int ch = cucul_get_char(cx->torender, x, y); | |||
if(ch != (unsigned char)' ') | |||
{ | |||
cucul_set_color_ansi(cx->torender, | |||
rainbow[(x / 2 + y + cx->lines) % 6], | |||
CUCUL_TRANSPARENT); | |||
cucul_putchar(cx->torender, x, y, ch); | |||
cucul_put_char(cx->torender, x, y, ch); | |||
} | |||
} | |||
} | |||
@@ -107,7 +107,8 @@ int render_end(context_t *cx) | |||
static int render_flush(context_t *cx) | |||
{ | |||
cucul_buffer_t *buffer; | |||
unsigned long int len; | |||
void *buffer; | |||
/* Flush current line */ | |||
cx->flush(cx); | |||
@@ -118,12 +119,11 @@ static int render_flush(context_t *cx) | |||
cx->lines += cucul_get_canvas_height(cx->torender); | |||
/* Output line */ | |||
buffer = cucul_export_canvas(cx->torender, cx->export); | |||
buffer = cucul_export_memory(cx->torender, cx->export, &len); | |||
if(!buffer) | |||
return -1; | |||
fwrite(cucul_get_buffer_data(buffer), | |||
cucul_get_buffer_size(buffer), 1, stdout); | |||
cucul_free_buffer(buffer); | |||
fwrite(buffer, len, 1, stdout); | |||
free(buffer); | |||
cucul_free_canvas(cx->torender); | |||
return 0; | |||
@@ -81,7 +81,7 @@ static int feed_tiny(context_t *cx, uint32_t ch) | |||
cucul_set_canvas_size(cx->cv, cx->ew, cx->eh); | |||
cucul_putchar(cx->cv, cx->x, cx->y, ch); | |||
cucul_put_char(cx->cv, cx->x, cx->y, ch); | |||
cx->x++; | |||
return 0; | |||
@@ -168,12 +168,13 @@ static void list_fonts(void) | |||
static void add_char(unsigned long int ch) | |||
{ | |||
cucul_buffer_t *buf; | |||
void *buf; | |||
unsigned long int len; | |||
unsigned int x, y, myw, mygw; | |||
int full = cucul_utf32_is_fullwidth(ch); | |||
cucul_set_canvas_size(onechar, full ? 2 : 1, 1); | |||
cucul_putchar(onechar, 0, 0, ch); | |||
cucul_put_char(onechar, 0, 0, ch); | |||
cucul_render_canvas(onechar, f, image, iw, ih, 4 * iw); | |||
myw = full ? 2 * w : w; | |||
@@ -190,15 +191,15 @@ static void add_char(unsigned long int ch) | |||
uint8_t c = image[4 * (x + y * iw) + 2]; | |||
if(c >= 0xa0) | |||
cucul_putstr(out, x, y, "█"); | |||
cucul_put_str(out, x, y, "█"); | |||
else if(c >= 0x80) | |||
cucul_putstr(out, x, y, "▓"); | |||
cucul_put_str(out, x, y, "▓"); | |||
else if(c >= 0x40) | |||
cucul_putstr(out, x, y, "▒"); | |||
cucul_put_str(out, x, y, "▒"); | |||
else if(c >= 0x20) | |||
cucul_putstr(out, x, y, "░"); | |||
cucul_put_str(out, x, y, "░"); | |||
else | |||
cucul_putchar(out, x, y, ' '); | |||
cucul_put_char(out, x, y, ' '); | |||
} | |||
break; | |||
case HALFBLOCKS: | |||
@@ -210,7 +211,7 @@ static void add_char(unsigned long int ch) | |||
uint8_t p1 = image[4 * (x + y * 2 * iw) + 2]; | |||
uint8_t p2 = image[4 * (x + (y * 2 + 1) * iw) + 2]; | |||
cucul_putstr(out, x, y, str[(p1 > 0x80) + 2 * (p2 > 0x80)]); | |||
cucul_put_str(out, x, y, str[(p1 > 0x80) + 2 * (p2 > 0x80)]); | |||
} | |||
break; | |||
case QUARTERBLOCKS: | |||
@@ -228,17 +229,17 @@ static void add_char(unsigned long int ch) | |||
uint8_t p3 = image[4 * (x * 2 + (y * 2 + 1) * iw) + 2]; | |||
uint8_t p4 = image[4 * (x * 2 + 1 + (y * 2 + 1) * iw) + 2]; | |||
cucul_putstr(out, x, y, str[(p1 > 0x80) + 2 * (p2 > 0x80) + | |||
4 * (p3 > 0x80) + 8 * (p4 > 0x80)]); | |||
cucul_put_str(out, x, y, str[(p1 > 0x80) + 2 * (p2 > 0x80) + | |||
4 * (p3 > 0x80) + 8 * (p4 > 0x80)]); | |||
} | |||
break; | |||
} | |||
cucul_draw_line(out, mygw, 0, mygw, gh - 1, '@'); | |||
cucul_putchar(out, mygw + 1, gh - 1, '@'); | |||
cucul_put_char(out, mygw + 1, gh - 1, '@'); | |||
buf = cucul_export_canvas(out, "utf8"); | |||
fwrite(cucul_get_buffer_data(buf), cucul_get_buffer_size(buf), 1, stdout); | |||
cucul_free_buffer(buf); | |||
buf = cucul_export_memory(out, "utf8", &len); | |||
fwrite(buf, len, 1, stdout); | |||
free(buf); | |||
} | |||