Compare commits

...
19 Commits
Author SHA1 Message Date
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
paris d07f61314b Bump version to 0.14 2014-08-16 03:53:52 +00:00
paris 7355a04274 Further fixing of xterm.fit 2014-08-16 03:53:22 +00:00
paris 3a782972e3 Bump version to 0.13 2014-08-16 03:25:46 +00:00
paris d12406bedc Fix wrong behavior of fit add-on 2014-08-16 03:25:13 +00:00
paris 561fc59dbc Added screenshot for docs
Bumped version to 0.12
2014-05-03 00:30:04 +00:00
paris ce1d788efe Bumped bower version to 0.11 2014-05-02 23:45:20 +00:00
paris 01e48b7406 Revamped the attach addon
Also updated docs with proper attach url
2014-05-02 23:45:00 +00:00
paris a1717fdd8d Update docs index 2014-05-02 23:21:07 +00:00
paris c9f5f235e2 Started documenting methods
Also added Getting Started section in docs
2014-05-02 22:51:38 +00:00
paris 21dde3cfa2 Updated version, in docs 2014-05-02 22:34:15 +00:00
paris 73bf6d1ce8 Started documenting events 2014-05-02 18:57:48 +00:00
13 changed files with 4858 additions and 4619 deletions
+10 -3
View File
@@ -1,6 +1,13 @@
# xterm.js # xterm.js — xterm, in the browser
xterm, in the browser. 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 serves as the foundation for the terminal found at www.sourcelair.com.
![xterm.js screenshot](docs/screenshot.png)
### Contribution and License Agreement ### Contribution and License Agreement
@@ -10,5 +17,5 @@ all code is your original work.
## License ## License
Copyright (c) 2014, sourceLair Limited (www.sourcelair.com) (MIT License) Copyright (c) 2014, SourceLair, Limited (www.sourcelair.com) (MIT License)
Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
+17 -2
View File
@@ -5,7 +5,21 @@
* 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) {
(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; var term = this;
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional; bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
@@ -20,4 +34,5 @@ Terminal.prototype.attach = function (socket, bidirectional) {
socket.send(data); socket.send(data);
}); });
} }
} };
});
+55
View File
@@ -5,8 +5,61 @@
<link rel="stylesheet" href="../../demo/style.css" /> <link rel="stylesheet" href="../../demo/style.css" />
<script src="../../src/xterm.js"></script> <script src="../../src/xterm.js"></script>
<script src="attach.js"></script> <script src="attach.js"></script>
<style>
body {
color: #111;
}
h1, h2 {
color: #444;
border-bottom: 1px solid #ddd;
text-align: left;
}
form {
margin-bottom: 32px;
}
input, button {
line-height: 22px;
font-size: 16px;
display: inline-block;
border-radius: 2px;
border: 1px solid #ccc;
}
input {
height: 22px;
padding-left: 4px;
padding-right: 4px;
}
button {
height: 28px;
background-color: #ccc;
cursor: pointer;
color: #333;
}
.container {
max-width: 900px;
margin: 0 auto;
}
</style>
</head> </head>
<body> <body>
<div class="container">
<h1>
xterm.js: socket attach
</h1>
<p>
Attach the terminal to a WebSocket terminal stream with ease. Perfect for attaching to your
Docker containers.
</p>
<h2>
Socket information
</h2>
<form id="socket-form"> <form id="socket-form">
<input id="socket-url" <input id="socket-url"
type="text" type="text"
@@ -17,6 +70,8 @@
</button> </button>
</form> </form>
<div id="terminal-container"></div> <div id="terminal-container"></div>
</div>
<script> <script>
var term = new Terminal(), var term = new Terminal(),
container = document.getElementById('terminal-container'), container = document.getElementById('terminal-container'),
+37 -6
View File
@@ -11,18 +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.element.parentElement, 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, subjectRow = this.rowContainer.firstElementChild,
rows = parseInt(container.offsetHeight / subjectRow.offsetHeight), rows,
contentBuffer,
characterWidth, characterWidth,
cols; cols;
subjectRow.style.display = 'inline'; subjectRow.style.display = 'inline';
characterWidth = parseInt(subjectRow.offsetWidth / this.cols);
contentBuffer = subjectRow.textContent;
subjectRow.innerHTML = '&nbsp;'; /* Arbitrary character to calculate its dimensions */
characterWidth = parseInt(subjectRow.offsetWidth);
characterHeight = parseInt(subjectRow.offsetHeight);
subjectRow.style.display = ''; subjectRow.style.display = '';
cols = parseInt(container.offsetWidth / characterWidth); 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(cols, rows);
} };
});
+16 -2
View File
@@ -10,7 +10,20 @@
* 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) {
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; var fn;
if (typeof fullscreen == 'undefined') { if (typeof fullscreen == 'undefined') {
@@ -22,4 +35,5 @@ Terminal.prototype.toggleFullscreen = function (fullscreen) {
} }
this.element.classList[fn]('fullscreen'); this.element.classList[fn]('fullscreen');
} };
});
+1 -1
View File
@@ -1,5 +1,5 @@
{ {
"name": "xterm.js", "name": "xterm.js",
"version": "0.10", "version": "0.17",
"ignore": ["demo", "docs", "test", ".gitignore"] "ignore": ["demo", "docs", "test", ".gitignore"]
} }
+1 -1
View File
@@ -3,7 +3,7 @@
<head> <head>
<title>xterm.js demo</title> <title>xterm.js demo</title>
<link rel="stylesheet" href="../src/xterm.css" /> <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" /> <link rel="stylesheet" href="style.css" />
<script src="../src/xterm.js" ></script> <script src="../src/xterm.js" ></script>
<script src="../addons/fit/fit.js" ></script> <script src="../addons/fit/fit.js" ></script>
+3 -3
View File
@@ -44,16 +44,16 @@ master_doc = 'index'
# General information about the project. # General information about the project.
project = u'xterm.js' project = u'xterm.js'
copyright = u'2014, sourceLair Limited' copyright = u'2014, SourceLair Limited'
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.1a' version = '0.17'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.1a' 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.
+43
View File
@@ -0,0 +1,43 @@
------
Events
------
focus
^^^^^
This event is fired, when the Terminal gets focus.
blur
^^^^
This event is fired, when the Terminal loses focus.
open
^^^^
This event is fired, when the Terminal gets opened into a DOM Element.
keydown
^^^^^^^
This event is fired, when the `keydown` DOM Event gets triggered on the Terminal.
keypress
^^^^^^^^
This event is fired, when the `keypress` DOM Event gets triggered on the Terminal.
key
^^^
This event is fired, when a key is being handled by the Terminal.
resize
^^^^^^
This event is being fired, when the Terminal view gets resized by the `resize` method.
data
^^^^
This event is being fired, when a chunk of input data gets handled by the terminal.
copy
^^^^
This event is fired, when the `copy` DOM Event gets triggered on the Terminal.
paste
^^^^^
This event is fired, when the `paste` DOM Event gets triggered on the Terminal.
+34 -11
View File
@@ -6,17 +6,40 @@
Welcome to xterm.js's documentation! Welcome to xterm.js's documentation!
==================================== ====================================
Contents: This is the documentation for xterm.js. 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 serves as the foundation for the terminal found at www.sourcelair.com.
.. image:: screenshot.png
Getting started
^^^^^^^^^^^^^^^
.. code-block:: javascript
var term = new Terminal(),
url = 'ws://docker/containers/mycontainer/attach/ws/?stdin=1&stdout=1&stderr=1&logs=1',
socket = new WebSocket(url);
term.open(document.body);
term.on('data', function (data) {
socket.send(data);
});
socket.onmessage = function (e) {
term.write(e.data);
}
Contents
^^^^^^^^
The standard way to create a terminal-based application with xterm.js is to work with its events and
methods, that let you manipulate input, output, state and size of the terminal.
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 1
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
methods
events
+47
View File
@@ -0,0 +1,47 @@
-------
Methods
-------
focus()
^^^^^^^
Sends focus to the terminal
blur()
^^^^^^
Blurs the Terminal
open(element)
^^^^
Open the Xterm terminal, inside the given element.
resize(x, y)
^^^^^^^^^^^^
Resize the terminal, according to the given columns and rows.
insertRow(row)
^^^^^^^^^^^^^^
Insert the given row in the terminal.
on(event, callback)
^^^^^^^^^^^^^^^^^^^
Hook the given callback, to the given event.
off(event, callback)
^^^^^^^^^^^^^^^^^^^
Remove the Hook of the given callback, from the given event.
once(event, callback)
^^^^^^^^^^^^^^^^^^^
Hook the given callback to the given event, for just a single invocation.
write(data)
^^^^^^^^^^^
Write the given data to the terminal.
writeln(data)
^^^^^^^^^^^^^
Write the given data to the terminal, followed by a carriage return and a new line.
handler(data)
^^^^^^^^^^^^^
Fire the data event, for the given data.
Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

+19 -15
View File
@@ -31,8 +31,20 @@
* other features. * other features.
*/ */
;(function() { (function (xterm) {
if (typeof define == 'function') {
/*
* Require.js is available
*/
define([], xterm);
} else {
/*
* Plain browser environment
*/
this.Xterm = xterm.call(this);
this.Terminal = this.Xterm; /* Backwards compatibility with term.js */
}
})(function() {
/** /**
* Terminal Emulation References: * Terminal Emulation References:
* http://vt100.net/ * http://vt100.net/
@@ -50,8 +62,7 @@
* Shared * Shared
*/ */
var window = this var window = this, document = this.document;
, document = this.document;
/** /**
* EventEmitter * EventEmitter
@@ -916,9 +927,9 @@ Terminal.prototype.bindMouse = function() {
if (self.mouseEvents) return; if (self.mouseEvents) return;
if (self.applicationKeypad) return; if (self.applicationKeypad) return;
if (ev.type === 'DOMMouseScroll') { if (ev.type === 'DOMMouseScroll') {
self.scrollDisp(ev.detail < 0 ? -5 : 5); self.scrollDisp(ev.detail < 0 ? -1 : 1);
} else { } else {
self.scrollDisp(ev.wheelDeltaY > 0 ? -5 : 5); self.scrollDisp(ev.wheelDeltaY > 0 ? -1 : 1);
} }
return self.cancel(ev); return self.cancel(ev);
}); });
@@ -4763,12 +4774,5 @@ Terminal.on = on;
Terminal.off = off; Terminal.off = off;
Terminal.cancel = cancel; Terminal.cancel = cancel;
if (typeof module !== 'undefined') { return Terminal;
module.exports = Terminal; });
} else {
this.Terminal = Terminal;
}
}).call(function() {
return this || (typeof window !== 'undefined' ? window : global);
}());