Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): copy terminal selection instead of a blank clipboard #7678

Mergedsethwebster(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/7678/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 3 changed files with 182 additions and 0 deletions (loading 1).

x
0 of 3 viewed, 3 left
83 additions and 0 deletionsapps/web/src/terminal/ghostty/runtimeAbi.test.tsModified
View file
@@ -320,6 +320,89 @@
call("ghostty_wasm_free_u8_array", options, 8);
});
​
+ it("formats a cell-drag selection installed from screen grid refs", async () => {
+ const result = await WebAssembly.instantiate(
+ decodeWasmDataUrl(wasmDataUrl).buffer as ArrayBuffer,
+ { env: { log: () => {} } },
+ );
+ const instance = result instanceof WebAssembly.Instance ? result : result.instance;
+ const memory = instance.exports.memory as WebAssembly.Memory;
+ const call = (name: string, ...args: number[]) =>
+ (instance.exports[name] as WasmFunction)(...args);
+ const alloc = (size: number) => call("ghostty_wasm_alloc_u8_array", size);
+ const free = (pointer: number, size: number) =>
+ call("ghostty_wasm_free_u8_array", pointer, size);
+ const options = alloc(8);
+ new DataView(memory.buffer, options, 8).setUint16(0, 80, true);
+ new DataView(memory.buffer, options, 8).setUint16(2, 24, true);
+ const terminalSlot = call("ghostty_wasm_alloc_opaque");
+ expect(call("ghostty_terminal_new", 0, terminalSlot, options)).toBe(0);
+ const terminal = new DataView(memory.buffer).getUint32(terminalSlot, true);
+ const input = new TextEncoder().encode("hello\r\nworld");
+ const inputPointer = alloc(input.length);
+ new Uint8Array(memory.buffer, inputPointer, input.length).set(input);
+ call("ghostty_terminal_vt_write", terminal, inputPointer, input.length);
+​
+ const gridRefAt = (x: number, y: number) => {
+ const point = alloc(24);
+ const pointView = new DataView(memory.buffer, point, 24);