Fix clippy warnings

pull/3/head
Florian Dehau 8 years ago
parent d7131ead11
commit 15c3471f0b

@ -30,14 +30,14 @@ fn draw(t: &mut Terminal) {
.direction(Direction::Vertical)
.alignment(Alignment::Left)
.chunks(&[Size::Fixed(7), Size::Min(5), Size::Fixed(3)])
.render(&Terminal::size().unwrap(), |chunks| {
t.render(chunks[0], Block::default().title("Block"));
.render(t, &Terminal::size().unwrap(), |t, chunks| {
Block::default().title("Block").render(&chunks[0], t);
Group::default()
.direction(Direction::Vertical)
.alignment(Alignment::Left)
.chunks(&[Size::Fixed(7), Size::Min(5), Size::Fixed(3)])
.render(&chunks[1], |chunks| {
t.render(chunks[0], Block::default().title("Block"));
.render(t, &chunks[1], |t, chunks| {
Block::default().title("Block").render(&chunks[0], t);
});
});
}

@ -9,7 +9,6 @@ use std::thread;
use std::time;
use std::sync::mpsc;
use std::io::stdin;
use std::cmp::min;
use rand::distributions::{IndependentSample, Range};
@ -19,7 +18,7 @@ use termion::input::TermRead;
use log::LogLevelFilter;
use log4rs::append::file::FileAppender;
use log4rs::encode::pattern::PatternEncoder;
use log4rs::config::{Appender, Config, Logger, Root};
use log4rs::config::{Appender, Config, Root};
use tui::Terminal;
use tui::widgets::{Widget, Block, List, Gauge, Sparkline, Text, border, Chart, Axis, Dataset};
@ -75,7 +74,6 @@ impl Iterator for SinSignal {
struct App {
name: String,
fetching: bool,
items: Vec<String>,
selected: usize,
show_chart: bool,
@ -104,7 +102,7 @@ fn main() {
.build(Root::builder().appender("log").build(LogLevelFilter::Debug))
.unwrap();
let handle = log4rs::init_config(config).unwrap();
log4rs::init_config(config).unwrap();
info!("Start");
let mut rand_signal = RandomSignal::new(Range::new(0, 100));
@ -113,7 +111,6 @@ fn main() {
let mut app = App {
name: String::from("Test app"),
fetching: false,
items: ["1", "2", "3"].into_iter().map(|e| String::from(*e)).collect(),
selected: 0,
show_chart: true,
@ -203,11 +200,19 @@ fn main() {
fn draw(t: &mut Terminal, app: &App) {
let size = Terminal::size().unwrap();
Block::default()
.borders(border::ALL)
.title(&app.name)
.render(&size, t);
Group::default()
.direction(Direction::Vertical)
.alignment(Alignment::Left)
.margin(1)
.chunks(&[Size::Fixed(7), Size::Min(5), Size::Fixed(3)])
.render(t, &Terminal::size().unwrap(), |t, chunks| {
.render(t, &size, |t, chunks| {
Block::default().borders(border::ALL).title("Graphs").render(&chunks[0], t);
Group::default()
.direction(Direction::Vertical)

@ -5,7 +5,6 @@ use cassowary::{Solver, Variable, Constraint};
use cassowary::WeightedRelation::*;
use cassowary::strength::{WEAK, REQUIRED};
use buffer::Buffer;
use terminal::Terminal;
use util::hash;

@ -6,7 +6,6 @@ use termion;
use termion::raw::{IntoRawMode, RawTerminal};
use buffer::Buffer;
use widgets::Widget;
use layout::Rect;
pub struct Terminal {
@ -55,7 +54,7 @@ impl Terminal {
cell.symbol))
}
}
write!(self.stdout, "{}", string);
write!(self.stdout, "{}", string).unwrap();
self.stdout.flush().unwrap();
}
pub fn clear(&mut self) {

@ -95,7 +95,7 @@ impl<'a> Widget<'a> for Block<'a> {
// Sides
if self.borders.intersects(border::LEFT) {
for y in 0..area.height {
let c = buf.update_cell(0, y, |c| {
buf.update_cell(0, y, |c| {
c.symbol = line::VERTICAL;
c.fg = self.border_fg;
c.bg = self.border_bg;
@ -104,7 +104,7 @@ impl<'a> Widget<'a> for Block<'a> {
}
if self.borders.intersects(border::TOP) {
for x in 0..area.width {
let c = buf.update_cell(x, 0, |c| {
buf.update_cell(x, 0, |c| {
c.symbol = line::HORIZONTAL;
c.fg = self.border_fg;
c.bg = self.border_bg;
@ -151,7 +151,7 @@ impl<'a> Widget<'a> for Block<'a> {
} else {
0
};
buf.set_string(margin_x, 0, &title, self.title_fg, self.title_bg);
buf.set_string(margin_x, 0, title, self.title_fg, self.title_bg);
}
buf
}

@ -6,7 +6,6 @@ use widgets::{Widget, Block};
use buffer::Buffer;
use layout::Rect;
use style::Color;
use util::hash;
use symbols;
pub struct Axis<'a> {

@ -2,7 +2,6 @@ use widgets::{Widget, Block};
use buffer::Buffer;
use style::Color;
use layout::Rect;
use util::hash;
/// Progress bar widget
///

@ -1,11 +1,9 @@
use std::cmp::min;
use std::hash::{Hash, Hasher};
use buffer::Buffer;
use widgets::{Widget, Block};
use layout::Rect;
use style::Color;
use util::hash;
pub struct List<'a> {
block: Option<Block<'a>>,

@ -12,12 +12,8 @@ pub use self::gauge::Gauge;
pub use self::sparkline::Sparkline;
pub use self::chart::{Chart, Axis, Dataset};
use std::hash::Hash;
use util::hash;
use buffer::{Buffer, Cell};
use buffer::Buffer;
use layout::Rect;
use style::Color;
use terminal::Terminal;
pub mod border {

@ -77,7 +77,7 @@ impl<'a> Widget<'a> for Sparkline<'a> {
for j in (0..spark_area.height).rev() {
for (i, d) in data.iter_mut().take(max_index).enumerate() {
buf.update_cell(margin_x + i as u16, margin_y + j, |c| {
c.symbol = &match *d {
c.symbol = match *d {
0 => " ",
1 => bar::ONE_EIGHTH,
2 => bar::ONE_QUATER,

@ -62,9 +62,8 @@ impl<'a> Widget<'a> for Text<'a> {
let margin_x = text_area.x - area.x;
let margin_y = text_area.y - area.y;
let height = min(lines.len(), text_area.height as usize);
let width = text_area.width as usize;
for line in lines.iter_mut().take(height) {
buf.set_string(margin_x, margin_y, &line, self.fg, self.bg);
buf.set_string(margin_x, margin_y, line, self.fg, self.bg);
}
for &(x, y, width, fg, bg) in self.colors {
for i in 0..width {

Loading…
Cancel
Save