From 51946a73c84369c1e35bc78fb599d8d27a237a2e Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 3 Feb 2012 12:10:09 -0600 Subject: [PATCH] up --- .gitignore | 9 +++++++++ LICENSE | 19 +++++++++++++++++++ README.md | 10 ++++++++++ index.js | 1 + package.json | 14 ++++++++++++++ test/bench.js | 36 ++++++++++++++++++++++++++++++++++++ test/data.diff | 10 ++++++++++ test/index.html | 44 ++++++++++++++++++++++++++++++++++++++++++++ test/index.js | 25 +++++++++++++++++++++++++ 9 files changed, 168 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 index.js create mode 100644 package.json create mode 100644 test/bench.js create mode 100644 test/data.diff create mode 100644 test/index.html create mode 100644 test/index.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..eaba9c60 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +node_modules/ +*.swp +build/* +.lock-wscript +out/ +Makefile.gyp +*.Makefile +*.target.gyp.mk +*.node diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..259500c9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2012-2013, Christopher Jeffrey (https://github.com/chjj/) + +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. diff --git a/README.md b/README.md new file mode 100644 index 00000000..2fbd1d64 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# term.js + +A terminal written in javascript. Used by +[tty.js](https://github.com/chjj/tty.js). + +## License + +Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) + +[1]: http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking diff --git a/index.js b/index.js new file mode 100644 index 00000000..4aad8798 --- /dev/null +++ b/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/term.js'); diff --git a/package.json b/package.json new file mode 100644 index 00000000..e70b78fc --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "term.js", + "description": "A terminal written in javascript", + "author": "Christopher Jeffrey", + "version": "0.0.1", + "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"], + "tags": ["tty", "terminal", "term"], + "engines": { "node": ">= 0.8.0" } +} diff --git a/test/bench.js b/test/bench.js new file mode 100644 index 00000000..ec6e99f8 --- /dev/null +++ b/test/bench.js @@ -0,0 +1,36 @@ +var element = { + createElement: function() { return element; }, + appendChild: function() {}, + removeChild: function() {}, + addEventListener: function() {}, + removeEventListener: function() {}, + style: {} +}; + +global.window = global; +window.navigator = { userAgent: '' }; +window.document = element; +window.document.body = element; + +var Terminal = require('../static/term'); +Terminal.cursorBlink = false; + +var data = require('./data').data; + +var term = new Terminal(250, 100); +term.open(); + +var time = new Date; +var t = 10; + +while (t--) { + var l = data.length + , i = 0; + + for (; i < l; i++) { + term.write(data[i]); + } +} + +console.log('Completed: %d.', new Date - time); +console.log('Average (?): 13.5k (for ~2.7k writes).'); diff --git a/test/data.diff b/test/data.diff new file mode 100644 index 00000000..fcd8e61a --- /dev/null +++ b/test/data.diff @@ -0,0 +1,10 @@ +167a168,170 +> var stream = fs.createWriteStream(__dirname + '/../test/data.js'); +> stream.write('this.data = [\n'); +> +169a173 +> stream.write(' ' + JSON.stringify(data) + ',\n'); +182a187,189 +> +> stream.write('];\n'); +> stream.end(); diff --git a/test/index.html b/test/index.html new file mode 100644 index 00000000..a7b93dda --- /dev/null +++ b/test/index.html @@ -0,0 +1,44 @@ + +tty.js test + + +

tty.js test

+ + + diff --git a/test/index.js b/test/index.js new file mode 100644 index 00000000..4118cc28 --- /dev/null +++ b/test/index.js @@ -0,0 +1,25 @@ +var path = require('path') + , fs = require('fs'); + +var express = require('express') + , app = express.createServer(); + +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.static(__dirname)); + +app.use(express.static(__dirname + '/../static')); + +app.listen(8080);