[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 text-background

Nate Moore (Jun 4, 2026, 12:33 AM -0500) e814b5ec d75fb4b6

+46
+46
test/text-background.test.ts
··· 1 + import { beforeEach, describe, expect, it } from "./suite.ts"; 2 + import { createTerm, type Term } 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("text background color", () => { 8 + let term: Term; 9 + beforeEach(async () => { 10 + term = await createTerm({ width: 20, height: 1 }); 11 + }); 12 + 13 + it("fills glyph cells with the text-level bg", () => { 14 + let ansi = decode( 15 + term.render([ 16 + open("root", { layout: { width: grow(), height: grow() } }), 17 + // PROPOSED: text() gains a `bg` prop; cast so it type-checks today 18 + // deno-lint-ignore no-explicit-any 19 + text("Hi", { bg: rgba(255, 0, 0) } as any), 20 + close(), 21 + ]).output, 22 + ); 23 + 24 + // pins down: the bg SGR is active when the first glyph "H" is emitted 25 + let before = ansi.slice(0, ansi.indexOf("H")); 26 + expect(before).toContain("\x1b[48;2;255;0;0"); 27 + }); 28 + 29 + it("fills only glyph cells, not the surrounding box fill", () => { 30 + let ansi = decode( 31 + term.render([ 32 + open("root", { layout: { width: grow(), height: grow() } }), 33 + // deno-lint-ignore no-explicit-any 34 + text("Hi", { bg: rgba(255, 0, 0) } as any), 35 + close(), 36 + ]).output, 37 + ); 38 + 39 + // pins down: bg present on the two glyph cells ... 40 + let before = ansi.slice(0, ansi.indexOf("H")); 41 + expect(before).toContain("\x1b[48;2;255;0;0"); 42 + // ... but absent from the trailing box fill past the glyphs (stays default) 43 + let afterGlyphs = ansi.slice(ansi.indexOf("Hi") + 2); 44 + expect(afterGlyphs).not.toContain("\x1b[48;2;255;0;0"); 45 + }); 46 + });