test playing and recording.

This commit is contained in:
Christopher Jeffrey 2015-05-13 21:00:55 -07:00
parent 9e0df1a6ae
commit 3690aae695
2 changed files with 65 additions and 0 deletions

13
test/widget-play.js Normal file
View File

@ -0,0 +1,13 @@
var blessed = require('../');
var screen = blessed.screen({
dump: __dirname + '/logs/play.log',
smartCSR: true
});
var frames = require(__dirname + '/frames.json');
setInterval(function() {
if (!frames.length) return process.exit(0);
process.stdout.write(frames.shift());
}, 100);

52
test/widget-record.js Normal file
View File

@ -0,0 +1,52 @@
var blessed = require('../')
, fs = require('fs');
var screen = blessed.screen({
dump: __dirname + '/logs/record.log',
smartCSR: true
});
var btext = blessed.box({
parent: screen,
left: 'center',
top: 'center',
width: '80%',
height: '80%',
style: {
bg: 'green'
},
border: 'line',
content: 'CSR should still work.'
});
var text = blessed.scrollabletext({
parent: screen,
content: fs.readFileSync(__dirname + '/git.diff', 'utf8'),
border: 'line',
left: 'center',
top: 'center',
draggable: true,
width: '50%',
height: '50%',
mouse: true,
keys: true,
vi: true
});
text.focus();
screen.key('q', function() {
return process.exit(0);
});
screen.render();
var frames = [];
setInterval(function() {
frames.push(screen.screenshot());
}, 100);
process.on('exit', function() {
fs.writeFileSync(__dirname + '/frames.json', JSON.stringify(frames));
});