neo-blessed/example/multiplex.js

80 lines
1.3 KiB
JavaScript
Raw Normal View History

2015-01-25 02:34:57 +00:00
#!/usr/bin/env node
/**
* multiplex.js
* https://github.com/chjj/blessed
* Copyright (c) 2013-2015, Christopher Jeffrey (MIT License)
* A terminal multiplexer created by blessed.
*/
process.title = 'multiplex.js';
var blessed = require('blessed')
2015-04-04 09:23:43 +00:00
, screen;
screen = blessed.screen({
smartCSR: true,
log: process.env.HOME + '/blessed-terminal.log'
});
2015-01-25 02:34:57 +00:00
var left = blessed.terminal({
2015-01-25 02:34:57 +00:00
parent: screen,
2015-02-12 01:20:22 +00:00
cursor: 'line',
cursorBlink: true,
screenKeys: false,
2015-01-25 02:34:57 +00:00
left: 0,
top: 2,
bottom: 2,
width: '40%',
border: 'line',
style: {
fg: 'default',
bg: 'default',
focus: {
border: {
fg: 'green'
}
}
2015-01-25 02:34:57 +00:00
}
});
2015-04-04 09:23:43 +00:00
left.pty.on('data', function(data) {
screen.log(JSON.stringify(data));
});
var right = blessed.terminal({
2015-01-25 02:34:57 +00:00
parent: screen,
2015-02-12 01:20:22 +00:00
cursor: 'block',
cursorBlink: true,
screenKeys: false,
2015-01-25 02:34:57 +00:00
right: 2,
top: 2,
bottom: 2,
width: '40%',
border: 'line',
style: {
fg: 'red',
bg: 'black',
focus: {
border: {
fg: 'green'
}
}
2015-01-25 02:34:57 +00:00
}
});
[left, right].forEach(function(term) {
term.on('title', function(title) {
screen.title = title;
});
term.on('click', term.focus.bind(term));
2015-01-25 02:34:57 +00:00
});
left.focus();
2015-01-25 02:34:57 +00:00
screen.key('C-c', function() {
return process.exit(0);
2015-01-25 02:34:57 +00:00
});
screen.render();