X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fhtml.c;h=d5798cca439647c6e50a6f7117af52ee16da0871;hb=0793c5beab6d4123b31aee6b9feb7da9c3b0e40e;hp=5f48fe378c7b45a9eda10b437b8b2a4c15c6c7d1;hpb=a1766d2d378710f924391784d0ffc736d59678db;p=sympathy.git diff --git a/src/html.c b/src/html.c index 5f48fe3..d5798cc 100644 --- a/src/html.c +++ b/src/html.c @@ -10,12 +10,56 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.7 2008/02/27 01:52:08 james + * *** empty log message *** + * + * Revision 1.6 2008/02/20 23:42:05 staffcvs + * *** empty log message *** + * + * Revision 1.5 2008/02/20 23:31:48 staffcvs + * *** empty log message *** + * + * Revision 1.4 2008/02/20 22:54:22 staffcvs + * *** empty log message *** + * + * Revision 1.3 2008/02/20 20:16:07 james + * *** empty log message *** + * + * Revision 1.2 2008/02/04 02:05:06 james + * *** empty log message *** + * * Revision 1.1 2008/02/03 23:31:25 james * *** empty log message *** * */ -void +#include "project.h" + + +#define V(i) (((i)==0)?0x80:(((i)==1)?0xc0:0xff)) +#define COLOR(r,g,b,i) ((((r)?(V(i)):0) << 0)| (((g)?(V(i)):0) << 8)| (((b)?(V(i)):0) << 16)) + +static int colormap[] = { + [CRT_COLOR_BLACK] = COLOR (0, 0, 0, 0), + [CRT_COLOR_RED] = COLOR (0, 0, 1, 0), + [CRT_COLOR_GREEN] = COLOR (0, 1, 0, 0), + [CRT_COLOR_YELLOW] = COLOR (0, 1, 1, 0), + [CRT_COLOR_BLUE] = COLOR (1, 0, 0, 0), + [CRT_COLOR_MAGENTA] = COLOR (1, 0, 1, 0), + [CRT_COLOR_CYAN] = COLOR (1, 1, 0, 0), + [CRT_COLOR_WHITE] = COLOR (1, 1, 1, 1), + [CRT_COLOR_BLACK | CRT_COLOR_INTENSITY] = COLOR (1, 1, 1, 0), + [CRT_COLOR_RED | CRT_COLOR_INTENSITY] = COLOR (0, 0, 1, 2), + [CRT_COLOR_GREEN | CRT_COLOR_INTENSITY] = COLOR (0, 1, 0, 2), + [CRT_COLOR_YELLOW | CRT_COLOR_INTENSITY] = COLOR (0, 1, 1, 2), + [CRT_COLOR_BLUE | CRT_COLOR_INTENSITY] = COLOR (1, 0, 0, 2), + [CRT_COLOR_MAGENTA | CRT_COLOR_INTENSITY] = COLOR (1, 0, 1, 2), + [CRT_COLOR_CYAN | CRT_COLOR_INTENSITY] = COLOR (1, 1, 0, 2), + [CRT_COLOR_WHITE | CRT_COLOR_INTENSITY] = COLOR (1, 1, 1, 2), +}; + + +static void html_entity (FILE * f, int c) { switch (c) @@ -33,32 +77,48 @@ html_entity (FILE * f, int c) fprintf (f, ">"); break; default: + + if ((c>=32) &&(c<127)) { fputc (c, f); + } else if (c>127) { + fprintf (f, "&#x%04x;",c); + } else { + fputc(' ',f); + } } } -void +static void html_render (FILE * f, CRT_CA c) { + int fg, bg; + if (c.attr & CRT_ATTR_REVERSE) { - fprintf (f, ""); + fg = CRT_COLOR_BG (c.color); + bg = CRT_COLOR_FG (c.color); } else { - fprintf (f, ""); + fg = CRT_COLOR_FG (c.color); + bg = CRT_COLOR_BG (c.color); + if (c.attr & CRT_ATTR_BOLD) + fg |= CRT_COLOR_INTENSITY; } +#ifdef CSS + fprintf (f, "", + colormap[fg], colormap[bg]); +#else + fprintf (f, "", colormap[bg], + colormap[fg]); + fprintf (f, ""); +#endif if (c.attr & CRT_ATTR_UNDERLINE) fprintf (f, "