* Set up StdinBuffer to split batched input into individual sequences. * This ensures components receive single events, making matchesKey/isKeyRelease work correctly. * * Also watches for Kitty protocol response and enables it when detected. * This is done here (after stdinBuffer parsing) ra
()
| 175 | * to handle the case where the response arrives split across multiple events. |
| 176 | */ |
| 177 | private setupStdinBuffer(): void { |
| 178 | this.stdinBuffer = new StdinBuffer({ timeout: 10 }); |
| 179 | |
| 180 | // Forward individual sequences to the input handler |
| 181 | this.stdinBuffer.on("data", (sequence) => { |
| 182 | const negotiationSequence = this.readKeyboardProtocolNegotiationSequence(sequence); |
| 183 | if (negotiationSequence === "pending") { |
| 184 | this.scheduleKeyboardProtocolNegotiationBufferFlush(); |
| 185 | return; // Wait briefly for the rest of a split Kitty response. |
| 186 | } |
| 187 | if (this.handleKeyboardProtocolNegotiationSequence(negotiationSequence)) { |
| 188 | return; |
| 189 | } |
| 190 | |
| 191 | this.forwardInputSequence(sequence); |
| 192 | }); |
| 193 | |
| 194 | // Re-wrap paste content with bracketed paste markers for existing editor handling |
| 195 | this.stdinBuffer.on("paste", (content) => { |
| 196 | if (this.inputHandler) { |
| 197 | this.inputHandler(`\x1b[200~${content}\x1b[201~`); |
| 198 | } |
| 199 | }); |
| 200 | |
| 201 | // Handler that pipes stdin data through the buffer |
| 202 | this.stdinDataHandler = (data: string) => { |
| 203 | this.stdinBuffer!.process(data); |
| 204 | }; |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Query terminal for Kitty keyboard protocol support and enable it if available. |
no test coverage detected