small refactor.

This commit is contained in:
Christopher Jeffrey 2013-07-15 13:15:41 -05:00
parent 97b442d3ec
commit bc99d7fc37

View File

@ -714,8 +714,8 @@ Screen.prototype.draw = function(start, end) {
, ch
, data
, attr
, fgColor
, bgColor
, fg
, bg
, flags;
var lx = -1
@ -773,8 +773,8 @@ Screen.prototype.draw = function(start, end) {
if (data !== this.dattr) {
out += '\x1b[';
bgColor = data & 0x1ff;
fgColor = (data >> 9) & 0x1ff;
bg = data & 0x1ff;
fg = (data >> 9) & 0x1ff;
flags = data >> 18;
// bold
@ -802,33 +802,33 @@ Screen.prototype.draw = function(start, end) {
out += '8;';
}
if (bgColor !== 0x1ff) {
bgColor = this._reduceColor(bgColor);
if (bgColor < 16) {
if (bgColor < 8) {
bgColor += 40;
} else if (bgColor < 16) {
bgColor -= 8;
bgColor += 100;
if (bg !== 0x1ff) {
bg = this._reduceColor(bg);
if (bg < 16) {
if (bg < 8) {
bg += 40;
} else if (bg < 16) {
bg -= 8;
bg += 100;
}
out += bgColor + ';';
out += bg + ';';
} else {
out += '48;5;' + bgColor + ';';
out += '48;5;' + bg + ';';
}
}
if (fgColor !== 0x1ff) {
fgColor = this._reduceColor(fgColor);
if (fgColor < 16) {
if (fgColor < 8) {
fgColor += 30;
} else if (fgColor < 16) {
fgColor -= 8;
fgColor += 90;
if (fg !== 0x1ff) {
fg = this._reduceColor(fg);
if (fg < 16) {
if (fg < 8) {
fg += 30;
} else if (fg < 16) {
fg -= 8;
fg += 90;
}
out += fgColor + ';';
out += fg + ';';
} else {
out += '38;5;' + fgColor + ';';
out += '38;5;' + fg + ';';
}
}