mirror of
https://github.com/wez/wezterm.git
synced 2024-11-12 21:30:45 +03:00
change backspace/delete handling
Previously we would try to pass through the Backspace and Delete code points without interference, but that behavior wasn't quite right. With this commit our behavior is now: - At the window layer: Classify a `Backspace` key press as logically `BS` and a `Delete` key press as logically `DEL` unless the `swap_backspace_and_delete` is true (macOS is true by default), in which case `Backspace` is mapped to `Delete` and vice versa. - At the terminal input layer: A `Backspace` input from the Window sends the `DEL` sequence to the pty as that matches the default `VERASE` stty configuration. A `Delete` input from the Window emits `\033[3~`, which matches up to the `TERMINFO` for `xterm-256color` which we claim to be compatible with, and is our default `$TERM` value. The net result of this is that `Backspace` will now start to emit `^?` which should match folks stty verase. Heads up to @fanzeyi! I've tested this only on a linux system so far and will follow up on a macOS system a little later today. Refs: https://github.com/wez/wezterm/issues/88 Refs: https://github.com/wez/wezterm/issues/63
This commit is contained in:
parent
d3c4e8e8b6
commit
f0e94084d1
@ -919,6 +919,13 @@ impl TerminalState {
|
||||
_ => mods,
|
||||
};
|
||||
|
||||
// Normalize Backspace and Delete
|
||||
let key = match key {
|
||||
Char('\x7f') => Delete,
|
||||
Char('\x08') => Backspace,
|
||||
c => c,
|
||||
};
|
||||
|
||||
let mut buf = String::new();
|
||||
|
||||
// TODO: also respect self.application_keypad
|
||||
@ -959,12 +966,13 @@ impl TerminalState {
|
||||
buf.as_str()
|
||||
}
|
||||
|
||||
Enter | Escape | Backspace | Char('\x08') | Delete | Char('\x7f') => {
|
||||
Enter | Escape | Backspace => {
|
||||
let c = match key {
|
||||
Enter => '\r',
|
||||
Escape => '\x1b',
|
||||
Char('\x08') | Backspace => '\x08',
|
||||
Char('\x7f') | Delete => '\x7f',
|
||||
// Backspace sends the default VERASE which is confusingly
|
||||
// the DEL ascii codepoint
|
||||
Backspace => '\x7f',
|
||||
_ => unreachable!(),
|
||||
};
|
||||
if mods.contains(KeyModifiers::SHIFT) || mods.contains(KeyModifiers::CTRL) {
|
||||
@ -1058,9 +1066,10 @@ impl TerminalState {
|
||||
""
|
||||
}
|
||||
|
||||
PageUp | PageDown | Insert => {
|
||||
PageUp | PageDown | Insert | Delete => {
|
||||
let c = match key {
|
||||
Insert => 2,
|
||||
Delete => 3,
|
||||
PageUp => 5,
|
||||
PageDown => 6,
|
||||
_ => unreachable!(),
|
||||
|
Loading…
Reference in New Issue
Block a user