Browse Source

* Always draw all background in troff output

tags/v0.99.beta17
Pascal Terjan pterjan 15 years ago
parent
commit
a2fff59c1e
1 changed files with 7 additions and 2 deletions
  1. +7
    -2
      caca/codec/export.c

+ 7
- 2
caca/codec/export.c View File

@@ -1018,10 +1018,10 @@ static void *export_troff(caca_canvas_t const *cv, size_t *bytes)
* 2x\mM (2x10)
* + \fB + \fI + \fR (9)
* + 4 bytes = 33
* Each line has a \n (1)
* Each line has a \n (1) and maybe 0xc2 0xa0 (2)
* Header has .nf\n (3)
*/
*bytes = 3 + cv->height + (cv->width * cv->height * 33);
*bytes = 3 + cv->height * 3 + (cv->width * cv->height * 33);
cur = data = malloc(*bytes);

cur += sprintf(cur, ".nf\n");
@@ -1040,6 +1040,7 @@ static void *export_troff(caca_canvas_t const *cv, size_t *bytes)
uint32_t fg = _rgb_to_troff_index(_caca_attr_to_rgb24fg(lineattr[x]));
uint32_t bg = _rgb_to_troff_index(_caca_attr_to_rgb24bg(lineattr[x]));
uint32_t ch = linechar[x];

if(fg != prevfg || !started)
cur += sprintf(cur, "\\m[%s]", colors[fg]);
if(bg != prevbg || !started)
@@ -1062,6 +1063,10 @@ static void *export_troff(caca_canvas_t const *cv, size_t *bytes)
started = 1;
}

/* Add unbreakable space at the end of lines, else spaces are dropped */
if(x > 0 && linechar[x-1] == ' ')
cur += sprintf(cur-1, "%c%c", 0xc2, 0xa0)-1;

cur += sprintf(cur, "\n");
}
/* Crop to really used size */


Loading…
Cancel
Save