Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87979aeed4 | ||
|
|
615f633f25 | ||
|
|
567b39dc98 | ||
|
|
0b2bdb182b | ||
|
|
4ce1440fb8 | ||
|
|
f24c020aca | ||
|
|
3fca219404 | ||
|
|
6906bf3e7d | ||
|
|
670efc4454 | ||
|
|
74f9526177 | ||
|
|
28b553caa6 | ||
|
|
22ff176c6a | ||
|
|
d24e00554d |
@@ -2,20 +2,18 @@
|
||||
|
||||
Xterm.js is a full xterm clone, written completely in JavaScript.
|
||||
|
||||
Xterm.js supplies a modular, event-based interface that lets developers build addons and themes that augment
|
||||
the experience of running a fully-feature terminal inside the browser.
|
||||
Xterm.js supplies a modular, event-based interface that lets developers build addons and themes that augment the experience of running a fully-featured terminal inside the browser.
|
||||
|
||||
Xterm.js serves as the foundation for the terminal found at www.sourcelair.com.
|
||||
Xterm.js serves as foundation for the terminal found at www.sourcelair.com.
|
||||
|
||||

|
||||
|
||||
### Contribution and License Agreement
|
||||
|
||||
If you contribute code to this project, you are implicitly allowing your code
|
||||
to be distributed under the MIT license. You are also implicitly verifying that
|
||||
all code is your original work.
|
||||
If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work.
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2014, SourceLair, Limited (www.sourcelair.com) (MIT License)
|
||||
Copyright (c) 2014, SourceLair, Ltd (www.sourcelair.com) (MIT License)
|
||||
|
||||
Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
||||
|
||||
+26
-5
@@ -25,14 +25,35 @@
|
||||
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
|
||||
this.socket = socket;
|
||||
|
||||
socket.addEventListener('message', function (ev) {
|
||||
term._getMessage = function (ev) {
|
||||
term.write(ev.data);
|
||||
});
|
||||
};
|
||||
|
||||
term._sendData = function (data) {
|
||||
socket.send(data);
|
||||
};
|
||||
|
||||
socket.addEventListener('message', term._getMessage);
|
||||
|
||||
if (bidirectional) {
|
||||
this.on('data', function (data) {
|
||||
socket.send(data);
|
||||
});
|
||||
this.on('data', term._sendData);
|
||||
}
|
||||
|
||||
socket.addEventListener('close', term.detach.bind(term, socket));
|
||||
socket.addEventListener('error', term.detach.bind(term, socket));
|
||||
};
|
||||
|
||||
Xterm.prototype.detach = function (socket) {
|
||||
var term = this;
|
||||
|
||||
term.off('data', term._sendData);
|
||||
|
||||
socket = (typeof socket == 'undefined') ? term.socket : socket;
|
||||
|
||||
if (socket) {
|
||||
socket.removeEventListener('message', term._getMessage);
|
||||
}
|
||||
|
||||
delete term.socket;
|
||||
};
|
||||
});
|
||||
+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': rows
|
||||
};
|
||||
|
||||
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.17",
|
||||
"version": "0.24",
|
||||
"ignore": ["demo", "docs", "test", ".gitignore"]
|
||||
}
|
||||
|
||||
+10
-4
@@ -1,12 +1,13 @@
|
||||
var terminalContainer = document.getElementById('terminal-container'),
|
||||
term = new Terminal();
|
||||
term = new Terminal(),
|
||||
prompt = '> ';
|
||||
|
||||
term.open(terminalContainer);
|
||||
term.fit();
|
||||
|
||||
term.prompt = function () {
|
||||
term.write('\r\n> ');
|
||||
}
|
||||
term.write('\r\n' + prompt);
|
||||
};
|
||||
|
||||
term.writeln('Welcome to xterm.js');
|
||||
term.writeln('Just type some keys in the prompt below.');
|
||||
@@ -19,7 +20,12 @@ term.on('key', function (key, ev) {
|
||||
if (ev.keyIdentifier == 'Enter') {
|
||||
term.prompt();
|
||||
} else if (ev.keyCode == 8) {
|
||||
term.write('\b \b');
|
||||
/*
|
||||
* Do not delete the prompt
|
||||
*/
|
||||
if (term.x > 2) {
|
||||
term.write('\b \b');
|
||||
}
|
||||
} else if (printable) {
|
||||
term.write(key);
|
||||
}
|
||||
|
||||
+2
-2
@@ -51,9 +51,9 @@ copyright = u'2014, SourceLair Limited'
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.17'
|
||||
version = '0.24'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.17 Alpha'
|
||||
release = '0.24 Alpha'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
|
||||
.xterm .terminal-cursor {
|
||||
background-color: #fff;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.xterm .xterm-helpers {
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
/*
|
||||
* Require.js is available
|
||||
*/
|
||||
define([], xterm);
|
||||
define([], xterm.bind(window));
|
||||
} else {
|
||||
/*
|
||||
* Plain browser environment
|
||||
|
||||
Reference in New Issue
Block a user