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