* Set the selection highlight background color. Replaces the per-cell * SGR-7 inverse with a solid theme-aware bg (matches native terminal * selection). Accepts the same color formats as Text backgroundColor * (rgb(), ansi:name, #hex, ansi256()) — colorize() routes through * chalk so the
(color: string)
| 1282 | * unobservable in practice. |
| 1283 | */ |
| 1284 | setSelectionBgColor(color: string): void { |
| 1285 | // Wrap a NUL marker, then split on it to extract the open/close SGR. |
| 1286 | // colorize returns the input unchanged if the color string is bad — |
| 1287 | // no NUL-split then, so fall through to null (inverse fallback). |
| 1288 | const wrapped = colorize('\0', color, 'background'); |
| 1289 | const nul = wrapped.indexOf('\0'); |
| 1290 | if (nul <= 0 || nul === wrapped.length - 1) { |
| 1291 | this.stylePool.setSelectionBg(null); |
| 1292 | return; |
| 1293 | } |
| 1294 | this.stylePool.setSelectionBg({ |
| 1295 | type: 'ansi', |
| 1296 | code: wrapped.slice(0, nul), |
| 1297 | endCode: wrapped.slice(nul + 1) // always \x1b[49m for bg |
| 1298 | }); |
| 1299 | // No scheduleRender: this is called from a React effect that already |
| 1300 | // runs inside the render cycle, and the bg only matters once a |
| 1301 | // selection exists (which itself triggers a full-damage frame). |
| 1302 | } |
| 1303 | |
| 1304 | /** |
| 1305 | * Capture text from rows about to scroll out of the viewport during |
no test coverage detected