diff --git a/src/addons/fit/README.md b/src/addons/fit/README.md deleted file mode 100644 index 68f015894..000000000 --- a/src/addons/fit/README.md +++ /dev/null @@ -1,3 +0,0 @@ -## fit addon - -The fit addon adjusts the dimensions of the terminal to match best fit its parent element container. `fit` will only work when the element is visible. diff --git a/src/addons/fit/fit.test.ts b/src/addons/fit/fit.test.ts deleted file mode 100644 index 781b50101..000000000 --- a/src/addons/fit/fit.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2017 The xterm.js authors. All rights reserved. - * @license MIT - */ - -import { assert } from 'chai'; - -import * as fit from './fit'; - -class MockTerminal {} - -describe('fit addon', () => { - describe('apply', () => { - it('should do register the `proposeGeometry` and `fit` methods', () => { - fit.apply(MockTerminal); - assert.equal(typeof (MockTerminal).prototype.proposeGeometry, 'function'); - assert.equal(typeof (MockTerminal).prototype.fit, 'function'); - }); - }); -}); diff --git a/src/addons/fit/fit.ts b/src/addons/fit/fit.ts deleted file mode 100644 index 26f8752c9..000000000 --- a/src/addons/fit/fit.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright (c) 2014 The xterm.js authors. All rights reserved. - * @license MIT - * - * Fit terminal columns and rows to the dimensions of its DOM element. - * - * ## Approach - * - * Rows: Truncate the division of the terminal parent element height by the - * terminal row height. - * Columns: Truncate the division of the terminal parent element width by the - * terminal character width (apply display: inline at the terminal - * row and truncate its width with the current number of columns). - */ - -import { Terminal } from 'xterm'; - -export interface IGeometry { - rows: number; - cols: number; -} - -export function proposeGeometry(term: Terminal): IGeometry { - if (!term.element.parentElement) { - return null; - } - const parentElementStyle = window.getComputedStyle(term.element.parentElement); - const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')); - const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width'))); - const elementStyle = window.getComputedStyle(term.element); - const elementPadding = { - top: parseInt(elementStyle.getPropertyValue('padding-top')), - bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')), - right: parseInt(elementStyle.getPropertyValue('padding-right')), - left: parseInt(elementStyle.getPropertyValue('padding-left')) - }; - const elementPaddingVer = elementPadding.top + elementPadding.bottom; - const elementPaddingHor = elementPadding.right + elementPadding.left; - const availableHeight = parentElementHeight - elementPaddingVer; - const availableWidth = parentElementWidth - elementPaddingHor - (term)._core.viewport.scrollBarWidth; - const geometry = { - cols: Math.floor(availableWidth / (term)._core._renderCoordinator.dimensions.actualCellWidth), - rows: Math.floor(availableHeight / (term)._core._renderCoordinator.dimensions.actualCellHeight) - }; - return geometry; -} - -export function fit(term: Terminal): void { - const geometry = proposeGeometry(term); - if (geometry) { - // Force a full render - if (term.rows !== geometry.rows || term.cols !== geometry.cols) { - (term)._core._renderCoordinator.clear(); - term.resize(geometry.cols, geometry.rows); - } - } -} - -export function apply(terminalConstructor: typeof Terminal): void { - (terminalConstructor.prototype).proposeGeometry = function (): IGeometry { - return proposeGeometry(this); - }; - - (terminalConstructor.prototype).fit = function (): void { - fit(this); - }; -} diff --git a/src/addons/fit/package.json b/src/addons/fit/package.json deleted file mode 100644 index f7cb5bc8c..000000000 --- a/src/addons/fit/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "xterm.fit", - "main": "fit.js", - "private": true -} diff --git a/src/addons/fit/tsconfig.json b/src/addons/fit/tsconfig.json deleted file mode 100644 index 3458d23a7..000000000 --- a/src/addons/fit/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es5", - "lib": [ - "dom", - "es5" - ], - "rootDir": ".", - "outDir": "../../../lib/addons/fit/", - "sourceMap": true, - "removeComments": true, - "declaration": true, - "types": [ - "../../node_modules/@types/mocha" - ] - }, - "include": [ - "**/*.ts", - "../../../typings/xterm.d.ts" - ] -} diff --git a/tsconfig.all.json b/tsconfig.all.json index 12f9b3dc6..4de8e9b50 100644 --- a/tsconfig.all.json +++ b/tsconfig.all.json @@ -6,7 +6,6 @@ { "path": "./addons/xterm-addon-attach/src" }, { "path": "./addons/xterm-addon-fit/src" }, { "path": "./addons/xterm-addon-search/src" }, - { "path": "./addons/xterm-addon-web-links/src" }, - { "path": "./src/addons/fit" } + { "path": "./addons/xterm-addon-web-links/src" } ] }