neo-blessed/test/widget-dock.js

136 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-04-04 03:08:01 +00:00
var blessed = require('../')
, screen;
screen = blessed.screen({
dump: __dirname + '/logs/dock.log',
smartCSR: true,
dockBorders: true
});
var topleft = blessed.box({
2015-04-04 03:08:01 +00:00
parent: screen,
left: 0,
top: 0,
2015-04-04 05:55:56 +00:00
width: '50%',
height: '50%',
border: {
type: 'line',
left: false,
top: false,
right: true,
bottom: false
},
// border: 'line',
2015-04-04 03:08:01 +00:00
content: 'Foo'
});
var topright = blessed.box({
2015-04-04 03:08:01 +00:00
parent: screen,
2015-04-04 05:55:56 +00:00
left: '50%-1',
2015-04-04 03:08:01 +00:00
top: 0,
2015-04-04 05:55:56 +00:00
width: '50%+1',
height: '50%',
border: {
type: 'line',
left: true,
top: false,
right: false,
bottom: false
},
// border: 'line',
content: 'Bar'
2015-04-04 03:08:01 +00:00
});
var bottomleft = blessed.box({
2015-04-04 03:08:01 +00:00
parent: screen,
left: 0,
2015-04-04 05:55:56 +00:00
top: '50%-1',
width: '50%',
height: '50%+1',
border: {
type: 'line',
left: false,
top: true,
right: false,
bottom: false
},
2015-04-04 03:08:01 +00:00
border: 'line',
content: 'Foo'
});
var bottomright = blessed.listtable({
2015-04-04 03:08:01 +00:00
parent: screen,
2015-04-04 05:55:56 +00:00
left: '50%-1',
top: '50%-1',
width: '50%+1',
height: '50%+1',
border: {
type: 'line',
left: true,
top: true,
right: false,
bottom: false
},
// border: 'line',
2015-04-04 06:43:24 +00:00
align: 'center',
tags: true,
keys: true,
vi: true,
mouse: true,
style: {
header: {
fg: 'blue',
bold: true
},
cell: {
fg: 'magenta',
selected: {
bg: 'blue'
}
}
},
data: [
[ 'Animals', 'Foods', 'Times', 'Numbers' ],
[ 'Elephant', 'Apple', '1:00am', 'One' ],
[ 'Bird', 'Orange', '2:15pm', 'Two' ],
[ 'T-Rex', 'Taco', '8:45am', 'Three' ],
[ 'Mouse', 'Cheese', '9:05am', 'Four' ]
]
});
bottomright.focus();
var over = blessed.box({
parent: screen,
hidden: true,
left: 'center',
top: 'center',
width: '50%',
height: '50%',
2015-04-07 04:13:43 +00:00
draggable: true,
border: {
type: 'line',
left: false,
top: true,
right: true,
bottom: true
},
content: 'Foo'
});
screen.on('keypress', function() {
over.toggle();
screen.render();
});
2015-04-04 06:43:24 +00:00
screen.key('escape', function() {
over.hide();
screen.render();
});
2015-04-04 03:08:01 +00:00
screen.key('q', function() {
return process.exit(0);
});
screen.render();