Make IRC export work with more clients

This commit is contained in:
Přemysl Eric Janouch 2014-11-30 17:25:34 +01:00
parent 3e9bc6cee7
commit 76cab9137b
1 changed files with 23 additions and 4 deletions

View File

@ -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);
}