mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Moved fit into its own addon
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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)
|
||||
*/
|
||||
Terminal.prototype.fit = function () {
|
||||
var container = this.element.parentElement,
|
||||
subjectRow = this.rowContainer.firstElementChild,
|
||||
rows = parseInt(container.offsetHeight / subjectRow.offsetHeight),
|
||||
characterWidth,
|
||||
cols;
|
||||
|
||||
subjectRow.style.display = 'inline';
|
||||
characterWidth = parseInt(subjectRow.offsetWidth / this.cols);
|
||||
subjectRow.style.display = '';
|
||||
|
||||
cols = parseInt(container.offsetWidth / characterWidth);
|
||||
|
||||
this.resize(cols, rows);
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "xterm.js",
|
||||
"version": "0.9.2",
|
||||
"version": "0.9.3",
|
||||
"ignore": ["demo", "docs", "test", ".gitignore"]
|
||||
}
|
||||
|
||||
+4
-3
@@ -5,9 +5,10 @@
|
||||
<link rel="stylesheet" href="../src/xterm.css" />
|
||||
<link rel="stylesheet" href="../addon/fullscreen/fullscreen.css" />
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<script src="../src/xterm.js"></script>
|
||||
<script src="../addon/fullscreen/fullscreen.js"></script>
|
||||
<script src="main.js" defer></script>
|
||||
<script src="../src/xterm.js" ></script>
|
||||
<script src="../addons/fit/fit.js" ></script>
|
||||
<script src="../addons/fullscreen/fullscreen.js" ></script>
|
||||
<script src="main.js" defer ></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
|
||||
@@ -2521,35 +2521,6 @@ Terminal.prototype.resize = function(x, y) {
|
||||
this.emit('resize', {terminal: this, cols: x, rows: y});
|
||||
};
|
||||
|
||||
/*
|
||||
* 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)
|
||||
*/
|
||||
Terminal.prototype.fit = function () {
|
||||
var container = this.element.parentElement,
|
||||
subjectRow = this.rowContainer.firstElementChild,
|
||||
rows = parseInt(container.offsetHeight / subjectRow.offsetHeight),
|
||||
characterWidth,
|
||||
cols;
|
||||
|
||||
subjectRow.style.display = 'inline';
|
||||
characterWidth = parseInt(subjectRow.offsetWidth / this.cols);
|
||||
subjectRow.style.display = '';
|
||||
|
||||
cols = parseInt(container.offsetWidth / characterWidth);
|
||||
|
||||
this.resize(cols, rows);
|
||||
}
|
||||
|
||||
Terminal.prototype.updateRange = function(y) {
|
||||
if (y < this.refreshStart) this.refreshStart = y;
|
||||
if (y > this.refreshEnd) this.refreshEnd = y;
|
||||
|
||||
Reference in New Issue
Block a user