reduce color in program._attr.

This commit is contained in:
Christopher Jeffrey 2015-07-22 08:32:22 -07:00
parent e506412f93
commit 82d4355517
3 changed files with 15 additions and 9 deletions

View File

@ -203,6 +203,17 @@ exports.blend._cache = {};
exports._cache = {}; exports._cache = {};
exports.reduce = function(color, total) {
if (color >= 16 && total <= 16) {
color = exports.ccolors[color];
} else if (color >= 8 && total <= 8) {
color -= 8;
} else if (color >= 2 && total <= 2) {
color %= 2;
}
return color;
};
// XTerm Colors // XTerm Colors
// These were actually tough to track down. The xterm source only uses color // These were actually tough to track down. The xterm source only uses color
// keywords. The X11 source needed to be examined to find the actual values. // keywords. The X11 source needed to be examined to find the actual values.

View File

@ -2686,6 +2686,8 @@ Program.prototype._attr = function(param, val) {
return this._attr('default ' + m[2]); return this._attr('default ' + m[2]);
} }
color = colors.reduce(color, this.tput.colors);
if (color < 16 || (this.tput && this.tput.colors <= 16)) { if (color < 16 || (this.tput && this.tput.colors <= 16)) {
if (m[2] === 'fg') { if (m[2] === 'fg') {
if (color < 8) { if (color < 8) {

View File

@ -1336,15 +1336,8 @@ Screen.prototype.draw = function(start, end) {
// this.emit('draw'); // this.emit('draw');
}; };
Screen.prototype._reduceColor = function(col) { Screen.prototype._reduceColor = function(color) {
if (col >= 16 && this.tput.colors <= 16) { return colors.reduce(color, this.tput.colors);
col = colors.ccolors[col];
} else if (col >= 8 && this.tput.colors <= 8) {
col -= 8;
} else if (col >= 2 && this.tput.colors <= 2) {
col %= 2;
}
return col;
}; };
// Convert an SGR string to our own attribute format. // Convert an SGR string to our own attribute format.