Skip to content

Commit

Permalink
Fix rustfmt and clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fdehau committed May 21, 2017
1 parent 29db3dd commit b2bb24b
Show file tree
Hide file tree
Showing 24 changed files with 458 additions and 393 deletions.
10 changes: 4 additions & 6 deletions examples/barchart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,10 @@ fn main() {
});

// Tick
thread::spawn(move || {
loop {
clock_tx.send(Event::Tick).unwrap();
thread::sleep(time::Duration::from_millis(500));
}
});
thread::spawn(move || loop {
clock_tx.send(Event::Tick).unwrap();
thread::sleep(time::Duration::from_millis(500));
});

// App
let mut app = App::new();
Expand Down
12 changes: 5 additions & 7 deletions examples/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ fn draw(t: &mut Terminal<TermionBackend>, size: &Rect) {
// Wrapping block for a group
// Just draw the block and the group on the same area and build the group
// with at least a margin of 1
Block::default()
.borders(border::ALL)
.render(t, &size);
Block::default().borders(border::ALL).render(t, size);
Group::default()
.direction(Direction::Vertical)
.margin(4)
.sizes(&[Size::Percent(50), Size::Percent(50)])
.render(t, &size, |t, chunks| {
.render(t, size, |t, chunks| {
Group::default()
.direction(Direction::Horizontal)
.sizes(&[Size::Percent(50), Size::Percent(50)])
Expand All @@ -59,9 +57,9 @@ fn draw(t: &mut Terminal<TermionBackend>, size: &Rect) {
Block::default()
.title("Styled title")
.title_style(Style::default()
.fg(Color::White)
.bg(Color::Red)
.modifier(Modifier::Bold))
.fg(Color::White)
.bg(Color::Red)
.modifier(Modifier::Bold))
.render(t, &chunks[1]);
});
Group::default()
Expand Down
90 changes: 42 additions & 48 deletions examples/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ impl App {

fn advance(&mut self) {
if self.ball.left() < self.playground.left() ||
self.ball.right() > self.playground.right() {
self.dir_x = !self.dir_x;
}
self.ball.right() > self.playground.right() {
self.dir_x = !self.dir_x;
}
if self.ball.top() < self.playground.top() ||
self.ball.bottom() > self.playground.bottom() {
self.dir_y = !self.dir_y;
}
self.ball.bottom() > self.playground.bottom() {
self.dir_y = !self.dir_y;
}

if self.dir_x {
self.ball.x += self.vx;
Expand Down Expand Up @@ -96,12 +96,10 @@ fn main() {
});

// Tick
thread::spawn(move || {
loop {
clock_tx.send(Event::Tick).unwrap();
thread::sleep(time::Duration::from_millis(500));
}
});
thread::spawn(move || loop {
clock_tx.send(Event::Tick).unwrap();
thread::sleep(time::Duration::from_millis(500));
});

// App
let mut app = App::new();
Expand Down Expand Up @@ -160,52 +158,48 @@ fn draw(t: &mut Terminal<TermionBackend>, app: &App) {
.sizes(&[Size::Percent(50), Size::Percent(50)])
.render(t, &app.size, |t, chunks| {
Canvas::default()
.block(Block::default()
.borders(border::ALL)
.title("World"))
.block(Block::default().borders(border::ALL).title("World"))
.paint(|ctx| {
ctx.draw(&Map {
color: Color::White,
resolution: MapResolution::High,
});
ctx.print(app.x, -app.y, "You are here", Color::Yellow);
})
ctx.draw(&Map {
color: Color::White,
resolution: MapResolution::High,
});
ctx.print(app.x, -app.y, "You are here", Color::Yellow);
})
.x_bounds([-180.0, 180.0])
.y_bounds([-90.0, 90.0])
.render(t, &chunks[0]);
Canvas::default()
.block(Block::default()
.borders(border::ALL)
.title("List"))
.block(Block::default().borders(border::ALL).title("List"))
.paint(|ctx| {
ctx.draw(&Line {
x1: app.ball.left() as f64,
y1: app.ball.top() as f64,
x2: app.ball.right() as f64,
y2: app.ball.top() as f64,
color: Color::Yellow,
});
x1: app.ball.left() as f64,
y1: app.ball.top() as f64,
x2: app.ball.right() as f64,
y2: app.ball.top() as f64,
color: Color::Yellow,
});
ctx.draw(&Line {
x1: app.ball.right() as f64,
y1: app.ball.top() as f64,
x2: app.ball.right() as f64,
y2: app.ball.bottom() as f64,
color: Color::Yellow,
});
x1: app.ball.right() as f64,
y1: app.ball.top() as f64,
x2: app.ball.right() as f64,
y2: app.ball.bottom() as f64,
color: Color::Yellow,
});
ctx.draw(&Line {
x1: app.ball.right() as f64,
y1: app.ball.bottom() as f64,
x2: app.ball.left() as f64,
y2: app.ball.bottom() as f64,
color: Color::Yellow,
});
x1: app.ball.right() as f64,
y1: app.ball.bottom() as f64,
x2: app.ball.left() as f64,
y2: app.ball.bottom() as f64,
color: Color::Yellow,
});
ctx.draw(&Line {
x1: app.ball.left() as f64,
y1: app.ball.bottom() as f64,
x2: app.ball.left() as f64,
y2: app.ball.top() as f64,
color: Color::Yellow,
});
x1: app.ball.left() as f64,
y1: app.ball.bottom() as f64,
x2: app.ball.left() as f64,
y2: app.ball.top() as f64,
color: Color::Yellow,
});
})
.x_bounds([10.0, 110.0])
.y_bounds([10.0, 110.0])
Expand Down
42 changes: 19 additions & 23 deletions examples/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,10 @@ fn main() {
});

// Tick
thread::spawn(move || {
loop {
clock_tx.send(Event::Tick).unwrap();
thread::sleep(time::Duration::from_millis(500));
}
});
thread::spawn(move || loop {
clock_tx.send(Event::Tick).unwrap();
thread::sleep(time::Duration::from_millis(500));
});

// App
let mut app = App::new();
Expand Down Expand Up @@ -129,25 +127,23 @@ fn draw(t: &mut Terminal<TermionBackend>, app: &App) {

Chart::default()
.block(Block::default()
.title("Chart")
.title_style(Style::default()
.fg(Color::Cyan)
.modifier(Modifier::Bold))
.borders(border::ALL))
.title("Chart")
.title_style(Style::default().fg(Color::Cyan).modifier(Modifier::Bold))
.borders(border::ALL))
.x_axis(Axis::default()
.title("X Axis")
.style(Style::default().fg(Color::Gray))
.labels_style(Style::default().modifier(Modifier::Italic))
.bounds(app.window)
.labels(&[&format!("{}", app.window[0]),
&format!("{}", (app.window[0] + app.window[1]) / 2.0),
&format!("{}", app.window[1])]))
.title("X Axis")
.style(Style::default().fg(Color::Gray))
.labels_style(Style::default().modifier(Modifier::Italic))
.bounds(app.window)
.labels(&[&format!("{}", app.window[0]),
&format!("{}", (app.window[0] + app.window[1]) / 2.0),
&format!("{}", app.window[1])]))
.y_axis(Axis::default()
.title("Y Axis")
.style(Style::default().fg(Color::Gray))
.labels_style(Style::default().modifier(Modifier::Italic))
.bounds([-20.0, 20.0])
.labels(&["-20", "0", "20"]))
.title("Y Axis")
.style(Style::default().fg(Color::Gray))
.labels_style(Style::default().modifier(Modifier::Italic))
.bounds([-20.0, 20.0])
.labels(&["-20", "0", "20"]))
.datasets(&[Dataset::default()
.name("data2")
.marker(Marker::Dot)
Expand Down
Loading

0 comments on commit b2bb24b

Please sign in to comment.