2015-02-01 13:43:52 -08:00
|
|
|
var blessed = require('../')
|
|
|
|
, screen;
|
|
|
|
|
|
|
|
screen = blessed.screen({
|
|
|
|
dump: __dirname + '/logs/image.log',
|
2015-07-21 19:23:57 -07:00
|
|
|
smartCSR: true,
|
|
|
|
warnings: true
|
2015-02-01 13:43:52 -08:00
|
|
|
});
|
|
|
|
|
2015-02-09 00:21:58 -08:00
|
|
|
// To ensure our w3mimgdisplay search works:
|
2015-02-11 17:20:22 -08:00
|
|
|
if (process.argv[2] === 'find') {
|
|
|
|
blessed.image.w3mdisplay = '/does/not/exist';
|
|
|
|
process.argv.length = 2;
|
|
|
|
}
|
2015-02-09 00:19:35 -08:00
|
|
|
|
|
|
|
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,
|
2015-07-18 14:40:51 -07:00
|
|
|
type: 'overlay',
|
2015-02-01 13:43:52 -08:00
|
|
|
left: 'center',
|
|
|
|
top: 'center',
|
2015-02-01 14:01:55 -08:00
|
|
|
width: 'shrink',
|
|
|
|
height: 'shrink',
|
2015-04-03 23:43:24 -07:00
|
|
|
style: {
|
|
|
|
bg: 'green'
|
2015-05-02 02:57:18 -07:00
|
|
|
},
|
|
|
|
draggable: true
|
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();
|
2015-02-11 17:20:22 -08:00
|
|
|
setTimeout(function() {
|
|
|
|
image.detach();
|
|
|
|
screen.render();
|
|
|
|
setTimeout(function() {
|
|
|
|
screen.append(image);
|
2015-05-02 02:57:18 -07:00
|
|
|
image.enableMouse();
|
2015-02-11 17:20:22 -08:00
|
|
|
screen.render();
|
|
|
|
}, 1000);
|
|
|
|
}, 1000);
|
2015-02-09 19:49:33 -08:00
|
|
|
}, 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
|
|
|
|
2015-02-08 23:42:44 -08:00
|
|
|
screen.key('i', function() {
|
2015-02-09 00:21:58 -08:00
|
|
|
screen.displayImage(file);
|
2015-02-08 23:42:44 -08:00
|
|
|
});
|
|
|
|
|
2015-02-01 13:43:52 -08:00
|
|
|
screen.key('q', function() {
|
2015-08-07 21:00:31 -07:00
|
|
|
return screen.destroy();
|
2015-02-01 13:43:52 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
screen.render();
|