bind function keys (F1 to F12)

This commit is contained in:
Mitchell Hashimoto
2022-08-26 10:27:41 -07:00
parent 4ffd5cd994
commit 469515c02b
3 changed files with 45 additions and 0 deletions

View File

@ -594,6 +594,18 @@ fn keyCallback(
.end => .end, .end => .end,
.page_up => .page_up, .page_up => .page_up,
.page_down => .page_down, .page_down => .page_down,
.F1 => .f1,
.F2 => .f2,
.F3 => .f3,
.F4 => .f4,
.F5 => .f5,
.F6 => .f6,
.F7 => .f7,
.F8 => .f8,
.F9 => .f9,
.F10 => .f10,
.F11 => .f11,
.F12 => .f12,
else => .invalid, else => .invalid,
}, },
}; };

View File

@ -94,6 +94,26 @@ pub const Config = struct {
try result.keybind.set.put(alloc, .{ .key = .page_up }, .{ .csi = "5~" }); try result.keybind.set.put(alloc, .{ .key = .page_up }, .{ .csi = "5~" });
try result.keybind.set.put(alloc, .{ .key = .page_down }, .{ .csi = "6~" }); try result.keybind.set.put(alloc, .{ .key = .page_down }, .{ .csi = "6~" });
// From xterm:
// Note that F1 through F4 are prefixed with SS3 , while the other keys are
// prefixed with CSI . Older versions of xterm implement different escape
// sequences for F1 through F4, with a CSI prefix. These can be activated
// by setting the oldXtermFKeys resource. However, since they do not
// correspond to any hardware terminal, they have been deprecated. (The
// DEC VT220 reserves F1 through F5 for local functions such as Setup).
try result.keybind.set.put(alloc, .{ .key = .f1 }, .{ .csi = "11~" });
try result.keybind.set.put(alloc, .{ .key = .f2 }, .{ .csi = "12~" });
try result.keybind.set.put(alloc, .{ .key = .f3 }, .{ .csi = "13~" });
try result.keybind.set.put(alloc, .{ .key = .f4 }, .{ .csi = "14~" });
try result.keybind.set.put(alloc, .{ .key = .f5 }, .{ .csi = "15~" });
try result.keybind.set.put(alloc, .{ .key = .f6 }, .{ .csi = "17~" });
try result.keybind.set.put(alloc, .{ .key = .f7 }, .{ .csi = "18~" });
try result.keybind.set.put(alloc, .{ .key = .f8 }, .{ .csi = "19~" });
try result.keybind.set.put(alloc, .{ .key = .f9 }, .{ .csi = "20~" });
try result.keybind.set.put(alloc, .{ .key = .f10 }, .{ .csi = "21~" });
try result.keybind.set.put(alloc, .{ .key = .f11 }, .{ .csi = "23~" });
try result.keybind.set.put(alloc, .{ .key = .f12 }, .{ .csi = "24~" });
return result; return result;
} }
}; };

View File

@ -59,6 +59,19 @@ pub const Key = enum {
page_up, page_up,
page_down, page_down,
f1,
f2,
f3,
f4,
f5,
f6,
f7,
f8,
f9,
f10,
f11,
f12,
// To support more keys (there are obviously more!) add them here // To support more keys (there are obviously more!) add them here
// and ensure the mapping is up to date in the Window key handler. // and ensure the mapping is up to date in the Window key handler.
}; };