This commit is contained in:
paris
2014-09-10 11:09:23 +00:00
parent ede9ee416a
commit 3f455f90d9
4 changed files with 4659 additions and 4612 deletions
+31 -16
View File
@@ -5,19 +5,34 @@
* The bidirectional argument indicates, whether the terminal should
* send data to the socket as well and is true, by default.
*/
Terminal.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);
});
}
}
(function (attach) {
if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../src/xterm'], attach);
} else {
/*
* Plain browser environment
*/
attach(this.Xterm);
}
})(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
View File
@@ -11,35 +11,49 @@
* terminal row and truncate its width with the current number
* of columns)
*/
Terminal.prototype.fit = function () {
var container = this.rowContainer,
subjectRow = this.rowContainer.firstElementChild,
rows,
contentBuffer,
characterWidth,
cols;
(function (fit) {
if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../src/xterm'], fit);
} 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';
contentBuffer = subjectRow.textContent;
subjectRow.style.display = 'inline';
subjectRow.innerHTML = ' '; /* Arbitrary character to calculate its dimensions */
characterWidth = parseInt(subjectRow.offsetWidth);
characterHeight = parseInt(subjectRow.offsetHeight);
contentBuffer = subjectRow.textContent;
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);
};
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);
};
});
+27 -13
View File
@@ -10,16 +10,30 @@
* If the `fullscreen` argument has not been supplied, the
* fullscreen mode is being toggled.
*/
Terminal.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');
}
(function (fullscreen) {
if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../src/xterm'], fullscreen);
} else {
/*
* Plain browser environment
*/
fullscreen(this.Xterm);
}
})(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');
};
});
+4558 -4554
View File
File diff suppressed because it is too large Load Diff