diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-16 23:28:05 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-16 23:29:28 +0300 |
| commit | 4a3302d19a2baa3a33e910e0088c24e780905b90 (patch) | |
| tree | dcaf76fae1c82102d933c9225b17ca7ac5d3a847 /vendor/patches | |
| parent | 550e9f8cc085f428429f5cf2da0bb2dba897e8b8 (diff) | |
chore: update vendored libghostty-vt
refs #276
Diffstat (limited to 'vendor/patches')
3 files changed, 22 insertions, 227 deletions
diff --git a/vendor/patches/libghostty-vt/0001-backport-resizecols-cursor-subtraction.patch b/vendor/patches/libghostty-vt/0001-backport-resizecols-cursor-subtraction.patch deleted file mode 100644 index 1f8d0f36..00000000 --- a/vendor/patches/libghostty-vt/0001-backport-resizecols-cursor-subtraction.patch +++ /dev/null @@ -1,115 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: herdr maintainers <maintainers@herdr.dev> -Date: Thu, 4 Jun 2026 00:00:00 +0000 -Subject: [PATCH] backport resizeCols cursor subtraction saturation - -Backport ghostty-org/ghostty#12907 onto the vendored libghostty-vt source. -Shrink-both resize can leave the old cursor row past the new row count after -resizeWithoutReflow reduces self.rows. Saturating subtraction treats rows below -that cursor as zero instead of trapping in safety builds. - -Herdr issue: https://github.com/ogulcancelik/herdr/issues/465 -Upstream discussion: https://github.com/ghostty-org/ghostty/discussions/12905 -Upstream PR: https://github.com/ghostty-org/ghostty/pull/12907 -Vendored base: 0f7cd84b880b203c98683e520e84b9db0c5938d8 ---- - vendor/libghostty-vt/src/terminal/PageList.zig | 33 +++++++++++++++++++++-- - vendor/libghostty-vt/src/terminal/c/terminal.zig | 23 ++++++++++++++++ - 2 files changed, 54 insertions(+), 2 deletions(-) - -diff --git a/vendor/libghostty-vt/src/terminal/PageList.zig b/vendor/libghostty-vt/src/terminal/PageList.zig -index 0000000..0000000 100644 ---- a/vendor/libghostty-vt/src/terminal/PageList.zig -+++ b/vendor/libghostty-vt/src/terminal/PageList.zig -@@ -1059,7 +1059,7 @@ fn resizeCols( - break :cursor .{ - .tracked_pin = c.pin orelse try self.trackPin(p), - .untrack = c.pin == null, -- .remaining_rows = self.rows - c.y - 1, -+ .remaining_rows = self.rows -| (c.y + 1), - .wrapped_rows = wrapped, - }; - } else null; -@@ -1192,7 +1192,7 @@ fn resizeCols( - break :wrapped wrapped; - }; - -- const current = self.rows - active_pt.active.y - 1; -+ const current = self.rows -| (active_pt.active.y + 1); - - var req_rows = c.remaining_rows; - req_rows -|= wrapped -| c.wrapped_rows; -@@ -10828,6 +10828,37 @@ test "PageList resize (no reflow) less rows and cols" { - } - } - -+test "PageList resize less rows and cols cursor at bottom" { -+ const testing = std.testing; -+ const alloc = testing.allocator; -+ -+ var s = try init(alloc, 80, 24, 0); -+ defer s.deinit(); -+ -+ const cursor_pin = try s.trackPin(s.pin(.{ .active = .{ -+ .x = 0, -+ .y = s.rows - 1, -+ } }).?); -+ defer s.untrackPin(cursor_pin); -+ -+ // Shrink both axes so the original cursor.y is strictly past the new row -+ // count, after resizeWithoutReflow has already reduced self.rows. -+ try s.resize(.{ -+ .cols = 79, -+ .rows = 20, -+ .reflow = true, -+ .cursor = .{ .x = 0, .y = 23, .pin = cursor_pin }, -+ }); -+ try testing.expectEqual(@as(usize, 79), s.cols); -+ try testing.expectEqual(@as(usize, 20), s.rows); -+ -+ // remaining_rows saturates to 0, so the cursor lands on the new bottom row. -+ try testing.expectEqual(point.Point{ .active = .{ -+ .x = 0, -+ .y = s.rows - 1, -+ } }, s.pointFromPin(.active, cursor_pin.*).?); -+} -+ - test "PageList resize (no reflow) more rows and less cols" { - const testing = std.testing; - const alloc = testing.allocator; -diff --git a/vendor/libghostty-vt/src/terminal/c/terminal.zig b/vendor/libghostty-vt/src/terminal/c/terminal.zig -index 0000000..0000000 100644 ---- a/vendor/libghostty-vt/src/terminal/c/terminal.zig -+++ b/vendor/libghostty-vt/src/terminal/c/terminal.zig -@@ -1005,6 +1005,29 @@ test "resize invalid value" { - try testing.expectEqual(Result.invalid_value, resize(t, 80, 0, 9, 18)); - } - -+test "resize shrinks both axes with cursor at bottom" { -+ var t: Terminal = null; -+ try testing.expectEqual(Result.success, new( -+ &lib.alloc.test_allocator, -+ &t, -+ .{ -+ .cols = 80, -+ .rows = 24, -+ .max_scrollback = 0, -+ }, -+ )); -+ defer free(t); -+ -+ // CSI 24;1H parks the cursor on the bottom row. -+ const move = "\x1b[24;1H"; -+ vt_write(t, move, move.len); -+ -+ // Shrink both axes; pre-resize cursor.y sits past the new bottom row. -+ try testing.expectEqual(Result.success, resize(t, 79, 23, 8, 16)); -+ try testing.expectEqual(79, t.?.terminal.cols); -+ try testing.expectEqual(23, t.?.terminal.rows); -+} -+ - test "mode_get and mode_set" { - var t: Terminal = null; - try testing.expectEqual(Result.success, new( --- -2.49.0 diff --git a/vendor/patches/libghostty-vt/0001-default-grapheme-cluster-mode.patch b/vendor/patches/libghostty-vt/0001-default-grapheme-cluster-mode.patch new file mode 100644 index 00000000..546112c7 --- /dev/null +++ b/vendor/patches/libghostty-vt/0001-default-grapheme-cluster-mode.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: herdr maintainers <maintainers@herdr.dev> +Date: Wed, 15 Jul 2026 00:00:00 +0000 +Subject: [PATCH] default lib-vt panes to grapheme clustering + +Herdr renders libghostty-vt cells directly and requires DEC mode 2027 to +store multi-codepoint grapheme clusters in one terminal cell. Set it in the +terminal's default modes so RIS restores clustering instead of disabling it. + +Herdr issue: https://github.com/ogulcancelik/herdr/issues/243 +Vendored base: c5a21edfcbc2d5b46540ad91b7980aca31f5f1f3 +--- +diff --git a/vendor/libghostty-vt/src/terminal/c/terminal.zig b/vendor/libghostty-vt/src/terminal/c/terminal.zig +index 1c3b9f0c..a896c0fd 100644 +--- a/vendor/libghostty-vt/src/terminal/c/terminal.zig ++++ b/vendor/libghostty-vt/src/terminal/c/terminal.zig +@@ -344,4 +344,5 @@ fn new_( + .rows = opts.rows, + .max_scrollback = opts.max_scrollback, ++ .default_modes = .{ .grapheme_cluster = true }, + }); + errdefer t.deinit(alloc); diff --git a/vendor/patches/libghostty-vt/0002-expose-kitty-image-transmit-time-ns.patch b/vendor/patches/libghostty-vt/0002-expose-kitty-image-transmit-time-ns.patch deleted file mode 100644 index 4289740c..00000000 --- a/vendor/patches/libghostty-vt/0002-expose-kitty-image-transmit-time-ns.patch +++ /dev/null @@ -1,112 +0,0 @@ -diff --git a/vendor/libghostty-vt/include/ghostty/vt/kitty_graphics.h b/vendor/libghostty-vt/include/ghostty/vt/kitty_graphics.h -index 9bace3a..d5b5006 100644 ---- a/vendor/libghostty-vt/include/ghostty/vt/kitty_graphics.h -+++ b/vendor/libghostty-vt/include/ghostty/vt/kitty_graphics.h -@@ -343,6 +343,15 @@ typedef enum GHOSTTY_ENUM_TYPED { - */ - GHOSTTY_KITTY_IMAGE_DATA_DATA_LEN = 8, - -+ /** -+ * Timestamp of the image's most recent transmission, in nanoseconds. -+ * The epoch is unspecified; only equality and ordering between values -+ * read from the same terminal are meaningful. -+ * -+ * Output type: uint64_t * -+ */ -+ GHOSTTY_KITTY_IMAGE_DATA_TRANSMIT_TIME_NS = 9, -+ - GHOSTTY_KITTY_IMAGE_DATA_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE, - } GhosttyKittyGraphicsImageData; - -diff --git a/vendor/libghostty-vt/src/terminal/c/kitty_graphics.zig b/vendor/libghostty-vt/src/terminal/c/kitty_graphics.zig -index d50b8c4..a00632e 100644 ---- a/vendor/libghostty-vt/src/terminal/c/kitty_graphics.zig -+++ b/vendor/libghostty-vt/src/terminal/c/kitty_graphics.zig -@@ -178,6 +178,7 @@ pub const ImageData = enum(c_int) { - compression = 6, - data_ptr = 7, - data_len = 8, -+ transmit_time_ns = 9, - - pub fn OutType(comptime self: ImageData) type { - return switch (self) { -@@ -187,6 +188,7 @@ pub const ImageData = enum(c_int) { - .compression => ImageCompression, - .data_ptr => [*]const u8, - .data_len => usize, -+ .transmit_time_ns => u64, - }; - } - }; -@@ -258,11 +260,22 @@ fn imageGetTyped( - .compression => out.* = image.compression, - .data_ptr => out.* = image.data.ptr, - .data_len => out.* = image.data.len, -+ .transmit_time_ns => out.* = instantNanos(image.transmit_time), - } - - return .success; - } - -+/// Flattens an Instant's platform timestamp to nanoseconds for the C API. -+/// The epoch is unspecified; only equality and ordering are meaningful. -+fn instantNanos(instant: std.time.Instant) u64 { -+ if (@TypeOf(instant.timestamp) == u64) return instant.timestamp; -+ const ts = instant.timestamp; -+ const sec: u64 = @intCast(@max(ts.sec, 0)); -+ const nsec: u64 = @intCast(@max(ts.nsec, 0)); -+ return sec *| std.time.ns_per_s +| nsec; -+} -+ - pub fn placement_iterator_new( - alloc_: ?*const CAllocator, - out: *PlacementIterator, -@@ -977,6 +990,48 @@ test "image_get_handle and image_get with transmitted image" { - try testing.expect(data_len > 0); - } - -+test "image_get transmit_time_ns changes on retransmission" { -+ if (comptime !build_options.kitty_graphics) return error.SkipZigTest; -+ -+ var t: terminal_c.Terminal = null; -+ try testing.expectEqual(Result.success, terminal_c.new( -+ &lib.alloc.test_allocator, -+ &t, -+ .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, -+ )); -+ defer terminal_c.free(t); -+ -+ const cmd = "\x1b_Ga=T,t=d,f=24,i=1,p=1,s=1,v=2;////////\x1b\\"; -+ terminal_c.vt_write(t, cmd.ptr, cmd.len); -+ -+ var graphics: KittyGraphics = undefined; -+ try testing.expectEqual(Result.success, terminal_c.get( -+ t, -+ .kitty_graphics, -+ @ptrCast(&graphics), -+ )); -+ -+ var first: u64 = undefined; -+ try testing.expectEqual(Result.success, image_get( -+ image_get_handle(graphics, 1), -+ .transmit_time_ns, -+ @ptrCast(&first), -+ )); -+ try testing.expect(first > 0); -+ -+ std.Thread.sleep(1 * std.time.ns_per_ms); -+ const retransmit = "\x1b_Ga=t,t=d,f=24,i=1,s=1,v=2;AAAAAAAA\x1b\\"; -+ terminal_c.vt_write(t, retransmit.ptr, retransmit.len); -+ -+ var second: u64 = undefined; -+ try testing.expectEqual(Result.success, image_get( -+ image_get_handle(graphics, 1), -+ .transmit_time_ns, -+ @ptrCast(&second), -+ )); -+ try testing.expect(second > first); -+} -+ - test "placement_rect with transmit and display" { - if (comptime !build_options.kitty_graphics) return error.SkipZigTest; - |
