Fix clippy warnings (#533)
This commit is contained in:
parent
6a1114b241
commit
6c0f8ebcf6
@ -50,14 +50,10 @@ fn print_events() -> Result<()> {
|
|||||||
fn flush_resize_events(event: Event) -> ((u16, u16), (u16, u16)) {
|
fn flush_resize_events(event: Event) -> ((u16, u16), (u16, u16)) {
|
||||||
if let Event::Resize(x, y) = event {
|
if let Event::Resize(x, y) = event {
|
||||||
let mut last_resize = (x, y);
|
let mut last_resize = (x, y);
|
||||||
loop {
|
while let Ok(true) = poll(Duration::from_millis(50)) {
|
||||||
if let Ok(true) = poll(Duration::from_millis(50)) {
|
|
||||||
if let Ok(Event::Resize(x, y)) = read() {
|
if let Ok(Event::Resize(x, y)) = read() {
|
||||||
last_resize = (x, y);
|
last_resize = (x, y);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((x, y), last_resize);
|
return ((x, y), last_resize);
|
||||||
|
@ -156,7 +156,7 @@ pub(crate) fn parse_csi(buffer: &[u8]) -> Result<Option<InternalEvent>> {
|
|||||||
// The final byte of a CSI sequence can be in the range 64-126, so
|
// The final byte of a CSI sequence can be in the range 64-126, so
|
||||||
// let's keep reading anything else.
|
// let's keep reading anything else.
|
||||||
let last_byte = *buffer.last().unwrap();
|
let last_byte = *buffer.last().unwrap();
|
||||||
if last_byte < 64 || last_byte > 126 {
|
if !(64..=126).contains(&last_byte) {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
match buffer[buffer.len() - 1] {
|
match buffer[buffer.len() - 1] {
|
||||||
|
@ -87,22 +87,19 @@ pub(crate) fn disable_raw_mode() -> Result<()> {
|
|||||||
///
|
///
|
||||||
/// The arg should be "cols" or "lines"
|
/// The arg should be "cols" or "lines"
|
||||||
fn tput_value(arg: &str) -> Option<u16> {
|
fn tput_value(arg: &str) -> Option<u16> {
|
||||||
match process::Command::new("tput").arg(arg).output() {
|
let output = process::Command::new("tput").arg(arg).output().ok()?;
|
||||||
Ok(process::Output { stdout, .. }) => {
|
let value = output
|
||||||
let value = stdout
|
.stdout
|
||||||
.iter()
|
.into_iter()
|
||||||
.map(|&b| b as u16)
|
.filter_map(|b| char::from(b).to_digit(10))
|
||||||
.take_while(|&b| b >= 48 && b <= 58)
|
.fold(0, |v, n| v * 10 + n as u16);
|
||||||
.fold(0, |v, b| v * 10 + (b - 48));
|
|
||||||
if value > 0 {
|
if value > 0 {
|
||||||
Some(value)
|
Some(value)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the size of the screen as determined by tput.
|
/// Returns the size of the screen as determined by tput.
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user