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.
This commit is contained in:
Johannes Altmanninger
2024-04-08 09:01:07 +02:00
parent 1c41bcd1a4
commit ece4ebaf72

View File

@@ -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}' {