neo-blessed/test/widget-file.js

70 lines
1.1 KiB
JavaScript
Raw Normal View History

2013-07-18 22:56:05 +00:00
var blessed = require('../');
2013-07-12 12:48:55 +00:00
var screen = blessed.screen({
2013-07-23 22:06:01 +00:00
tput: true,
smartCSR: true,
2013-07-28 19:29:07 +00:00
dump: __dirname + '/logs/file.log'
2013-07-12 12:48:55 +00:00
});
var fm = blessed.filemanager({
parent: screen,
2015-04-04 06:43:24 +00:00
border: 'line',
style: {
selected: {
bg: 'blue'
}
2013-07-12 12:48:55 +00:00
},
height: 'half',
width: 'half',
top: 'center',
left: 'center',
label: ' {blue-fg}%path{/blue-fg} ',
2013-07-12 12:48:55 +00:00
cwd: process.env.HOME,
keys: true,
vi: true,
scrollbar: {
bg: 'white',
ch: ' '
}
});
var box = blessed.box({
parent: screen,
2015-04-04 06:43:24 +00:00
style: {
bg: 'green'
2013-07-12 12:48:55 +00:00
},
2015-04-04 06:43:24 +00:00
border: 'line',
2013-07-12 12:48:55 +00:00
height: 'half',
width: 'half',
top: 'center',
left: 'center',
hidden: true
});
fm.refresh();
screen.render();
screen.key('q', function() {
process.exit(0);
});
screen.key(['s', 'p'], function() {
fm.hide();
screen.render();
setTimeout(function() {
fm.pick(function(err, file) {
box.show();
box.setContent(err ? err + '' : file);
screen.render();
setTimeout(function() {
box.hide();
fm.reset(function() {
fm.show();
screen.render();
});
}, 2000);
});
}, 2000);
});