(onInput: (data: string) => void, onResize: () => void)
| 132 | } |
| 133 | |
| 134 | start(onInput: (data: string) => void, onResize: () => void): void { |
| 135 | this.inputHandler = onInput; |
| 136 | this.resizeHandler = onResize; |
| 137 | |
| 138 | // Save previous state and enable raw mode |
| 139 | this.wasRaw = process.stdin.isRaw || false; |
| 140 | if (process.stdin.setRawMode) { |
| 141 | process.stdin.setRawMode(true); |
| 142 | } |
| 143 | process.stdin.setEncoding("utf8"); |
| 144 | process.stdin.resume(); |
| 145 | |
| 146 | // Enable bracketed paste mode - terminal will wrap pastes in \x1b[200~ ... \x1b[201~ |
| 147 | process.stdout.write("\x1b[?2004h"); |
| 148 | |
| 149 | // Set up resize handler immediately |
| 150 | process.stdout.on("resize", this.resizeHandler); |
| 151 | |
| 152 | // Refresh terminal dimensions - they may be stale after suspend/resume |
| 153 | // (SIGWINCH is lost while process is stopped). Unix only. |
| 154 | if (process.platform !== "win32") { |
| 155 | process.kill(process.pid, "SIGWINCH"); |
| 156 | } |
| 157 | |
| 158 | // On Windows, enable ENABLE_VIRTUAL_TERMINAL_INPUT so the console sends |
| 159 | // VT escape sequences (e.g. \x1b[Z for Shift+Tab) instead of raw console |
| 160 | // events that lose modifier information. Must run AFTER setRawMode(true) |
| 161 | // since that resets console mode flags. |
| 162 | this.enableWindowsVTInput(); |
| 163 | |
| 164 | // Query Kitty keyboard protocol and fall back to modifyOtherKeys when DA confirms no Kitty response. |
| 165 | // See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/ |
| 166 | this.queryAndEnableKittyProtocol(); |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Set up StdinBuffer to split batched input into individual sequences. |
nothing calls this directly
no test coverage detected