MCPcopy Index your code
hub / github.com/codeaashu/claude-code / get256Color

Function get256Color

web/lib/ansi-to-html.ts:39–50  ·  view source on GitHub ↗
(n: number)

Source from the content-addressed store, hash-verified

37};
38
39function get256Color(n: number): string {
40 if (n < 16) return FG[n + 30] ?? FG[n + 82] ?? "#ffffff";
41 if (n < 232) {
42 const i = n - 16;
43 const b = i % 6, g = Math.floor(i / 6) % 6, r = Math.floor(i / 36);
44 const h = (v: number) => (v === 0 ? 0 : 55 + v * 40).toString(16).padStart(2, "0");
45 return `#${h(r)}${h(g)}${h(b)}`;
46 }
47 const gray = (n - 232) * 10 + 8;
48 const hex = gray.toString(16).padStart(2, "0");
49 return `#${hex}${hex}${hex}`;
50}
51
52interface AnsiStyle {
53 color?: string;

Callers 1

parseAnsiSegmentsFunction · 0.70

Calls 2

hFunction · 0.70
toStringMethod · 0.65

Tested by

no test coverage detected