1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-27 02:25:28 +03:00

term: fix encoding F1-F4

This was accidentally broken by 8da1f676a8

refs: #892
This commit is contained in:
Wez Furlong 2021-09-12 09:27:39 -07:00
parent 1f97a8324e
commit 0e5d0d8117
2 changed files with 16 additions and 8 deletions

View File

@ -17,7 +17,7 @@ impl TerminalState {
},
)?;
// debug!("sending {:?}, {:?}", to_send, key);
log::trace!("sending {:?}, {:?}", to_send, key);
self.writer.write_all(to_send.as_bytes())?;
self.writer.flush()?;

View File

@ -411,13 +411,17 @@ impl KeyCode {
Function(n) => {
if mods.is_empty() && n < 5 {
// F1-F4 are encoded using SS3 if there are no modifiers
match n {
1 => "\x1bOP",
2 => "\x1bOQ",
3 => "\x1bOR",
4 => "\x1bOS",
_ => unreachable!("wat?"),
};
write!(
buf,
"{}",
match n {
1 => "\x1bOP",
2 => "\x1bOQ",
3 => "\x1bOR",
4 => "\x1bOS",
_ => unreachable!("wat?"),
}
)?;
} else {
// Higher numbered F-keys plus modified F-keys are encoded
// using CSI instead of SS3.
@ -1532,5 +1536,9 @@ mod test {
KeyCode::PageUp.encode(Modifiers::ALT, mode).unwrap(),
"\x1b[5;3~".to_string()
);
assert_eq!(
KeyCode::Function(1).encode(Modifiers::NONE, mode).unwrap(),
"\x1bOP".to_string()
);
}
}