Change to F3 legacy encoding with modifiers

The [fixterms](http://www.leonerd.org.uk/hacks/fixterms/) "Really
Special Keypresses" section suggests using CSI 1 ; Ps R for F3, but this
is also a valid cursor position report.  The intention was to make back-
compatible changes, so this is fairly considered a specification bug.

This changes F3 in legacy mode to send CSI 13 ; Ps ~ instead, this is a
variant listed in fixterms, is what kitty protocol uses, and lacks the
problematic overlap with cursor positions.

The KeyEncoder.zig unit test has been changed accordingly, and all tests
pass on my machine.
This commit is contained in:
Sam Atman
2024-12-19 17:05:29 -05:00
parent 64af685897
commit 8cadc7030c
2 changed files with 2 additions and 2 deletions

View File

@ -2067,7 +2067,7 @@ test "legacy: f1" {
{
enc.event.key = .f3;
const actual = try enc.legacy(&buf);
try testing.expectEqualStrings("\x1b[1;5R", actual);
try testing.expectEqualStrings("\x1b[13;5~", actual);
}
// F4

View File

@ -89,7 +89,7 @@ pub const keys = keys: {
// Function Keys. todo: f13-f35 but we need to add to input.Key
result.set(.f1, pcStyle("\x1b[1;{}P") ++ .{.{ .sequence = "\x1BOP" }});
result.set(.f2, pcStyle("\x1b[1;{}Q") ++ .{.{ .sequence = "\x1BOQ" }});
result.set(.f3, pcStyle("\x1b[1;{}R") ++ .{.{ .sequence = "\x1BOR" }});
result.set(.f3, pcStyle("\x1b[13;{}~") ++ .{.{ .sequence = "\x1BOR" }});
result.set(.f4, pcStyle("\x1b[1;{}S") ++ .{.{ .sequence = "\x1BOS" }});
result.set(.f5, pcStyle("\x1b[15;{}~") ++ .{.{ .sequence = "\x1B[15~" }});
result.set(.f6, pcStyle("\x1b[17;{}~") ++ .{.{ .sequence = "\x1B[17~" }});