1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-25 22:33:52 +03:00

kitty keeb: avoid sending function codes in mode 1

refs: #3626
This commit is contained in:
Wez Furlong 2023-04-15 19:15:26 -07:00
parent c544b0edce
commit a562cb5a92
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387

View File

@ -1842,18 +1842,16 @@ impl KeyEvent {
} }
_ => { _ => {
if self.key.is_modifier() let code = self.raw.as_ref().and_then(|raw| raw.kitty_function_code());
&& !flags.contains(KittyKeyboardFlags::REPORT_ALL_KEYS_AS_ESCAPE_CODES)
{ match (
// Don't report bare modifier only key events unless code,
// we're reporting all keys with escape codes flags.contains(KittyKeyboardFlags::REPORT_ALL_KEYS_AS_ESCAPE_CODES),
String::new() ) {
} else if let Some(code) = (Some(code), true) => {
self.raw.as_ref().and_then(|raw| raw.kitty_function_code()) format!("\x1b[{code};{modifiers}{event_type}{generated_text}u")
{ }
format!("\x1b[{code};{modifiers}{event_type}{generated_text}u") _ => String::new(),
} else {
String::new()
} }
} }
} }
@ -2652,5 +2650,37 @@ mod test {
.encode_kitty(flags), .encode_kitty(flags),
" ".to_string() " ".to_string()
); );
assert_eq!(
make_event_with_raw(
KeyEvent {
key: KeyCode::NumLock,
modifiers: Modifiers::NONE,
leds: KeyboardLedStatus::empty(),
repeat_count: 1,
key_is_down: true,
raw: None
},
Some(PhysKeyCode::NumLock)
)
.encode_kitty(flags),
"".to_string()
);
assert_eq!(
make_event_with_raw(
KeyEvent {
key: KeyCode::CapsLock,
modifiers: Modifiers::NONE,
leds: KeyboardLedStatus::empty(),
repeat_count: 1,
key_is_down: true,
raw: None,
},
Some(PhysKeyCode::CapsLock)
)
.encode_kitty(flags),
"".to_string()
);
} }
} }