fix setEffects and failed fg/bg 256 color sequences.

This commit is contained in:
Christopher Jeffrey 2013-07-29 04:19:35 -05:00
parent 9a1411338c
commit 9b77e3df63

View File

@ -1221,7 +1221,8 @@ Screen.prototype.attrCode = function(code, cur, def) {
} else if (c === 48 && +code[i+1] === 2) {
i += 2;
bg = colors.match(+code[i], +code[i+1], +code[i+2]);
if (bg === -1) bg = 0x1ff;
//if (bg === -1) bg = 0x1ff;
if (bg === -1) bg = def & 0x1ff;
i += 2;
break;
} else if (c === 38 && +code[i+1] === 5) {
@ -1231,7 +1232,8 @@ Screen.prototype.attrCode = function(code, cur, def) {
} else if (c === 38 && +code[i+1] === 2) {
i += 2;
fg = colors.match(+code[i], +code[i+1], +code[i+2]);
if (fg === -1) fg = 0x1ff;
//if (fg === -1) fg = 0x1ff;
if (fg === -1) fg = (def >> 9) & 0x1ff;
i += 2;
break;
}
@ -1554,40 +1556,42 @@ Screen.prototype.setEffects = function(el, fel, over, out, effects, temp) {
}
fel.on(over, function() {
var element = el();
Object.keys(effects).forEach(function(key) {
var val = effects[key];
if (val !== null && typeof val === 'object') {
tmp[key] = tmp[key] || {};
Object.keys(val).forEach(function(k) {
var v = val[k];
tmp[key][k] = el()[key][k];
el().style[key][k] = v;
tmp[key][k] = element.style[key][k];
element.style[key][k] = v;
});
return;
}
tmp[key] = el().style[key];
el().style[key] = val;
tmp[key] = element.style[key];
element.style[key] = val;
});
el().screen.render();
element.screen.render();
});
fel.on(out, function() {
var element = el();
Object.keys(effects).forEach(function(key) {
var val = effects[key];
if (val !== null && typeof val === 'object') {
tmp[key] = tmp[key] || {};
Object.keys(val).forEach(function(k) {
if (tmp[key].hasOwnProperty(k)) {
el().style[key][k] = tmp[key][k];
element.style[key][k] = tmp[key][k];
}
});
return;
}
if (tmp.hasOwnProperty(key)) {
el().style[key] = tmp[key];
element.style[key] = tmp[key];
}
});
el().screen.render();
element.screen.render();
});
};