From de43eb05d2e43ab31effce3dcca62ad91a556b26 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 5 Oct 2025 16:42:02 -0700 Subject: Init --- src/utils/ansi.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/utils/ansi.ts') diff --git a/src/utils/ansi.ts b/src/utils/ansi.ts index 551a365..e57c075 100644 --- a/src/utils/ansi.ts +++ b/src/utils/ansi.ts @@ -66,3 +66,15 @@ export const getStyleForAnsiColor = (color: AnsiTermColor): CSSProperties => { color: foreground ? ansiRgbToHex(foreground) : undefined, }; }; + +export const parseAnsiColorCode = (code: number): AnsiRgb | null => { + // Only handle 216 color cube (16-231) + if (code < 16 || code > 231) return null; + + const adjusted = code - 16; + const r = Math.floor(adjusted / 36) as AnsiColorVal; + const g = Math.floor((adjusted % 36) / 6) as AnsiColorVal; + const b = (adjusted % 6) as AnsiColorVal; + + return { r, g, b }; +}; -- cgit v1.2.3-70-g09d2