[READ-ONLY] Mirror of https://github.com/bombshell-dev/tty. Platform independent 2D layout engine for terminal applications based on Clay
5

Configure Feed

Select the types of activity you want to include in your feed.

test: failing repro for color-encoding-modes

Nate Moore (Jun 4, 2026, 12:51 AM -0500) f96967ab d75fb4b6

+41
+41
test/color-encoding-modes.test.ts
··· 1 + import { describe, expect, it } from "./suite.ts"; 2 + import { createTerm } from "../term.ts"; 3 + import { close, grow, open, rgba, text } from "../ops.ts"; 4 + 5 + const decode = (b: Uint8Array) => new TextDecoder().decode(b); 6 + 7 + describe("color encoding modes", () => { 8 + it("16-color mode downgrades standard red foreground to 4-bit", async () => { 9 + let term = await createTerm({ width: 4, height: 1 }); 10 + let ansi = decode( 11 + term.render([ 12 + open("root", { layout: { width: grow(), height: grow() } }), 13 + text("X", { color: rgba(255, 0, 0) }), 14 + close(), 15 + // deno-lint-ignore no-explicit-any 16 + ], { colorMode: "16" } as any).output, 17 + ); 18 + 19 + let before = ansi.slice(0, ansi.indexOf("X")); 20 + // pins: standard-palette red maps to 4-bit \x1b[31m under colorMode:"16" 21 + expect(before).toContain("\x1b[31m"); 22 + // pins: the 24-bit sequence must not survive the downgrade 23 + expect(before).not.toContain("\x1b[38;2;255;0;0"); 24 + }); 25 + 26 + it("256-color mode downgrades standard red foreground to a palette index", async () => { 27 + let term = await createTerm({ width: 4, height: 1 }); 28 + let ansi = decode( 29 + term.render([ 30 + open("root", { layout: { width: grow(), height: grow() } }), 31 + text("X", { color: rgba(255, 0, 0) }), 32 + close(), 33 + // deno-lint-ignore no-explicit-any 34 + ], { colorMode: "256" } as any).output, 35 + ); 36 + 37 + let before = ansi.slice(0, ansi.indexOf("X")); 38 + // pins: standard-palette red maps to index 1 (\x1b[38;5;1m) under colorMode:"256" 39 + expect(before).toContain("\x1b[38;5;1m"); 40 + }); 41 + });