neo-blessed/test/widget-csr.js

74 lines
1.2 KiB
JavaScript
Raw Normal View History

2013-07-18 22:56:05 +00:00
var blessed = require('../')
2013-07-15 06:44:11 +00:00
, screen;
screen = blessed.screen({
2013-07-28 19:29:07 +00:00
dump: __dirname + '/logs/csr.log',
2013-07-15 06:44:11 +00:00
smartCSR: true
});
var lorem = require('fs').readFileSync(__dirname + '/git.diff', 'utf8');
function expectClean(value) {
var cleanSides = screen.cleanSides;
screen.cleanSides = function() {
var ret = cleanSides.apply(this, arguments);
if (ret !== value) {
throw new Error('Failed. Expected '
+ value + ' from cleanSides. Got '
+ ret + '.');
}
return ret;
};
}
2013-07-15 06:44:11 +00:00
/*
blessed.box({
parent: screen,
left: 0,
top: 'center',
width: '50%',
height: 2,
2015-04-04 06:43:24 +00:00
style: {
bg: 'green'
},
content: 'This will disallow CSR.'
});
expectClean(false);
2013-07-15 06:44:11 +00:00
*/
blessed.box({
parent: screen,
left: 'center',
top: 'center',
width: '80%',
height: '80%',
2015-04-04 06:43:24 +00:00
style: {
bg: 'green'
},
2015-04-04 06:43:24 +00:00
border: 'line',
content: 'CSR should still work.'
});
expectClean(true);
var text = blessed.scrollabletext({
parent: screen,
content: lorem,
2015-04-04 06:43:24 +00:00
border: 'line',
left: 'center',
top: 'center',
width: '100%',
width: '50%',
height: '50%',
mouse: true,
keys: true,
vi: true
});
text.focus();
screen.key('q', function() {
return process.exit(0);
});
screen.render();