From 128ec7cd047ab0d9ceb4f0b5c2c449984702266d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 21 Aug 2026 12:26:56 -0700 Subject: [PATCH] terminal: rename paste_events mode to kitty_paste_events --- src/terminal/modes.zig | 7 +++---- src/terminal/snapshot/snapshot.ksy | 6 ++++-- src/terminal/snapshot/terminal.zig | 30 ++++++++++++++++++++---------- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/terminal/modes.zig b/src/terminal/modes.zig index 9b95e85ce..baacd0089 100644 --- a/src/terminal/modes.zig +++ b/src/terminal/modes.zig @@ -332,10 +332,9 @@ const entries: []const ModeEntry = &.{ // one-time password instead of pasting the text. // See https://sw.kovidgoyal.net/kitty/clipboard/ // - // Disabled until the apprt paste integration lands; until then the - // mode reports as unrecognized so applications correctly detect - // paste events as unsupported. - .{ .name = "paste_events", .value = 5522, .disabled = true }, + // Forcibly disabled for now since the functionality isn't exposed + // yet to libghostty or any GUI apps. + .{ .name = "kitty_paste_events", .value = 5522, .disabled = true }, }; test { diff --git a/src/terminal/snapshot/snapshot.ksy b/src/terminal/snapshot/snapshot.ksy index 80a1d182f..2da917ea3 100644 --- a/src/terminal/snapshot/snapshot.ksy +++ b/src/terminal/snapshot/snapshot.ksy @@ -390,13 +390,13 @@ types: Each named instance exposes one bit from the little-endian integer. Arithmetic division is used instead of bitwise operations because the JavaScript target implements those operations with signed 32-bit values. - All values remain exact because the registry occupies only 42 bits, + All values remain exact because the registry occupies only 43 bits, within JavaScript's 53-bit safe integer range. seq: - id: raw type: u8 valid: - max: 4398046511103 + max: 8796093022207 instances: disable_keyboard: value: (raw / 1) % 2 != 0 @@ -482,6 +482,8 @@ types: value: (raw / 1099511627776) % 2 != 0 in_band_size_reports: value: (raw / 2199023255552) % 2 != 0 + kitty_paste_events: + value: (raw / 4398046511104) % 2 != 0 tab_stops: params: diff --git a/src/terminal/snapshot/terminal.zig b/src/terminal/snapshot/terminal.zig index f20b97707..11c9004bb 100644 --- a/src/terminal/snapshot/terminal.zig +++ b/src/terminal/snapshot/terminal.zig @@ -206,7 +206,8 @@ //! bit 39 report_color_scheme //! bit 40 report_visibility //! bit 41 in_band_size_reports -//! bits 42-63 reserved, zero +//! bit 42 kitty_paste_events +//! bits 43-63 reserved, zero //! ``` //! //! This is the packed field order of native `ModePacked`. Its layout is @@ -470,7 +471,7 @@ pub const Header = struct { try writer.writeByte(@intCast(@intFromEnum(self.mouse_shape))); try writer.writeByte(@intFromBool(self.password_input)); - // Runtime, saved, and reset mode sets. ModePacked occupies 41 bits; + // Runtime, saved, and reset mode sets. ModePacked occupies 43 bits; // its eight-byte wire slots zero-extend the native packed value. const mode_values = [_]terminal_modes.ModePacked{ self.current_modes, @@ -1203,7 +1204,7 @@ const test_header_fixture = test_fixture.parse( test "TERMINAL mode bit layout" { try std.testing.expectEqual( - @as(usize, 42), + @as(usize, 43), @bitSizeOf(terminal_modes.ModePacked), ); @@ -1212,8 +1213,8 @@ test "TERMINAL mode bit layout" { ); first.disable_keyboard = true; try std.testing.expectEqual( - @as(u42, 1) << 0, - @as(u42, @bitCast(first)), + @as(u43, 1) << 0, + @as(u43, @bitCast(first)), ); var visibility: terminal_modes.ModePacked = std.mem.zeroes( @@ -1221,17 +1222,26 @@ test "TERMINAL mode bit layout" { ); visibility.report_visibility = true; try std.testing.expectEqual( - @as(u42, 1) << 40, - @as(u42, @bitCast(visibility)), + @as(u43, 1) << 40, + @as(u43, @bitCast(visibility)), + ); + + var size_reports: terminal_modes.ModePacked = std.mem.zeroes( + terminal_modes.ModePacked, + ); + size_reports.in_band_size_reports = true; + try std.testing.expectEqual( + @as(u43, 1) << 41, + @as(u43, @bitCast(size_reports)), ); var last: terminal_modes.ModePacked = std.mem.zeroes( terminal_modes.ModePacked, ); - last.in_band_size_reports = true; + last.kitty_paste_events = true; try std.testing.expectEqual( - @as(u42, 1) << 41, - @as(u42, @bitCast(last)), + @as(u43, 1) << 42, + @as(u43, @bitCast(last)), ); }