From 4c4d5f5a890a9ba34883b665976d7107278048bc Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 8 Mar 2024 20:52:14 -0800 Subject: [PATCH] terminal/kitty: graphics exec ported --- src/terminal/kitty/graphics_exec.zig | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/terminal/kitty/graphics_exec.zig b/src/terminal/kitty/graphics_exec.zig index b4047c1d5..65c7f5bf7 100644 --- a/src/terminal/kitty/graphics_exec.zig +++ b/src/terminal/kitty/graphics_exec.zig @@ -184,15 +184,19 @@ fn display( // Make sure our response has the image id in case we looked up by number result.id = img.id; - // Determine the screen point for the placement. - const placement_point = (point.Viewport{ - .x = terminal.screen.cursor.x, - .y = terminal.screen.cursor.y, - }).toScreen(&terminal.screen); + // Track a new pin for our cursor. The cursor is always tracked but we + // don't want this one to move with the cursor. + const placement_pin = terminal.screen.pages.trackPin( + terminal.screen.cursor.page_pin.*, + ) catch |err| { + log.warn("failed to create pin for Kitty graphics err={}", .{err}); + result.message = "EINVAL: failed to prepare terminal state"; + return result; + }; // Add the placement const p: ImageStorage.Placement = .{ - .point = placement_point, + .pin = placement_pin, .x_offset = d.x_offset, .y_offset = d.y_offset, .source_x = d.x, @@ -209,6 +213,7 @@ fn display( result.placement_id, p, ) catch |err| { + p.deinit(&terminal.screen); encodeError(&result, err); return result; };