mirror of
https://github.com/fdehau/tui-rs.git
synced 2024-10-30 21:20:22 +00:00
Fix clippy warnings
This commit is contained in:
parent
b30fede80c
commit
4f8a57d500
@ -161,8 +161,7 @@ impl Buffer {
|
||||
x,
|
||||
y,
|
||||
self.area);
|
||||
let index = ((y - self.area.y) * self.area.width + (x - self.area.x)) as usize;
|
||||
index
|
||||
((y - self.area.y) * self.area.width + (x - self.area.x)) as usize
|
||||
}
|
||||
|
||||
/// Returns the coordinates of a cell given its index
|
||||
@ -188,7 +187,7 @@ impl Buffer {
|
||||
for s in graphemes.into_iter().take(max_index) {
|
||||
self.content[index].symbol.clear();
|
||||
self.content[index].symbol.push_str(s);
|
||||
self.content[index].style = style.clone();
|
||||
self.content[index].style = *style;
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
|
22
src/style.rs
22
src/style.rs
@ -143,26 +143,19 @@ impl Color {
|
||||
}
|
||||
|
||||
fn rgb_to_byte(r: u8, g: u8, b: u8) -> u16 {
|
||||
(((r & 255 & 0xC0) + (g & 255 & 0xE0) >> 2 + (b & 0xE0) >> 5) & 0xFF) as u16
|
||||
((((r & 255 & 0xC0) + ((g & 255 & 0xE0) >> 2) + ((b & 0xE0) >> 5))) & 0xFF) as u16
|
||||
}
|
||||
|
||||
impl Into<rustbox::Color> for Color {
|
||||
fn into(self) -> rustbox::Color {
|
||||
match self {
|
||||
Color::Reset => rustbox::Color::Default,
|
||||
Color::Black => rustbox::Color::Black,
|
||||
Color::Red => rustbox::Color::Red,
|
||||
Color::Green => rustbox::Color::Green,
|
||||
Color::Yellow => rustbox::Color::Yellow,
|
||||
Color::Magenta => rustbox::Color::Magenta,
|
||||
Color::Cyan => rustbox::Color::Cyan,
|
||||
Color::Gray => rustbox::Color::Black,
|
||||
Color::DarkGray => rustbox::Color::Black,
|
||||
Color::LightRed => rustbox::Color::Red,
|
||||
Color::LightGreen => rustbox::Color::Green,
|
||||
Color::LightYellow => rustbox::Color::Yellow,
|
||||
Color::LightMagenta => rustbox::Color::Magenta,
|
||||
Color::LightCyan => rustbox::Color::Cyan,
|
||||
Color::Black | Color::Gray | Color::DarkGray => rustbox::Color::Black,
|
||||
Color::Red | Color::LightRed => rustbox::Color::Red,
|
||||
Color::Green | Color::LightGreen => rustbox::Color::Green,
|
||||
Color::Yellow | Color::LightYellow => rustbox::Color::Yellow,
|
||||
Color::Magenta | Color::LightMagenta => rustbox::Color::Magenta,
|
||||
Color::Cyan | Color::LightCyan => rustbox::Color::Cyan,
|
||||
Color::White => rustbox::Color::White,
|
||||
Color::Rgb(r, g, b) => rustbox::Color::Byte(rgb_to_byte(r, g, b)),
|
||||
}
|
||||
@ -195,7 +188,6 @@ impl Modifier {
|
||||
impl Into<rustbox::Style> for Modifier {
|
||||
fn into(self) -> rustbox::Style {
|
||||
match self {
|
||||
Modifier::Reset => rustbox::RB_NORMAL,
|
||||
Modifier::Bold => rustbox::RB_BOLD,
|
||||
Modifier::Underline => rustbox::RB_UNDERLINE,
|
||||
Modifier::Invert => rustbox::RB_REVERSE,
|
||||
|
@ -229,7 +229,7 @@ impl<B> Terminal<B>
|
||||
/// clean outdated ones at the end of the draw call.
|
||||
pub fn compute_layout(&mut self, group: &Group, area: &Rect) -> Vec<Rect> {
|
||||
let entry = self.layout_cache
|
||||
.entry((group.clone(), area.clone()))
|
||||
.entry((group.clone(), *area))
|
||||
.or_insert_with(|| {
|
||||
let chunks = split(area, &group.direction, group.margin, &group.sizes);
|
||||
debug!("New layout computed:\n* Group = {:?}\n* Chunks = {:?}",
|
||||
@ -291,7 +291,7 @@ impl<B> Terminal<B>
|
||||
// Clean layout cache
|
||||
let hot = self.layout_cache
|
||||
.drain()
|
||||
.filter(|&(_, ref v)| v.hot == true)
|
||||
.filter(|&(_, ref v)| v.hot)
|
||||
.collect::<Vec<((Group, Rect), LayoutEntry)>>();
|
||||
|
||||
for (key, value) in hot {
|
||||
|
@ -93,7 +93,7 @@ impl<'a> Widget for Gauge<'a> {
|
||||
let label = self.label.unwrap_or(&precent_label);
|
||||
let label_width = label.width() as u16;
|
||||
let middle = (gauge_area.width - label_width) / 2 + gauge_area.left();
|
||||
buf.set_string(middle, y, &label, &self.style);
|
||||
buf.set_string(middle, y, label, &self.style);
|
||||
}
|
||||
|
||||
// Fix colors
|
||||
|
@ -72,7 +72,7 @@ impl<'a, T> Widget for List<'a, T>
|
||||
list_area.top() + i as u16,
|
||||
item.as_ref(),
|
||||
list_area.width as usize,
|
||||
&style);
|
||||
style);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -193,7 +193,7 @@ impl<'a> Widget for SelectableList<'a> {
|
||||
|
||||
// Render items
|
||||
List::default()
|
||||
.block(self.block.unwrap_or(Default::default()))
|
||||
.block(self.block.unwrap_or_default())
|
||||
.items(&items)
|
||||
.draw(area, buf);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user