mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-01-11 11:34:20 +00:00
use telnet2 for example.
This commit is contained in:
parent
a45575fee6
commit
10edaa088b
45
README.md
45
README.md
@ -2140,47 +2140,20 @@ a full example):
|
|||||||
|
|
||||||
``` js
|
``` js
|
||||||
var blessed = require('blessed');
|
var blessed = require('blessed');
|
||||||
var telnet = require('telnet');
|
var telnet = require('telnet2');
|
||||||
|
|
||||||
telnet.createServer(function(client) {
|
telnet({ tty: true }, function(client) {
|
||||||
client.do.transmit_binary();
|
client.on('term', function(terminal) {
|
||||||
client.do.terminal_type();
|
screen.terminal = terminal;
|
||||||
client.do.window_size();
|
screen.render();
|
||||||
|
|
||||||
client.on('terminal type', function(data) {
|
|
||||||
if (data.command === 'sb' && data.name) {
|
|
||||||
screen.terminal = data.name;
|
|
||||||
screen.render();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('window size', function(data) {
|
client.on('size', function(width, height) {
|
||||||
if (data.command === 'sb') {
|
client.columns = width;
|
||||||
client.columns = data.columns;
|
client.rows = height;
|
||||||
client.rows = data.rows;
|
client.emit('resize');
|
||||||
client.emit('resize');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make the client look like a tty:
|
|
||||||
client.setRawMode = function(mode) {
|
|
||||||
client.isRaw = mode;
|
|
||||||
if (!client.writable) return;
|
|
||||||
if (mode) {
|
|
||||||
client.do.suppress_go_ahead();
|
|
||||||
client.will.suppress_go_ahead();
|
|
||||||
client.will.echo();
|
|
||||||
} else {
|
|
||||||
client.dont.suppress_go_ahead();
|
|
||||||
client.wont.suppress_go_ahead();
|
|
||||||
client.wont.echo();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
client.isTTY = true;
|
|
||||||
client.isRaw = false;
|
|
||||||
client.columns = 80;
|
|
||||||
client.rows = 24;
|
|
||||||
|
|
||||||
var screen = blessed.screen({
|
var screen = blessed.screen({
|
||||||
smartCSR: true,
|
smartCSR: true,
|
||||||
input: client,
|
input: client,
|
||||||
|
@ -13,64 +13,24 @@ process.title = 'blessed-telnet';
|
|||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var blessed = require('blessed');
|
var blessed = require('blessed');
|
||||||
var telnet = require('telnet');
|
var telnet = require('telnet2');
|
||||||
|
|
||||||
var server = telnet.createServer(function(client) {
|
|
||||||
client.do.transmit_binary();
|
|
||||||
client.do.terminal_type();
|
|
||||||
client.do.window_size();
|
|
||||||
client.do.environment_variables();
|
|
||||||
|
|
||||||
|
var server = telnet({ tty: true }, function(client) {
|
||||||
client.on('debug', function(msg) {
|
client.on('debug', function(msg) {
|
||||||
console.error(msg);
|
console.error(msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('environment variables', function(data) {
|
client.on('term', function(terminal) {
|
||||||
if (data.command === 'sb') {
|
screen.terminal = terminal;
|
||||||
if (data.name === 'TERM') {
|
screen.render();
|
||||||
screen.terminal = data.value;
|
|
||||||
} else {
|
|
||||||
// Clear the screen since they may have used `env send [var]`.
|
|
||||||
screen.realloc();
|
|
||||||
}
|
|
||||||
screen.render();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('terminal type', function(data) {
|
client.on('size', function(width, height) {
|
||||||
if (data.command === 'sb' && data.name) {
|
client.columns = width;
|
||||||
screen.terminal = data.name;
|
client.rows = height;
|
||||||
screen.render();
|
client.emit('resize');
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('window size', function(data) {
|
|
||||||
if (data.command === 'sb') {
|
|
||||||
client.columns = data.columns;
|
|
||||||
client.rows = data.rows;
|
|
||||||
client.emit('resize');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Make the client look like a tty:
|
|
||||||
client.setRawMode = function(mode) {
|
|
||||||
client.isRaw = mode;
|
|
||||||
if (!client.writable) return;
|
|
||||||
if (mode) {
|
|
||||||
client.do.suppress_go_ahead();
|
|
||||||
client.will.suppress_go_ahead();
|
|
||||||
client.will.echo();
|
|
||||||
} else {
|
|
||||||
client.dont.suppress_go_ahead();
|
|
||||||
client.wont.suppress_go_ahead();
|
|
||||||
client.wont.echo();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
client.isTTY = true;
|
|
||||||
client.isRaw = false;
|
|
||||||
client.columns = 80;
|
|
||||||
client.rows = 24;
|
|
||||||
|
|
||||||
var screen = blessed.screen({
|
var screen = blessed.screen({
|
||||||
smartCSR: true,
|
smartCSR: true,
|
||||||
input: client,
|
input: client,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user