make _twrite() wait for the first bytes to be output.
This commit is contained in:
parent
bb83be4b47
commit
f026de2e52
|
@ -1559,6 +1559,8 @@ Program.prototype._buffer = function(text) {
|
||||||
this._buf = text;
|
this._buf = text;
|
||||||
|
|
||||||
nextTick(this._flush);
|
nextTick(this._flush);
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
Program.prototype.flush = function(text) {
|
Program.prototype.flush = function(text) {
|
||||||
|
@ -1578,16 +1580,33 @@ Program.prototype._write = function(text) {
|
||||||
// Example: `DCS tmux; ESC Pt ST`
|
// Example: `DCS tmux; ESC Pt ST`
|
||||||
// Real: `DCS tmux; ESC Pt ESC \`
|
// Real: `DCS tmux; ESC Pt ESC \`
|
||||||
Program.prototype._twrite = function(data) {
|
Program.prototype._twrite = function(data) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
if (this.tmux) {
|
if (this.tmux) {
|
||||||
// Replace all STs with BELs so they can be nested within the DCS code.
|
// Replace all STs with BELs so they can be nested within the DCS code.
|
||||||
data = data.replace(/\x1b\\/g, '\x07');
|
data = data.replace(/\x1b\\/g, '\x07');
|
||||||
|
|
||||||
// Wrap in tmux forward DCS:
|
// Wrap in tmux forward DCS:
|
||||||
data = '\x1bPtmux;\x1b' + data + '\x1b\\';
|
data = '\x1bPtmux;\x1b' + data + '\x1b\\';
|
||||||
|
|
||||||
|
// If we've never even flushed yet, it means we're still in
|
||||||
|
// the normal buffer. Wait for alt screen buffer.
|
||||||
|
if (this.output.bytesWritten === 0) {
|
||||||
|
nextTick(function() {
|
||||||
|
self.flush();
|
||||||
|
self.output.write(data);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: Flushing the buffer is required in some cases.
|
// NOTE: Flushing the buffer is required in some cases.
|
||||||
|
// The DCS code must be at the start of the output.
|
||||||
this.flush();
|
this.flush();
|
||||||
|
|
||||||
// Write out raw now that the buffer is flushed.
|
// Write out raw now that the buffer is flushed.
|
||||||
return this.output.write(data);
|
return this.output.write(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._write(data);
|
return this._write(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue