input: keypad enter should act as normal "\r" if no other seq matches

This matches Kitty behavior on both macOS and Linux. In certain keyboard
modes and Kitty keyboard modes, the behavior changes but those already
matched (tested).
This commit is contained in:
Mitchell Hashimoto
2023-08-26 07:42:12 -07:00
parent 73ff43590c
commit 39c2332d35
2 changed files with 15 additions and 1 deletions

View File

@ -1042,6 +1042,20 @@ test "legacy: shift+function key should use all mods" {
try testing.expectEqualStrings("\x1b[1;2A", actual);
}
test "legacy: keypad enter" {
var buf: [128]u8 = undefined;
var enc: KeyEncoder = .{
.event = .{
.key = .kp_enter,
.mods = .{},
.consumed_mods = .{},
},
};
const actual = try enc.legacy(&buf);
try testing.expectEqualStrings("\r", actual);
}
test "ctrlseq: normal ctrl c" {
const seq = ctrlSeq(.c, .{ .ctrl = true });
try testing.expectEqual(@as(u8, 0x03), seq.?);

View File

@ -116,7 +116,7 @@ pub const keys = keys: {
result.set(.kp_multiply, kpDefault("j") ++ pcStyle("\x1bO{}j"));
result.set(.kp_subtract, kpDefault("m") ++ pcStyle("\x1bO{}m"));
result.set(.kp_add, kpDefault("k") ++ pcStyle("\x1bO{}k"));
result.set(.kp_enter, kpDefault("M") ++ pcStyle("\x1bO{}M"));
result.set(.kp_enter, kpDefault("M") ++ pcStyle("\x1bO{}M") ++ .{.{ .sequence = "\r" }});
result.set(.backspace, &.{
// Modify Keys Normal