MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / applyBackgroundToLine

Function applyBackgroundToLine

packages/pi-tui/src/utils.ts:919–928  ·  view source on GitHub ↗
(line: string, width: number, bgFn: (text: string) => string)

Source from the content-addressed store, hash-verified

917 * @returns Line with background applied and padded to width
918 */
919export 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.

Callers 3

renderMethod · 0.90
renderMethod · 0.90
applyBgMethod · 0.90

Calls 1

visibleWidthFunction · 0.85

Tested by

no test coverage detected