Updated LICENSE and REAMDE

Also removed useless files.
This commit is contained in:
paris
2014-03-24 16:11:27 +00:00
parent 36c6036d67
commit b621669af4
9 changed files with 3 additions and 367 deletions
-12
View File
@@ -1,12 +0,0 @@
.git*
build/
.lock-wscript
out/
Makefile.gyp
*.Makefile
*.target.gyp.mk
node_modules/
img/
test/
*.node
example/*.log
+1
View File
@@ -1,3 +1,4 @@
Copyright (c) 2014, sourceLair Limited (https://github.com/sourcelair/)
Copyright (c) 2012-2013, Christopher Jeffrey (https://github.com/chjj/)
Permission is hereby granted, free of charge, to any person obtaining a copy
-12
View File
@@ -1,12 +0,0 @@
all:
@cp src/term.js term.js
@uglifyjs -o term.min.js term.js
clean:
@rm term.js
@rm term.min.js
bench:
@node test/bench
.PHONY: clean all
+2 -70
View File
@@ -1,74 +1,6 @@
# term.js
# xterm.js
A full xterm clone written in javascript. Used by
[**tty.js**](https://github.com/chjj/tty.js).
## Example
Server:
``` js
var term = require('term.js');
app.use(term.middleware());
...
```
Client:
``` js
window.addEventListener('load', function() {
var socket = io.connect();
socket.on('connect', function() {
var term = new Terminal({
cols: 80,
rows: 24,
screenKeys: true
});
term.on('data', function(data) {
socket.emit('data', data);
});
term.on('title', function(title) {
document.title = title;
});
term.open(document.body);
term.write('\x1b[31mWelcome to term.js!\x1b[m\r\n');
socket.on('data', function(data) {
term.write(data);
});
socket.on('disconnect', function() {
term.destroy();
});
});
}, false);
```
## Tmux-like
While term.js has always supported copy/paste using the mouse, it now also
supports several keyboard based solutions for copy/paste.
term.js includes a tmux-like selection mode (enabled with the `screenKeys`
option) which makes copy and paste very simple. `Ctrl-A` enters `prefix` mode,
from here you can type `Ctrl-V` to paste. Press `[` in prefix mode to enter
selection mode. To select text press `v` (or `space`) to enter visual mode, use
`hjkl` to navigate and create a selection, and press `Ctrl-C` to copy.
`Ctrl-C` (in visual mode) and `Ctrl-V` (in prefix mode) should work in any OS
for copy and paste. `y` (in visual mode) will work for copying only on X11
systems. It will copy to the primary selection.
Note: `Ctrl-C` will also work in prefix mode for the regular OS/browser
selection. If you want to select text with your mouse and copy it to the
clipboard, simply select the text and type `Ctrl-A + Ctrl-C`, and
`Ctrl-A + Ctrl-V` to paste it.
For mac users: consider `Ctrl` to be `Command/Apple` above.
xterm, in the browser.
### Contribution and License Agreement
-70
View File
@@ -1,70 +0,0 @@
<!doctype html>
<title>term.js</title>
<!--
term.js
Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
-->
<style>
html {
background: #555;
}
h1 {
margin-bottom: 20px;
font: 20px/1.5 sans-serif;
}
/*
.terminal {
float: left;
border: #000 solid 5px;
font-family: "DejaVu Sans Mono", "Liberation Mono", monospace;
font-size: 11px;
color: #f0f0f0;
background: #000;
}
.terminal-cursor {
color: #000;
background: #f0f0f0;
}
*/
</style>
<h1>term.js</h1>
<script src="/socket.io/socket.io.js"></script>
<script src="term.js"></script>
<script>
;(function() {
window.onload = function() {
var socket = io.connect();
socket.on('connect', function() {
var term = new Terminal({
cols: 80,
rows: 24,
useStyle: true,
screenKeys: true
});
term.on('data', function(data) {
socket.emit('data', data);
});
term.on('title', function(title) {
document.title = title;
});
term.open(document.body);
term.write('\x1b[31mWelcome to term.js!\x1b[m\r\n');
socket.on('data', function(data) {
term.write(data);
});
socket.on('disconnect', function() {
term.destroy();
});
});
};
}).call(this);
</script>
-128
View File
@@ -1,128 +0,0 @@
#!/usr/bin/env node
/**
* term.js
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
*/
var http = require('http')
, express = require('express')
, io = require('socket.io')
, pty = require('pty.js')
, terminal = require('../');
/**
* term.js
*/
process.title = 'term.js';
/**
* Dump
*/
var stream;
if (process.argv[2] === '--dump') {
stream = require('fs').createWriteStream(__dirname + '/dump.log');
}
/**
* Open Terminal
*/
var buff = []
, socket
, term;
term = pty.fork(process.env.SHELL || 'sh', [], {
name: require('fs').existsSync('/usr/share/terminfo/x/xterm-256color')
? 'xterm-256color'
: 'xterm',
cols: 80,
rows: 24,
cwd: process.env.HOME
});
term.on('data', function(data) {
if (stream) stream.write('OUT: ' + data + '\n-\n');
return !socket
? buff.push(data)
: socket.emit('data', data);
});
console.log(''
+ 'Created shell with pty master/slave'
+ ' pair (master: %d, pid: %d)',
term.fd, term.pid);
/**
* App & Server
*/
var app = express()
, server = http.createServer(app);
app.use(function(req, res, next) {
var setHeader = res.setHeader;
res.setHeader = function(name) {
switch (name) {
case 'Cache-Control':
case 'Last-Modified':
case 'ETag':
return;
}
return setHeader.apply(res, arguments);
};
next();
});
app.use(express.basicAuth(function(user, pass, next) {
if (user !== 'foo' || pass !== 'bar') {
return next(true);
}
return next(null, user);
}));
app.use(express.static(__dirname));
app.use(terminal.middleware());
if (!~process.argv.indexOf('-n')) {
server.on('connection', function(socket) {
var address = socket.remoteAddress;
if (address !== '127.0.0.1' && address !== '::1') {
try {
socket.destroy();
} catch (e) {
;
}
console.log('Attempted connection from %s. Refused.', address);
}
});
}
server.listen(8080);
/**
* Sockets
*/
io = io.listen(server, {
log: false
});
io.sockets.on('connection', function(sock) {
socket = sock;
socket.on('data', function(data) {
if (stream) stream.write('IN: ' + data + '\n-\n');
term.write(data);
});
socket.on('disconnect', function() {
socket = null;
});
while (buff.length) {
socket.emit('data', buff.shift());
}
});
-1
View File
@@ -1 +0,0 @@
module.exports = require('./lib/index.js');
-55
View File
@@ -1,55 +0,0 @@
/**
* term.js - an xterm emulator
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
* https://github.com/chjj/term.js
*/
function term(options) {
return new term.Terminal(options);
}
term.middleware = function(options) {
var url = require('url');
options = options || {};
options.path = options.path || '/term.js';
return function(req, res, next) {
if (url.parse(req.url).pathname !== options.path) {
return next();
}
if (+new Date(req.headers['if-modified-since']) === term.last) {
res.statusCode = 304;
res.end();
return;
}
res.writeHead(200, {
'Content-Type': 'application/javascript; charset=utf-8',
'Content-Length': Buffer.byteLength(term.script),
'Last-Modified': term.last
});
res.end(term.script);
};
};
term.path = __dirname + '/../src/term.js';
term.__defineGetter__('script', function() {
if (term._script) return term._script;
term.last = +new Date;
return term._script = require('fs').readFileSync(term.path, 'utf8');
});
term.__defineGetter__('Terminal', function() {
if (term._Terminal) return term._Terminal;
return term._Terminal = require('../src/term');
});
/**
* Expose
*/
module.exports = term;
-19
View File
@@ -1,19 +0,0 @@
{
"name": "term.js",
"description": "A terminal written in javascript",
"author": "Christopher Jeffrey",
"version": "0.0.3",
"main": "./index.js",
"preferGlobal": false,
"repository": "git://github.com/chjj/term.js.git",
"homepage": "https://github.com/chjj/term.js",
"bugs": { "url": "https://github.com/chjj/term.js/issues" },
"keywords": ["tty", "terminal", "term", "xterm"],
"tags": ["tty", "terminal", "term", "xterm"],
"engines": { "node": ">= 0.8.0" },
"devDependencies": {
"express": "3.1.0",
"socket.io": "0.9.13",
"pty.js": "0.2.3"
}
}