2013-06-01 05:29:31 +00:00
|
|
|
var blessed = require('blessed')
|
|
|
|
, program = blessed()
|
|
|
|
, screen;
|
|
|
|
|
|
|
|
var high = require('blessed/lib/high');
|
|
|
|
|
|
|
|
Object.keys(high).forEach(function(key) {
|
|
|
|
blessed[key] = high[key];
|
|
|
|
});
|
|
|
|
|
|
|
|
screen = new blessed.Screen({
|
|
|
|
program: program
|
|
|
|
});
|
|
|
|
|
2013-06-01 07:06:04 +00:00
|
|
|
/*
|
2013-06-01 05:29:31 +00:00
|
|
|
screen.append(new blessed.Box({
|
|
|
|
screen: screen,
|
|
|
|
parent: screen,
|
2013-06-01 07:06:04 +00:00
|
|
|
fg: 4,
|
|
|
|
bg: -1,
|
2013-06-01 05:29:31 +00:00
|
|
|
border: {
|
|
|
|
type: 'ascii',
|
2013-06-01 07:06:04 +00:00
|
|
|
fg: -1,
|
|
|
|
bg: -1
|
2013-06-01 05:29:31 +00:00
|
|
|
},
|
|
|
|
content: 'Hello world!',
|
|
|
|
width: '50%',
|
|
|
|
height: '50%',
|
|
|
|
top: 'center',
|
|
|
|
left: 'center'
|
|
|
|
}));
|
|
|
|
|
2013-06-01 07:06:04 +00:00
|
|
|
screen.children[0].append(new blessed.Box({
|
|
|
|
screen: screen,
|
|
|
|
parent: screen.children[0],
|
|
|
|
fg: 4,
|
|
|
|
bg: 3,
|
|
|
|
border: {
|
|
|
|
type: 'bg',
|
|
|
|
fg: 0,
|
|
|
|
bg: 1,
|
|
|
|
ch: '/'
|
|
|
|
},
|
|
|
|
content: 'Foobar',
|
|
|
|
width: '50%',
|
|
|
|
height: '50%',
|
|
|
|
top: 'center',
|
|
|
|
left: 'center'
|
|
|
|
}));
|
|
|
|
*/
|
|
|
|
|
|
|
|
screen.append(new blessed.List({
|
|
|
|
screen: screen,
|
|
|
|
parent: screen,
|
|
|
|
fg: 4,
|
|
|
|
bg: -1,
|
|
|
|
border: {
|
|
|
|
type: 'ascii',
|
|
|
|
fg: -1,
|
|
|
|
bg: -1
|
|
|
|
},
|
|
|
|
width: '50%',
|
|
|
|
height: '50%',
|
|
|
|
top: 'center',
|
|
|
|
left: 'center',
|
|
|
|
selectedBg: 2,
|
|
|
|
items: [
|
|
|
|
{ content: 'one' },
|
|
|
|
{ content: 'two' },
|
|
|
|
{ content: 'three' },
|
2013-06-01 10:47:18 +00:00
|
|
|
{ content: 'four' },
|
|
|
|
{ content: 'five' },
|
|
|
|
{ content: 'six' },
|
|
|
|
{ content: 'seven' },
|
|
|
|
{ content: 'eight' },
|
|
|
|
{ content: 'nine' },
|
|
|
|
{ content: 'ten' }
|
2013-06-01 07:06:04 +00:00
|
|
|
]
|
|
|
|
}));
|
|
|
|
|
2013-06-01 10:47:18 +00:00
|
|
|
screen.children[0].prepend(new blessed.Text({
|
|
|
|
screen: screen,
|
|
|
|
parent: screen.children[0],
|
|
|
|
left: 2,
|
|
|
|
content: ' My list '
|
|
|
|
}));
|
|
|
|
|
2013-06-01 05:29:31 +00:00
|
|
|
program.on('keypress', function(ch, key) {
|
2013-06-01 10:47:18 +00:00
|
|
|
if (key.name === 'up') {
|
|
|
|
screen.children[0].up();
|
|
|
|
screen.render();
|
|
|
|
return;
|
|
|
|
} else if (key.name === 'down') {
|
|
|
|
screen.children[0].down();
|
|
|
|
screen.render();
|
|
|
|
return;
|
|
|
|
}
|
2013-06-01 05:29:31 +00:00
|
|
|
if (key.name === 'escape' || key.name === 'q') {
|
2013-06-01 07:06:04 +00:00
|
|
|
program.disableMouse();
|
|
|
|
program.clear();
|
|
|
|
program.showCursor();
|
|
|
|
program.normalBuffer();
|
|
|
|
return process.exit(0);
|
2013-06-01 05:29:31 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
program.alternateBuffer();
|
|
|
|
program.hideCursor();
|
|
|
|
|
|
|
|
screen.render();
|