From b621669af4cb35f773006670845d934083968791 Mon Sep 17 00:00:00 2001 From: paris Date: Mon, 24 Mar 2014 16:11:27 +0000 Subject: [PATCH] Updated LICENSE and REAMDE Also removed useless files. --- .npmignore | 12 ----- LICENSE | 1 + Makefile | 12 ----- README.md | 72 +------------------------ example/index.html | 70 ------------------------- example/index.js | 128 --------------------------------------------- index.js | 1 - lib/index.js | 55 ------------------- package.json | 19 ------- 9 files changed, 3 insertions(+), 367 deletions(-) delete mode 100644 .npmignore delete mode 100644 Makefile delete mode 100644 example/index.html delete mode 100755 example/index.js delete mode 100644 index.js delete mode 100644 lib/index.js delete mode 100644 package.json diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 8961f804..00000000 --- a/.npmignore +++ /dev/null @@ -1,12 +0,0 @@ -.git* -build/ -.lock-wscript -out/ -Makefile.gyp -*.Makefile -*.target.gyp.mk -node_modules/ -img/ -test/ -*.node -example/*.log diff --git a/LICENSE b/LICENSE index 259500c9..1ed6f2a5 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/Makefile b/Makefile deleted file mode 100644 index a425d1c9..00000000 --- a/Makefile +++ /dev/null @@ -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 diff --git a/README.md b/README.md index 49a2c6fd..e8483eaa 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/example/index.html b/example/index.html deleted file mode 100644 index 10b67c11..00000000 --- a/example/index.html +++ /dev/null @@ -1,70 +0,0 @@ - -term.js - - -

term.js

- - - diff --git a/example/index.js b/example/index.js deleted file mode 100755 index c3b3b8ba..00000000 --- a/example/index.js +++ /dev/null @@ -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()); - } -}); diff --git a/index.js b/index.js deleted file mode 100644 index bf4d18ac..00000000 --- a/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./lib/index.js'); diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 4a18fc2d..00000000 --- a/lib/index.js +++ /dev/null @@ -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; diff --git a/package.json b/package.json deleted file mode 100644 index 20396954..00000000 --- a/package.json +++ /dev/null @@ -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" - } -}