Skip to content

Commit d26a870

Browse files
committed
feat(admin): graph row glyphs in the styler's twin tables (issue #54)
arrowRight, foldOpen, foldClosed and rearm join the overlay glyph twins, width-identical across both tables on purpose: a graph row's padding math must not depend on which table is active, or the 80-col invariant would break only on ASCII terminals, the least debuggable place for it. Key parity and the twin widths are pinned; the ascii table stays pure ASCII by assertion. Signed-off-by: Rob Boerman <robboerman@live.nl>
1 parent 777b19c commit d26a870

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

admin/src/style.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ export const PLAIN_THEME = {
4747
// switch (`setGlyphs`) must not restyle overlays behind a styler's back, so the overlay opts in per
4848
// styler instance via `makeStyler(theme, { ascii })`. (The sparkline ramp is the one exception -- its
4949
// quantization geometry lives only in panel.mjs, so `styler.sparkline` follows panel's active table.)
50-
const OVERLAY_GLYPHS = { tl: "┌", tr: "┐", bl: "└", br: "┘", ml: "├", mr: "┤", h: "─", v: "│", full: "█", empty: "░", ellipsis: "…" };
51-
const OVERLAY_ASCII = { tl: "+", tr: "+", bl: "+", br: "+", ml: "+", mr: "+", h: "-", v: "|", full: "#", empty: ".", ellipsis: "..." };
50+
// The graph rows (issue #54) add four keys; every twin pair below is width-identical on purpose, so a
51+
// renderer's padding math never depends on which table is active.
52+
const OVERLAY_GLYPHS = { tl: "┌", tr: "┐", bl: "└", br: "┘", ml: "├", mr: "┤", h: "─", v: "│", full: "█", empty: "░", ellipsis: "…", arrowRight: "─▶", foldOpen: "▾", foldClosed: "▸", rearm: "↻" };
53+
const OVERLAY_ASCII = { tl: "+", tr: "+", bl: "+", br: "+", ml: "+", mr: "+", h: "-", v: "|", full: "#", empty: ".", ellipsis: "...", arrowRight: "->", foldOpen: "v", foldClosed: ">", rearm: "~" };
5254

5355
/** Per-class colors for `fmtCost`: an estimate must LOOK provisional, and plan coverage must not look free. */
5456
const COST_COLORS = {

admin/test/style.test.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,20 @@ test("makeStyler ascii option swaps frame/meter/divider glyphs with identical ge
116116
assert.equal(s.cell("abcdefgh", 5), "ab...", "the 3-char ellipsis still lands on exactly width");
117117
});
118118

119+
test("the graph glyphs (issue #54) keep key parity and identical widths across both tables", () => {
120+
// Width-identical twins are the contract: a graph row's padding math must not depend on which
121+
// table is active, or the 80-col invariant breaks only for ASCII terminals -- the least debuggable
122+
// place for it to break.
123+
const box = makeStyler(PLAIN_THEME).glyphs;
124+
const ascii = makeStyler(PLAIN_THEME, { ascii: true }).glyphs;
125+
assert.deepEqual(Object.keys(ascii).sort(), Object.keys(box).sort(), "key parity between the twin tables");
126+
for (const key of ["arrowRight", "foldOpen", "foldClosed", "rearm"]) {
127+
assert.ok(typeof box[key] === "string" && box[key].length > 0, key);
128+
assert.equal(ascii[key].length, box[key].length, `${key}: twin widths must match`);
129+
}
130+
assert.doesNotMatch(Object.values(ascii).join(""), /[]/, "no non-ASCII glyph leaks into the ascii table");
131+
});
132+
119133
test("styler.sparkline under PLAIN_THEME is byte-identical to the plain sparkline", () => {
120134
const s = makeStyler(PLAIN_THEME);
121135
const values = [0, 1, null, 4, 2];

0 commit comments

Comments
 (0)