mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
terminfo: reset kbs back to ^?, clear high bit for encoding
This commit is contained in:
@ -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")).?,
|
||||
|
@ -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" } },
|
||||
|
Reference in New Issue
Block a user