浏览代码

work around table layout bugs by ensuring that if there are multiple

cells on any row of the table then the very first row does not use the
cell-merging optimization; this appears to fix the last of the table
layout bugs seen in truecolor.php; also fix the foreground and
background color bugs seen in truecolor.php.
tags/v0.99.beta17
Ben Wiley Sittler bsittler 17 年前
父节点
当前提交
86a512cf34
共有 1 个文件被更改,包括 25 次插入3 次删除
  1. +25
    -3
      caca/codec/export.c

+ 25
- 3
caca/codec/export.c 查看文件

@@ -460,16 +460,36 @@ static void *export_html3(caca_canvas_t const *cv, size_t *bytes)
char *data, *cur; char *data, *cur;
int x, y, len; int x, y, len;
int maxcols; int maxcols;
int has_multi_cell_row = 0;


/* Table */ /* Table */
maxcols = 0; maxcols = 0;
for(y = 0; y < cv->height; y++) for(y = 0; y < cv->height; y++)
{ {
uint32_t *lineattr = cv->attrs + y * cv->width;
uint32_t *linechar = cv->chars + y * cv->width; uint32_t *linechar = cv->chars + y * cv->width;
int cols = 0; int cols = 0;


for(x = 0; x < cv->width; x++) for(x = 0; x < cv->width; x++)
{ {
if((! has_multi_cell_row)
&&
(x > 1)
&&
(caca_attr_to_ansi_bg(lineattr[x - 1])
!=
caca_attr_to_ansi_bg(lineattr[x]))
&&
((caca_attr_to_ansi_bg(lineattr[x]) < 0x10)
?
(_caca_attr_to_rgb24bg(lineattr[x - 1])
!=
_caca_attr_to_rgb24bg(lineattr[x]))
:
0))
{
has_multi_cell_row = 1;
}
if(linechar[x] == 0x00000009) if(linechar[x] == 0x00000009)
while((cols + 1) % 8) while((cols + 1) % 8)
cols ++; cols ++;
@@ -506,7 +526,9 @@ static void *export_html3(caca_canvas_t const *cv, size_t *bytes)
/* Use colspan option to factor cells with same attributes /* Use colspan option to factor cells with same attributes
* (see below) */ * (see below) */
len = 1; len = 1;
while((x + len < cv->width)
while((y || ! has_multi_cell_row)
&&
(x + len < cv->width)
&& &&
(caca_attr_to_ansi_bg(lineattr[x + len]) (caca_attr_to_ansi_bg(lineattr[x + len])
== ==
@@ -515,7 +537,7 @@ static void *export_html3(caca_canvas_t const *cv, size_t *bytes)
((caca_attr_to_ansi_bg(lineattr[x]) < 0x10) ((caca_attr_to_ansi_bg(lineattr[x]) < 0x10)
? ?
(_caca_attr_to_rgb24bg(lineattr[x + len]) (_caca_attr_to_rgb24bg(lineattr[x + len])
&&
==
_caca_attr_to_rgb24bg(lineattr[x])) _caca_attr_to_rgb24bg(lineattr[x]))
: :
1)) 1))
@@ -543,7 +565,7 @@ static void *export_html3(caca_canvas_t const *cv, size_t *bytes)
{ {
if((! i) || (lineattr[x + i] != lineattr[x + i - 1])) if((! i) || (lineattr[x + i] != lineattr[x + i - 1]))
{ {
needfont = caca_attr_to_ansi_fg(lineattr[x + i]) < 0x10;
needfont = (caca_attr_to_ansi_fg(lineattr[x + i]) != CACA_DEFAULT);


if(needfont) if(needfont)
cur += sprintf(cur, "<font color=\"#%.06lx\">", (unsigned long int) cur += sprintf(cur, "<font color=\"#%.06lx\">", (unsigned long int)


正在加载...
取消
保存