(data: Buffer)
| 52 | } |
| 53 | |
| 54 | const handler = (data: Buffer) => { |
| 55 | const str = data.toString() |
| 56 | |
| 57 | // Match OSC 11 (background color) |
| 58 | const bgMatch = str.match(/\x1b]11;([^\x07\x1b]+)/) |
| 59 | if (bgMatch) { |
| 60 | background = parseColor(bgMatch[1]) |
| 61 | } |
| 62 | |
| 63 | // Match OSC 10 (foreground color) |
| 64 | const fgMatch = str.match(/\x1b]10;([^\x07\x1b]+)/) |
| 65 | if (fgMatch) { |
| 66 | foreground = parseColor(fgMatch[1]) |
| 67 | } |
| 68 | |
| 69 | // Match OSC 4 (palette colors) |
| 70 | const paletteMatches = str.matchAll(/\x1b]4;(\d+);([^\x07\x1b]+)/g) |
| 71 | for (const match of paletteMatches) { |
| 72 | const index = parseInt(match[1]) |
| 73 | const color = parseColor(match[2]) |
| 74 | if (color) paletteColors[index] = color |
| 75 | } |
| 76 | |
| 77 | // Return immediately if we have all 16 palette colors |
| 78 | if (paletteColors.filter((c) => c !== undefined).length === 16) { |
| 79 | cleanup() |
| 80 | resolve({ background, foreground, colors: paletteColors }) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | process.stdin.setRawMode(true) |
| 85 | process.stdin.on("data", handler) |
nothing calls this directly
no test coverage detected