From bc99d7fc375f4df5990a2c12bd7405905423ae3c Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 15 Jul 2013 13:15:41 -0500 Subject: [PATCH] small refactor. --- lib/widget.js | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/widget.js b/lib/widget.js index 4227761..68a4243 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -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 + ';'; } }