From 76cab9137bb98992a63169d5fbd52ad6debc1134 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sun, 30 Nov 2014 17:25:34 +0100
Subject: Make IRC export work with more clients
---
autistdraw.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/autistdraw.c b/autistdraw.c
index 8e85285..31d8c0b 100644
--- a/autistdraw.c
+++ b/autistdraw.c
@@ -757,17 +757,36 @@ export_irc (app_context_t *app)
size_t x, y, w, h;
find_data_bounding_rect (app, &x, &y, &w, &h);
+ // This is tricky and needs to be tested with major IRC clients. Currently
+ // works with: weechat 1.0, xchat 2.8.8, freenode's qwebirc.
+
+ // We cannot use the same non-space character for transparent and opaque
+ // pixels because many clients don't understand the transparent 99 colour
+ // that is needed for the foreground of transparent pixels. Therefore it
+ // is not possible to display correctly using non-monospace fonts.
+
for (size_t row = 0; row < h; row++)
{
- int color = MIRC_NONE;
+ // qwebirc is retarded and in some cases it reduces spaces, misaligning
+ // the picture. Appending two spaces after the attribute reset and
+ // rendering opaque pixels as something different from a space seems
+ // to prevent that behaviour.
+ int color = MIRC_TRANSPARENT;
+ fprintf (fp, "\x0f ");
+
for (size_t column = 0; column < w; column++)
{
int new_color = color_to_mirc
(BITMAP_PIXEL (app, x + column, y + row));
if (color != new_color)
- fprintf (fp, "\x03%02d,%02d", new_color, new_color);
- color = new_color;
- fputc ('_', fp);
+ {
+ color = new_color;
+ if (color == MIRC_TRANSPARENT)
+ fprintf (fp, "\x0f");
+ else
+ fprintf (fp, "\x03%02d,%02d", color, color);
+ }
+ fputc ("# "[color == MIRC_TRANSPARENT], fp);
}
fputc ('\n', fp);
}
--
cgit v1.2.3-70-g09d2