mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
[fit addon] Introduce proposeGeometry method
- Introduce new method to propose optimal geometry for the current terminal - Bump version to 0.23
This commit is contained in:
+40
-29
@@ -24,36 +24,47 @@
|
||||
fit(this.Xterm);
|
||||
}
|
||||
})(function (Xterm) {
|
||||
Xterm.prototype.proposeGeometry = function () {
|
||||
var container = this.rowContainer,
|
||||
subjectRow = this.rowContainer.firstElementChild,
|
||||
rows,
|
||||
contentBuffer,
|
||||
characterWidth,
|
||||
cols;
|
||||
|
||||
subjectRow.style.display = 'inline';
|
||||
|
||||
contentBuffer = subjectRow.textContent;
|
||||
|
||||
subjectRow.innerHTML = ' '; /* Arbitrary character to calculate its dimensions */
|
||||
characterWidth = parseInt(subjectRow.offsetWidth);
|
||||
characterHeight = parseInt(subjectRow.offsetHeight);
|
||||
|
||||
subjectRow.style.display = '';
|
||||
|
||||
cols = container.offsetWidth / characterWidth;
|
||||
cols = parseInt(cols);
|
||||
|
||||
var parentElementStyle = window.getComputedStyle(this.element.parentElement),
|
||||
parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')),
|
||||
elementStyle = window.getComputedStyle(this.element),
|
||||
elementPadding = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom')),
|
||||
availableHeight = parentElementHeight - elementPadding,
|
||||
rowHeight = this.rowContainer.firstElementChild.offsetHeight;
|
||||
|
||||
rows = parseInt(availableHeight / rowHeight);
|
||||
|
||||
var geometry = {
|
||||
'cols': cols,
|
||||
'rows': rowss
|
||||
};
|
||||
|
||||
return geometry;
|
||||
};
|
||||
|
||||
Xterm.prototype.fit = function () {
|
||||
var container = this.rowContainer,
|
||||
subjectRow = this.rowContainer.firstElementChild,
|
||||
rows,
|
||||
contentBuffer,
|
||||
characterWidth,
|
||||
cols;
|
||||
var geometry = this.proposeGeometry();
|
||||
|
||||
subjectRow.style.display = 'inline';
|
||||
|
||||
contentBuffer = subjectRow.textContent;
|
||||
|
||||
subjectRow.innerHTML = ' '; /* Arbitrary character to calculate its dimensions */
|
||||
characterWidth = parseInt(subjectRow.offsetWidth);
|
||||
characterHeight = parseInt(subjectRow.offsetHeight);
|
||||
|
||||
subjectRow.style.display = '';
|
||||
|
||||
cols = container.offsetWidth / characterWidth;
|
||||
cols = parseInt(cols);
|
||||
|
||||
var parentElementStyle = window.getComputedStyle(this.element.parentElement),
|
||||
parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')),
|
||||
elementStyle = window.getComputedStyle(this.element),
|
||||
elementPadding = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom')),
|
||||
availableHeight = parentElementHeight - elementPadding,
|
||||
rowHeight = this.rowContainer.firstElementChild.offsetHeight;
|
||||
|
||||
rows = parseInt(availableHeight / rowHeight);
|
||||
|
||||
this.resize(cols, rows);
|
||||
this.resize(geometry.cols, geometry.rows);
|
||||
};
|
||||
});
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "xterm.js",
|
||||
"version": "0.22",
|
||||
"version": "0.23",
|
||||
"ignore": ["demo", "docs", "test", ".gitignore"]
|
||||
}
|
||||
|
||||
+2
-2
@@ -51,9 +51,9 @@ copyright = u'2014, SourceLair Limited'
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.22'
|
||||
version = '0.23'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.22 Alpha'
|
||||
release = '0.23 Alpha'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
Reference in New Issue
Block a user