mirror of
https://github.com/crossterm-rs/crossterm.git
synced 2025-05-05 15:32:57 +00:00
clippy
This commit is contained in:
parent
a4b64220c0
commit
8ca5dc8a8b
@ -264,22 +264,22 @@ pub(crate) fn parse_csi_u_encoded_key_code(buffer: &[u8]) -> Result<Option<Inter
|
||||
let keycode = {
|
||||
if let Some(c) = char::from_u32(codepoint) {
|
||||
match c {
|
||||
'\x1B' => KeyCode::Esc.into(),
|
||||
'\r' => KeyCode::Enter.into(),
|
||||
'\x1B' => KeyCode::Esc,
|
||||
'\r' => KeyCode::Enter,
|
||||
// Issue #371: \n = 0xA, which is also the keycode for Ctrl+J. The only reason we get
|
||||
// newlines as input is because the terminal converts \r into \n for us. When we
|
||||
// enter raw mode, we disable that, so \n no longer has any meaning - it's better to
|
||||
// use Ctrl+J. Waiting to handle it here means it gets picked up later
|
||||
'\n' if !crate::terminal::sys::is_raw_mode_enabled() => KeyCode::Enter.into(),
|
||||
'\n' if !crate::terminal::sys::is_raw_mode_enabled() => KeyCode::Enter,
|
||||
'\t' => {
|
||||
if modifiers.contains(KeyModifiers::SHIFT) {
|
||||
KeyCode::BackTab.into()
|
||||
KeyCode::BackTab
|
||||
} else {
|
||||
KeyCode::Tab.into()
|
||||
KeyCode::Tab
|
||||
}
|
||||
}
|
||||
'\x7F' => KeyCode::Backspace.into(),
|
||||
_ => KeyCode::Char(c).into(),
|
||||
'\x7F' => KeyCode::Backspace,
|
||||
_ => KeyCode::Char(c),
|
||||
}
|
||||
} else {
|
||||
return Err(could_not_parse_event_error());
|
||||
|
@ -414,7 +414,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_raw_mode() {
|
||||
// check we start from normal mode (may fail on some test harnesses)
|
||||
assert_eq!(is_raw_mode_enabled().unwrap(), false);
|
||||
assert!(!is_raw_mode_enabled().unwrap());
|
||||
|
||||
// enable the raw mode
|
||||
if enable_raw_mode().is_err() {
|
||||
@ -425,18 +425,18 @@ mod tests {
|
||||
|
||||
// check it worked (on unix it doesn't really check the underlying
|
||||
// tty but rather check that the code is consistent)
|
||||
assert_eq!(is_raw_mode_enabled().unwrap(), true);
|
||||
assert!(is_raw_mode_enabled().unwrap());
|
||||
|
||||
// enable it again, this should not change anything
|
||||
enable_raw_mode().unwrap();
|
||||
|
||||
// check we're still in raw mode
|
||||
assert_eq!(is_raw_mode_enabled().unwrap(), true);
|
||||
assert!(is_raw_mode_enabled().unwrap());
|
||||
|
||||
// now let's disable it
|
||||
disable_raw_mode().unwrap();
|
||||
|
||||
// check we're back to normal mode
|
||||
assert_eq!(is_raw_mode_enabled().unwrap(), false);
|
||||
assert!(!is_raw_mode_enabled().unwrap());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user