diff --git a/term/src/terminalstate/keyboard.rs b/term/src/terminalstate/keyboard.rs index 0381f1cfc..a98b2afe6 100644 --- a/term/src/terminalstate/keyboard.rs +++ b/term/src/terminalstate/keyboard.rs @@ -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()?; diff --git a/termwiz/src/input.rs b/termwiz/src/input.rs index 6371bcb40..f51d47714 100644 --- a/termwiz/src/input.rs +++ b/termwiz/src/input.rs @@ -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() + ); } }