buffer everything - this prevents flickering on xterm and may improve terminal rendering speed.

This commit is contained in:
Christopher Jeffrey 2013-07-23 17:57:04 -05:00
parent 65829a2234
commit 31030113cf
2 changed files with 54 additions and 54 deletions

View File

@ -305,6 +305,7 @@ function Screen(options) {
this.grabKeys = false; this.grabKeys = false;
this.lockKeys = false; this.lockKeys = false;
this.focused; this.focused;
this._buf = '';
this._ci = -1; this._ci = -1;
@ -627,20 +628,17 @@ Screen.prototype.blankLine = function(ch, dirty) {
}; };
Screen.prototype.insertLine = function(n, y, top, bottom) { Screen.prototype.insertLine = function(n, y, top, bottom) {
// if (y === top) return this.insertLineNC(n, y, top, bottom);
if (!this.tput if (!this.tput
|| !this.tput.strings.change_scroll_region || !this.tput.strings.change_scroll_region
|| !this.tput.strings.delete_line || !this.tput.strings.delete_line
|| !this.tput.strings.insert_line) return; || !this.tput.strings.insert_line) return;
this.program.sc(); this._buf += this.tput.csr(top, bottom);
this.program.csr(top, bottom); this._buf += this.tput.cup(y, 0);
this.program.cup(y, 0); this._buf += this.tput.il(n);
//if (y === top && n === 1) { this._buf += this.tput.csr(0, this.height - 1);
// this.program.ri(); // su
//} else {
this.program.il(n);
this.program.csr(0, this.height - 1);
this.program.rc();
var j = bottom + 1; var j = bottom + 1;
@ -653,21 +651,17 @@ Screen.prototype.insertLine = function(n, y, top, bottom) {
}; };
Screen.prototype.deleteLine = function(n, y, top, bottom) { Screen.prototype.deleteLine = function(n, y, top, bottom) {
// if (y === top) return this.deleteLineNC(n, y, top, bottom);
if (!this.tput if (!this.tput
|| !this.tput.strings.change_scroll_region || !this.tput.strings.change_scroll_region
|| !this.tput.strings.delete_line || !this.tput.strings.delete_line
|| !this.tput.strings.insert_line) return; || !this.tput.strings.insert_line) return;
this.program.sc(); this._buf += this.tput.csr(top, bottom);
this.program.csr(top, bottom); this._buf += this.tput.cup(y, 0);
//if (y === top && n === 1) { this._buf += this.tput.dl(n);
// this.program.cup(bottom, 0); this._buf += this.tput.csr(0, this.height - 1);
// this.program.ind(); // sd
//} else {
this.program.cup(y, 0);
this.program.dl(n);
this.program.csr(0, this.height - 1);
this.program.rc();
var j = bottom + 1; var j = bottom + 1;
@ -688,15 +682,10 @@ Screen.prototype.insertLineNC = function(n, y, top, bottom) {
|| !this.tput.strings.delete_line || !this.tput.strings.delete_line
|| !this.tput.strings.insert_line) return; || !this.tput.strings.insert_line) return;
if (y !== top) return this.insertLine.apply(this, arguments); this._buf += this.tput.csr(top, bottom);
this._buf += this.tput.cup(top, 0);
this.program.sc(); this._buf += this.tput.dl(n);
this.program.csr(top, bottom); this._buf += this.tput.csr(0, this.height - 1);
this.program.cup(top, 0);
this.program.dl(n);
this.program.csr(0, this.height - 1);
// this.program.cup(top, 0);
this.program.rc();
var j = bottom + 1; var j = bottom + 1;
@ -717,15 +706,10 @@ Screen.prototype.deleteLineNC = function(n, y, top, bottom) {
|| !this.tput.strings.delete_line || !this.tput.strings.delete_line
|| !this.tput.strings.insert_line) return; || !this.tput.strings.insert_line) return;
if (y !== bottom) return this.deleteLine.apply(this, arguments); this._buf += this.tput.csr(top, bottom);
this._buf += this.tput.cup(bottom, 0);
this.program.sc(); this._buf += Array(n + 1).join('\n');
this.program.csr(top, bottom); this._buf += this.tput.csr(0, this.height - 1);
this.program.cup(bottom, 0);
this.program.write(Array(n + 1).join('\n'));
this.program.csr(0, this.height - 1);
// this.program.cup(bottom - 1, 0);
this.program.rc();
var j = bottom + 1; var j = bottom + 1;
@ -830,6 +814,8 @@ Screen.prototype.draw = function(start, end) {
, bg , bg
, flags; , flags;
var main = '';
var clr var clr
, neq , neq
, xx; , xx;
@ -840,14 +826,10 @@ Screen.prototype.draw = function(start, end) {
var acs; var acs;
// var cx = this.program.x if (this._buf) {
// , cy = this.program.y main += this._buf;
// , ch = this.program.cursorHidden; this._buf = '';
// }
// if (!ch) this.program.hideCursor();
// this.program.sc('draw');
this.program.sc();
for (y = start; y <= end; y++) { for (y = start; y <= end; y++) {
line = this.lines[y]; line = this.lines[y];
@ -1097,18 +1079,35 @@ Screen.prototype.draw = function(start, end) {
out += '\x1b[m'; out += '\x1b[m';
} }
if (this.tput) { if (out) {
if (out) this.program.write(this.tput.cup(y, 0) + out); main += this.tput
} else { ? this.tput.cup(y, 0) + out
if (out) this.program.write('\x1b[' + (y + 1) + ';1H' + out); : '\x1b[' + (y + 1) + ';1H' + out;
} }
} }
// this.program.cup(cy, cx); if (main) {
// if (ch) this.program.hideCursor(); var pre = ''
, post = '';
// this.program.rc('draw', true); pre += this.tput
this.program.rc(); ? this.tput.sc()
: '\x1b7';
post += this.tput
? this.tput.rc()
: '\x1b8';
if (!this.program.cursorHidden) {
pre += this.tput
? this.tput.civis()
: '\x1b[?25l';
post += this.tput
? this.tput.cnorm()
: '\x1b[?25h';
}
this.program.write(pre + main + post);
}
}; };
Screen.prototype._reduceColor = function(col) { Screen.prototype._reduceColor = function(col) {

View File

@ -2,7 +2,8 @@ var blessed = require('../');
var screen = blessed.screen({ var screen = blessed.screen({
tput: true, tput: true,
smartCSR: true smartCSR: true,
dump: __dirname + '/file.log'
}); });
var fm = blessed.filemanager({ var fm = blessed.filemanager({