2015-03-30 11:58:15 +00:00
|
|
|
var blessed = require('../')
|
|
|
|
, screen;
|
|
|
|
|
|
|
|
screen = blessed.screen({
|
|
|
|
dump: __dirname + '/logs/table.log',
|
2015-05-01 06:44:46 +00:00
|
|
|
autoPadding: false,
|
|
|
|
fullUnicode: true
|
2015-03-30 11:58:15 +00:00
|
|
|
});
|
|
|
|
|
2015-05-01 06:44:46 +00:00
|
|
|
var DU = '杜';
|
|
|
|
var JUAN = '鹃';
|
|
|
|
|
2015-03-30 11:58:15 +00:00
|
|
|
var table = blessed.table({
|
|
|
|
parent: screen,
|
|
|
|
top: 'center',
|
|
|
|
left: 'center',
|
|
|
|
data: null,
|
|
|
|
border: 'line',
|
2015-03-30 12:16:22 +00:00
|
|
|
align: 'center',
|
2015-03-31 07:25:38 +00:00
|
|
|
tags: true,
|
2015-07-04 10:33:42 +00:00
|
|
|
//width: '80%',
|
|
|
|
width: 'shrink',
|
2015-03-30 11:58:15 +00:00
|
|
|
style: {
|
|
|
|
border: {
|
|
|
|
fg: 'red'
|
|
|
|
},
|
|
|
|
header: {
|
|
|
|
fg: 'blue',
|
|
|
|
bold: true
|
|
|
|
},
|
|
|
|
cell: {
|
|
|
|
fg: 'magenta'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-07-04 10:33:42 +00:00
|
|
|
var data1 = [
|
2015-03-30 11:58:15 +00:00
|
|
|
[ 'Animals', 'Foods', 'Times' ],
|
|
|
|
[ 'Elephant', 'Apple', '1:00am' ],
|
2015-03-31 07:39:59 +00:00
|
|
|
[ 'Bird', 'Orange', '2:15pm' ],
|
|
|
|
[ 'T-Rex', 'Taco', '8:45am' ],
|
|
|
|
[ 'Mouse', 'Cheese', '9:05am' ]
|
2015-03-31 07:25:38 +00:00
|
|
|
];
|
|
|
|
|
2015-07-04 10:33:42 +00:00
|
|
|
data1[1][0] = '{red-fg}' + data1[1][0] + '{/red-fg}';
|
|
|
|
data1[2][0] += ' (' + DU + JUAN + ')';
|
2015-03-31 07:25:38 +00:00
|
|
|
|
2015-07-04 10:33:42 +00:00
|
|
|
var data2 = [
|
|
|
|
[ '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' ]
|
|
|
|
];
|
|
|
|
|
|
|
|
data2[1][0] = '{red-fg}' + data2[1][0] + '{/red-fg}';
|
|
|
|
data2[2][0] += ' (' + DU + JUAN + ')';
|
2015-03-30 11:58:15 +00:00
|
|
|
|
|
|
|
screen.key('q', function() {
|
|
|
|
return process.exit(0);
|
|
|
|
});
|
|
|
|
|
2015-07-04 10:33:42 +00:00
|
|
|
table.setData(data2);
|
2015-03-30 11:58:15 +00:00
|
|
|
screen.render();
|
2015-07-04 10:33:42 +00:00
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
table.setData(data1);
|
|
|
|
screen.render();
|
|
|
|
}, 3000);
|