diff --git a/src/cursor.rs b/src/cursor.rs index 9e9d029..a5e2033 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -330,7 +330,7 @@ impl Command for Show { /// A command that enables blinking of the terminal cursor. /// /// See `SetCursorStyle` which is more advanced and better supported. -/// +/// /// # Notes /// /// - Windows versions lower than Windows 10 do not support this functionality. @@ -347,9 +347,8 @@ impl Command for EnableBlinking { } } - /// A command that disables blinking of the terminal cursor. -/// +/// /// See `SetCursorStyle` which is more advanced and better supported. /// /// # Notes @@ -370,7 +369,7 @@ impl Command for DisableBlinking { /// A command that sets the style of the cursor. /// It uses two types of escape codes, one to control blinking, and the other the shape. -/// +/// /// # Note /// /// - Commands must be executed/queued for execution otherwise they do nothing. diff --git a/src/event/source/unix.rs b/src/event/source/unix.rs index b866d7d..810bad3 100644 --- a/src/event/source/unix.rs +++ b/src/event/source/unix.rs @@ -8,4 +8,4 @@ pub(crate) mod mio; pub(crate) use self::tty::UnixInternalEventSource; #[cfg(not(feature = "use-dev-tty"))] -pub(crate) use self::mio::UnixInternalEventSource; \ No newline at end of file +pub(crate) use self::mio::UnixInternalEventSource; diff --git a/src/event/source/unix/tty.rs b/src/event/source/unix/tty.rs index a4ab1f2..b9eb436 100644 --- a/src/event/source/unix/tty.rs +++ b/src/event/source/unix/tty.rs @@ -12,15 +12,13 @@ use filedescriptor::{poll, pollfd, POLLIN}; #[cfg(feature = "event-stream")] use crate::event::sys::Waker; -use crate::{ - event::{ - sys::unix::{ - file_descriptor::{tty_fd, FileDesc}, - parse::parse_event, - }, - InternalEvent, - source::EventSource, +use crate::event::{ + source::EventSource, + sys::unix::{ + file_descriptor::{tty_fd, FileDesc}, + parse::parse_event, }, + InternalEvent, }; /// Holds a prototypical Waker and a receiver we can wait on when doing select(). diff --git a/src/event/sys/unix/file_descriptor.rs b/src/event/sys/unix/file_descriptor.rs index 268d57e..f588eb2 100644 --- a/src/event/sys/unix/file_descriptor.rs +++ b/src/event/sys/unix/file_descriptor.rs @@ -37,7 +37,7 @@ impl FileDesc { self.fd, buffer.as_mut_ptr() as *mut libc::c_void, size as size_t, - ) + ) }; if result < 0 { diff --git a/src/event/sys/unix/waker.rs b/src/event/sys/unix/waker.rs index 8ac6367..1c55f3b 100644 --- a/src/event/sys/unix/waker.rs +++ b/src/event/sys/unix/waker.rs @@ -8,4 +8,4 @@ pub(crate) mod mio; pub(crate) use self::tty::Waker; #[cfg(not(feature = "use-dev-tty"))] -pub(crate) use self::mio::Waker; \ No newline at end of file +pub(crate) use self::mio::Waker; diff --git a/src/event/sys/unix/waker/mio.rs b/src/event/sys/unix/waker/mio.rs index 891f006..4509e9b 100644 --- a/src/event/sys/unix/waker/mio.rs +++ b/src/event/sys/unix/waker/mio.rs @@ -33,4 +33,4 @@ impl Waker { pub(crate) fn reset(&self) -> Result<()> { Ok(()) } -} \ No newline at end of file +} diff --git a/src/event/sys/windows/parse.rs b/src/event/sys/windows/parse.rs index 697a49a..98b3167 100644 --- a/src/event/sys/windows/parse.rs +++ b/src/event/sys/windows/parse.rs @@ -110,7 +110,7 @@ fn try_ensure_char_case(ch: char, desired_case: CharCase) -> char { let mut iter = ch.to_lowercase(); // Unwrap is safe; iterator yields one or more chars. let ch_lower = iter.next().unwrap(); - if iter.next() == None { + if iter.next().is_none() { ch_lower } else { ch @@ -120,7 +120,7 @@ fn try_ensure_char_case(ch: char, desired_case: CharCase) -> char { let mut iter = ch.to_uppercase(); // Unwrap is safe; iterator yields one or more chars. let ch_upper = iter.next().unwrap(); - if iter.next() == None { + if iter.next().is_none() { ch_upper } else { ch @@ -186,7 +186,7 @@ fn get_char_for_key(key_event: &KeyEventRecord) -> Option { let mut ch_iter = std::char::decode_utf16(utf16_buf.into_iter().take(ret as usize)); let mut ch = ch_iter.next()?.ok()?; - if ch_iter.next() != None { + if ch_iter.next().is_some() { // Key doesn't map to a single char. return None; } diff --git a/src/style/sys/windows.rs b/src/style/sys/windows.rs index 48114a4..a7e74a5 100644 --- a/src/style/sys/windows.rs +++ b/src/style/sys/windows.rs @@ -34,8 +34,8 @@ pub(crate) fn set_foreground_color(fg_color: Color) -> Result<()> { // background intensity is a separate value in attrs, // we need to check if this was applied to the current bg color. - if (attrs & wincon::BACKGROUND_INTENSITY as u16) != 0 { - color |= wincon::BACKGROUND_INTENSITY as u16; + if (attrs & wincon::BACKGROUND_INTENSITY) != 0 { + color |= wincon::BACKGROUND_INTENSITY; } Console::from(screen_buffer.handle().clone()).set_text_attribute(color)?; @@ -58,8 +58,8 @@ pub(crate) fn set_background_color(bg_color: Color) -> Result<()> { // Foreground intensity is a separate value in attrs, // So we need to check if this was applied to the current fg color. - if (attrs & wincon::FOREGROUND_INTENSITY as u16) != 0 { - color |= wincon::FOREGROUND_INTENSITY as u16; + if (attrs & wincon::FOREGROUND_INTENSITY) != 0 { + color |= wincon::FOREGROUND_INTENSITY; } Console::from(screen_buffer.handle().clone()).set_text_attribute(color)?; diff --git a/src/terminal/sys/unix.rs b/src/terminal/sys/unix.rs index 184a808..808ff0f 100644 --- a/src/terminal/sys/unix.rs +++ b/src/terminal/sys/unix.rs @@ -123,13 +123,15 @@ fn read_supports_keyboard_enhancement_raw() -> Result { // ESC [ c Query primary device attributes. const QUERY: &[u8] = b"\x1B[?u\x1B[c"; - if let Err(_) = File::open("/dev/tty").and_then(|mut file| { + let result = File::open("/dev/tty").and_then(|mut file| { file.write_all(QUERY)?; file.flush() - }) { + }); + if result.is_err() { let mut stdout = io::stdout(); stdout.write_all(QUERY)?; stdout.flush()?; + return Ok(false); } loop { diff --git a/src/terminal/sys/windows.rs b/src/terminal/sys/windows.rs index 9ca1a32..697146a 100644 --- a/src/terminal/sys/windows.rs +++ b/src/terminal/sys/windows.rs @@ -234,7 +234,7 @@ fn clear_after_cursor(location: Coord, buffer_size: Size, current_attribute: u16 let (mut x, mut y) = (location.x, location.y); // if cursor position is at the outer right position - if x as i16 > buffer_size.width { + if x > buffer_size.width { y += 1; x = 0; } @@ -303,7 +303,7 @@ fn clear_until_line(location: Coord, buffer_size: Size, current_attribute: u16) let start_location = Coord::new(x, y); // get sum cells before cursor - let cells_to_write = (buffer_size.width - x as i16) as u32; + let cells_to_write = (buffer_size.width - x) as u32; // clear until the current line clear_winapi(start_location, cells_to_write, current_attribute)?;