mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
fix(tui): add iterm payload size for xterm.js image addon (#7612)
- include decoded byte count in iterm2 osc 1337 sequences - satisfy @xterm/addon-image@0.9.0 image validation - fixes #7465
This commit is contained in:
parent
bb6a1cddc7
commit
2c233a5c04
2 changed files with 12 additions and 1 deletions
|
|
@ -250,7 +250,10 @@ export function encodeITerm2(
|
|||
inline?: boolean;
|
||||
} = {},
|
||||
): string {
|
||||
const params: string[] = [`inline=${options.inline !== false ? 1 : 0}`];
|
||||
const params: string[] = [
|
||||
`inline=${options.inline !== false ? 1 : 0}`,
|
||||
`size=${Buffer.byteLength(base64Data, "base64")}`,
|
||||
];
|
||||
|
||||
if (options.width !== undefined) params.push(`width=${options.width}`);
|
||||
if (options.height !== undefined) params.push(`height=${options.height}`);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import {
|
|||
deleteAllKittyPlacements,
|
||||
deleteKittyImage,
|
||||
detectCapabilities,
|
||||
encodeITerm2,
|
||||
encodeKitty,
|
||||
getKittyImageMetadata,
|
||||
getKittyImagePlacement,
|
||||
|
|
@ -375,6 +376,13 @@ describe("detectCapabilities", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("iTerm2 image encoding", () => {
|
||||
it("includes the decoded payload size in OSC 1337 metadata", () => {
|
||||
const sequence = encodeITerm2("AAAA", { width: 2, height: "auto" });
|
||||
assert.strictEqual(sequence, "\x1b]1337;File=inline=1;size=3;width=2;height=auto:AAAA\x07");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Kitty image cursor movement", () => {
|
||||
it("can request no terminal-side cursor movement", () => {
|
||||
const sequence = encodeKitty("AAAA", { columns: 2, rows: 2, moveCursor: false });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue