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,
|
2015-07-11 21:59:50 +00:00
|
|
|
itype: 'w3m',
|
2015-02-01 21:43:52 +00:00
|
|
|
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-05-02 09:57:18 +00:00
|
|
|
},
|
|
|
|
draggable: true
|
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);
|
2015-05-02 09:57:18 +00:00
|
|
|
image.enableMouse();
|
2015-02-12 01:20:22 +00:00
|
|
|
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
|
|
|
|
2015-02-09 07:42:44 +00:00
|
|
|
screen.key('i', function() {
|
2015-02-09 08:21:58 +00:00
|
|
|
screen.displayImage(file);
|
2015-02-09 07:42:44 +00:00
|
|
|
});
|
|
|
|
|
2015-02-01 21:43:52 +00:00
|
|
|
screen.key('q', function() {
|
|
|
|
return process.exit(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
screen.render();
|