Make IRC export work with more clients
This commit is contained in:
parent
3e9bc6cee7
commit
76cab9137b
25
autistdraw.c
25
autistdraw.c
|
@ -757,17 +757,36 @@ export_irc (app_context_t *app)
|
||||||
size_t x, y, w, h;
|
size_t x, y, w, h;
|
||||||
find_data_bounding_rect (app, &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++)
|
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++)
|
for (size_t column = 0; column < w; column++)
|
||||||
{
|
{
|
||||||
int new_color = color_to_mirc
|
int new_color = color_to_mirc
|
||||||
(BITMAP_PIXEL (app, x + column, y + row));
|
(BITMAP_PIXEL (app, x + column, y + row));
|
||||||
if (color != new_color)
|
if (color != new_color)
|
||||||
fprintf (fp, "\x03%02d,%02d", new_color, new_color);
|
{
|
||||||
color = new_color;
|
color = new_color;
|
||||||
fputc ('_', fp);
|
if (color == MIRC_TRANSPARENT)
|
||||||
|
fprintf (fp, "\x0f");
|
||||||
|
else
|
||||||
|
fprintf (fp, "\x03%02d,%02d", color, color);
|
||||||
|
}
|
||||||
|
fputc ("# "[color == MIRC_TRANSPARENT], fp);
|
||||||
}
|
}
|
||||||
fputc ('\n', fp);
|
fputc ('\n', fp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue