From 55765045c806009ef64d86a5cb5fdc6588499589 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 16 Nov 2006 15:01:31 +0000 Subject: [PATCH] * Support for CUCUL_DEFAULT and CUCUL_TRANSPARENT in the HTML exporters. * Updated export test accordingly. --- cucul/export.c | 33 +++++++++++++++++++++++---------- test/export.c | 16 ++++++++++++++-- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/cucul/export.c b/cucul/export.c index ded5a67..bea3950 100644 --- a/cucul/export.c +++ b/cucul/export.c @@ -389,10 +389,13 @@ static void *export_html(cucul_canvas_t *cv, unsigned long int *bytes) for(x = 0; x < cv->width; x += len) { - cur += sprintf(cur, "width; x += len) { - unsigned int i; + unsigned int i, needfont; /* Use colspan option to factor cells with same attributes * (see below) */ @@ -474,14 +477,22 @@ static void *export_html3(cucul_canvas_t *cv, unsigned long int *bytes) while(x + len < cv->width && lineattr[x + len] == lineattr[x]) len++; - cur += sprintf(cur, " 1) cur += sprintf(cur, " colspan=%d", len); - cur += sprintf(cur, ">", (unsigned long int) - _cucul_attr_to_rgb24fg(lineattr[x])); + cur += sprintf(cur, ">"); + + needfont = cucul_attr_to_ansi_bg(lineattr[x]) < 0x10; + + if(needfont) + cur += sprintf(cur, "", (unsigned long int) + _cucul_attr_to_rgb24fg(lineattr[x])); if(lineattr[x] & CUCUL_BOLD) cur += sprintf(cur, ""); @@ -513,7 +524,9 @@ static void *export_html3(cucul_canvas_t *cv, unsigned long int *bytes) if(lineattr[x] & CUCUL_BOLD) cur += sprintf(cur, ""); - cur += sprintf(cur, ""); + if(needfont) + cur += sprintf(cur, ""); + cur += sprintf(cur, ""); } cur += sprintf(cur, "\n"); } diff --git a/test/export.c b/test/export.c index 09adba0..ec5fd87 100644 --- a/test/export.c +++ b/test/export.c @@ -114,10 +114,22 @@ int main(int argc, char *argv[]) cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_WHITE); cucul_fill_ellipse(cv, WIDTH / 2, HEIGHT / 2, WIDTH / 4, HEIGHT / 4, ' '); - cucul_put_str(cv, WIDTH / 2 - 5, HEIGHT / 2 - 5, "(\") \\o/ <&>"); + + cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); + cucul_put_str(cv, WIDTH / 2 - 12, HEIGHT / 2 - 6, + " lightgray on black "); + cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT); + cucul_put_str(cv, WIDTH / 2 - 12, HEIGHT / 2 - 5, + " default on transparent "); + cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_WHITE); + cucul_put_str(cv, WIDTH / 2 - 12, HEIGHT / 2 - 4, + " black on white "); + + cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_WHITE); 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_put_str(cv, WIDTH / 2 - 5, HEIGHT / 2 + 4, "(\") \\o/ <&>"); cucul_set_attr(cv, CUCUL_BOLD); cucul_put_str(cv, WIDTH / 2 - 16, HEIGHT / 2 + 3, "Bold"); @@ -135,7 +147,7 @@ int main(int argc, char *argv[]) for(x = 0; x < 16; x++) { cucul_set_color_argb(cv, 0xff00 | x, 0xf00f | (x << 4)); - cucul_put_str(cv, WIDTH / 2 - 7 + x, HEIGHT / 2 + 5, "#"); + cucul_put_char(cv, WIDTH / 2 - 7 + x, HEIGHT / 2 + 6, '#'); } }