1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-20 11:17:15 +03:00

ALT+ "function" keys incorrectly sent ESC prefixed sequences

closes: #892
This commit is contained in:
Wez Furlong 2021-09-03 11:35:01 -07:00
parent c5d1f67853
commit 8da1f676a8
2 changed files with 51 additions and 8 deletions

View File

@ -25,6 +25,7 @@ As features stabilize some brief notes about them will accumulate here.
* Fixed: macOS: `send_composed_key_when_left_alt_is_pressed` and `send_composed_key_when_right_alt_is_pressed` are now respected when `use_ime=true`. Thanks to [@jakelinnzy](https://github.com/jakelinnzy)! [#1096](https://github.com/wez/wezterm/pull/1096)
* Fixed: X11: jittery resize with some window managers [#1051](https://github.com/wez/wezterm/issues/1051)
* Fixed: X11: [window:get_appearance](config/lua/window/get_appearance.md) now actually returns Dark when the theme is dark. [#1098](https://github.com/wez/wezterm/issues/1098)
* Fixed: ALT + Arrow, PageUp/PageDown, Ins, Del, Home, End incorrectly sent ESC prefixed key sequences. [#892](https://github.com/wez/wezterm/issues/892)
### 20210814-124438-54e29167

View File

@ -379,12 +379,12 @@ impl KeyCode {
CSI
};
if mods.contains(Modifiers::SHIFT) || mods.contains(Modifiers::CTRL) {
if mods.contains(Modifiers::ALT)
|| mods.contains(Modifiers::SHIFT)
|| mods.contains(Modifiers::CTRL)
{
write!(buf, "{}1;{}{}", CSI, 1 + encode_modifiers(mods), c)?;
} else {
if mods.contains(Modifiers::ALT) {
buf.push(0x1b as char);
}
write!(buf, "{}{}", csi_or_ss3, c)?;
}
}
@ -398,12 +398,12 @@ impl KeyCode {
_ => unreachable!(),
};
if mods.contains(Modifiers::SHIFT) || mods.contains(Modifiers::CTRL) {
if mods.contains(Modifiers::ALT)
|| mods.contains(Modifiers::SHIFT)
|| mods.contains(Modifiers::CTRL)
{
write!(buf, "\x1b[{};{}~", c, 1 + encode_modifiers(mods))?;
} else {
if mods.contains(Modifiers::ALT) {
buf.push(0x1b as char);
}
write!(buf, "\x1b[{}~", c)?;
}
}
@ -1491,4 +1491,46 @@ mod test {
inputs
);
}
#[test]
fn encode_issue_892() {
let mode = KeyCodeEncodeModes {
enable_csi_u_key_encoding: false,
newline_mode: false,
application_cursor_keys: false,
};
assert_eq!(
KeyCode::LeftArrow.encode(Modifiers::NONE, mode).unwrap(),
"\x1b[D".to_string()
);
assert_eq!(
KeyCode::LeftArrow.encode(Modifiers::ALT, mode).unwrap(),
"\x1b[1;3D".to_string()
);
assert_eq!(
KeyCode::Home.encode(Modifiers::NONE, mode).unwrap(),
"\x1b[H".to_string()
);
assert_eq!(
KeyCode::Home.encode(Modifiers::ALT, mode).unwrap(),
"\x1b[1;3H".to_string()
);
assert_eq!(
KeyCode::End.encode(Modifiers::NONE, mode).unwrap(),
"\x1b[F".to_string()
);
assert_eq!(
KeyCode::End.encode(Modifiers::ALT, mode).unwrap(),
"\x1b[1;3F".to_string()
);
assert_eq!(
KeyCode::Tab.encode(Modifiers::ALT, mode).unwrap(),
"\x1b\t".to_string()
);
assert_eq!(
KeyCode::PageUp.encode(Modifiers::ALT, mode).unwrap(),
"\x1b[5;3~".to_string()
);
}
}