feat: enabled text-sizing and fixed OSC66 and DECCARA rendering behavior

- Added `textSizing` terminal capability and `tui.textSizing` setting for Kitty OSC66 scaling.
- Updated OSC66 range and visible-width handling to preserve grapheme slice behavior.
- Updated markdown rendering to apply heading text sizing only when enabled.
- Fixed DECCARA trailing-background fill tracking and DECRPM status 3/4 recognition.
This commit is contained in:
can1357
2026-06-04 01:33:48 +02:00
parent ea105b4211
commit 53aaced81f
16 changed files with 272 additions and 87 deletions
@@ -1,6 +1,11 @@
import { beforeAll, describe, expect, it } from "bun:test";
import { getImageDimensions } from "@oh-my-pi/pi-tui";
import { buildLargeTextLines, buildSampleImage, encodeRgbPng } from "../../src/debug/protocol-probe";
import { afterEach, beforeAll, describe, expect, it } from "bun:test";
import { getImageDimensions, ImageBudget, ImageProtocol, TERMINAL } from "@oh-my-pi/pi-tui";
import {
buildLargeTextLines,
buildSampleImage,
encodeRgbPng,
ProtocolProbeComponent,
} from "../../src/debug/protocol-probe";
import { initTheme } from "../../src/modes/theme/theme";
beforeAll(async () => {
@@ -8,6 +13,14 @@ beforeAll(async () => {
await initTheme();
});
type MutableTerminalInfo = { imageProtocol: ImageProtocol | null };
const terminal = TERMINAL as unknown as MutableTerminalInfo;
const originalImageProtocol = TERMINAL.imageProtocol;
afterEach(() => {
terminal.imageProtocol = originalImageProtocol;
});
describe("encodeRgbPng / buildSampleImage", () => {
it("emits a PNG whose IHDR dimensions decode back to the requested size", () => {
// The graphics test relies on producing a *valid* PNG: Kitty/iTerm2 hand
@@ -30,6 +43,22 @@ describe("encodeRgbPng / buildSampleImage", () => {
});
});
it("uses independent graphics ids for repeated probe panels", () => {
terminal.imageProtocol = ImageProtocol.Kitty;
const budget = new ImageBudget(8, () => {});
const image = buildSampleImage(8, 8);
const first = new ProtocolProbeComponent({ image, imageBudget: budget, notificationSuppressed: true });
const second = new ProtocolProbeComponent({ image, imageBudget: budget, notificationSuppressed: true });
budget.beginPass();
const firstBytes = first.render(80).join("\n");
const secondBytes = second.render(80).join("\n");
budget.endPass();
expect(firstBytes).toContain("i=1");
expect(secondBytes).toContain("i=2");
});
describe("buildLargeTextLines", () => {
it("encodes each scale as an OSC 66 span and reserves scale-1 blank rows below it", () => {
const lines = buildLargeTextLines([2, 3]);