/*
* $Log$
+ * Revision 1.13 2008/02/07 12:16:04 james
+ * *** empty log message ***
+ *
* Revision 1.12 2008/02/07 11:32:41 james
* *** empty log message ***
*
{
ansi_write (a, "\033[0m", 4);
a->attr = CRT_ATTR_NORMAL;
+ a->color = ANSI_INVAL;
+}
+
+void
+ansi_set_color (ANSI * a, int color)
+{
+ int dif;
+ char buf[16];
+ int i;
+ int fg,bg;
+
+ if ((a->color == ANSI_INVAL) || (color!=a->color)) {
+ fg=CRT_COLOR_FG(color);
+ bg=CRT_COLOR_BG(color);
+
+ if (fg & CRT_COLOR_INTENSITY) {
+ fg+=90;
+ } else {
+ fg+=30;
+ }
+
+ if (bg & CRT_COLOR_INTENSITY) {
+ bg+=100;
+ } else {
+ bg+=40;
+ }
+
+ i=sprintf(buf,"\033[%d;%dm",fg,bg);
+ fprintf(stderr,"Color set to %d %d %x\n",fg,bg,color);
+
+ ansi_write (a,buf,i);
+ a->color=color;
+ }
}
void
a->attr = attr;
+#if 0
if (attr == CRT_ATTR_NORMAL)
{
ansi_force_attr_normal (a);
return;
}
+#endif
if (dif & CRT_ATTR_UNDERLINE)
{
ca.chr = ' ';
ansi_set_attr (a, ca.attr);
+ ansi_set_color(a,ca.color);
ansi_write (a, &ca.chr, 1);
crt_cls (&a->crt);
ansi_force_attr_normal (a);
+ ansi_set_color(a,CRT_COLOR_NORMAL);
ansi_move (a, p);
ansi_write (a, "\033[2J", 4);
/*different emulators leave cursor in different places after cls differently*/
ansi_showhide_cursor (a, 1);
ansi_set_attr (a, CRT_ATTR_REVERSE);
+ ansi_set_color(a,CRT_MAKE_COLOR(CRT_COLOR_WHITE,CRT_COLOR_RED));
ansi_move (a, p);
ansi_write (a, msg, sizeof (msg));
/*
* $Log$
+ * Revision 1.5 2008/02/07 12:16:04 james
+ * *** empty log message ***
+ *
* Revision 1.4 2008/02/07 00:43:27 james
* *** empty log message ***
*
CRT_Pos size;
int hide_cursor;
int attr;
+ int color;
ANSI_Parser parser;
} ANSI;
/*
* $Log$
+ * Revision 1.6 2008/02/07 12:16:04 james
+ * *** empty log message ***
+ *
* Revision 1.5 2008/02/06 11:30:37 james
* *** empty log message ***
*
while (ps <= pe)
{
ps->chr = ' ';
- if (ea)
+ if (ea){
ps->attr = CRT_ATTR_NORMAL;
+ ps->color = CRT_COLOR_NORMAL;
+ }
ps++;
}
crt_erase (c, s, e, 1);
-#if 0
- for (i = 0; i < CRT_ROWS; ++i)
- {
- c->screen[CRT_ADDR (i, i)].chr = '@' + i;
- c->screen[CRT_ADDR (i, i)].attr = CRT_ATTR_NORMAL;
- }
-#endif
-
}
void
/*
* $Log$
+ * Revision 1.4 2008/02/07 12:16:04 james
+ * *** empty log message ***
+ *
* Revision 1.3 2008/02/06 11:30:37 james
* *** empty log message ***
*
#define CRT_ATTR_BLINK 0x4
#define CRT_ATTR_BOLD 0x8
+
+#define CRT_COLOR_BLACK 0x0
+#define CRT_COLOR_RED 0x1
+#define CRT_COLOR_GREEN 0x2
+#define CRT_COLOR_YELLOW 0x3
+#define CRT_COLOR_BLUE 0x4
+#define CRT_COLOR_MAGENTA 0x5
+#define CRT_COLOR_CYAN 0x6
+#define CRT_COLOR_WHITE 0x7
+#define CRT_COLOR_INTENSITY 0x8
+
+#define CRT_COLOR_FG_MASK 0xf0
+#define CRT_COLOR_FG_SHIFT 4
+
+#define CRT_COLOR_BG_MASK 0xf
+#define CRT_COLOR_BG_SHIFT 0
+
+#define CRT_COLOR_BG(a) (((a) & CRT_COLOR_BG_MASK) >> CRT_COLOR_BG_SHIFT)
+#define CRT_COLOR_FG(a) (((a) & CRT_COLOR_FG_MASK) >> CRT_COLOR_FG_SHIFT)
+
+#define CRT_MAKE_COLOR(f,b) (((f) << CRT_COLOR_FG_SHIFT)|(b))
+
+#define CRT_BGCOLOR_NORMAL CRT_COLOR_BLACK
+#define CRT_FGCOLOR_NORMAL CRT_COLOR_WHITE
+
+#define CRT_COLOR_NORMAL CRT_MAKE_COLOR(CRT_FGCOLOR_NORMAL,CRT_BGCOLOR_NORMAL)
+
typedef struct
{
uint8_t chr;
uint8_t attr;
+ uint8_t color;
} CRT_CA;
typedef struct
/*
* $Log$
+ * Revision 1.20 2008/02/07 12:16:04 james
+ * *** empty log message ***
+ *
* Revision 1.19 2008/02/07 11:27:02 james
* *** empty log message ***
*
v->crt.screen[CRT_ADDR (p.y, v->bottom_margin.x)].chr = ' ';
v->crt.screen[CRT_ADDR (p.y, v->bottom_margin.x)].attr = CRT_ATTR_NORMAL;
+ v->crt.screen[CRT_ADDR (p.y, v->bottom_margin.x)].color = CRT_COLOR_NORMAL;
}
{
case 0:
v->attr = CRT_ATTR_NORMAL;
+ v->color= CRT_COLOR_NORMAL;
break;
case 1:
v->attr |= CRT_ATTR_BOLD;
case 27:
v->attr &= ~CRT_ATTR_REVERSE;
break;
+ case 30:
+ case 31:
+ case 32:
+ case 33:
+ case 34:
+ case 35:
+ case 36:
+ case 37:
+ v->color &= CRT_COLOR_FG_MASK;
+ v->color |= ((a-30) << CRT_COLOR_FG_SHIFT) & CRT_COLOR_FG_MASK;
+ break;
+ case 90:
+ case 91:
+ case 92:
+ case 93:
+ case 94:
+ case 95:
+ case 96:
+ case 97:
+ v->color &= CRT_COLOR_FG_MASK;
+ v->color |= (((a-90)|CRT_COLOR_INTENSITY) << CRT_COLOR_FG_SHIFT) & CRT_COLOR_FG_MASK;
+ break;
+ case 39:
+ case 99:
+ v->color &= CRT_COLOR_FG_MASK;
+ v->color |= (CRT_FGCOLOR_NORMAL << CRT_COLOR_FG_SHIFT) & CRT_COLOR_FG_MASK;
+ break;
+ case 40:
+ case 41:
+ case 42:
+ case 43:
+ case 44:
+ case 45:
+ case 46:
+ case 47:
+ v->color &= CRT_COLOR_BG_MASK;
+ v->color |= ((a-40) << CRT_COLOR_BG_SHIFT) & CRT_COLOR_BG_MASK;
+ break;
+ case 100:
+ case 101:
+ case 102:
+ case 103:
+ case 104:
+ case 105:
+ case 106:
+ case 107:
+ v->color &= CRT_COLOR_BG_MASK;
+ v->color |= (((a-100)|CRT_COLOR_INTENSITY) << CRT_COLOR_BG_SHIFT) & CRT_COLOR_BG_MASK;
+ break;
+ case 49:
+ case 109:
+ v->color &= CRT_COLOR_BG_MASK;
+ v->color |= (CRT_BGCOLOR_NORMAL << CRT_COLOR_BG_SHIFT) & CRT_COLOR_BG_MASK;
+ break;
+
default:
;
#if 0
{
v->saved.pos = v->pos;
v->saved.attr = v->attr;
+ v->saved.color= v->color;
v->saved.origin_mode = v->private_modes[VT102_PRIVATE_MODE_ORIGIN_MODE];
}
{
v->pos = v->saved.pos;
v->attr = v->saved.attr;
+ v->color= v->saved.color;
v->private_modes[VT102_PRIVATE_MODE_ORIGIN_MODE] = v->saved.origin_mode;
vt102_cursor_normalize (v);
v->pending_wrap = 0;
while (i--)
{
ca->attr = CRT_ATTR_REVERSE;
+ ca->color=CRT_COLOR_NORMAL;
ca->chr = *str;
if (*str)
str++;
v->crt.screen[CRT_ADDR_POS (&v->pos)].chr = c;
v->crt.screen[CRT_ADDR_POS (&v->pos)].attr = v->attr;
+ v->crt.screen[CRT_ADDR_POS (&v->pos)].color = v->color;
vt102_cursor_advance (v);
}
}
vt102_parser_reset (p);
crt_cls (&v->crt);
+ v->attr=CRT_ATTR_NORMAL;
+ v->color=CRT_COLOR_NORMAL;
v->application_keypad_mode = 0;
/*
* $Log$
+ * Revision 1.10 2008/02/07 12:16:04 james
+ * *** empty log message ***
+ *
* Revision 1.9 2008/02/07 01:57:46 james
* *** empty log message ***
*
{
CRT_Pos pos;
int attr;
+ int color;
int origin_mode;
} VT102_State;
CRT_Pos screen_start, screen_end;
VT102_parser parser;
int attr;
+ int color;
CRT crt;
int pending_wrap;