Merge pull request #5 from kylefleming/master

Fix scroll performance for widgets with huge content
This commit is contained in:
Iuri Matias 2018-07-07 01:41:35 +03:00 committed by GitHub
commit ce88e0553d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 1 deletions

View File

@ -530,7 +530,8 @@ Element.prototype._parseAttr = function(lines) {
, j , j
, c; , c;
if (lines[0].attr === attr) { if (Array.isArray(lines.attr) && lines.attr.length > 0
&& lines.attr[0] === attr) {
return; return;
} }

View File

@ -0,0 +1,45 @@
var blessed = require('../')
, screen;
screen = blessed.screen({
dump: __dirname + '/logs/huge-content.log',
smartCSR: true,
warnings: true
});
var content = '';
for (var j = 0; j < 2000; j++) {
for (var i = 0; i < 100; i++) {
content += 'line: ' + i + '\n';
}
for (var i = 0; i < 10000; i++) {
content += 'longline';
}
content += '\n';
}
var box = blessed.box({
parent: screen,
scrollable: true,
left: 'center',
top: 'center',
width: '80%',
height: '80%',
border: 'line',
content: content,
keys: true,
vi: true,
alwaysScroll: true,
scrollbar: {
ch: ' ',
inverse: true
}
});
screen.key('q', function() {
return screen.destroy();
});
box.focus();
screen.render();