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',
|
2015-07-22 02:23:57 +00:00
|
|
|
smartCSR: true,
|
|
|
|
warnings: true
|
2013-07-15 06:44:11 +00:00
|
|
|
});
|
2013-07-15 03:11:48 +00:00
|
|
|
|
|
|
|
var lorem = require('fs').readFileSync(__dirname + '/git.diff', 'utf8');
|
|
|
|
|
2015-05-02 02:11:34 +00:00
|
|
|
var cleanSides = screen.cleanSides;
|
2013-07-15 03:11:48 +00:00
|
|
|
function expectClean(value) {
|
2015-05-02 02:11:34 +00:00
|
|
|
screen.cleanSides = function(el) {
|
2013-07-15 03:11:48 +00:00
|
|
|
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
|
|
|
/*
|
2013-07-15 03:11:48 +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'
|
|
|
|
},
|
2013-07-15 03:11:48 +00:00
|
|
|
content: 'This will disallow CSR.'
|
|
|
|
});
|
|
|
|
expectClean(false);
|
2013-07-15 06:44:11 +00:00
|
|
|
*/
|
2013-07-15 03:11:48 +00:00
|
|
|
|
2015-05-02 02:11:34 +00:00
|
|
|
var btext = blessed.box({
|
2013-07-15 03:11:48 +00:00
|
|
|
parent: screen,
|
|
|
|
left: 'center',
|
|
|
|
top: 'center',
|
|
|
|
width: '80%',
|
|
|
|
height: '80%',
|
2015-04-04 06:43:24 +00:00
|
|
|
style: {
|
|
|
|
bg: 'green'
|
2013-07-15 03:11:48 +00:00
|
|
|
},
|
2015-04-04 06:43:24 +00:00
|
|
|
border: 'line',
|
2013-07-15 03:11:48 +00:00
|
|
|
content: 'CSR should still work.'
|
|
|
|
});
|
2015-05-02 02:11:34 +00:00
|
|
|
btext._oscroll = btext.scroll;
|
|
|
|
btext.scroll = function(offset, always) {
|
|
|
|
expectClean(true);
|
|
|
|
return btext._oscroll(offset, always);
|
|
|
|
};
|
2013-07-15 03:11:48 +00:00
|
|
|
|
|
|
|
var text = blessed.scrollabletext({
|
|
|
|
parent: screen,
|
|
|
|
content: lorem,
|
2015-04-04 06:43:24 +00:00
|
|
|
border: 'line',
|
2013-07-15 03:11:48 +00:00
|
|
|
left: 'center',
|
|
|
|
top: 'center',
|
2015-05-02 02:11:34 +00:00
|
|
|
draggable: true,
|
2013-07-15 03:11:48 +00:00
|
|
|
width: '50%',
|
|
|
|
height: '50%',
|
|
|
|
mouse: true,
|
|
|
|
keys: true,
|
|
|
|
vi: true
|
|
|
|
});
|
|
|
|
|
2015-05-02 02:11:34 +00:00
|
|
|
text._oscroll = text.scroll;
|
|
|
|
text.scroll = function(offset, always) {
|
|
|
|
var el = this;
|
|
|
|
var value = true;
|
|
|
|
if (el.left < 0) value = true;
|
|
|
|
if (el.top < 0) value = false;
|
|
|
|
if (el.left + el.width > screen.width) value = true;
|
|
|
|
if (el.top + el.height > screen.height) value = false;
|
|
|
|
expectClean(value);
|
|
|
|
return text._oscroll(offset, always);
|
|
|
|
};
|
|
|
|
|
2013-07-15 03:11:48 +00:00
|
|
|
text.focus();
|
|
|
|
|
|
|
|
screen.key('q', function() {
|
|
|
|
return process.exit(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
screen.render();
|