()
| 229 | // ─── Lifecycle ─────────────────────────────────────────────────────── |
| 230 | |
| 231 | enter() { |
| 232 | this.active = true; |
| 233 | |
| 234 | // The TerminalController owns alt-buffer / raw-mode / mouse-tracking / |
| 235 | // bracketed-paste setup and — critically — guarantees teardown on suspend |
| 236 | // (Ctrl+Z), termination, and crashes (issue #71). On resume it redraws. |
| 237 | if (!this._terminal) { |
| 238 | this._terminal = new TerminalController({ |
| 239 | onResume: () => { this._computeLayout(); this.render(); }, |
| 240 | }); |
| 241 | } |
| 242 | this._terminal.enter(); |
| 243 | |
| 244 | // Store a direct reference to the real stdout.write (before any overrides) |
| 245 | this._rawWrite = this._terminal.rawWrite; |
| 246 | |
| 247 | // Handle resize |
| 248 | process.stdout.on('resize', () => this._onResize()); |
| 249 | |
| 250 | // Handle raw keypresses |
| 251 | process.stdin.on('data', (data) => this._onKeypress(data)); |
| 252 | |
| 253 | this._computeLayout(); |
| 254 | this.render(); |
| 255 | } |
| 256 | |
| 257 | leave() { |
| 258 | if (!this.active) return; |
no test coverage detected