MCPcopy
hub / github.com/codeaashu/claude-code / themeColorToAnsi

Function themeColorToAnsi

src/utils/theme.ts:626–639  ·  view source on GitHub ↗
(themeColor: string)

Source from the content-addressed store, hash-verified

624 * Uses chalk to generate the escape codes, with 256-color mode for Apple Terminal.
625 */
626export function themeColorToAnsi(themeColor: string): string {
627 const rgbMatch = themeColor.match(/rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)/)
628 if (rgbMatch) {
629 const r = parseInt(rgbMatch[1]!, 10)
630 const g = parseInt(rgbMatch[2]!, 10)
631 const b = parseInt(rgbMatch[3]!, 10)
632 // Use chalk.rgb which auto-converts to 256 colors when level is 2
633 // Extract just the opening escape sequence by using a marker
634 const colored = chalkForChart.rgb(r, g, b)('X')
635 return colored.slice(0, colored.indexOf('X'))
636 }
637 // Fallback to magenta if parsing fails
638 return '\x1b[35m'
639}
640

Callers 1

generateTokenChartFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected