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;
|
||||
|
||||
nextTick(this._flush);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
Program.prototype.flush = function(text) {
|
||||
|
@ -1578,16 +1580,33 @@ Program.prototype._write = function(text) {
|
|||
// Example: `DCS tmux; ESC Pt ST`
|
||||
// Real: `DCS tmux; ESC Pt ESC \`
|
||||
Program.prototype._twrite = function(data) {
|
||||
var self = this;
|
||||
|
||||
if (this.tmux) {
|
||||
// Replace all STs with BELs so they can be nested within the DCS code.
|
||||
data = data.replace(/\x1b\\/g, '\x07');
|
||||
|
||||
// Wrap in tmux forward DCS:
|
||||
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.
|
||||
// The DCS code must be at the start of the output.
|
||||
this.flush();
|
||||
|
||||
// Write out raw now that the buffer is flushed.
|
||||
return this.output.write(data);
|
||||
}
|
||||
|
||||
return this._write(data);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue