(
context: Context,
formattedString: FormattedString,
width: number,
backgroundColor?: ThemeColor
)
| 8 | * the config. |
| 9 | */ |
| 10 | export function* iterFitTextToWidth( |
| 11 | context: Context, |
| 12 | formattedString: FormattedString, |
| 13 | width: number, |
| 14 | backgroundColor?: ThemeColor |
| 15 | ): Iterable<FormattedString> { |
| 16 | if (context.WRAP_LINES) { |
| 17 | for (const wrappedLine of wrapSpannedStringByWord( |
| 18 | formattedString, |
| 19 | width |
| 20 | )) { |
| 21 | wrappedLine.fillWidth(width); |
| 22 | if (backgroundColor) { |
| 23 | wrappedLine.addSpan(0, width, backgroundColor); |
| 24 | } |
| 25 | yield wrappedLine; |
| 26 | } |
| 27 | } else { |
| 28 | const truncatedLine = formattedString.slice(0, width).fillWidth(width); |
| 29 | if (backgroundColor) { |
| 30 | truncatedLine.addSpan(0, width, backgroundColor); |
| 31 | } |
| 32 | yield truncatedLine; |
| 33 | } |
| 34 | } |
no test coverage detected