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,
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%',
bg: 'green',
border: {
type: 'ascii'
},
content: 'CSR should still work.'
});
expectClean(true);
var text = blessed.scrollabletext({
parent: screen,
content: lorem,
border: {
type: 'ascii'
},
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();