Browse Source

* Support for CUCUL_DEFAULT and CUCUL_TRANSPARENT in the HTML exporters.

* Updated export test accordingly.
tags/v0.99.beta14
Sam Hocevar sam 18 years ago
parent
commit
55765045c8
2 changed files with 37 additions and 12 deletions
  1. +23
    -10
      cucul/export.c
  2. +14
    -2
      test/export.c

+ 23
- 10
cucul/export.c View File

@@ -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, "<span style=\"color:#%.03x;"
"background-color:#%.03x",
_cucul_attr_to_rgb12fg(lineattr[x]),
_cucul_attr_to_rgb12bg(lineattr[x]));
cur += sprintf(cur, "<span style=\"");
if(cucul_attr_to_ansi_fg(lineattr[x]) < 0x10)
cur += sprintf(cur, ";color:#%.03x",
_cucul_attr_to_rgb12fg(lineattr[x]));
if(cucul_attr_to_ansi_bg(lineattr[x]) < 0x10)
cur += sprintf(cur, ";background-color:#%.03x",
_cucul_attr_to_rgb12bg(lineattr[x]));
if(lineattr[x] & CUCUL_BOLD)
cur += sprintf(cur, ";font-weight:bold");
if(lineattr[x] & CUCUL_ITALICS)
@@ -466,7 +469,7 @@ static void *export_html3(cucul_canvas_t *cv, unsigned long int *bytes)

for(x = 0; x < cv->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, "<td bgcolor=#%.06lx", (unsigned long int)
_cucul_attr_to_rgb24bg(lineattr[x]));
cur += sprintf(cur, "<td");

if(cucul_attr_to_ansi_fg(lineattr[x]) < 0x10)
cur += sprintf(cur, " bgcolor=#%.06lx", (unsigned long int)
_cucul_attr_to_rgb24bg(lineattr[x]));

if(len > 1)
cur += sprintf(cur, " colspan=%d", len);

cur += sprintf(cur, "><font color=#%.06lx>", (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, "<font color=#%.06lx>", (unsigned long int)
_cucul_attr_to_rgb24fg(lineattr[x]));

if(lineattr[x] & CUCUL_BOLD)
cur += sprintf(cur, "<b>");
@@ -513,7 +524,9 @@ static void *export_html3(cucul_canvas_t *cv, unsigned long int *bytes)
if(lineattr[x] & CUCUL_BOLD)
cur += sprintf(cur, "</b>");

cur += sprintf(cur, "</font></td>");
if(needfont)
cur += sprintf(cur, "</font>");
cur += sprintf(cur, "</td>");
}
cur += sprintf(cur, "</tr>\n");
}


+ 14
- 2
test/export.c View File

@@ -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, '#');
}
}



Loading…
Cancel
Save