Skip to content

Commit

Permalink
Fix CI failures (#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyogo authored Jan 12, 2023
1 parent 614e6a7 commit 814df1c
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 27 deletions.
7 changes: 3 additions & 4 deletions src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/event/source/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
pub(crate) use self::mio::UnixInternalEventSource;
14 changes: 6 additions & 8 deletions src/event/source/unix/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
2 changes: 1 addition & 1 deletion src/event/sys/unix/file_descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl FileDesc {
self.fd,
buffer.as_mut_ptr() as *mut libc::c_void,
size as size_t,
)
)
};

if result < 0 {
Expand Down
2 changes: 1 addition & 1 deletion src/event/sys/unix/waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
pub(crate) use self::mio::Waker;
2 changes: 1 addition & 1 deletion src/event/sys/unix/waker/mio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ impl Waker {
pub(crate) fn reset(&self) -> Result<()> {
Ok(())
}
}
}
6 changes: 3 additions & 3 deletions src/event/sys/windows/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -186,7 +186,7 @@ fn get_char_for_key(key_event: &KeyEventRecord) -> Option<char> {

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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/style/sys/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand All @@ -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)?;
Expand Down
6 changes: 4 additions & 2 deletions src/terminal/sys/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ fn read_supports_keyboard_enhancement_raw() -> Result<bool> {
// 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 {
Expand Down
4 changes: 2 additions & 2 deletions src/terminal/sys/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)?;
Expand Down

0 comments on commit 814df1c

Please sign in to comment.