mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-22 20:31:15 -03:00
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:
@@ -72,7 +72,7 @@ function __fish_bind_complete
|
||||
printf '%sshift-\tShift modifier…\n' $prefix
|
||||
set -l key_names minus comma backspace delete escape \
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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.
|
||||
let key = match params[0][0] {
|
||||
57361 => key::PrintScreen,
|
||||
57363 => key::Menu,
|
||||
57399 => '0',
|
||||
57400 => '1',
|
||||
57401 => '2',
|
||||
|
||||
18
src/key.rs
18
src/key.rs
@@ -19,16 +19,18 @@
|
||||
pub(crate) const Right: char = '\u{F507}';
|
||||
pub(crate) const PageUp: char = '\u{F508}';
|
||||
pub(crate) const PageDown: char = '\u{F509}';
|
||||
pub(crate) const Home: char = '\u{F50a}';
|
||||
pub(crate) const End: char = '\u{F50b}';
|
||||
pub(crate) const Insert: char = '\u{F50c}';
|
||||
pub(crate) const Tab: char = '\u{F50d}';
|
||||
pub(crate) const Space: char = '\u{F50e}';
|
||||
pub(crate) const Invalid: char = '\u{F50f}';
|
||||
pub(crate) const Home: char = '\u{F50A}';
|
||||
pub(crate) const End: char = '\u{F50B}';
|
||||
pub(crate) const Insert: char = '\u{F50C}';
|
||||
pub(crate) const Tab: char = '\u{F50D}';
|
||||
pub(crate) const Space: char = '\u{F50E}';
|
||||
pub(crate) const Menu: char = '\u{F50F}';
|
||||
pub(crate) const PrintScreen: char = '\u{F510}';
|
||||
pub(crate) fn function_key(n: u32) -> char {
|
||||
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)] = &[
|
||||
('-', L!("minus")),
|
||||
@@ -48,6 +50,8 @@ pub(crate) fn function_key(n: u32) -> char {
|
||||
(Insert, L!("insert")),
|
||||
(Tab, L!("tab")),
|
||||
(Space, L!("space")),
|
||||
(Menu, L!("menu")),
|
||||
(PrintScreen, L!("printscreen")),
|
||||
];
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
|
||||
Reference in New Issue
Block a user