256 colors support in terminal (compatible with xterm)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38090 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues 2010-08-13 16:23:21 +00:00
parent 6100b6aa33
commit dbf7fa8716
2 changed files with 475 additions and 198 deletions

View File

@ -746,7 +746,9 @@ TermParse::EscParse()
break;
case CASE_SGR:
{
/* SGR */
char xterm256_mode = 0;
for (row = 0; row < nparam; ++row) {
switch (param[row]) {
case DEFAULT:
@ -754,8 +756,11 @@ TermParse::EscParse()
fAttr = 0;
break;
case 1:
case 5: /* Bold */
case 5: /* Bold or validation of xterm 256 col*/
if (xterm256_mode)
xterm256_mode |= 4;
// falthrough
case 1: /* Bold */
fAttr |= BOLD;
break;
@ -792,6 +797,10 @@ TermParse::EscParse()
fAttr |= FORESET;
break;
case 38:
xterm256_mode = 1;
break;
case 39:
fAttr &= ~FORESET;
break;
@ -809,13 +818,30 @@ TermParse::EscParse()
fAttr |= BACKSET;
break;
case 48:
xterm256_mode = 2;
break;
case 49:
fAttr &= ~BACKSET;
break;
}
if (xterm256_mode == 5) {
fAttr &= ~FORECOLOR;
fAttr |= FORECOLORED(param[row]);
fAttr |= FORESET;
}
if (xterm256_mode == 6) {
fAttr &= ~BACKCOLOR;
fAttr |= BACKCOLORED(param[row]);
fAttr |= BACKSET;
}
}
parsestate = groundtable;
break;
}
case CASE_CPR:
// Q & D hack by Y.Hayakawa (hida@sawada.riec.tohoku.ac.jp)

View File

@ -62,7 +62,7 @@
extern int function_keycode_table[];
extern char *function_key_char_table[];
const static rgb_color kTermColorTable[8] = {
const static rgb_color kTermColorTable[256] = {
{ 40, 40, 40, 0}, // black
{204, 0, 0, 0}, // red
{ 78, 154, 6, 0}, // green
@ -71,6 +71,257 @@ const static rgb_color kTermColorTable[8] = {
{115, 68, 123, 0}, // magenta
{ 6, 152, 154, 0}, // cyan
{245, 245, 245, 0}, // white
{128, 128, 128, 0}, // black
{255, 0, 0, 0}, // red
{ 0, 255, 0, 0}, // green
{255, 255, 0, 0}, // yellow
{ 0, 0, 255, 0}, // blue
{255, 0, 255, 0}, // magenta
{ 0, 255, 255, 0}, // cyan
{255, 255, 255, 0}, // white
{ 0, 0, 0, 0},
{ 0, 0, 51, 0},
{ 0, 0, 102, 0},
{ 0, 0, 153, 0},
{ 0, 0, 204, 0},
{ 0, 0, 255, 0},
{ 0, 51, 0, 0},
{ 0, 51, 51, 0},
{ 0, 51, 102, 0},
{ 0, 51, 153, 0},
{ 0, 51, 204, 0},
{ 0, 51, 255, 0},
{ 0, 102, 0, 0},
{ 0, 102, 51, 0},
{ 0, 102, 102, 0},
{ 0, 102, 153, 0},
{ 0, 102, 204, 0},
{ 0, 102, 255, 0},
{ 0, 153, 0, 0},
{ 0, 153, 51, 0},
{ 0, 153, 102, 0},
{ 0, 153, 153, 0},
{ 0, 153, 204, 0},
{ 0, 153, 255, 0},
{ 0, 204, 0, 0},
{ 0, 204, 51, 0},
{ 0, 204, 102, 0},
{ 0, 204, 153, 0},
{ 0, 204, 204, 0},
{ 0, 204, 255, 0},
{ 0, 255, 0, 0},
{ 0, 255, 51, 0},
{ 0, 255, 102, 0},
{ 0, 255, 153, 0},
{ 0, 255, 204, 0},
{ 0, 255, 255, 0},
{ 51, 0, 0, 0},
{ 51, 0, 51, 0},
{ 51, 0, 102, 0},
{ 51, 0, 153, 0},
{ 51, 0, 204, 0},
{ 51, 0, 255, 0},
{ 51, 51, 0, 0},
{ 51, 51, 51, 0},
{ 51, 51, 102, 0},
{ 51, 51, 153, 0},
{ 51, 51, 204, 0},
{ 51, 51, 255, 0},
{ 51, 102, 0, 0},
{ 51, 102, 51, 0},
{ 51, 102, 102, 0},
{ 51, 102, 153, 0},
{ 51, 102, 204, 0},
{ 51, 102, 255, 0},
{ 51, 153, 0, 0},
{ 51, 153, 51, 0},
{ 51, 153, 102, 0},
{ 51, 153, 153, 0},
{ 51, 153, 204, 0},
{ 51, 153, 255, 0},
{ 51, 204, 0, 0},
{ 51, 204, 51, 0},
{ 51, 204, 102, 0},
{ 51, 204, 153, 0},
{ 51, 204, 204, 0},
{ 51, 204, 255, 0},
{ 51, 255, 0, 0},
{ 51, 255, 51, 0},
{ 51, 255, 102, 0},
{ 51, 255, 153, 0},
{ 51, 255, 204, 0},
{ 51, 255, 255, 0},
{102, 0, 0, 0},
{102, 0, 51, 0},
{102, 0, 102, 0},
{102, 0, 153, 0},
{102, 0, 204, 0},
{102, 0, 255, 0},
{102, 51, 0, 0},
{102, 51, 51, 0},
{102, 51, 102, 0},
{102, 51, 153, 0},
{102, 51, 204, 0},
{102, 51, 255, 0},
{102, 102, 0, 0},
{102, 102, 51, 0},
{102, 102, 102, 0},
{102, 102, 153, 0},
{102, 102, 204, 0},
{102, 102, 255, 0},
{102, 153, 0, 0},
{102, 153, 51, 0},
{102, 153, 102, 0},
{102, 153, 153, 0},
{102, 153, 204, 0},
{102, 153, 255, 0},
{102, 204, 0, 0},
{102, 204, 51, 0},
{102, 204, 102, 0},
{102, 204, 153, 0},
{102, 204, 204, 0},
{102, 204, 255, 0},
{102, 255, 0, 0},
{102, 255, 51, 0},
{102, 255, 102, 0},
{102, 255, 153, 0},
{102, 255, 204, 0},
{102, 255, 255, 0},
{153, 0, 0, 0},
{153, 0, 51, 0},
{153, 0, 102, 0},
{153, 0, 153, 0},
{153, 0, 204, 0},
{153, 0, 255, 0},
{153, 51, 0, 0},
{153, 51, 51, 0},
{153, 51, 102, 0},
{153, 51, 153, 0},
{153, 51, 204, 0},
{153, 51, 255, 0},
{153, 102, 0, 0},
{153, 102, 51, 0},
{153, 102, 102, 0},
{153, 102, 153, 0},
{153, 102, 204, 0},
{153, 102, 255, 0},
{153, 153, 0, 0},
{153, 153, 51, 0},
{153, 153, 102, 0},
{153, 153, 153, 0},
{153, 153, 204, 0},
{153, 153, 255, 0},
{153, 204, 0, 0},
{153, 204, 51, 0},
{153, 204, 102, 0},
{153, 204, 153, 0},
{153, 204, 204, 0},
{153, 204, 255, 0},
{153, 255, 0, 0},
{153, 255, 51, 0},
{153, 255, 102, 0},
{153, 255, 153, 0},
{153, 255, 204, 0},
{153, 255, 255, 0},
{204, 0, 0, 0},
{204, 0, 51, 0},
{204, 0, 102, 0},
{204, 0, 153, 0},
{204, 0, 204, 0},
{204, 0, 255, 0},
{204, 51, 0, 0},
{204, 51, 51, 0},
{204, 51, 102, 0},
{204, 51, 153, 0},
{204, 51, 204, 0},
{204, 51, 255, 0},
{204, 102, 0, 0},
{204, 102, 51, 0},
{204, 102, 102, 0},
{204, 102, 153, 0},
{204, 102, 204, 0},
{204, 102, 255, 0},
{204, 153, 0, 0},
{204, 153, 51, 0},
{204, 153, 102, 0},
{204, 153, 153, 0},
{204, 153, 204, 0},
{204, 153, 255, 0},
{204, 204, 0, 0},
{204, 204, 51, 0},
{204, 204, 102, 0},
{204, 204, 153, 0},
{204, 204, 204, 0},
{204, 204, 255, 0},
{204, 255, 0, 0},
{204, 255, 51, 0},
{204, 255, 102, 0},
{204, 255, 153, 0},
{204, 255, 204, 0},
{204, 255, 255, 0},
{255, 0, 0, 0},
{255, 0, 51, 0},
{255, 0, 102, 0},
{255, 0, 153, 0},
{255, 0, 204, 0},
{255, 0, 255, 0},
{255, 51, 0, 0},
{255, 51, 51, 0},
{255, 51, 102, 0},
{255, 51, 153, 0},
{255, 51, 204, 0},
{255, 51, 255, 0},
{255, 102, 0, 0},
{255, 102, 51, 0},
{255, 102, 102, 0},
{255, 102, 153, 0},
{255, 102, 204, 0},
{255, 102, 255, 0},
{255, 153, 0, 0},
{255, 153, 51, 0},
{255, 153, 102, 0},
{255, 153, 153, 0},
{255, 153, 204, 0},
{255, 153, 255, 0},
{255, 204, 0, 0},
{255, 204, 51, 0},
{255, 204, 102, 0},
{255, 204, 153, 0},
{255, 204, 204, 0},
{255, 204, 255, 0},
{255, 255, 0, 0},
{255, 255, 51, 0},
{255, 255, 102, 0},
{255, 255, 153, 0},
{255, 255, 204, 0},
{255, 255, 255, 0},
{ 0, 0, 0, 0},
{ 11, 11, 11, 0},
{ 22, 22, 22, 0},
{ 33, 33, 33, 0},
{ 44, 44, 44, 0},
{ 55, 55, 55, 0},
{ 66, 66, 66, 0},
{ 77, 77, 77, 0},
{ 88, 88, 88, 0},
{ 99, 99, 99, 0},
{110, 110, 110, 0},
{121, 121, 121, 0},
{132, 132, 132, 0},
{143, 143, 143, 0},
{154, 154, 154, 0},
{165, 165, 165, 0},
{176, 176, 176, 0},
{187, 187, 187, 0},
{198, 198, 198, 0},
{209, 209, 209, 0},
{220, 220, 220, 0},
{231, 231, 231, 0},
{242, 242, 242, 0},
{253, 253, 253, 0},
};
#define ROWS_DEFAULT 25