sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
term.js File Reference

Functions

function EventEmitter ()
 
function Stream ()
 
 inherits (Stream, EventEmitter)
 
function Terminal (options)
 
 each (keys(Terminal.defaults), function(key){Terminal[key]=Terminal.defaults[key];Terminal.options[key]=Terminal.defaults[key];})
 

Variables

function use strict
 
var window = this
 
var document = this.document
 
EventEmitter prototype addListener
 
EventEmitter prototype on = EventEmitter.prototype.addListener
 
EventEmitter prototype removeListener
 
EventEmitter prototype off = EventEmitter.prototype.removeListener
 
EventEmitter prototype removeAllListeners
 
EventEmitter prototype once
 
EventEmitter prototype emit
 
EventEmitter prototype listeners
 
Stream prototype pipe
 
var normal = 0
 
var escaped = 1
 
var csi = 2
 
var osc = 3
 
var charset = 4
 
var dcs = 5
 
var ignore = 6
 
var UDK = { type: 'udk' }
 
Terminal tangoColors
 
Terminal xtermColors
 
Terminal colors
 
Terminal _colors = Terminal.colors.slice()
 
Terminal vcolors
 
Terminal defaults
 
Terminal options = {}
 
Terminal focus = null
 
Terminal prototype blur
 
Terminal prototype initGlobal
 
Terminal bindPaste
 
Terminal bindKeys
 
Terminal bindCopy
 
Terminal prototype fixMobile
 
Terminal insertStyle
 
Terminal prototype open
 
Terminal prototype setRawMode
 
Terminal prototype bindMouse
 
Terminal prototype close
 
Terminal prototype refresh
 
Terminal prototype _cursorBlink
 
Terminal prototype showCursor
 
Terminal prototype startBlink
 
Terminal prototype refreshBlink
 
Terminal prototype scroll
 
Terminal prototype scrollDisp
 

Function Documentation

each ( keys(Terminal.defaults ,
function(key){Terminal[key]=Terminal.defaults[key];Terminal.options[key]=Terminal.defaults[key];}   
)
function EventEmitter ( )

EventEmitter

inherits ( Stream  ,
EventEmitter   
)
function Stream ( )

Stream

function Terminal (   options)

Terminal

Variable Documentation

Terminal _colors = Terminal.colors.slice()
Terminal prototype _cursorBlink
Initial value:
= function() {
if (Terminal.focus !== this) return;
this.cursorState ^= 1;
this.refresh(this.y, this.y);
}
function Terminal(options)
Definition: term.js:182
Terminal prototype refresh
Definition: term.js:1288
static __inline__ uint32_t uint32_t y
Definition: arm_acle.h:113
EventEmitter prototype addListener
Initial value:
= function(type, listener) {
this._events[type] = this._events[type] || [];
this._events[type].push(listener);
}
Terminal bindCopy

Copy Selection w/ Ctrl-C (Select Mode)

Terminal bindKeys

Global Events for key handling

Terminal prototype bindMouse
Terminal bindPaste
Initial value:
= function(document) {
var window = document.defaultView;
on(window, 'paste', function(ev) {
var term = Terminal.focus;
if (!term) return;
if (ev.clipboardData) {
term.send(ev.clipboardData.getData('text/plain'));
} else if (term.context.clipboardData) {
term.send(term.context.clipboardData.getData('Text'));
}
term.element.contentEditable = 'inherit';
return cancel(ev);
});
}
var window
Definition: term.js:52
function Terminal(options)
Definition: term.js:182
var document
Definition: term.js:53
EventEmitter prototype on
Definition: term.js:68

Bind to paste event

Terminal prototype blur
Initial value:
= function() {
if (Terminal.focus !== this) return;
this.cursorState = 0;
this.refresh(this.y, this.y);
if (this.sendFocus) this.send('\x1b[O');
Terminal.focus = null;
}
function Terminal(options)
Definition: term.js:182
Terminal prototype refresh
Definition: term.js:1288
static __inline__ uint32_t uint32_t y
Definition: arm_acle.h:113
var charset = 4
Terminal prototype close
Initial value:
=
Terminal.prototype.destroySoon =
Terminal.prototype.destroy = function() {
if (this.destroyed) {
return;
}
if (this._blink) {
clearInterval(this._blink);
delete this._blink;
}
this.readable = false;
this.writable = false;
this.destroyed = true;
this._events = {};
this.handler = function() {};
this.write = function() {};
this.end = function() {};
if (this.element.parentNode) {
this.element.parentNode.removeChild(this.element);
}
this.emit('end');
this.emit('close');
this.emit('finish');
this.emit('destroy');
}
function Terminal(options)
Definition: term.js:182
def write
Definition: ow-slave-test.py:28
EventEmitter prototype emit
Definition: term.js:100

Destroy Terminal

Terminal colors
Initial value:
= (function() {
var colors = Terminal.tangoColors.slice()
, r = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff]
, i;
i = 0;
for (; i < 216; i++) {
out(r[(i / 36) % 6 | 0], r[(i / 6) % 6 | 0], r[i % 6]);
}
i = 0;
for (; i < 24; i++) {
r = 8 + i * 10;
out(r, r, r);
}
function out(r, g, b) {
colors.push('#' + hex(r) + hex(g) + hex(b));
}
function hex(c) {
c = c.toString(16);
return c.length < 2 ? '0' + c : c;
}
return colors;
})()
Terminal colors
Definition: term.js:378
function Terminal(options)
Definition: term.js:182
string out
Definition: rf-id-control.py:34
int32_t int16_t b
Definition: IMU.cpp:172
return r
Definition: IMU.cpp:176
int i
Definition: ser-log.py:25
var csi = 2
var dcs = 5
Terminal defaults
Initial value:
= {
colors: Terminal.colors,
convertEol: false,
termName: 'xterm',
geometry: [80, 24],
cursorBlink: true,
visualBell: false,
popOnBell: false,
scrollback: 1000,
screenKeys: false,
debug: false,
useStyle: false
}
Terminal colors
Definition: term.js:378
function Terminal(options)
Definition: term.js:182
int16_t debug[4]
Definition: MultiWii.cpp:188

Options

var document = this.document
EventEmitter prototype emit
Initial value:
= function(type) {
if (!this._events[type]) return;
var args = Array.prototype.slice.call(arguments, 1)
, obj = this._events[type]
, l = obj.length
, i = 0;
for (; i < l; i++) {
obj[i].apply(this, args);
}
}
int i
Definition: ser-log.py:25
var escaped = 1
Terminal prototype fixMobile

Fix Mobile

Terminal prototype focus = null

Focused Terminal

var ignore = 6
Terminal prototype initGlobal
Initial value:
= function() {
var document = this.document;
Terminal._boundDocs = Terminal._boundDocs || [];
if (~indexOf(Terminal._boundDocs, document)) {
return;
}
Terminal._boundDocs.push(document);
Terminal.bindPaste(document);
Terminal.bindKeys(document);
Terminal.bindCopy(document);
if (this.isMobile) {
this.fixMobile(document);
}
if (this.useStyle) {
Terminal.insertStyle(document, this.colors[256], this.colors[257]);
}
}
Terminal colors
Definition: term.js:378
function Terminal(options)
Definition: term.js:182
Terminal prototype fixMobile
Definition: term.js:663
var document
Definition: term.js:53

Initialize global behavior

Terminal insertStyle

Insert a default style

EventEmitter prototype listeners
Initial value:
= function(type) {
return this._events[type] = this._events[type] || [];
}
var normal = 0

States

EventEmitter prototype once
Initial value:
= function(type, listener) {
function on() {
var args = Array.prototype.slice.call(arguments);
this.removeListener(type, on);
return listener.apply(this, args);
}
on.listener = listener;
return this.on(type, on);
}
EventEmitter prototype removeListener
Definition: term.js:70
EventEmitter prototype on
Definition: term.js:68
Terminal prototype open

Open Terminal

Terminal options = {}
var osc = 3
Stream prototype pipe
Terminal prototype refresh

Rendering Engine

Terminal prototype refreshBlink
Initial value:
= function() {
if (!this.cursorBlink || !this._blink) return;
clearInterval(this._blink);
this._blink = setInterval(this._blinker, 500);
}
EventEmitter prototype removeAllListeners
Initial value:
= function(type) {
if (this._events[type]) delete this._events[type];
}
EventEmitter prototype removeListener
Initial value:
= function(type, listener) {
if (!this._events[type]) return;
var obj = this._events[type]
, i = obj.length;
while (i--) {
if (obj[i] === listener || obj[i].listener === listener) {
obj.splice(i, 1);
return;
}
}
}
int i
Definition: ser-log.py:25
Terminal prototype scroll
Terminal prototype scrollDisp
Initial value:
= function(disp) {
this.ydisp += disp;
if (this.ydisp > this.ybase) {
this.ydisp = this.ybase;
} else if (this.ydisp < 0) {
this.ydisp = 0;
}
this.refresh(0, this.rows - 1);
}
Terminal prototype refresh
Definition: term.js:1288
Terminal prototype setRawMode
Initial value:
= function(value) {
this.isRaw = !!value;
}
Terminal prototype showCursor
Initial value:
= function() {
if (!this.cursorState) {
this.cursorState = 1;
this.refresh(this.y, this.y);
} else {
}
}
Terminal prototype refresh
Definition: term.js:1288
static __inline__ uint32_t uint32_t y
Definition: arm_acle.h:113
Terminal prototype startBlink
Initial value:
= function() {
if (!this.cursorBlink) return;
var self = this;
this._blinker = function() {
self._cursorBlink();
};
this._blink = setInterval(this._blinker, 500);
}
function use strict

term.js - an xterm emulator Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) https://github.com/chjj/term.js

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Originally forked from (with the author's permission): Fabrice Bellard's javascript vt100 for jslinux: http://bellard.org/jslinux/ Copyright (c) 2011 Fabrice Bellard The original design remains. The terminal itself has been extended to include xterm CSI codes, among other features. Terminal Emulation References: http://vt100.net/ http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt http://invisible-island.net/xterm/ctlseqs/ctlseqs.html http://invisible-island.net/vttest/ http://www.inwap.com/pdp10/ansicode.txt http://linux.die.net/man/4/console_codes http://linux.die.net/man/7/urxvt

Terminal tangoColors
Initial value:
= [
'#2e3436',
'#cc0000',
'#4e9a06',
'#c4a000',
'#3465a4',
'#75507b',
'#06989a',
'#d3d7cf',
'#555753',
'#ef2929',
'#8ae234',
'#fce94f',
'#729fcf',
'#ad7fa8',
'#34e2e2',
'#eeeeec'
]

Colors

var UDK = { type: 'udk' }
Terminal vcolors
Initial value:
= (function() {
var out = []
, colors = Terminal.colors
, i = 0
, color;
for (; i < 256; i++) {
color = parseInt(colors[i].substring(1), 16);
out.push([
(color >> 16) & 0xff,
(color >> 8) & 0xff,
color & 0xff
]);
}
return out;
})()
Terminal colors
Definition: term.js:378
function Terminal(options)
Definition: term.js:182
string out
Definition: rf-id-control.py:34
int i
Definition: ser-log.py:25
var window = this

Shared

Terminal xtermColors
Initial value:
= [
'#000000',
'#cd0000',
'#00cd00',
'#cdcd00',
'#0000ee',
'#cd00cd',
'#00cdcd',
'#e5e5e5',
'#7f7f7f',
'#ff0000',
'#00ff00',
'#ffff00',
'#5c5cff',
'#ff00ff',
'#00ffff',
'#ffffff'
]