mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-18 21:31:39 +08:00
Update xterm.js
This commit is contained in:
parent
bfbe3abed5
commit
aa7aba1d5e
@ -1,86 +1,59 @@
|
|||||||
/*
|
/**
|
||||||
* Fit terminal columns and rows to the dimensions of its
|
* Fit terminal columns and rows to the dimensions of its DOM element.
|
||||||
* DOM element.
|
|
||||||
*
|
*
|
||||||
* Approach:
|
* ## Approach
|
||||||
* - Rows: Truncate the division of the terminal parent element height
|
* - Rows: Truncate the division of the terminal parent element height by the terminal row height.
|
||||||
* by the terminal row height
|
|
||||||
*
|
*
|
||||||
* - Columns: Truncate the division of the terminal parent element width by
|
* - Columns: Truncate the division of the terminal parent element width by the terminal character
|
||||||
* the terminal character width (apply display: inline at the
|
* width (apply display: inline at the terminal row and truncate its width with the current
|
||||||
* terminal row and truncate its width with the current number
|
* number of columns).
|
||||||
* of columns)
|
* @module xterm/addons/fit/fit
|
||||||
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
(function (fit) {
|
(function (fit) {
|
||||||
if (typeof exports === 'object' && typeof module === 'object') {
|
if (typeof exports === 'object' && typeof module === 'object') {
|
||||||
/*
|
/*
|
||||||
* CommonJS environment
|
* CommonJS environment
|
||||||
*/
|
*/
|
||||||
module.exports = fit(require('../../dist/xterm'));
|
module.exports = fit(require('../../xterm'));
|
||||||
} else if (typeof define == 'function') {
|
}
|
||||||
/*
|
else if (typeof define == 'function') {
|
||||||
* Require.js is available
|
/*
|
||||||
*/
|
* Require.js is available
|
||||||
define(['../../dist/xterm'], fit);
|
*/
|
||||||
} else {
|
define(['../../xterm'], fit);
|
||||||
/*
|
}
|
||||||
* Plain browser environment
|
else {
|
||||||
*/
|
/*
|
||||||
fit(window.Terminal);
|
* Plain browser environment
|
||||||
}
|
*/
|
||||||
|
fit(window.Terminal);
|
||||||
|
}
|
||||||
})(function (Xterm) {
|
})(function (Xterm) {
|
||||||
/**
|
var exports = {};
|
||||||
* This module provides methods for fitting a terminal's size to a parent container.
|
exports.proposeGeometry = function (term) {
|
||||||
*
|
var parentElementStyle = window.getComputedStyle(term.element.parentElement), parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')), parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')) - 17), elementStyle = window.getComputedStyle(term.element), elementPaddingVer = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom')), elementPaddingHor = parseInt(elementStyle.getPropertyValue('padding-right')) + parseInt(elementStyle.getPropertyValue('padding-left')), availableHeight = parentElementHeight - elementPaddingVer, availableWidth = parentElementWidth - elementPaddingHor, container = term.rowContainer, subjectRow = term.rowContainer.firstElementChild, contentBuffer = subjectRow.innerHTML, characterHeight, rows, characterWidth, cols, geometry;
|
||||||
* @module xterm/addons/fit/fit
|
subjectRow.style.display = 'inline';
|
||||||
*/
|
subjectRow.innerHTML = 'W'; // Common character for measuring width, although on monospace
|
||||||
var exports = {};
|
characterWidth = subjectRow.getBoundingClientRect().width;
|
||||||
|
subjectRow.style.display = ''; // Revert style before calculating height, since they differ.
|
||||||
exports.proposeGeometry = function (term) {
|
characterHeight = parseInt(subjectRow.offsetHeight);
|
||||||
var parentElementStyle = window.getComputedStyle(term.element.parentElement),
|
subjectRow.innerHTML = contentBuffer;
|
||||||
parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')),
|
rows = parseInt(availableHeight / characterHeight);
|
||||||
parentElementWidth = parseInt(parentElementStyle.getPropertyValue('width')),
|
cols = parseInt(availableWidth / characterWidth);
|
||||||
elementStyle = window.getComputedStyle(term.element),
|
geometry = { cols: cols, rows: rows };
|
||||||
elementPaddingVer = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom')),
|
return geometry;
|
||||||
elementPaddingHor = parseInt(elementStyle.getPropertyValue('padding-right')) + parseInt(elementStyle.getPropertyValue('padding-left')),
|
};
|
||||||
availableHeight = parentElementHeight - elementPaddingVer,
|
exports.fit = function (term) {
|
||||||
availableWidth = parentElementWidth - elementPaddingHor,
|
var geometry = exports.proposeGeometry(term);
|
||||||
container = term.rowContainer,
|
term.resize(geometry.cols, geometry.rows);
|
||||||
subjectRow = term.rowContainer.firstElementChild,
|
};
|
||||||
contentBuffer = subjectRow.innerHTML,
|
Xterm.prototype.proposeGeometry = function () {
|
||||||
characterHeight,
|
return exports.proposeGeometry(this);
|
||||||
rows,
|
};
|
||||||
characterWidth,
|
Xterm.prototype.fit = function () {
|
||||||
cols,
|
return exports.fit(this);
|
||||||
geometry;
|
};
|
||||||
|
return exports;
|
||||||
subjectRow.style.display = 'inline';
|
|
||||||
subjectRow.innerHTML = 'W'; // Common character for measuring width, although on monospace
|
|
||||||
characterWidth = subjectRow.getBoundingClientRect().width;
|
|
||||||
subjectRow.style.display = ''; // Revert style before calculating height, since they differ.
|
|
||||||
characterHeight = parseInt(subjectRow.offsetHeight);
|
|
||||||
subjectRow.innerHTML = contentBuffer;
|
|
||||||
|
|
||||||
rows = parseInt(availableHeight / characterHeight);
|
|
||||||
cols = parseInt(availableWidth / characterWidth) - 1;
|
|
||||||
|
|
||||||
geometry = {cols: cols, rows: rows};
|
|
||||||
return geometry;
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.fit = function (term) {
|
|
||||||
var geometry = exports.proposeGeometry(term);
|
|
||||||
|
|
||||||
term.resize(geometry.cols, geometry.rows);
|
|
||||||
};
|
|
||||||
|
|
||||||
Xterm.prototype.proposeGeometry = function () {
|
|
||||||
return exports.proposeGeometry(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
Xterm.prototype.fit = function () {
|
|
||||||
return exports.fit(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
return exports;
|
|
||||||
});
|
});
|
||||||
|
//# sourceMappingURL=fit.js.map
|
5797
www/assets/xterm.js
5797
www/assets/xterm.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user