Override the buggy hexToRGB implementation in hterm. (#272)

This commit is contained in:
Mauro Otonelli 2016-07-19 14:46:26 -03:00 committed by Guillermo Rauch
parent 7a3d661afd
commit a8de019665

View file

@ -86,5 +86,37 @@ hterm.Terminal.prototype.clearPreserveCursorRow = function () {
this.scrollPort_.redraw_();
};
// fixes a bug in hterm, where the shorthand hex
// is not properly converted to rgb
lib.colors.hexToRGB = function(arg) {
var hex16 = lib.colors.re_.hex16;
var hex24 = lib.colors.re_.hex24;
function convert(hex) {
if (hex.length == 4) {
hex = hex.replace(hex16, function(h, r, g, b) {
return "#" + r + r + g + g + b + b;
});
}
var ary = hex.match(hex24);
if (!ary)
return null;
return 'rgb(' + parseInt(ary[1], 16) + ', ' +
parseInt(ary[2], 16) + ', ' +
parseInt(ary[3], 16) + ')';
}
if (arg instanceof Array) {
for (var i = 0; i < arg.length; i++) {
arg[i] = convert(arg[i]);
}
} else {
arg = convert(arg);
}
return arg;
};
export default hterm;
export { lib };