From c73ff6d51d53ff1a5d970305f8220b12b4814c96 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Sun, 24 Jan 2010 22:04:10 +0000 Subject: [PATCH] * Always draw all background in troff output, on beginning of lines too --- caca/codec/export.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/caca/codec/export.c b/caca/codec/export.c index 5c6b761..111b7d4 100644 --- a/caca/codec/export.c +++ b/caca/codec/export.c @@ -1051,6 +1051,14 @@ static void *export_troff(caca_canvas_t const *cv, size_t *bytes) if(ch == '\\') cur += sprintf(cur, "\\\\"); + else if(ch == ' ') + { + /* Use unbreakable space at line ends, else spaces are dropped */ + if(x == 0 || x == cv->width-1) + cur += sprintf(cur, "%c%c", 0xc2, 0xa0); + else + cur += caca_utf32_to_utf8(cur, ch); + } else cur += caca_utf32_to_utf8(cur, ch); @@ -1061,11 +1069,6 @@ static void *export_troff(caca_canvas_t const *cv, size_t *bytes) prevbg = bg; 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 */