summaryrefslogtreecommitdiff
path: root/src/Terminal.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Terminal.zig')
-rw-r--r--src/Terminal.zig17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/Terminal.zig b/src/Terminal.zig
index 32595d25..c99a92a6 100644
--- a/src/Terminal.zig
+++ b/src/Terminal.zig
@@ -1113,6 +1113,11 @@ pub fn forwardKey(p: *Pardes, id: usize, key: Key) void {
const pane = p.panes[id] orelse return;
const state = pane.terminal orelse return;
const input = ghostty_vt.input;
+ const function_keys = comptime keys: {
+ var keys: [Key.f25 - Key.f1 + 1]input.Key = undefined;
+ for (&keys, 1..) |*k, n| k.* = @field(input.Key, std.fmt.comptimePrint("f{d}", .{n}));
+ break :keys keys;
+ };
const physical: input.Key = switch (key.cp) {
Key.enter => .enter,
Key.backspace => .backspace,
@@ -1127,11 +1132,21 @@ pub fn forwardKey(p: *Pardes, id: usize, key: Key) void {
Key.page_up => .page_up,
Key.page_down => .page_down,
Key.delete => .delete,
+ Key.insert => .insert,
+ Key.print_screen => .print_screen,
+ Key.scroll_lock => .scroll_lock,
+ Key.pause => .pause,
+ Key.menu => .context_menu,
+ Key.f1...Key.f25 => function_keys[key.cp - Key.f1],
else => if (key.cp < 128) input.Key.fromASCII(@intCast(key.cp)) orelse .unidentified else .unidentified,
};
var utf8: [4]u8 = undefined;
const text_cp = if (key.shift and key.cp >= 'a' and key.cp <= 'z') key.cp - 'a' + 'A' else key.cp;
- const text = if (key.text.len > 0) key.text else if (key.cp >= 32 and key.cp < Key.up and key.cp != Key.backspace)
+ // A key with no text of its own types its code point only when that
+ // is a character: the kitty keyboard protocol numbers function and
+ // modifier keys in the private use area (F3 is U+E016), and a shell
+ // was typed those as junk.
+ const text = if (key.text.len > 0) key.text else if (key.cp >= 32 and key.cp < Key.up and key.cp != Key.backspace and !(key.cp >= 0xE000 and key.cp <= 0xF8FF))
utf8[0 .. std.unicode.utf8Encode(text_cp, &utf8) catch return]
else
"";