neo-blessed/test/widget-image.js

54 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-02-01 13:43:52 -08:00
var blessed = require('../')
, screen;
screen = blessed.screen({
dump: __dirname + '/logs/image.log',
smartCSR: true
});
2015-02-09 00:21:58 -08:00
// To ensure our w3mimgdisplay search works:
2015-02-09 00:19:35 -08:00
blessed.image.w3mdisplay = '/does/not/exist';
var file = process.argv[2] || __dirname + '/test-image.png';
2015-02-09 00:21:58 -08:00
var image = blessed.image({
2015-02-01 13:43:52 -08:00
parent: screen,
left: 'center',
top: 'center',
2015-02-01 14:01:55 -08:00
width: 'shrink',
height: 'shrink',
2015-02-09 00:19:35 -08:00
bg: 'green'
2015-02-01 13:43:52 -08:00
});
2015-02-09 00:19:35 -08:00
setTimeout(function() {
2015-02-09 19:49:33 -08: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();
}, 1000);
}, 5000);
});
2015-02-09 00:19:35 -08:00
}, 1000);
2015-02-09 00:21:58 -08:00
image.focus();
2015-02-01 13:43:52 -08:00
screen.key('i', function() {
2015-02-09 00:21:58 -08:00
screen.displayImage(file);
});
2015-02-01 13:43:52 -08:00
screen.key('q', function() {
return process.exit(0);
});
screen.render();