1
1
mirror of https://github.com/wez/wezterm.git synced 2025-01-03 11:11:43 +03:00

win32: fix encoding of delete and backspace keys

When using the win32 keyboard encoding, the delete and backspace keys
were encoded with the wrong character codes compared to the native
terminal. This caused subtle issues in multiple applications.

This change brings the encoding in line with the native terminal.
This commit is contained in:
Dominik Kreutzer 2022-07-09 03:56:53 +02:00 committed by Wez Furlong
parent 686daf7bca
commit 51c30e2ee2

View File

@ -1222,13 +1222,33 @@ impl KeyEvent {
match &self.key { match &self.key {
KeyCode::Composed(_) => None, KeyCode::Composed(_) => None,
KeyCode::Char(c) => { KeyCode::Char(c) => {
let c = match *c {
// Delete key is transmitted as 0x0
'\x7f' => '\x00',
// Backspace key is transmitted as 0x8, 0x7f or 0x0
'\x08' => {
if self.modifiers.contains(Modifiers::CTRL) {
if self.modifiers.contains(Modifiers::ALT)
|| self.modifiers.contains(Modifiers::SHIFT)
{
'\x00'
} else {
'\x7f'
}
} else {
'\x08'
}
}
_ => *c,
};
let c = if self.modifiers.contains(Modifiers::CTRL) { let c = if self.modifiers.contains(Modifiers::CTRL) {
// Ensure that we rewrite the unicode value to the ASCII CTRL // Ensure that we rewrite the unicode value to the ASCII CTRL
// equivalent value. // equivalent value.
// <https://github.com/microsoft/terminal/issues/13134> // <https://github.com/microsoft/terminal/issues/13134>
ctrl_mapping(*c).unwrap_or(*c) ctrl_mapping(c).unwrap_or(c)
} else { } else {
*c c
}; };
let uni = c as u32; let uni = c as u32;