neo-blessed/example/multiplex.js

139 lines
2.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,
2015-05-02 04:09:40 +00:00
log: process.env.HOME + '/blessed-terminal.log',
fullUnicode: true,
dockBorders: true,
ignoreDockContrast: true
2015-04-04 09:23:43 +00:00
});
2015-01-25 02:34:57 +00:00
var topleft = 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-05-02 10:08:28 +00:00
label: ' multiplex.js ',
2015-01-25 02:34:57 +00:00
left: 0,
2015-05-02 04:09:40 +00:00
top: 0,
width: '50%',
height: '50%',
border: 'line',
style: {
fg: 'default',
bg: 'default',
focus: {
border: {
fg: 'green'
}
}
2015-01-25 02:34:57 +00:00
}
});
topleft.pty.on('data', function(data) {
2015-04-04 09:23:43 +00:00
screen.log(JSON.stringify(data));
});
var topright = 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-05-02 10:08:28 +00:00
label: ' multiplex.js ',
2015-05-02 04:09:40 +00:00
left: '50%-1',
top: 0,
width: '50%+1',
height: '50%',
border: 'line',
style: {
fg: 'red',
bg: 'black',
focus: {
border: {
fg: 'green'
}
}
2015-01-25 02:34:57 +00:00
}
});
var bottomleft = blessed.terminal({
parent: screen,
cursor: 'block',
cursorBlink: true,
screenKeys: false,
2015-05-02 10:08:28 +00:00
label: ' multiplex.js ',
left: 0,
top: '50%-1',
width: '50%',
height: '50%+1',
border: 'line',
style: {
fg: 'default',
bg: 'default',
focus: {
border: {
fg: 'green'
}
}
}
});
var bottomright = blessed.terminal({
parent: screen,
cursor: 'block',
cursorBlink: true,
screenKeys: false,
2015-05-02 10:08:28 +00:00
label: ' multiplex.js ',
left: '50%-1',
top: '50%-1',
width: '50%+1',
height: '50%+1',
border: 'line',
style: {
fg: 'default',
bg: 'default',
focus: {
border: {
fg: 'green'
}
}
}
});
[topleft, topright, bottomleft, bottomright].forEach(function(term) {
2015-05-02 05:14:49 +00:00
term.enableDrag(function(mouse) {
return !!mouse.ctrl;
});
term.on('title', function(title) {
screen.title = title;
2015-05-02 10:08:28 +00:00
term.setLabel(' ' + title + ' ');
screen.render();
});
term.on('click', term.focus.bind(term));
2015-01-25 02:34:57 +00:00
});
topleft.focus();
2015-01-25 02:34:57 +00:00
screen.key('C-q', function() {
return process.exit(0);
2015-01-25 02:34:57 +00:00
});
screen.program.key('S-tab', function() {
screen.focusNext();
screen.render();
});
2015-01-25 02:34:57 +00:00
screen.render();