Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51fe17ee43 | ||
|
|
1d5737f843 | ||
|
|
13103aecb2 | ||
|
|
e9d2c806ba | ||
|
|
932ab00a53 | ||
|
|
6cfd957697 | ||
|
|
f00d8964c2 | ||
|
|
9ef6b52352 |
+64
-28
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Implements the attach method, that
|
* Implements the attach method, that
|
||||||
* attaches the terminal to a WebSocket stream.
|
* attaches the terminal to a WebSocket stream.
|
||||||
*
|
*
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
@@ -15,45 +15,81 @@
|
|||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Plain browser environment
|
* Plain browser environment
|
||||||
*/
|
*/
|
||||||
attach(this.Xterm);
|
attach(this.Xterm);
|
||||||
}
|
}
|
||||||
})(function (Xterm) {
|
})(function (Xterm) {
|
||||||
Xterm.prototype.attach = function (socket, bidirectional) {
|
/**
|
||||||
var term = this;
|
* Attaches the current terminal to the given socket
|
||||||
|
*
|
||||||
|
* @param {WebSocket} socket - The socket to attach the current terminal
|
||||||
|
* @param {boolean} bidirectional - Whether the terminal should send data
|
||||||
|
* to the socket as well
|
||||||
|
* @param {boolean} buffered - Whether the rendering of incoming data
|
||||||
|
* should happen instantly or at a maximum
|
||||||
|
* frequency of 1 rendering per 10ms
|
||||||
|
*/
|
||||||
|
Xterm.prototype.attach = function (socket, bidirectional, buffered) {
|
||||||
|
var term = this;
|
||||||
|
|
||||||
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
|
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
|
|
||||||
term._getMessage = function (ev) {
|
term._flushBuffer = function () {
|
||||||
term.write(ev.data);
|
term.write(term._attachSocketBuffer);
|
||||||
};
|
term._attachSocketBuffer = null;
|
||||||
|
clearTimeout(term._attachSocketBufferTimer);
|
||||||
term._sendData = function (data) {
|
term._attachSocketBufferTimer = null;
|
||||||
socket.send(data);
|
};
|
||||||
};
|
|
||||||
|
|
||||||
socket.addEventListener('message', term._getMessage);
|
term._pushToBuffer = function (data) {
|
||||||
|
if (term._attachSocketBuffer) {
|
||||||
|
term._attachSocketBuffer += data;
|
||||||
|
} else {
|
||||||
|
term._attachSocketBuffer = data;
|
||||||
|
setTimeout(term._flushBuffer, 10);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (bidirectional) {
|
term._getMessage = function (ev) {
|
||||||
this.on('data', term._sendData);
|
if (buffered) {
|
||||||
}
|
term._pushToBuffer(ev.data);
|
||||||
|
} else {
|
||||||
socket.addEventListener('close', term.detach.bind(term, socket));
|
term.write(ev.data);
|
||||||
socket.addEventListener('error', term.detach.bind(term, socket));
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detaches the current terminal from the given socket
|
||||||
|
*
|
||||||
|
* @param {WebSocket} socket - The socket from which to detach the current
|
||||||
|
* terminal
|
||||||
|
*/
|
||||||
Xterm.prototype.detach = function (socket) {
|
Xterm.prototype.detach = function (socket) {
|
||||||
var term = this;
|
var term = this;
|
||||||
|
|
||||||
term.off('data', term._sendData);
|
term.off('data', term._sendData);
|
||||||
|
|
||||||
socket = (typeof socket == 'undefined') ? term.socket : socket;
|
socket = (typeof socket == 'undefined') ? term.socket : socket;
|
||||||
|
|
||||||
if (socket) {
|
if (socket) {
|
||||||
socket.removeEventListener('message', term._getMessage);
|
socket.removeEventListener('message', term._getMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete term.socket;
|
delete term.socket;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "xterm.js",
|
"name": "xterm.js",
|
||||||
"version": "0.27",
|
"version": "0.30",
|
||||||
"ignore": ["demo", "docs", "test", ".gitignore"]
|
"ignore": ["demo", "docs", "test", ".gitignore"]
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -51,9 +51,9 @@ copyright = u'2015, SourceLair Limited'
|
|||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '0.29'
|
version = '0.30'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = '0.29 Alpha'
|
release = '0.30 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.
|
||||||
|
|||||||
@@ -2201,6 +2201,7 @@
|
|||||||
// left-arrow
|
// left-arrow
|
||||||
case 37:
|
case 37:
|
||||||
if (ev.altKey) {
|
if (ev.altKey) {
|
||||||
|
this.cancel(ev, true);
|
||||||
key = '\x1bb' // Jump a word back
|
key = '\x1bb' // Jump a word back
|
||||||
break;
|
break;
|
||||||
} else if (this.applicationCursor) {
|
} else if (this.applicationCursor) {
|
||||||
@@ -2212,6 +2213,7 @@
|
|||||||
// right-arrow
|
// right-arrow
|
||||||
case 39:
|
case 39:
|
||||||
if (ev.altKey) {
|
if (ev.altKey) {
|
||||||
|
this.cancel(ev, true);
|
||||||
key = '\x1bf' // Jump a word forward
|
key = '\x1bf' // Jump a word forward
|
||||||
break;
|
break;
|
||||||
} else if (this.applicationCursor) {
|
} else if (this.applicationCursor) {
|
||||||
|
|||||||
Reference in New Issue
Block a user