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::backend::TermionBackend;
|
||||||
use tui::layout::{Constraint, Direction, Layout, Rect};
|
use tui::layout::{Constraint, Direction, Layout, Rect};
|
||||||
use tui::style::Color;
|
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::widgets::{Block, Borders, Widget};
|
||||||
use tui::Terminal;
|
use tui::Terminal;
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,18 @@ pub struct CrosstermBackend {
|
||||||
screen: crossterm::Screen,
|
screen: crossterm::Screen,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CrosstermBackend {
|
impl Default for CrosstermBackend {
|
||||||
pub fn new() -> CrosstermBackend {
|
fn default() -> CrosstermBackend {
|
||||||
CrosstermBackend {
|
CrosstermBackend {
|
||||||
screen: crossterm::Screen::default(),
|
screen: crossterm::Screen::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CrosstermBackend {
|
||||||
|
pub fn new() -> CrosstermBackend {
|
||||||
|
CrosstermBackend::default()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn screen(&self) -> &crossterm::Screen {
|
pub fn screen(&self) -> &crossterm::Screen {
|
||||||
&self.screen
|
&self.screen
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub struct RustboxBackend {
|
||||||
impl RustboxBackend {
|
impl RustboxBackend {
|
||||||
pub fn new() -> Result<RustboxBackend, rustbox::InitError> {
|
pub fn new() -> Result<RustboxBackend, rustbox::InitError> {
|
||||||
let rustbox = r#try!(rustbox::RustBox::init(Default::default()));
|
let rustbox = r#try!(rustbox::RustBox::init(Default::default()));
|
||||||
Ok(RustboxBackend { rustbox: rustbox })
|
Ok(RustboxBackend { rustbox })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_rustbox(instance: rustbox::RustBox) -> RustboxBackend {
|
pub fn with_rustbox(instance: rustbox::RustBox) -> RustboxBackend {
|
||||||
|
|
|
@ -187,10 +187,8 @@ impl Buffer {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
});
|
});
|
||||||
let mut y = 0;
|
for (y, line) in lines.iter().enumerate() {
|
||||||
for line in &lines {
|
buffer.set_string(0, y as u16, line, Style::default());
|
||||||
buffer.set_string(0, y, line, Style::default());
|
|
||||||
y += 1;
|
|
||||||
}
|
}
|
||||||
buffer
|
buffer
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ impl<'a> Widget for BarChart<'a> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.background(&chart_area, buf, self.style.bg);
|
self.background(chart_area, buf, self.style.bg);
|
||||||
|
|
||||||
let max = self
|
let max = self
|
||||||
.max
|
.max
|
||||||
|
|
|
@ -103,7 +103,7 @@ impl<'a> Widget for Block<'a> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.background(&area, buf, self.style.bg);
|
self.background(area, buf, self.style.bg);
|
||||||
|
|
||||||
// Sides
|
// Sides
|
||||||
if self.borders.intersects(Borders::LEFT) {
|
if self.borders.intersects(Borders::LEFT) {
|
||||||
|
|
|
@ -356,7 +356,7 @@ where
|
||||||
return;
|
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 {
|
if let Some((x, y)) = layout.title_x {
|
||||||
let title = self.x_axis.title.unwrap();
|
let title = self.x_axis.title.unwrap();
|
||||||
|
|
|
@ -87,7 +87,7 @@ impl<'a> Widget for Gauge<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.style.bg != Color::Reset {
|
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();
|
let center = gauge_area.height / 2 + gauge_area.top();
|
||||||
|
|
|
@ -86,7 +86,7 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.background(&list_area, buf, self.style.bg);
|
self.background(list_area, buf, self.style.bg);
|
||||||
|
|
||||||
for (i, item) in self
|
for (i, item) in self
|
||||||
.items
|
.items
|
||||||
|
|
|
@ -68,7 +68,7 @@ pub trait Widget {
|
||||||
/// implement a custom widget.
|
/// implement a custom widget.
|
||||||
fn draw(&mut self, area: Rect, buf: &mut Buffer);
|
fn draw(&mut self, area: Rect, buf: &mut Buffer);
|
||||||
/// Helper method to quickly set the background of all cells inside the specified area.
|
/// 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 y in area.top()..area.bottom() {
|
||||||
for x in area.left()..area.right() {
|
for x in area.left()..area.right() {
|
||||||
buf.get_mut(x, y).set_bg(color);
|
buf.get_mut(x, y).set_bg(color);
|
||||||
|
|
|
@ -120,7 +120,7 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.background(&text_area, buf, self.style.bg);
|
self.background(text_area, buf, self.style.bg);
|
||||||
|
|
||||||
let style = self.style;
|
let style = self.style;
|
||||||
let mut styled = self.text.by_ref().flat_map(|t| match *t {
|
let mut styled = self.text.by_ref().flat_map(|t| match *t {
|
||||||
|
|
|
@ -167,7 +167,7 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set the background
|
// 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
|
// Save widths of the columns that will fit in the given area
|
||||||
let mut x = 0;
|
let mut x = 0;
|
||||||
|
|
|
@ -109,7 +109,7 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.background(&tabs_area, buf, self.style.bg);
|
self.background(tabs_area, buf, self.style.bg);
|
||||||
|
|
||||||
let mut x = tabs_area.left();
|
let mut x = tabs_area.left();
|
||||||
let titles_length = self.titles.len();
|
let titles_length = self.titles.len();
|
||||||
|
|
Loading…
Reference in a new issue