2 Object.defineProperty(exports, "__esModule", { value: true });
5 var FitAddon = (function () {
8 FitAddon.prototype.activate = function (terminal) {
9 this._terminal = terminal;
11 FitAddon.prototype.dispose = function () { };
12 FitAddon.prototype.fit = function () {
13 var dims = this.proposeDimensions();
14 if (!dims || !this._terminal) {
17 var core = this._terminal._core;
18 if (this._terminal.rows !== dims.rows || this._terminal.cols !== dims.cols) {
19 core._renderService.clear();
20 this._terminal.resize(dims.cols, dims.rows);
23 FitAddon.prototype.proposeDimensions = function () {
24 if (!this._terminal) {
27 if (!this._terminal.element || !this._terminal.element.parentElement) {
30 var core = this._terminal._core;
31 var parentElementStyle = window.getComputedStyle(this._terminal.element.parentElement);
32 var parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
33 var parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));
34 var elementStyle = window.getComputedStyle(this._terminal.element);
35 var elementPadding = {
36 top: parseInt(elementStyle.getPropertyValue('padding-top')),
37 bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),
38 right: parseInt(elementStyle.getPropertyValue('padding-right')),
39 left: parseInt(elementStyle.getPropertyValue('padding-left'))
41 var elementPaddingVer = elementPadding.top + elementPadding.bottom;
42 var elementPaddingHor = elementPadding.right + elementPadding.left;
43 var availableHeight = parentElementHeight - elementPaddingVer;
44 var availableWidth = parentElementWidth - elementPaddingHor - core.viewport.scrollBarWidth;
46 cols: Math.max(MINIMUM_COLS, Math.floor(availableWidth / core._renderService.dimensions.actualCellWidth)),
47 rows: Math.max(MINIMUM_ROWS, Math.floor(availableHeight / core._renderService.dimensions.actualCellHeight))
53 exports.FitAddon = FitAddon;
54 //# sourceMappingURL=FitAddon.js.map