summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-11-30 17:25:34 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2014-11-30 17:25:34 +0100
commit76cab9137bb98992a63169d5fbd52ad6debc1134 (patch)
tree9e05d82b1fccee6511590c82c3a305a0580ac4bf
parent3e9bc6cee75c9afd8737bf5b3b20e22a720b65d7 (diff)
downloadneetdraw-76cab9137bb98992a63169d5fbd52ad6debc1134.tar.gz
neetdraw-76cab9137bb98992a63169d5fbd52ad6debc1134.tar.xz
neetdraw-76cab9137bb98992a63169d5fbd52ad6debc1134.zip
Make IRC export work with more clients
-rw-r--r--autistdraw.c27
1 files 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);
}