Fix addon lint
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
import { assert, expect } from 'chai';
|
||||
|
||||
import * as fit from './fit'
|
||||
import * as fit from './fit';
|
||||
|
||||
class MockTerminal {}
|
||||
|
||||
|
||||
+24
-19
@@ -13,28 +13,33 @@
|
||||
* row and truncate its width with the current number of columns).
|
||||
*/
|
||||
|
||||
export function proposeGeometry(term) {
|
||||
export interface IGeometry {
|
||||
rows: number;
|
||||
cols: number;
|
||||
}
|
||||
|
||||
export function proposeGeometry(term: any): IGeometry {
|
||||
if (!term.element.parentElement) {
|
||||
return null;
|
||||
}
|
||||
var parentElementStyle = window.getComputedStyle(term.element.parentElement);
|
||||
var parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
|
||||
var parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')) - 17);
|
||||
var elementStyle = window.getComputedStyle(term.element);
|
||||
var elementPaddingVer = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom'));
|
||||
var elementPaddingHor = parseInt(elementStyle.getPropertyValue('padding-right')) + parseInt(elementStyle.getPropertyValue('padding-left'));
|
||||
var availableHeight = parentElementHeight - elementPaddingVer;
|
||||
var availableWidth = parentElementWidth - elementPaddingHor;
|
||||
var geometry = {
|
||||
const parentElementStyle = window.getComputedStyle(term.element.parentElement);
|
||||
const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
|
||||
const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')) - 17);
|
||||
const elementStyle = window.getComputedStyle(term.element);
|
||||
const elementPaddingVer = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom'));
|
||||
const elementPaddingHor = parseInt(elementStyle.getPropertyValue('padding-right')) + parseInt(elementStyle.getPropertyValue('padding-left'));
|
||||
const availableHeight = parentElementHeight - elementPaddingVer;
|
||||
const availableWidth = parentElementWidth - elementPaddingHor;
|
||||
const geometry = {
|
||||
cols: Math.floor(availableWidth / term.renderer.dimensions.actualCellWidth),
|
||||
rows: Math.floor(availableHeight / term.renderer.dimensions.actualCellHeight)
|
||||
};
|
||||
|
||||
return geometry;
|
||||
};
|
||||
}
|
||||
|
||||
export function fit(term) {
|
||||
var geometry = proposeGeometry(term);
|
||||
export function fit(term: any): void {
|
||||
const geometry = proposeGeometry(term);
|
||||
if (geometry) {
|
||||
// Force a full render
|
||||
if (term.rows !== geometry.rows || term.cols !== geometry.cols) {
|
||||
@@ -44,12 +49,12 @@ export function fit(term) {
|
||||
}
|
||||
};
|
||||
|
||||
export function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.proposeGeometry = function() {
|
||||
export function apply(terminalConstructor: any): void {
|
||||
terminalConstructor.prototype.proposeGeometry = function (): IGeometry {
|
||||
return proposeGeometry(this);
|
||||
}
|
||||
};
|
||||
|
||||
terminalConstructor.prototype.fit = function() {
|
||||
return fit(this);
|
||||
}
|
||||
terminalConstructor.prototype.fit = function (): void {
|
||||
fit(this);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user