Compare commits

...
21 Commits
Author SHA1 Message Date
paris 87979aeed4 Bind window to AMD module
- Bind window to Xterm AMD module
- Fix typo in fit addon
- Bump version to 0.24
2014-11-17 12:28:52 +02:00
paris 615f633f25 [fit addon] Introduce proposeGeometry method
- Introduce new method to propose optimal geometry for the current terminal
- Bump version to 0.23
2014-11-17 12:21:05 +02:00
paris 567b39dc98 Fix #6 2014-09-22 05:48:05 +00:00
paris 0b2bdb182b Bump version to 0.22 2014-09-18 11:11:45 +00:00
paris 4ce1440fb8 [addon attach] Make reference to socket fail-safe 2014-09-18 11:11:29 +00:00
paris f24c020aca [addon attach] Fix reference error
Also bump version to 0.21
2014-09-18 10:15:10 +00:00
paris 3fca219404 [addon attach] Implement detach method (Bump to 0.20) 2014-09-18 10:02:29 +00:00
paris 6906bf3e7d Implement detach function 2014-09-18 10:01:54 +00:00
paris 670efc4454 Bump Bower version to 0.19 2014-09-18 09:06:53 +00:00
paris 74f9526177 [addon attach] Implement auto-detaching on socket close/error 2014-09-18 09:06:23 +00:00
paris 28b553caa6 Bump version to 0.18 2014-09-15 13:52:20 +00:00
paris 22ff176c6a Fix #5 2014-09-15 13:51:42 +00:00
paris d24e00554d Tiny README updates 2014-09-10 11:15:24 +00:00
paris bc67c788d2 Bump version to 0.17 2014-09-10 11:09:59 +00:00
paris 3f455f90d9 Fix #4 2014-09-10 11:09:23 +00:00
paris ede9ee416a Bump version to 0.16 2014-08-29 09:58:27 +00:00
paris 53f5672524 Fix #3 2014-08-29 09:57:53 +00:00
paris 9d00eec6c4 Fix #2 2014-08-27 09:50:09 +00:00
paris 3b1f1ddb2d Bump version to 0.15 2014-08-19 13:25:27 +00:00
paris a249d2714f Fix terminal fitting height 2014-08-19 13:24:43 +00:00
Paris Kasidiaris 3d40dcf3c5 Update company name 2014-08-18 11:00:49 +03:00
10 changed files with 4713 additions and 4619 deletions
+5 -7
View File
@@ -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.
![xterm.js screenshot](docs/screenshot.png)
### 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)
+52 -16
View File
@@ -5,19 +5,55 @@
* 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;
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', 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;
};
});
+55 -20
View File
@@ -11,25 +11,60 @@
* 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 = parseInt(container.offsetHeight / subjectRow.offsetHeight),
contentBuffer,
characterWidth,
cols;
subjectRow.style.display = 'inline';
contentBuffer = subjectRow.textContent;
(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.proposeGeometry = function () {
var container = this.rowContainer,
subjectRow = this.rowContainer.firstElementChild,
rows,
contentBuffer,
characterWidth,
cols;
subjectRow.textContent = ' ';
characterWidth = parseInt(subjectRow.offsetWidth);
subjectRow.style.display = 'inline';
subjectRow.style.display = '';
cols = container.offsetWidth / characterWidth;
cols = parseInt(cols);
this.resize(cols, rows);
};
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 geometry = this.proposeGeometry();
this.resize(geometry.cols, geometry.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');
};
});
+1 -1
View File
@@ -1,5 +1,5 @@
{
"name": "xterm.js",
"version": "0.14",
"version": "0.24",
"ignore": ["demo", "docs", "test", ".gitignore"]
}
+1 -1
View File
@@ -3,7 +3,7 @@
<head>
<title>xterm.js demo</title>
<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" />
<script src="../src/xterm.js" ></script>
<script src="../addons/fit/fit.js" ></script>
+10 -4
View File
@@ -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
View File
@@ -51,9 +51,9 @@ copyright = u'2014, SourceLair Limited'
# built documents.
#
# The short X.Y version.
version = '0.14'
version = '0.24'
# The full version, including alpha/beta/rc tags.
release = '0.14 Alpha'
release = '0.24 Alpha'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
+1
View File
@@ -45,6 +45,7 @@
.xterm .terminal-cursor {
background-color: #fff;
color: #000;
}
.xterm .xterm-helpers {
+4559 -4555
View File
File diff suppressed because it is too large Load Diff