(line: string, width: number, bgFn: (text: string) => string)
| 917 | * @returns Line with background applied and padded to width |
| 918 | */ |
| 919 | export function applyBackgroundToLine(line: string, width: number, bgFn: (text: string) => string): string { |
| 920 | // Calculate padding needed |
| 921 | const visibleLen = visibleWidth(line); |
| 922 | const paddingNeeded = Math.max(0, width - visibleLen); |
| 923 | const padding = " ".repeat(paddingNeeded); |
| 924 | |
| 925 | // Apply background to content + padding |
| 926 | const withPadding = line + padding; |
| 927 | return bgFn(withPadding); |
| 928 | } |
| 929 | |
| 930 | /** |
| 931 | * Truncate text to fit within a maximum visible width, adding ellipsis if needed. |
no test coverage detected