mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-21 19:26:09 +03:00
Merge pull request #662 from mitchellh/legacy-sides
input: legacy encoding pc style keys should ignore directional modifiers
This commit is contained in:
@ -319,7 +319,11 @@ fn pcStyleFunctionKey(
|
|||||||
keypad_key_application: bool,
|
keypad_key_application: bool,
|
||||||
modify_other_keys: bool, // True if state 2
|
modify_other_keys: bool, // True if state 2
|
||||||
) ?[]const u8 {
|
) ?[]const u8 {
|
||||||
const mods_int = mods.int();
|
// We only want binding-sensitive mods because lock keys
|
||||||
|
// and directional modifiers (left/right) don't matter for
|
||||||
|
// pc-style function keys.
|
||||||
|
const mods_int = mods.binding().int();
|
||||||
|
|
||||||
for (function_keys.keys.get(keyval)) |entry| {
|
for (function_keys.keys.get(keyval)) |entry| {
|
||||||
switch (entry.cursor) {
|
switch (entry.cursor) {
|
||||||
.any => {},
|
.any => {},
|
||||||
@ -1328,6 +1332,38 @@ test "legacy: f1" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "legacy: left_shift+tab" {
|
||||||
|
var buf: [128]u8 = undefined;
|
||||||
|
var enc: KeyEncoder = .{
|
||||||
|
.event = .{
|
||||||
|
.key = .tab,
|
||||||
|
.mods = .{
|
||||||
|
.shift = true,
|
||||||
|
.sides = .{ .shift = .left },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const actual = try enc.legacy(&buf);
|
||||||
|
try testing.expectEqualStrings("\x1b[Z", actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
test "legacy: right_shift+tab" {
|
||||||
|
var buf: [128]u8 = undefined;
|
||||||
|
var enc: KeyEncoder = .{
|
||||||
|
.event = .{
|
||||||
|
.key = .tab,
|
||||||
|
.mods = .{
|
||||||
|
.shift = true,
|
||||||
|
.sides = .{ .shift = .right },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const actual = try enc.legacy(&buf);
|
||||||
|
try testing.expectEqualStrings("\x1b[Z", actual);
|
||||||
|
}
|
||||||
|
|
||||||
test "ctrlseq: normal ctrl c" {
|
test "ctrlseq: normal ctrl c" {
|
||||||
const seq = ctrlSeq(.c, .{ .ctrl = true });
|
const seq = ctrlSeq(.c, .{ .ctrl = true });
|
||||||
try testing.expectEqual(@as(u8, 0x03), seq.?);
|
try testing.expectEqual(@as(u8, 0x03), seq.?);
|
||||||
|
Reference in New Issue
Block a user