From ece4ebaf7242746ea50f2f3cc59993c4d1f6d3c1 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 8 Apr 2024 09:01:07 +0200 Subject: [PATCH] fish_key_reader: show unmapped function key as hex code We don't yet support all keys from https://sw.kovidgoyal.net/kitty/keyboard-protocol/#functional-key-definitions Instead of displaying a private-use character, show the character code; this can be used to map the key even if we don't know a name for it. bind \uE011 'echo print screen' bind ctrl-\uE011 'echo do control + print screen' Note that it's also possible to mape the raw CSI u sequence, like bind \e\[57361u 'echo print screen' but we should not encourage that syntax because it does not allow adding the modifiers like ctrl. Of course leaking the PUA character code is not ideal. --- src/key.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/key.rs b/src/key.rs index 2d9d692eb..4cd7b9426 100644 --- a/src/key.rs +++ b/src/key.rs @@ -421,6 +421,9 @@ fn char_to_symbol(c: char) -> WString { } else if c < '\u{80}' { // ASCII characters that are not control characters ascii_printable_to_symbol(buf, c); + } else if ('\u{e000}'..='\u{f8ff}').contains(&c) { + // Unmapped key from https://sw.kovidgoyal.net/kitty/keyboard-protocol/#functional-key-definitions + sprintf!(=> buf, "\\u%04X", u32::from(c)); } else if fish_wcwidth(c) > 0 { sprintf!(=> buf, "%lc", c); } else if c <= '\u{FFFF}' {