[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 floating-attach

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

+55
+55
test/floating-attach.test.ts
··· 1 + import { describe, expect, it } from "./suite.ts"; 2 + import { createTerm } from "../term.ts"; 3 + import { close, fixed, open, text } from "../ops.ts"; 4 + 5 + // Clay attach-point enum (clay.h L433-441): LEFT_TOP=0 ... RIGHT_TOP=6. 6 + const ATTACH_TO_PARENT = 1; 7 + const LEFT_TOP = 0; 8 + const RIGHT_TOP = 6; 9 + 10 + describe("floating attach corners", () => { 11 + it("anchors a float to the parent's right-top corner", async () => { 12 + let term = await createTerm({ width: 10, height: 3 }); 13 + // PROPOSED attachPoints: {element, parent} so the float's element corner 14 + // attaches to a chosen parent corner. Cast so it type-checks today; the 15 + // parent corner is dropped at runtime against the current build. 16 + let res = term.render([ 17 + open("box", { layout: { width: fixed(5), height: fixed(3) } }), 18 + open("dot", { 19 + floating: { 20 + x: 0, 21 + y: 0, 22 + attachTo: ATTACH_TO_PARENT, 23 + attachPoints: { element: LEFT_TOP, parent: RIGHT_TOP } as never, 24 + }, 25 + }), 26 + text("X"), 27 + close(), 28 + close(), 29 + ]); 30 + // pins: float's left edge sits at parent.x(0) + parent.width(5) = 5 31 + expect(res.info.get("dot")!.bounds.x).toBe(5); 32 + }); 33 + 34 + it("keeps the parent corner independent of the element corner", async () => { 35 + let term = await createTerm({ width: 10, height: 3 }); 36 + // element RIGHT_TOP, parent RIGHT_TOP: the float's right edge attaches to 37 + // the parent's right edge, so its left edge lands at parent.width - 1 = 4. 38 + let res = term.render([ 39 + open("box", { layout: { width: fixed(5), height: fixed(3) } }), 40 + open("dot", { 41 + floating: { 42 + x: 0, 43 + y: 0, 44 + attachTo: ATTACH_TO_PARENT, 45 + attachPoints: { element: RIGHT_TOP, parent: RIGHT_TOP } as never, 46 + }, 47 + }), 48 + text("X"), 49 + close(), 50 + close(), 51 + ]); 52 + // pins: element RIGHT_TOP onto parent RIGHT_TOP -> dot.x = 5 - 1 = 4 53 + expect(res.info.get("dot")!.bounds.x).toBe(4); 54 + }); 55 + });