diff --git a/crates/beer-protocols/src/key.rs b/crates/beer-protocols/src/key.rs index 0dc0348..edc0780 100644 --- a/crates/beer-protocols/src/key.rs +++ b/crates/beer-protocols/src/key.rs @@ -9,8 +9,8 @@ use smithay_client_toolkit::seat::keyboard::{KeyEvent, Keysym, Modifiers}; /// (DECCKM). pub fn encode(event: &KeyEvent, mods: Modifiers, app_cursor: bool) -> Option> { let seq = match event.keysym { - Keysym::Return | Keysym::KP_Enter => prefix_alt(b"\r".to_vec(), mods), - Keysym::BackSpace => prefix_alt(b"\x7f".to_vec(), mods), + Keysym::Return | Keysym::KP_Enter => prefix_alt(b"\r", mods), + Keysym::BackSpace => prefix_alt(b"\x7f", mods), Keysym::Tab if mods.shift => b"\x1b[Z".to_vec(), Keysym::Tab => b"\t".to_vec(), Keysym::Escape => b"\x1b".to_vec(), @@ -48,7 +48,7 @@ pub fn encode(event: &KeyEvent, mods: Modifiers, app_cursor: bool) -> Option Stri cp.to_string() } -fn prefix_alt(bytes: Vec, mods: Modifiers) -> Vec { +fn prefix_alt(bytes: &[u8], mods: Modifiers) -> Vec { if mods.alt { let mut out = Vec::with_capacity(bytes.len() + 1); out.push(0x1b); - out.extend_from_slice(&bytes); + out.extend_from_slice(bytes); out } else { - bytes + bytes.to_vec() } }