用JavaScript编写终端:term.js
jopen
10年前
term.js是一个采用JavaScript编写终端。用JavaScript实现的一个完整xterm克隆。
Server: var term = require('term.js'); app.use(term.middleware()); ... Client: 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);