mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Override the buggy hexToRGB implementation in hterm. (#272)
This commit is contained in:
parent
7a3d661afd
commit
a8de019665
1 changed files with 32 additions and 0 deletions
|
|
@ -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 };
|
||||
|
|
|
|||
Loading…
Reference in a new issue