[attach addon] Improve documentation
This commit is contained in:
+47
-13
@@ -19,21 +19,30 @@
|
|||||||
attach(this.Xterm);
|
attach(this.Xterm);
|
||||||
}
|
}
|
||||||
})(function (Xterm) {
|
})(function (Xterm) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attaches the current terminal to the given socket
|
* This module provides methods for attaching a terminal to a WebSocket
|
||||||
|
* stream.
|
||||||
*
|
*
|
||||||
* @param {WebSocket} socket - The socket to attach the current terminal
|
* @module xterm/addons/attach/attach
|
||||||
|
*/
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attaches the given terminal to the given socket.
|
||||||
|
*
|
||||||
|
* @param {Xterm} term - The terminal to be attached to the given socket.
|
||||||
|
* @param {WebSocket} socket - The socket to attach the current terminal.
|
||||||
* @param {boolean} bidirectional - Whether the terminal should send data
|
* @param {boolean} bidirectional - Whether the terminal should send data
|
||||||
* to the socket as well
|
* to the socket as well.
|
||||||
* @param {boolean} buffered - Whether the rendering of incoming data
|
* @param {boolean} buffered - Whether the rendering of incoming data
|
||||||
* should happen instantly or at a maximum
|
* should happen instantly or at a maximum
|
||||||
* frequency of 1 rendering per 10ms
|
* frequency of 1 rendering per 10ms.
|
||||||
*/
|
*/
|
||||||
Xterm.prototype.attach = function (socket, bidirectional, buffered) {
|
exports.attach = function (term, socket, biderectional, buffered) {
|
||||||
var term = this;
|
|
||||||
|
|
||||||
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
|
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
|
||||||
this.socket = socket;
|
term.socket = socket;
|
||||||
|
|
||||||
term._flushBuffer = function () {
|
term._flushBuffer = function () {
|
||||||
term.write(term._attachSocketBuffer);
|
term.write(term._attachSocketBuffer);
|
||||||
@@ -74,14 +83,13 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detaches the current terminal from the given socket
|
* Detaches the given terminal from the given socket
|
||||||
*
|
*
|
||||||
|
* @param {Xterm} term - The terminal to be detached from the given socket.
|
||||||
* @param {WebSocket} socket - The socket from which to detach the current
|
* @param {WebSocket} socket - The socket from which to detach the current
|
||||||
* terminal
|
* terminal.
|
||||||
*/
|
*/
|
||||||
Xterm.prototype.detach = function (socket) {
|
exports.detach = function (term, socket) {
|
||||||
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;
|
||||||
@@ -92,4 +100,30 @@
|
|||||||
|
|
||||||
delete term.socket;
|
delete term.socket;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
return exports.attach(this, socket, bidirectional, buffered);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
return exports.detach(this, socket);
|
||||||
|
};
|
||||||
|
|
||||||
|
return exports;
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user