(data: string | Buffer)
| 494 | } |
| 495 | |
| 496 | public write(data: string | Buffer) { |
| 497 | if (!this.terminal) { // Writes after a terminal is closed |
| 498 | return; |
| 499 | } |
| 500 | if (!this.isReady) { |
| 501 | this.pendingWrites.push(data); |
| 502 | return; |
| 503 | } |
| 504 | try { |
| 505 | this.unPrompt(); |
| 506 | if ((typeof data !== 'string') && !(data instanceof String)) { |
| 507 | data = data.toString('utf8'); |
| 508 | } |
| 509 | data = data.replace(/[\r]?\n/g, '\r\n'); |
| 510 | this.writeEmitter.fire(data); |
| 511 | if (data.endsWith('\n')) { |
| 512 | this.doPrompt(); |
| 513 | } else if (this.promptTimer) { |
| 514 | this.promptTimer.kill(); |
| 515 | } |
| 516 | } |
| 517 | catch (e) { |
| 518 | console.error(`MyPtyTerminal: write: ${e}`); |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | // When we prompt, we not only write the prompt but also any remaining input |
| 523 | protected doPrompt() { |
no test coverage detected