support intense colors.

SVN revision: 72406
This commit is contained in:
Carsten Haitzler 2012-06-18 13:59:09 +00:00
parent b12b4da7e9
commit a36cce4ef6
5 changed files with 161 additions and 38 deletions

View File

@ -1,34 +1,66 @@
#include "col.h" #include "col.h"
const Color colors[2][12] = const Color colors[2][2][12] =
{ {
{ // normal { // normal
{ 0xaa, 0xaa, 0xaa, 0xff }, // COL_DEF { // normal
{ 0x00, 0x00, 0x00, 0xff }, // COL_BLACK { 0xaa, 0xaa, 0xaa, 0xff }, // COL_DEF
{ 0xcc, 0x33, 0x33, 0xff }, // COL_RED { 0x00, 0x00, 0x00, 0xff }, // COL_BLACK
{ 0x33, 0xcc, 0x33, 0xff }, // COL_GREEN { 0xcc, 0x33, 0x33, 0xff }, // COL_RED
{ 0xcc, 0x88, 0x33, 0xff }, // COL_YELLOW { 0x33, 0xcc, 0x33, 0xff }, // COL_GREEN
{ 0x33, 0x33, 0xcc, 0xff }, // COL_BLUE { 0xcc, 0x88, 0x33, 0xff }, // COL_YELLOW
{ 0xcc, 0x33, 0xcc, 0xff }, // COL_MAGENTA { 0x33, 0x33, 0xcc, 0xff }, // COL_BLUE
{ 0x33, 0xcc, 0xcc, 0xff }, // COL_CYAN { 0xcc, 0x33, 0xcc, 0xff }, // COL_MAGENTA
{ 0xcc, 0xcc, 0xcc, 0xff }, // COL_WHITE { 0x33, 0xcc, 0xcc, 0xff }, // COL_CYAN
{ 0x00, 0x00, 0x00, 0x00 }, // COL_INVIS { 0xcc, 0xcc, 0xcc, 0xff }, // COL_WHITE
{ 0x22, 0x22, 0x22, 0xff }, // COL_INVERSE { 0x00, 0x00, 0x00, 0x00 }, // COL_INVIS
{ 0xaa, 0xaa, 0xaa, 0xff }, // COL_INVERSEBG { 0x22, 0x22, 0x22, 0xff }, // COL_INVERSE
{ 0xaa, 0xaa, 0xaa, 0xff }, // COL_INVERSEBG
},
{ // bright/bold
{ 0xee, 0xee, 0xee, 0xff }, // COL_DEF
{ 0x66, 0x66, 0x66, 0xff }, // COL_BLACK
{ 0xff, 0x66, 0x66, 0xff }, // COL_RED
{ 0x66, 0xff, 0x66, 0xff }, // COL_GREEN
{ 0xff, 0xff, 0x66, 0xff }, // COL_YELLOW
{ 0x66, 0x66, 0xff, 0xff }, // COL_BLUE
{ 0xff, 0x66, 0xff, 0xff }, // COL_MAGENTA
{ 0x66, 0xff, 0xff, 0xff }, // COL_CYAN
{ 0xff, 0xff, 0xff, 0xff }, // COL_WHITE
{ 0x00, 0x00, 0x00, 0x00 }, // COL_INVIS
{ 0x11, 0x11, 0x11, 0xff }, // COL_INVERSE
{ 0xee, 0xee, 0xee, 0xff }, // COL_INVERSEBG
},
}, },
{ // bright/bold { // intense
{ 0xee, 0xee, 0xee, 0xff }, // COL_DEF { // normal
{ 0x66, 0x66, 0x66, 0xff }, // COL_BLACK { 0xdd, 0xdd, 0xdd, 0xff }, // COL_DEF
{ 0xff, 0x66, 0x66, 0xff }, // COL_RED { 0x00, 0x00, 0x00, 0xff }, // COL_BLACK
{ 0x66, 0xff, 0x66, 0xff }, // COL_GREEN { 0xcc, 0x88, 0x88, 0xff }, // COL_RED
{ 0xff, 0xff, 0x66, 0xff }, // COL_YELLOW { 0x88, 0xcc, 0x88, 0xff }, // COL_GREEN
{ 0x66, 0x66, 0xff, 0xff }, // COL_BLUE { 0xcc, 0xaa, 0x88, 0xff }, // COL_YELLOW
{ 0xff, 0x66, 0xff, 0xff }, // COL_MAGENTA { 0x88, 0x88, 0xcc, 0xff }, // COL_BLUE
{ 0x66, 0xff, 0xff, 0xff }, // COL_CYAN { 0xcc, 0x88, 0xcc, 0xff }, // COL_MAGENTA
{ 0xff, 0xff, 0xff, 0xff }, // COL_WHITE { 0x88, 0xcc, 0xcc, 0xff }, // COL_CYAN
{ 0x00, 0x00, 0x00, 0x00 }, // COL_INVIS { 0xcc, 0xcc, 0xcc, 0xff }, // COL_WHITE
{ 0x11, 0x11, 0x11, 0xff }, // COL_INVERSE { 0x00, 0x00, 0x00, 0x00 }, // COL_INVIS
{ 0xee, 0xee, 0xee, 0xff }, // COL_INVERSEBG { 0x11, 0x11, 0x11, 0xff }, // COL_INVERSE
{ 0xcc, 0xcc, 0xcc, 0xff }, // COL_INVERSEBG
},
{ // bright/bold
{ 0xff, 0xff, 0xff, 0xff }, // COL_DEF
{ 0xcc, 0xcc, 0xcc, 0xff }, // COL_BLACK
{ 0xff, 0xcc, 0xcc, 0xff }, // COL_RED
{ 0xcc, 0xff, 0xcc, 0xff }, // COL_GREEN
{ 0xff, 0xff, 0xcc, 0xff }, // COL_YELLOW
{ 0xcc, 0xcc, 0xff, 0xff }, // COL_BLUE
{ 0xff, 0xcc, 0xff, 0xff }, // COL_MAGENTA
{ 0xcc, 0xff, 0xff, 0xff }, // COL_CYAN
{ 0xff, 0xff, 0xff, 0xff }, // COL_WHITE
{ 0x00, 0x00, 0x00, 0x00 }, // COL_INVIS
{ 0x00, 0x00, 0x00, 0xff }, // COL_INVERSE
{ 0xff, 0xff, 0xff, 0xff }, // COL_INVERSEBG
}
} }
}; };

View File

@ -5,5 +5,5 @@ struct _Color
unsigned char r, g, b, a; unsigned char r, g, b, a;
}; };
extern const Color colors[2][12]; extern const Color colors[2][2][12];
extern const Color colors256[256]; extern const Color colors256[256];

View File

@ -126,10 +126,15 @@ _smart_apply(Evas_Object *obj)
if (cells[j].att.inverse) if (cells[j].att.inverse)
{ {
int t;
fgext = 0; fgext = 0;
bgext = 0; bgext = 0;
fg = COL_INVERSE; fg = cells[j].att.fg;
bg = COL_INVERSEBG; bg = cells[j].att.bg;
if (fg == COL_DEF) fg = COL_INVERSEBG;
if (bg == COL_DEF) bg = COL_INVERSE;
t = bg; bg = fg; fg = t;
if (bold) if (bold)
{ {
fg += 12; fg += 12;
@ -140,6 +145,8 @@ _smart_apply(Evas_Object *obj)
fg += 24; fg += 24;
bg += 24; bg += 24;
} }
if (cells[j].att.fgintense) fg += 48;
if (cells[j].att.bgintense) bg += 48;
} }
else else
{ {
@ -159,6 +166,8 @@ _smart_apply(Evas_Object *obj)
if (!fgext) fg += 24; if (!fgext) fg += 24;
if (!bgext) bg += 24; if (!bgext) bg += 24;
} }
if (cells[j].att.fgintense) fg += 48;
if (cells[j].att.bgintense) bg += 48;
if ((glyph == ' ') || (glyph == 0)) if ((glyph == ' ') || (glyph == 0))
fg = COL_INVIS; fg = COL_INVIS;
} }
@ -749,7 +758,7 @@ _smart_add(Evas_Object *obj)
Termio *sd; Termio *sd;
Evas_Object_Smart_Clipped_Data *cd; Evas_Object_Smart_Clipped_Data *cd;
Evas_Object *o; Evas_Object *o;
int i, j, k, n; int i, j, k, l, n;
_parent_sc.add(obj); _parent_sc.add(obj);
cd = evas_object_smart_data_get(obj); cd = evas_object_smart_data_get(obj);
@ -767,15 +776,20 @@ _smart_add(Evas_Object *obj)
evas_object_show(o); evas_object_show(o);
sd->grid.obj = o; sd->grid.obj = o;
for (n = 0, k = 0; k < 2; k++) for (n = 0, l = 0; l < 2; l++) // normal/intense
{ {
for (j = 0; j < 2; j++) for (k = 0; k < 2; k++) // normal/faint
{ {
for (i = 0; i < 12; i++, n++) for (j = 0; j < 2; j++) // normal/bright
evas_object_textgrid_palette_set {
(o, EVAS_TEXTGRID_PALETTE_STANDARD, n, for (i = 0; i < 12; i++, n++) //colors
colors[j][i].r / (k + 1), colors[j][i].g / (k + 1), evas_object_textgrid_palette_set
colors[j][i].b / (k + 1), colors[j][i].a / (k + 1)); (o, EVAS_TEXTGRID_PALETTE_STANDARD, n,
colors[l][j][i].r / (k + 1),
colors[l][j][i].g / (k + 1),
colors[l][j][i].b / (k + 1),
colors[l][j][i].a / (k + 1));
}
} }
} }
for (n = 0; n < 256; n++) for (n = 0; n < 256; n++)

View File

@ -270,6 +270,8 @@ _reset_att(Termatt *att)
att->strike = 0; att->strike = 0;
att->fg256 = 0; att->fg256 = 0;
att->bg256 = 0; att->bg256 = 0;
att->fgintense = 0;
att->bgintense = 0;
att->autowrapped = 0; att->autowrapped = 0;
att->newline = 0; att->newline = 0;
att->tab = 0; att->tab = 0;
@ -433,6 +435,7 @@ _handle_esc_csi(Termpty *ty, const int *c, int *ce)
case 37: case 37:
ty->state.att.fg256 = 0; ty->state.att.fg256 = 0;
ty->state.att.fg = (arg - 30) + COL_BLACK; ty->state.att.fg = (arg - 30) + COL_BLACK;
ty->state.att.fgintense = 0;
break; break;
case 38: // xterm 256 fg color ??? case 38: // xterm 256 fg color ???
// now check if next arg is 5 // now check if next arg is 5
@ -449,10 +452,12 @@ _handle_esc_csi(Termpty *ty, const int *c, int *ce)
ty->state.att.fg = arg; ty->state.att.fg = arg;
} }
} }
ty->state.att.fgintense = 0;
break; break;
case 39: // default fg color case 39: // default fg color
ty->state.att.fg256 = 0; ty->state.att.fg256 = 0;
ty->state.att.fg = COL_DEF; ty->state.att.fg = COL_DEF;
ty->state.att.fgintense = 0;
break; break;
case 40: // bg case 40: // bg
case 41: case 41:
@ -464,6 +469,7 @@ _handle_esc_csi(Termpty *ty, const int *c, int *ce)
case 47: case 47:
ty->state.att.bg256 = 0; ty->state.att.bg256 = 0;
ty->state.att.bg = (arg - 40) + COL_BLACK; ty->state.att.bg = (arg - 40) + COL_BLACK;
ty->state.att.bgintense = 0;
break; break;
case 48: // xterm 256 bg color ??? case 48: // xterm 256 bg color ???
// now check if next arg is 5 // now check if next arg is 5
@ -480,10 +486,80 @@ _handle_esc_csi(Termpty *ty, const int *c, int *ce)
ty->state.att.bg = arg; ty->state.att.bg = arg;
} }
} }
ty->state.att.bgintense = 0;
break; break;
case 49: // default bg color case 49: // default bg color
ty->state.att.bg256 = 0; ty->state.att.bg256 = 0;
ty->state.att.bg = COL_DEF; ty->state.att.bg = COL_DEF;
ty->state.att.bgintense = 0;
break;
case 90: // fg
case 91:
case 92:
case 93:
case 94:
case 95:
case 96:
case 97:
ty->state.att.fg256 = 0;
ty->state.att.fg = (arg - 90) + COL_BLACK;
ty->state.att.fgintense = 1;
break;
case 98: // xterm 256 fg color ???
// now check if next arg is 5
arg = _csi_arg_get(&b);
if (arg != 5) ERR("Failed xterm 256 color fg esc 5\n");
else
{
// then get next arg - should be color index 0-255
arg = _csi_arg_get(&b);
if (!b) ERR("Failed xterm 256 color fg esc val\n");
else
{
ty->state.att.fg256 = 1;
ty->state.att.fg = arg;
}
}
ty->state.att.fgintense = 1;
break;
case 99: // default fg color
ty->state.att.fg256 = 0;
ty->state.att.fg = COL_DEF;
ty->state.att.fgintense = 1;
break;
case 100: // bg
case 101:
case 102:
case 103:
case 104:
case 105:
case 106:
case 107:
ty->state.att.bg256 = 0;
ty->state.att.bg = (arg - 100) + COL_BLACK;
ty->state.att.bgintense = 1;
break;
case 108: // xterm 256 bg color ???
// now check if next arg is 5
arg = _csi_arg_get(&b);
if (arg != 5) ERR("Failed xterm 256 color bg esc 5\n");
else
{
// then get next arg - should be color index 0-255
arg = _csi_arg_get(&b);
if (!b) ERR("Failed xterm 256 color bg esc val\n");
else
{
ty->state.att.bg256 = 1;
ty->state.att.bg = arg;
}
}
ty->state.att.bgintense = 1;
break;
case 109: // default bg color
ty->state.att.bg256 = 0;
ty->state.att.bg = COL_DEF;
ty->state.att.bgintense = 1;
break; break;
default: // not handled??? default: // not handled???
ERR(" color cmd [%i] not handled\n", arg); ERR(" color cmd [%i] not handled\n", arg);

View File

@ -32,11 +32,12 @@ struct _Termatt
unsigned short strike : 1; unsigned short strike : 1;
unsigned short fg256 : 1; unsigned short fg256 : 1;
unsigned short bg256 : 1; unsigned short bg256 : 1;
unsigned short fgintense : 1;
unsigned short bgintense : 1;
// below used for working out text from selections // below used for working out text from selections
unsigned short autowrapped : 1; unsigned short autowrapped : 1;
unsigned short newline : 1; unsigned short newline : 1;
unsigned short tab : 1; unsigned short tab : 1;
// 2 bits left
}; };
struct _Termstate struct _Termstate