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

Function parseColorFgBg

apps/kimi-code/src/tui/theme/detect.ts:111–121  ·  view source on GitHub ↗
(value: string | undefined)

Source from the content-addressed store, hash-verified

109 * the background ANSI 16-color index; 0–6 and 8 are dark, the rest light.
110 */
111export function parseColorFgBg(value: string | undefined): ResolvedTheme | null {
112 if (value === undefined || value === "") return null;
113 const parts = value.split(";");
114 const bgRaw = parts.at(-1);
115 if (bgRaw === undefined) return null;
116 const bg = parseInt(bgRaw, 10);
117 if (!Number.isInteger(bg)) return null;
118 // ANSI 0=black, 1=red, 2=green, 3=yellow, 4=blue, 5=magenta, 6=cyan, 8=bright black.
119 const darkBgs = new Set([0, 1, 2, 3, 4, 5, 6, 8]);
120 return darkBgs.has(bg) ? "dark" : "light";
121}

Callers 1

detectTerminalThemeFunction · 0.85

Calls 1

hasMethod · 0.65

Tested by

no test coverage detected