diff --git a/src/terminfo/Source.zig b/src/terminfo/Source.zig index 0f4373df9..c61ecc060 100644 --- a/src/terminfo/Source.zig +++ b/src/terminfo/Source.zig @@ -101,8 +101,15 @@ pub fn xtgettcapMap(comptime self: Source) type { // Replace '^' with the control char version of that char. while (std.mem.indexOfScalar(u8, result, '^')) |idx| { if (idx > 0) @compileError("handle control-char in middle of string"); - const c = result[idx + 1]; - result = comptimeReplace(result, result[idx .. idx + 2], &.{c - 64}); + const replacement = switch (result[idx + 1]) { + '?' => 0x7F, // DEL, special cased from ncurses + else => |c| c - 64, + }; + result = comptimeReplace( + result, + result[idx .. idx + 2], + &.{replacement}, + ); } break :string result; }, @@ -174,6 +181,7 @@ test "xtgettcap map" { .capabilities = &.{ .{ .name = "am", .value = .{ .boolean = {} } }, .{ .name = "colors", .value = .{ .numeric = 256 } }, + .{ .name = "kx", .value = .{ .string = "^?" } }, .{ .name = "kbs", .value = .{ .string = "^H" } }, .{ .name = "kf1", .value = .{ .string = "\\EOP" } }, .{ .name = "Smulx", .value = .{ .string = "\\E[4:%p1%dm" } }, @@ -185,6 +193,10 @@ test "xtgettcap map" { "\x1bP1+r616D\x1b\\", map.get(hexencode("am")).?, ); + try testing.expectEqualStrings( + "\x1bP1+r6B78=7F\x1b\\", + map.get(hexencode("kx")).?, + ); try testing.expectEqualStrings( "\x1bP1+r6B6273=08\x1b\\", map.get(hexencode("kbs")).?, diff --git a/src/terminfo/ghostty.zig b/src/terminfo/ghostty.zig index 84059aae0..f96154c9b 100644 --- a/src/terminfo/ghostty.zig +++ b/src/terminfo/ghostty.zig @@ -304,7 +304,7 @@ pub const ghostty: Source = .{ .{ .name = "kUP5", .value = .{ .string = "\\E[1;5A" } }, .{ .name = "kUP6", .value = .{ .string = "\\E[1;6A" } }, .{ .name = "kUP7", .value = .{ .string = "\\E[1;7A" } }, - .{ .name = "kbs", .value = .{ .string = "^H" } }, + .{ .name = "kbs", .value = .{ .string = "^?" } }, .{ .name = "kcbt", .value = .{ .string = "\\E[Z" } }, .{ .name = "kcub1", .value = .{ .string = "\\EOD" } }, .{ .name = "kcud1", .value = .{ .string = "\\EOB" } },