use _owrite instead of output.write.

This commit is contained in:
Christopher Jeffrey 2015-08-05 03:27:24 -07:00
parent 2b26fe9952
commit ee31799e7f
3 changed files with 15 additions and 9 deletions

View File

@ -243,7 +243,7 @@ Program.prototype.setupTput = function() {
var self = this
, options = this.options
, write = this.write.bind(this);
, write = this._write.bind(this);
var tput = this.tput = new Tput({
term: this.terminal,
@ -1596,10 +1596,16 @@ Program.prototype.response = function(name, text, callback, noBypass) {
: this._twrite(text);
};
Program.prototype._owrite =
Program.prototype.write = function(text) {
if (!this.output.writable) return;
return this.output.write(text);
};
Program.prototype._buffer = function(text) {
if (this._exiting) {
this.flush();
this.output.write(text);
this._owrite(text);
return;
}
@ -1617,7 +1623,7 @@ Program.prototype._buffer = function(text) {
Program.prototype.flush = function(text) {
if (!this._buf) return;
this.output.write(this._buf);
this._owrite(this._buf);
this._buf = '';
};
@ -1626,7 +1632,7 @@ Program.prototype._write = function(text) {
if (this.useBuffer) {
return this._buffer(text);
}
return this.output.write(text);
return this._owrite(text);
};
// Example: `DCS tmux; ESC Pt ST`
@ -1650,7 +1656,7 @@ Program.prototype._twrite = function(data) {
if (self.output.bytesWritten > 0 || ++iterations === 50) {
clearInterval(timer);
self.flush();
self.output.write(data);
self._owrite(data);
}
}, 100);
return true;
@ -1661,14 +1667,14 @@ Program.prototype._twrite = function(data) {
this.flush();
// Write out raw now that the buffer is flushed.
return this.output.write(data);
return this._owrite(data);
}
return this._write(data);
};
Program.prototype.echo =
Program.prototype.write = function(text, attr) {
Program.prototype.print = function(text, attr) {
return attr
? this._write(this.text(text, attr))
: this._write(text);

View File

@ -1351,7 +1351,7 @@ Screen.prototype.draw = function(start, end) {
}
// this.program.flush();
// this.program.output.write(pre + main + post);
// this.program._owrite(pre + main + post);
this.program._write(pre + main + post);
}

View File

@ -194,7 +194,7 @@ Terminal.prototype.bootstrap = function() {
this.term.on('passthrough', function(data) {
self.screen.program.flush();
self.screen.program.output.write(data);
self.screen.program._owrite(data);
});
this.on('resize', function() {