neo-blessed/test/widget-image.js

67 lines
1.4 KiB
JavaScript
Raw Normal View History

2015-02-01 21:43:52 +00:00
var blessed = require('../')
, screen;
screen = blessed.screen({
dump: __dirname + '/logs/image.log',
smartCSR: true
});
2015-02-09 08:21:58 +00:00
// To ensure our w3mimgdisplay search works:
2015-02-12 01:20:22 +00:00
if (process.argv[2] === 'find') {
blessed.image.w3mdisplay = '/does/not/exist';
process.argv.length = 2;
}
2015-02-09 08:19:35 +00:00
var file = process.argv[2] || __dirname + '/test-image.png';
2015-02-09 08:21:58 +00:00
var image = blessed.image({
2015-02-01 21:43:52 +00:00
parent: screen,
left: 'center',
top: 'center',
2015-02-01 22:01:55 +00:00
width: 'shrink',
height: 'shrink',
2015-04-04 06:43:24 +00:00
style: {
bg: 'green'
}
2015-02-01 21:43:52 +00:00
});
2015-02-09 08:19:35 +00:00
setTimeout(function() {
2015-02-10 03:49:33 +00:00
image.setImage(file, function() {
// XXX For some reason the image sometimes envelopes
// the entire screen at the end if this is uncommented:
// NOTE: Might have to do with an uncached ratio and
// a bad termSize being reported.
screen.render();
setTimeout(function() {
image.rtop = 4;
image.rleft = 10;
screen.render();
setTimeout(function() {
image.rtop = 2;
image.rleft = 7;
screen.render();
2015-02-12 01:20:22 +00:00
setTimeout(function() {
image.detach();
screen.render();
setTimeout(function() {
screen.append(image);
screen.render();
}, 1000);
}, 1000);
2015-02-10 03:49:33 +00:00
}, 1000);
}, 5000);
});
2015-02-09 08:19:35 +00:00
}, 1000);
2015-02-09 08:21:58 +00:00
image.focus();
2015-02-01 21:43:52 +00:00
screen.key('i', function() {
2015-02-09 08:21:58 +00:00
screen.displayImage(file);
});
2015-02-01 21:43:52 +00:00
screen.key('q', function() {
return process.exit(0);
});
screen.render();