buffer everything - this prevents flickering on xterm and may improve terminal rendering speed.
This commit is contained in:
parent
65829a2234
commit
31030113cf
105
lib/widget.js
105
lib/widget.js
|
@ -305,6 +305,7 @@ function Screen(options) {
|
|||
this.grabKeys = false;
|
||||
this.lockKeys = false;
|
||||
this.focused;
|
||||
this._buf = '';
|
||||
|
||||
this._ci = -1;
|
||||
|
||||
|
@ -627,20 +628,17 @@ Screen.prototype.blankLine = function(ch, dirty) {
|
|||
};
|
||||
|
||||
Screen.prototype.insertLine = function(n, y, top, bottom) {
|
||||
// if (y === top) return this.insertLineNC(n, y, top, bottom);
|
||||
|
||||
if (!this.tput
|
||||
|| !this.tput.strings.change_scroll_region
|
||||
|| !this.tput.strings.delete_line
|
||||
|| !this.tput.strings.insert_line) return;
|
||||
|
||||
this.program.sc();
|
||||
this.program.csr(top, bottom);
|
||||
this.program.cup(y, 0);
|
||||
//if (y === top && n === 1) {
|
||||
// this.program.ri(); // su
|
||||
//} else {
|
||||
this.program.il(n);
|
||||
this.program.csr(0, this.height - 1);
|
||||
this.program.rc();
|
||||
this._buf += this.tput.csr(top, bottom);
|
||||
this._buf += this.tput.cup(y, 0);
|
||||
this._buf += this.tput.il(n);
|
||||
this._buf += this.tput.csr(0, this.height - 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) {
|
||||
// if (y === top) return this.deleteLineNC(n, y, top, bottom);
|
||||
|
||||
if (!this.tput
|
||||
|| !this.tput.strings.change_scroll_region
|
||||
|| !this.tput.strings.delete_line
|
||||
|| !this.tput.strings.insert_line) return;
|
||||
|
||||
this.program.sc();
|
||||
this.program.csr(top, bottom);
|
||||
//if (y === top && n === 1) {
|
||||
// this.program.cup(bottom, 0);
|
||||
// this.program.ind(); // sd
|
||||
//} else {
|
||||
this.program.cup(y, 0);
|
||||
this.program.dl(n);
|
||||
this.program.csr(0, this.height - 1);
|
||||
this.program.rc();
|
||||
this._buf += this.tput.csr(top, bottom);
|
||||
this._buf += this.tput.cup(y, 0);
|
||||
this._buf += this.tput.dl(n);
|
||||
this._buf += this.tput.csr(0, this.height - 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.insert_line) return;
|
||||
|
||||
if (y !== top) return this.insertLine.apply(this, arguments);
|
||||
|
||||
this.program.sc();
|
||||
this.program.csr(top, bottom);
|
||||
this.program.cup(top, 0);
|
||||
this.program.dl(n);
|
||||
this.program.csr(0, this.height - 1);
|
||||
// this.program.cup(top, 0);
|
||||
this.program.rc();
|
||||
this._buf += this.tput.csr(top, bottom);
|
||||
this._buf += this.tput.cup(top, 0);
|
||||
this._buf += this.tput.dl(n);
|
||||
this._buf += this.tput.csr(0, this.height - 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.insert_line) return;
|
||||
|
||||
if (y !== bottom) return this.deleteLine.apply(this, arguments);
|
||||
|
||||
this.program.sc();
|
||||
this.program.csr(top, bottom);
|
||||
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();
|
||||
this._buf += this.tput.csr(top, bottom);
|
||||
this._buf += this.tput.cup(bottom, 0);
|
||||
this._buf += Array(n + 1).join('\n');
|
||||
this._buf += this.tput.csr(0, this.height - 1);
|
||||
|
||||
var j = bottom + 1;
|
||||
|
||||
|
@ -830,6 +814,8 @@ Screen.prototype.draw = function(start, end) {
|
|||
, bg
|
||||
, flags;
|
||||
|
||||
var main = '';
|
||||
|
||||
var clr
|
||||
, neq
|
||||
, xx;
|
||||
|
@ -840,14 +826,10 @@ Screen.prototype.draw = function(start, end) {
|
|||
|
||||
var acs;
|
||||
|
||||
// var cx = this.program.x
|
||||
// , cy = this.program.y
|
||||
// , ch = this.program.cursorHidden;
|
||||
//
|
||||
// if (!ch) this.program.hideCursor();
|
||||
|
||||
// this.program.sc('draw');
|
||||
this.program.sc();
|
||||
if (this._buf) {
|
||||
main += this._buf;
|
||||
this._buf = '';
|
||||
}
|
||||
|
||||
for (y = start; y <= end; y++) {
|
||||
line = this.lines[y];
|
||||
|
@ -1097,18 +1079,35 @@ Screen.prototype.draw = function(start, end) {
|
|||
out += '\x1b[m';
|
||||
}
|
||||
|
||||
if (this.tput) {
|
||||
if (out) this.program.write(this.tput.cup(y, 0) + out);
|
||||
} else {
|
||||
if (out) this.program.write('\x1b[' + (y + 1) + ';1H' + out);
|
||||
if (out) {
|
||||
main += this.tput
|
||||
? this.tput.cup(y, 0) + out
|
||||
: '\x1b[' + (y + 1) + ';1H' + out;
|
||||
}
|
||||
}
|
||||
|
||||
// this.program.cup(cy, cx);
|
||||
// if (ch) this.program.hideCursor();
|
||||
if (main) {
|
||||
var pre = ''
|
||||
, post = '';
|
||||
|
||||
// this.program.rc('draw', true);
|
||||
this.program.rc();
|
||||
pre += this.tput
|
||||
? 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) {
|
||||
|
|
|
@ -2,7 +2,8 @@ var blessed = require('../');
|
|||
|
||||
var screen = blessed.screen({
|
||||
tput: true,
|
||||
smartCSR: true
|
||||
smartCSR: true,
|
||||
dump: __dirname + '/file.log'
|
||||
});
|
||||
|
||||
var fm = blessed.filemanager({
|
||||
|
|
Loading…
Reference in New Issue