/*
* $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 ***
*
#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 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),
};
fprintf (f, ">");
break;
default:
+
+ if ((c>=32) &&(c<127)) {
fputc (c, f);
+ } else if (c>127) {
+ fprintf (f, "&#x%04x;",c);
+ } else {
+ fputc(' ',f);
+ }
}
}
static void
html_render (FILE * f, CRT_CA c)
{
-int fg,bg;
-
+ int fg, bg;
+
if (c.attr & CRT_ATTR_REVERSE)
{
- fg=CRT_COLOR_BG(c.color);
- bg=CRT_COLOR_FG(c.color);
+ fg = CRT_COLOR_BG (c.color);
+ bg = CRT_COLOR_FG (c.color);
}
else
{
- fg=CRT_COLOR_FG(c.color);
- bg=CRT_COLOR_BG(c.color);
- if (c.attr & CRT_ATTR_BOLD)
- fg|=CRT_COLOR_INTENSITY;
+ fg = CRT_COLOR_FG (c.color);
+ bg = CRT_COLOR_BG (c.color);
+ if (c.attr & CRT_ATTR_BOLD)
+ fg |= CRT_COLOR_INTENSITY;
}
- fprintf (f, "<td bgcolor='#%06x'><font color='#%06x'>",colormap[bg],colormap[fg]);
+#ifdef CSS
+ fprintf (f, "<span style='color: #%06x; background-color: #%06x'>",
+ colormap[fg], colormap[bg]);
+#else
+ fprintf (f, "<td bgcolor='#%06x'><font color='#%06x'>", colormap[bg],
+ colormap[fg]);
+ fprintf (f, "<tt>");
+#endif
if (c.attr & CRT_ATTR_UNDERLINE)
fprintf (f, "<ul>");
if (c.attr & CRT_ATTR_BOLD)
fprintf (f, "<b>");
- if (c.chr < 32)
- c.chr = 32;
- if (c.chr > 126)
- c.chr = 32;
-
html_entity (f, c.chr);
if (c.attr & CRT_ATTR_BOLD)
{
fprintf (f, "</font>");
}
+#ifdef CSS
+ fprintf (f, "</span>");
+#else
+ fprintf (f, "</tt>");
fprintf (f, "</td>");
+#endif
}
static void
CRT_Pos p;
int o;
+#ifdef CSS
+ fprintf (f, "<pre>");
+#else
fprintf (f, "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
+#endif
for (p.y = 0; p.y < CRT_ROWS; ++p.y)
{
o = CRT_ADDR (p.y, 0);
+#ifndef CSS
fprintf (f, "<tr>");
+#endif
for (p.x = 0; p.x < CRT_COLS; ++p.x, ++o)
{
html_render (f, c->screen[o]);
}
+#ifdef CSS
+ fprintf (f, "\n");
+#else
fprintf (f, "</tr>\n");
+#endif
}
- fprintf (f, "</table>\n");
+#ifdef CSS
+ fprintf (f, "</pre>\n");
+#else
+ fprintf (f, "</table>");
+#endif
}
-static void html_one_shot(ANSI *a,CRT *c)
+static void
+html_one_shot (ANSI * a, CRT * c)
{
-html_draw(a->file,c);
+ html_draw (a->file, c);
}
-static void ansi_free(ANSI *a)
+static void
+ansi_free (ANSI * a)
{
-free(a);
+ free (a);
}
-ANSI *ansi_new_html(FILE *f)
+ANSI *
+ansi_new_html (FILE * f)
{
-ANSI *ret;
+ ANSI *ret;
-ret=malloc(sizeof(ANSI));
-memset(ret,0,sizeof(ANSI));
+ ret = malloc (sizeof (ANSI));
+ memset (ret, 0, sizeof (ANSI));
-ret->file=f;
-ret->close=ansi_free;
-ret->one_shot=html_one_shot;
+ ret->file = f;
+ ret->close = ansi_free;
+ ret->one_shot = html_one_shot;
-return ret;
+ return ret;
}
-
-
-
-