Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc67c788d2 | ||
|
|
3f455f90d9 |
+31
-16
@@ -5,19 +5,34 @@
|
|||||||
* The bidirectional argument indicates, whether the terminal should
|
* The bidirectional argument indicates, whether the terminal should
|
||||||
* send data to the socket as well and is true, by default.
|
* send data to the socket as well and is true, by default.
|
||||||
*/
|
*/
|
||||||
Terminal.prototype.attach = function (socket, bidirectional) {
|
|
||||||
var term = this;
|
(function (attach) {
|
||||||
|
if (typeof define == 'function') {
|
||||||
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
|
/*
|
||||||
this.socket = socket;
|
* Require.js is available
|
||||||
|
*/
|
||||||
socket.addEventListener('message', function (ev) {
|
define(['../../src/xterm'], attach);
|
||||||
term.write(ev.data);
|
} else {
|
||||||
});
|
/*
|
||||||
|
* Plain browser environment
|
||||||
if (bidirectional) {
|
*/
|
||||||
this.on('data', function (data) {
|
attach(this.Xterm);
|
||||||
socket.send(data);
|
}
|
||||||
});
|
})(function (Xterm) {
|
||||||
}
|
Xterm.prototype.attach = function (socket, bidirectional) {
|
||||||
}
|
var term = this;
|
||||||
|
|
||||||
|
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
|
||||||
|
this.socket = socket;
|
||||||
|
|
||||||
|
socket.addEventListener('message', function (ev) {
|
||||||
|
term.write(ev.data);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (bidirectional) {
|
||||||
|
this.on('data', function (data) {
|
||||||
|
socket.send(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
+43
-29
@@ -11,35 +11,49 @@
|
|||||||
* terminal row and truncate its width with the current number
|
* terminal row and truncate its width with the current number
|
||||||
* of columns)
|
* of columns)
|
||||||
*/
|
*/
|
||||||
Terminal.prototype.fit = function () {
|
(function (fit) {
|
||||||
var container = this.rowContainer,
|
if (typeof define == 'function') {
|
||||||
subjectRow = this.rowContainer.firstElementChild,
|
/*
|
||||||
rows,
|
* Require.js is available
|
||||||
contentBuffer,
|
*/
|
||||||
characterWidth,
|
define(['../../src/xterm'], fit);
|
||||||
cols;
|
} else {
|
||||||
|
/*
|
||||||
|
* Plain browser environment
|
||||||
|
*/
|
||||||
|
fit(this.Xterm);
|
||||||
|
}
|
||||||
|
})(function (Xterm) {
|
||||||
|
Xterm.prototype.fit = function () {
|
||||||
|
var container = this.rowContainer,
|
||||||
|
subjectRow = this.rowContainer.firstElementChild,
|
||||||
|
rows,
|
||||||
|
contentBuffer,
|
||||||
|
characterWidth,
|
||||||
|
cols;
|
||||||
|
|
||||||
subjectRow.style.display = 'inline';
|
subjectRow.style.display = 'inline';
|
||||||
|
|
||||||
contentBuffer = subjectRow.textContent;
|
|
||||||
|
|
||||||
subjectRow.innerHTML = ' '; /* Arbitrary character to calculate its dimensions */
|
contentBuffer = subjectRow.textContent;
|
||||||
characterWidth = parseInt(subjectRow.offsetWidth);
|
|
||||||
characterHeight = parseInt(subjectRow.offsetHeight);
|
|
||||||
|
|
||||||
subjectRow.style.display = '';
|
subjectRow.innerHTML = ' '; /* Arbitrary character to calculate its dimensions */
|
||||||
|
characterWidth = parseInt(subjectRow.offsetWidth);
|
||||||
cols = container.offsetWidth / characterWidth;
|
characterHeight = parseInt(subjectRow.offsetHeight);
|
||||||
cols = parseInt(cols);
|
|
||||||
|
subjectRow.style.display = '';
|
||||||
var parentElementStyle = window.getComputedStyle(this.element.parentElement),
|
|
||||||
parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')),
|
cols = container.offsetWidth / characterWidth;
|
||||||
elementStyle = window.getComputedStyle(this.element),
|
cols = parseInt(cols);
|
||||||
elementPadding = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom')),
|
|
||||||
availableHeight = parentElementHeight - elementPadding,
|
var parentElementStyle = window.getComputedStyle(this.element.parentElement),
|
||||||
rowHeight = this.rowContainer.firstElementChild.offsetHeight;
|
parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')),
|
||||||
|
elementStyle = window.getComputedStyle(this.element),
|
||||||
rows = parseInt(availableHeight / rowHeight);
|
elementPadding = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom')),
|
||||||
|
availableHeight = parentElementHeight - elementPadding,
|
||||||
this.resize(cols, rows);
|
rowHeight = this.rowContainer.firstElementChild.offsetHeight;
|
||||||
};
|
|
||||||
|
rows = parseInt(availableHeight / rowHeight);
|
||||||
|
|
||||||
|
this.resize(cols, rows);
|
||||||
|
};
|
||||||
|
});
|
||||||
@@ -10,16 +10,30 @@
|
|||||||
* If the `fullscreen` argument has not been supplied, the
|
* If the `fullscreen` argument has not been supplied, the
|
||||||
* fullscreen mode is being toggled.
|
* fullscreen mode is being toggled.
|
||||||
*/
|
*/
|
||||||
Terminal.prototype.toggleFullscreen = function (fullscreen) {
|
(function (fullscreen) {
|
||||||
var fn;
|
if (typeof define == 'function') {
|
||||||
|
/*
|
||||||
if (typeof fullscreen == 'undefined') {
|
* Require.js is available
|
||||||
fn = (this.element.classList.contains('fullscreen')) ? 'remove' : 'add';
|
*/
|
||||||
} else if (!fullscreen) {
|
define(['../../src/xterm'], fullscreen);
|
||||||
fn = 'remove';
|
} else {
|
||||||
} else {
|
/*
|
||||||
fn = 'add';
|
* Plain browser environment
|
||||||
}
|
*/
|
||||||
|
fullscreen(this.Xterm);
|
||||||
this.element.classList[fn]('fullscreen');
|
}
|
||||||
}
|
})(function (Xterm) {
|
||||||
|
Xterm.prototype.toggleFullscreen = function (fullscreen) {
|
||||||
|
var fn;
|
||||||
|
|
||||||
|
if (typeof fullscreen == 'undefined') {
|
||||||
|
fn = (this.element.classList.contains('fullscreen')) ? 'remove' : 'add';
|
||||||
|
} else if (!fullscreen) {
|
||||||
|
fn = 'remove';
|
||||||
|
} else {
|
||||||
|
fn = 'add';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.element.classList[fn]('fullscreen');
|
||||||
|
};
|
||||||
|
});
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "xterm.js",
|
"name": "xterm.js",
|
||||||
"version": "0.16",
|
"version": "0.17",
|
||||||
"ignore": ["demo", "docs", "test", ".gitignore"]
|
"ignore": ["demo", "docs", "test", ".gitignore"]
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -51,9 +51,9 @@ copyright = u'2014, SourceLair Limited'
|
|||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '0.16'
|
version = '0.17'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = '0.16 Alpha'
|
release = '0.17 Alpha'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
|||||||
+4559
-4555
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user