Convert a list of spans to fixed-width plain text while preserving logical clipping.
(spans: RenderSpan[], width: number, horizontalOffset = 0)
| 424 | |
| 425 | /** Convert a list of spans to fixed-width plain text while preserving logical clipping. */ |
| 426 | function spansToPlainText(spans: RenderSpan[], width: number, horizontalOffset = 0) { |
| 427 | if (width <= 0) { |
| 428 | return ""; |
| 429 | } |
| 430 | |
| 431 | const visible = sliceTextByWidth( |
| 432 | sanitizeTerminalSpans(spans) |
| 433 | .map((span) => span.text) |
| 434 | .join(""), |
| 435 | Math.max(0, horizontalOffset), |
| 436 | width, |
| 437 | ); |
| 438 | |
| 439 | return padTextByWidth(visible.text, Math.max(0, width)); |
| 440 | } |
| 441 | |
| 442 | /** Flatten styled spans to their visible text content. */ |
| 443 | function spansText(spans: RenderSpan[]) { |
no test coverage detected