diff --git a/fish-rust/src/curses.rs b/fish-rust/src/curses.rs index ca03669b2..e7d3b2f45 100644 --- a/fish-rust/src/curses.rs +++ b/fish-rust/src/curses.rs @@ -121,7 +121,7 @@ pub struct Term { pub set_title: Option, // Number capabilities - pub max_colors: Option, + pub max_colors: Option, // Flag/boolean capabilities pub eat_newline_glitch: bool, @@ -241,11 +241,11 @@ fn get_str_cap(code: &str) -> Option { /// Return a number capability from termcap, or None if missing. /// Panics if the given code string does not contain exactly two bytes. -fn get_num_cap(code: &str) -> Option { +fn get_num_cap(code: &str) -> Option { let code = to_cstr_code(code); match unsafe { sys::tgetnum(code.as_ptr()) } { -1 => None, - n => Some(n), + n => Some(usize::try_from(n).unwrap()), } } diff --git a/fish-rust/src/output.rs b/fish-rust/src/output.rs index f5f068620..44627f220 100644 --- a/fish-rust/src/output.rs +++ b/fish-rust/src/output.rs @@ -35,10 +35,10 @@ extern "C" fn output_set_color_support(val: u8) { } /// Returns true if we think tparm can handle outputting a color index. -fn term_supports_color_natively(term: &Term, c: i32) -> bool { +fn term_supports_color_natively(term: &Term, c: u8) -> bool { #[allow(clippy::int_plus_one)] if let Some(max_colors) = term.max_colors { - max_colors >= c + 1 + max_colors >= usize::try_from(c).unwrap() + 1 } else { false } @@ -61,7 +61,7 @@ fn index_for_color(c: RgbColor) -> u8 { } fn write_color_escape(outp: &mut Outputter, term: &Term, todo: &CStr, mut idx: u8, is_fg: bool) { - if term_supports_color_natively(term, idx.into()) { + if term_supports_color_natively(term, idx) { // Use tparm to emit color escape. outp.tputs_if_some(&tparm1(todo, idx.into())); } else {