Fix terminal fitting height
This commit is contained in:
+13
-3
@@ -14,22 +14,32 @@
|
|||||||
Terminal.prototype.fit = function () {
|
Terminal.prototype.fit = function () {
|
||||||
var container = this.rowContainer,
|
var container = this.rowContainer,
|
||||||
subjectRow = this.rowContainer.firstElementChild,
|
subjectRow = this.rowContainer.firstElementChild,
|
||||||
rows = parseInt(container.offsetHeight / subjectRow.offsetHeight),
|
rows,
|
||||||
contentBuffer,
|
contentBuffer,
|
||||||
characterWidth,
|
characterWidth,
|
||||||
|
characterHeight,
|
||||||
cols;
|
cols;
|
||||||
|
|
||||||
subjectRow.style.display = 'inline';
|
subjectRow.style.display = 'inline';
|
||||||
|
|
||||||
contentBuffer = subjectRow.textContent;
|
contentBuffer = subjectRow.textContent;
|
||||||
|
|
||||||
subjectRow.textContent = ' ';
|
subjectRow.innerHTML = ' '; /* Arbitrary character to calculate its dimensions */
|
||||||
characterWidth = parseInt(subjectRow.offsetWidth);
|
characterWidth = parseInt(subjectRow.offsetWidth);
|
||||||
|
characterHeight = parseInt(subjectRow.offsetHeight);
|
||||||
|
|
||||||
subjectRow.style.display = '';
|
subjectRow.style.display = '';
|
||||||
|
|
||||||
cols = container.offsetWidth / characterWidth;
|
cols = container.offsetWidth / characterWidth;
|
||||||
cols = parseInt(cols);
|
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;
|
||||||
|
|
||||||
|
rows = parseInt(availableHeight / characterHeight);
|
||||||
|
|
||||||
this.resize(cols, rows);
|
this.resize(cols, rows);
|
||||||
};
|
};
|
||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>xterm.js demo</title>
|
<title>xterm.js demo</title>
|
||||||
<link rel="stylesheet" href="../src/xterm.css" />
|
<link rel="stylesheet" href="../src/xterm.css" />
|
||||||
<link rel="stylesheet" href="../addon/fullscreen/fullscreen.css" />
|
<link rel="stylesheet" href="../addons/fullscreen/fullscreen.css" />
|
||||||
<link rel="stylesheet" href="style.css" />
|
<link rel="stylesheet" href="style.css" />
|
||||||
<script src="../src/xterm.js" ></script>
|
<script src="../src/xterm.js" ></script>
|
||||||
<script src="../addons/fit/fit.js" ></script>
|
<script src="../addons/fit/fit.js" ></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user