mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-26 06:30:29 +00:00
style: fix clippy warnings
This commit is contained in:
parent
5bc617a9a6
commit
b669cf9ce7
13 changed files with 21 additions and 17 deletions
|
@ -11,7 +11,7 @@ use termion::screen::AlternateScreen;
|
|||
use tui::backend::TermionBackend;
|
||||
use tui::layout::{Constraint, Direction, Layout, Rect};
|
||||
use tui::style::Color;
|
||||
use tui::widgets::canvas::{Canvas, Line, Map, MapResolution, Rectangle};
|
||||
use tui::widgets::canvas::{Canvas, Map, MapResolution, Rectangle};
|
||||
use tui::widgets::{Block, Borders, Widget};
|
||||
use tui::Terminal;
|
||||
|
||||
|
|
|
@ -10,12 +10,18 @@ pub struct CrosstermBackend {
|
|||
screen: crossterm::Screen,
|
||||
}
|
||||
|
||||
impl CrosstermBackend {
|
||||
pub fn new() -> CrosstermBackend {
|
||||
impl Default for CrosstermBackend {
|
||||
fn default() -> CrosstermBackend {
|
||||
CrosstermBackend {
|
||||
screen: crossterm::Screen::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CrosstermBackend {
|
||||
pub fn new() -> CrosstermBackend {
|
||||
CrosstermBackend::default()
|
||||
}
|
||||
|
||||
pub fn screen(&self) -> &crossterm::Screen {
|
||||
&self.screen
|
||||
|
|
|
@ -13,7 +13,7 @@ pub struct RustboxBackend {
|
|||
impl RustboxBackend {
|
||||
pub fn new() -> Result<RustboxBackend, rustbox::InitError> {
|
||||
let rustbox = r#try!(rustbox::RustBox::init(Default::default()));
|
||||
Ok(RustboxBackend { rustbox: rustbox })
|
||||
Ok(RustboxBackend { rustbox })
|
||||
}
|
||||
|
||||
pub fn with_rustbox(instance: rustbox::RustBox) -> RustboxBackend {
|
||||
|
|
|
@ -187,10 +187,8 @@ impl Buffer {
|
|||
width,
|
||||
height,
|
||||
});
|
||||
let mut y = 0;
|
||||
for line in &lines {
|
||||
buffer.set_string(0, y, line, Style::default());
|
||||
y += 1;
|
||||
for (y, line) in lines.iter().enumerate() {
|
||||
buffer.set_string(0, y as u16, line, Style::default());
|
||||
}
|
||||
buffer
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ impl<'a> Widget for BarChart<'a> {
|
|||
return;
|
||||
}
|
||||
|
||||
self.background(&chart_area, buf, self.style.bg);
|
||||
self.background(chart_area, buf, self.style.bg);
|
||||
|
||||
let max = self
|
||||
.max
|
||||
|
|
|
@ -103,7 +103,7 @@ impl<'a> Widget for Block<'a> {
|
|||
return;
|
||||
}
|
||||
|
||||
self.background(&area, buf, self.style.bg);
|
||||
self.background(area, buf, self.style.bg);
|
||||
|
||||
// Sides
|
||||
if self.borders.intersects(Borders::LEFT) {
|
||||
|
|
|
@ -356,7 +356,7 @@ where
|
|||
return;
|
||||
}
|
||||
|
||||
self.background(&chart_area, buf, self.style.bg);
|
||||
self.background(chart_area, buf, self.style.bg);
|
||||
|
||||
if let Some((x, y)) = layout.title_x {
|
||||
let title = self.x_axis.title.unwrap();
|
||||
|
|
|
@ -87,7 +87,7 @@ impl<'a> Widget for Gauge<'a> {
|
|||
}
|
||||
|
||||
if self.style.bg != Color::Reset {
|
||||
self.background(&gauge_area, buf, self.style.bg);
|
||||
self.background(gauge_area, buf, self.style.bg);
|
||||
}
|
||||
|
||||
let center = gauge_area.height / 2 + gauge_area.top();
|
||||
|
|
|
@ -86,7 +86,7 @@ where
|
|||
return;
|
||||
}
|
||||
|
||||
self.background(&list_area, buf, self.style.bg);
|
||||
self.background(list_area, buf, self.style.bg);
|
||||
|
||||
for (i, item) in self
|
||||
.items
|
||||
|
|
|
@ -68,7 +68,7 @@ pub trait Widget {
|
|||
/// implement a custom widget.
|
||||
fn draw(&mut self, area: Rect, buf: &mut Buffer);
|
||||
/// Helper method to quickly set the background of all cells inside the specified area.
|
||||
fn background(&self, area: &Rect, buf: &mut Buffer, color: Color) {
|
||||
fn background(&self, area: Rect, buf: &mut Buffer, color: Color) {
|
||||
for y in area.top()..area.bottom() {
|
||||
for x in area.left()..area.right() {
|
||||
buf.get_mut(x, y).set_bg(color);
|
||||
|
|
|
@ -120,7 +120,7 @@ where
|
|||
return;
|
||||
}
|
||||
|
||||
self.background(&text_area, buf, self.style.bg);
|
||||
self.background(text_area, buf, self.style.bg);
|
||||
|
||||
let style = self.style;
|
||||
let mut styled = self.text.by_ref().flat_map(|t| match *t {
|
||||
|
|
|
@ -167,7 +167,7 @@ where
|
|||
};
|
||||
|
||||
// Set the background
|
||||
self.background(&table_area, buf, self.style.bg);
|
||||
self.background(table_area, buf, self.style.bg);
|
||||
|
||||
// Save widths of the columns that will fit in the given area
|
||||
let mut x = 0;
|
||||
|
|
|
@ -109,7 +109,7 @@ where
|
|||
return;
|
||||
}
|
||||
|
||||
self.background(&tabs_area, buf, self.style.bg);
|
||||
self.background(tabs_area, buf, self.style.bg);
|
||||
|
||||
let mut x = tabs_area.left();
|
||||
let titles_length = self.titles.len();
|
||||
|
|
Loading…
Reference in a new issue