(text: string)
| 192 | const OSC52_MAX_PAYLOAD = 32_000 |
| 193 | |
| 194 | function buildOsc52Sequence(text: string): string | null { |
| 195 | const env = getCliEnv() |
| 196 | if (env.TERM === 'dumb') return null |
| 197 | |
| 198 | const base64 = Buffer.from(text, 'utf8').toString('base64') |
| 199 | if (base64.length > OSC52_MAX_PAYLOAD) return null |
| 200 | |
| 201 | const osc = `\x1b]52;c;${base64}\x07` |
| 202 | |
| 203 | // tmux: wrap in DCS passthrough with doubled ESC |
| 204 | if (env.TMUX) { |
| 205 | return `\x1bPtmux;${osc.replace(/\x1b/g, '\x1b\x1b')}\x1b\\` |
| 206 | } |
| 207 | |
| 208 | // GNU screen: wrap in DCS passthrough |
| 209 | if (env.STY) { |
| 210 | return `\x1bP${osc}\x1b\\` |
| 211 | } |
| 212 | |
| 213 | return osc |
| 214 | } |
| 215 | |
| 216 | function tryCopyViaOsc52(text: string): boolean { |
| 217 | const sequence = buildOsc52Sequence(text) |
no test coverage detected