MCPcopy Create free account
hub / github.com/arctic-cli/interface / parseColor

Function parseColor

packages/arctic/src/cli/cmd/tui/util/terminal.ts:34–52  ·  view source on GitHub ↗
(colorStr: string)

Source from the content-addressed store, hash-verified

32 }
33
34 const parseColor = (colorStr: string): RGBA | null => {
35 if (colorStr.startsWith("rgb:")) {
36 const parts = colorStr.substring(4).split("/")
37 return RGBA.fromInts(
38 parseInt(parts[0], 16) >> 8, // Convert 16-bit to 8-bit
39 parseInt(parts[1], 16) >> 8,
40 parseInt(parts[2], 16) >> 8,
41 255,
42 )
43 }
44 if (colorStr.startsWith("#")) {
45 return RGBA.fromHex(colorStr)
46 }
47 if (colorStr.startsWith("rgb(")) {
48 const parts = colorStr.substring(4, colorStr.length - 1).split(",")
49 return RGBA.fromInts(parseInt(parts[0]), parseInt(parts[1]), parseInt(parts[2]), 255)
50 }
51 return null
52 }
53
54 const handler = (data: Buffer) => {
55 const str = data.toString()

Callers 1

handlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected