Add menu and printscreen keys

These aren't typically used in the terminal but they are present on
many keyboards.

Also reorganize the named key constants a bit.  Between F500 and
ENCODE_DIRECT_BASE (F600) we have space for 256 named keys.
This commit is contained in:
Johannes Altmanninger
2025-01-01 21:32:40 +01:00
parent f9b79926f1
commit 109ef88831
3 changed files with 14 additions and 8 deletions

View File

@@ -72,7 +72,7 @@ function __fish_bind_complete
printf '%sshift-\tShift modifier…\n' $prefix printf '%sshift-\tShift modifier…\n' $prefix
set -l key_names minus comma backspace delete escape \ set -l key_names minus comma backspace delete escape \
enter up down left right pageup pagedown home end insert tab \ enter up down left right pageup pagedown home end insert tab \
space f(seq 12) space menu printscreen f(seq 12)
printf '%s\tNamed key\n' $prefix$key_names printf '%s\tNamed key\n' $prefix$key_names
end end
end end

View File

@@ -1114,6 +1114,8 @@ fn parse_csi(&mut self, buffer: &mut Vec<u8>) -> Option<Key> {
// Treat numpad keys the same as their non-numpad counterparts. Could add a numpad modifier here. // Treat numpad keys the same as their non-numpad counterparts. Could add a numpad modifier here.
let key = match params[0][0] { let key = match params[0][0] {
57361 => key::PrintScreen,
57363 => key::Menu,
57399 => '0', 57399 => '0',
57400 => '1', 57400 => '1',
57401 => '2', 57401 => '2',

View File

@@ -19,16 +19,18 @@
pub(crate) const Right: char = '\u{F507}'; pub(crate) const Right: char = '\u{F507}';
pub(crate) const PageUp: char = '\u{F508}'; pub(crate) const PageUp: char = '\u{F508}';
pub(crate) const PageDown: char = '\u{F509}'; pub(crate) const PageDown: char = '\u{F509}';
pub(crate) const Home: char = '\u{F50a}'; pub(crate) const Home: char = '\u{F50A}';
pub(crate) const End: char = '\u{F50b}'; pub(crate) const End: char = '\u{F50B}';
pub(crate) const Insert: char = '\u{F50c}'; pub(crate) const Insert: char = '\u{F50C}';
pub(crate) const Tab: char = '\u{F50d}'; pub(crate) const Tab: char = '\u{F50D}';
pub(crate) const Space: char = '\u{F50e}'; pub(crate) const Space: char = '\u{F50E}';
pub(crate) const Invalid: char = '\u{F50f}'; pub(crate) const Menu: char = '\u{F50F}';
pub(crate) const PrintScreen: char = '\u{F510}';
pub(crate) fn function_key(n: u32) -> char { pub(crate) fn function_key(n: u32) -> char {
assert!((1..=12).contains(&n)); assert!((1..=12).contains(&n));
char::from_u32(u32::from(Invalid) + n).unwrap() char::from_u32(u32::from('\u{F5FF}') - n).unwrap()
} }
pub(crate) const Invalid: char = '\u{F5FF}';
const KEY_NAMES: &[(char, &wstr)] = &[ const KEY_NAMES: &[(char, &wstr)] = &[
('-', L!("minus")), ('-', L!("minus")),
@@ -48,6 +50,8 @@ pub(crate) fn function_key(n: u32) -> char {
(Insert, L!("insert")), (Insert, L!("insert")),
(Tab, L!("tab")), (Tab, L!("tab")),
(Space, L!("space")), (Space, L!("space")),
(Menu, L!("menu")),
(PrintScreen, L!("printscreen")),
]; ];
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]