* 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)
| 1129 | * unobservable in practice. |
| 1130 | */ |
| 1131 | setSelectionBgColor(color: string): void { |
| 1132 | // Wrap a NUL marker, then split on it to extract the open/close SGR. |
| 1133 | // colorize returns the input unchanged if the color string is bad — |
| 1134 | // no NUL-split then, so fall through to null (inverse fallback). |
| 1135 | const wrapped = colorize('\0', color, 'background'); |
| 1136 | const nul = wrapped.indexOf('\0'); |
| 1137 | if (nul <= 0 || nul === wrapped.length - 1) { |
| 1138 | this.stylePool.setSelectionBg(null); |
| 1139 | return; |
| 1140 | } |
| 1141 | this.stylePool.setSelectionBg({ |
| 1142 | type: 'ansi', |
| 1143 | code: wrapped.slice(0, nul), |
| 1144 | endCode: wrapped.slice(nul + 1) // always \x1b[49m for bg |
| 1145 | }); |
| 1146 | // No scheduleRender: this is called from a React effect that already |
| 1147 | // runs inside the render cycle, and the bg only matters once a |
| 1148 | // selection exists (which itself triggers a full-damage frame). |
| 1149 | } |
| 1150 | |
| 1151 | /** |
| 1152 | * Capture text from rows about to scroll out of the viewport during |
no test coverage detected