UNPKG

xterm

Version:

Full xterm terminal, in your browser

62 lines (60 loc) 2.48 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var 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 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 EventEmitter_1 = require("../EventEmitter"); var CharMeasure = (function (_super) { __extends(CharMeasure, _super); function CharMeasure(document, parentElement) { var _this = _super.call(this) || this; _this._document = document; _this._parentElement = parentElement; _this._measureElement = _this._document.createElement('span'); _this._measureElement.style.position = 'absolute'; _this._measureElement.style.top = '0'; _this._measureElement.style.left = '-9999em'; _this._measureElement.style.lineHeight = 'normal'; _this._measureElement.textContent = 'W'; _this._measureElement.setAttribute('aria-hidden', 'true'); _this._parentElement.appendChild(_this._measureElement); return _this; } Object.defineProperty(CharMeasure.prototype, "width", { get: function () { return this._width; }, enumerable: true, configurable: true }); Object.defineProperty(CharMeasure.prototype, "height", { get: function () { return this._height; }, enumerable: true, configurable: true }); CharMeasure.prototype.measure = function (options) { this._measureElement.style.fontFamily = options.fontFamily; this._measureElement.style.fontSize = options.fontSize + "px"; var geometry = this._measureElement.getBoundingClientRect(); if (geometry.width === 0 || geometry.height === 0) { return; } if (this._width !== geometry.width || this._height !== geometry.height) { this._width = geometry.width; this._height = Math.ceil(geometry.height); this.emit('charsizechanged'); } }; return CharMeasure; }(EventEmitter_1.EventEmitter)); exports.CharMeasure = CharMeasure; //# sourceMappingURL=CharMeasure.js.map