73 lines
3.1 KiB
JavaScript
73 lines
3.1 KiB
JavaScript
"use strict";
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = function (d, b) {
|
|
extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return extendStatics(d, b);
|
|
};
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var BaseRenderLayer_1 = require("./BaseRenderLayer");
|
|
var Constants_1 = require("browser/renderer/atlas/Constants");
|
|
var CharAtlasUtils_1 = require("../atlas/CharAtlasUtils");
|
|
var LinkRenderLayer = (function (_super) {
|
|
__extends(LinkRenderLayer, _super);
|
|
function LinkRenderLayer(container, zIndex, colors, terminal) {
|
|
var _this = _super.call(this, container, 'link', zIndex, true, colors) || this;
|
|
terminal.linkifier.onLinkHover(function (e) { return _this._onLinkHover(e); });
|
|
terminal.linkifier.onLinkLeave(function (e) { return _this._onLinkLeave(e); });
|
|
return _this;
|
|
}
|
|
LinkRenderLayer.prototype.resize = function (terminal, dim) {
|
|
_super.prototype.resize.call(this, terminal, dim);
|
|
this._state = undefined;
|
|
};
|
|
LinkRenderLayer.prototype.reset = function (terminal) {
|
|
this._clearCurrentLink();
|
|
};
|
|
LinkRenderLayer.prototype._clearCurrentLink = function () {
|
|
if (this._state) {
|
|
this._clearCells(this._state.x1, this._state.y1, this._state.cols - this._state.x1, 1);
|
|
var middleRowCount = this._state.y2 - this._state.y1 - 1;
|
|
if (middleRowCount > 0) {
|
|
this._clearCells(0, this._state.y1 + 1, this._state.cols, middleRowCount);
|
|
}
|
|
this._clearCells(0, this._state.y2, this._state.x2, 1);
|
|
this._state = undefined;
|
|
}
|
|
};
|
|
LinkRenderLayer.prototype._onLinkHover = function (e) {
|
|
if (e.fg === Constants_1.INVERTED_DEFAULT_COLOR) {
|
|
this._ctx.fillStyle = this._colors.background.css;
|
|
}
|
|
else if (e.fg !== undefined && CharAtlasUtils_1.is256Color(e.fg)) {
|
|
this._ctx.fillStyle = this._colors.ansi[e.fg].css;
|
|
}
|
|
else {
|
|
this._ctx.fillStyle = this._colors.foreground.css;
|
|
}
|
|
if (e.y1 === e.y2) {
|
|
this._fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1);
|
|
}
|
|
else {
|
|
this._fillBottomLineAtCells(e.x1, e.y1, e.cols - e.x1);
|
|
for (var y = e.y1 + 1; y < e.y2; y++) {
|
|
this._fillBottomLineAtCells(0, y, e.cols);
|
|
}
|
|
this._fillBottomLineAtCells(0, e.y2, e.x2);
|
|
}
|
|
this._state = e;
|
|
};
|
|
LinkRenderLayer.prototype._onLinkLeave = function (e) {
|
|
this._clearCurrentLink();
|
|
};
|
|
return LinkRenderLayer;
|
|
}(BaseRenderLayer_1.BaseRenderLayer));
|
|
exports.LinkRenderLayer = LinkRenderLayer;
|
|
//# sourceMappingURL=LinkRenderLayer.js.map
|