Fix examples

This commit is contained in:
Florian Dehau 2017-09-03 15:34:05 +02:00
parent a9aa23aead
commit bb61028e0c
12 changed files with 40 additions and 40 deletions

View file

@ -10,7 +10,7 @@ use termion::event;
use termion::input::TermRead; use termion::input::TermRead;
use tui::Terminal; use tui::Terminal;
use tui::backend::TermionBackend; use tui::backend::MouseBackend;
use tui::widgets::{Widget, Block, border, BarChart}; use tui::widgets::{Widget, Block, border, BarChart};
use tui::layout::{Group, Direction, Size, Rect}; use tui::layout::{Group, Direction, Size, Rect};
use tui::style::{Style, Color, Modifier}; use tui::style::{Style, Color, Modifier};
@ -64,7 +64,7 @@ enum Event {
fn main() { fn main() {
// Terminal initialization // Terminal initialization
let backend = TermionBackend::new().unwrap(); let backend = MouseBackend::new().unwrap();
let mut terminal = Terminal::new(backend).unwrap(); let mut terminal = Terminal::new(backend).unwrap();
// Channels // Channels
@ -123,7 +123,7 @@ fn main() {
terminal.show_cursor().unwrap(); terminal.show_cursor().unwrap();
} }
fn draw(t: &mut Terminal<TermionBackend>, app: &App) { fn draw(t: &mut Terminal<MouseBackend>, app: &App) {
Group::default() Group::default()
.direction(Direction::Vertical) .direction(Direction::Vertical)

View file

@ -6,13 +6,13 @@ use termion::event;
use termion::input::TermRead; use termion::input::TermRead;
use tui::Terminal; use tui::Terminal;
use tui::backend::TermionBackend; use tui::backend::MouseBackend;
use tui::widgets::{Widget, Block, border}; use tui::widgets::{Widget, Block, border};
use tui::layout::{Group, Direction, Size, Rect}; use tui::layout::{Group, Direction, Size, Rect};
use tui::style::{Style, Color, Modifier}; use tui::style::{Style, Color, Modifier};
fn main() { fn main() {
let mut terminal = Terminal::new(TermionBackend::new().unwrap()).unwrap(); let mut terminal = Terminal::new(MouseBackend::new().unwrap()).unwrap();
let stdin = io::stdin(); let stdin = io::stdin();
terminal.clear().unwrap(); terminal.clear().unwrap();
terminal.hide_cursor().unwrap(); terminal.hide_cursor().unwrap();
@ -34,7 +34,7 @@ fn main() {
terminal.show_cursor().unwrap(); terminal.show_cursor().unwrap();
} }
fn draw(t: &mut Terminal<TermionBackend>, size: &Rect) { fn draw(t: &mut Terminal<MouseBackend>, size: &Rect) {
// Wrapping block for a group // Wrapping block for a group
// Just draw the block and the group on the same area and build the group // Just draw the block and the group on the same area and build the group

View file

@ -10,7 +10,7 @@ use termion::event;
use termion::input::TermRead; use termion::input::TermRead;
use tui::Terminal; use tui::Terminal;
use tui::backend::TermionBackend; use tui::backend::MouseBackend;
use tui::widgets::{Widget, Block, border}; use tui::widgets::{Widget, Block, border};
use tui::widgets::canvas::{Canvas, Map, MapResolution, Line}; use tui::widgets::canvas::{Canvas, Map, MapResolution, Line};
use tui::layout::{Group, Rect, Direction, Size}; use tui::layout::{Group, Rect, Direction, Size};
@ -75,7 +75,7 @@ enum Event {
fn main() { fn main() {
// Terminal initialization // Terminal initialization
let backend = TermionBackend::new().unwrap(); let backend = MouseBackend::new().unwrap();
let mut terminal = Terminal::new(backend).unwrap(); let mut terminal = Terminal::new(backend).unwrap();
// Channels // Channels
@ -150,7 +150,7 @@ fn main() {
terminal.show_cursor().unwrap(); terminal.show_cursor().unwrap();
} }
fn draw(t: &mut Terminal<TermionBackend>, app: &App) { fn draw(t: &mut Terminal<MouseBackend>, app: &App) {
Group::default() Group::default()

View file

@ -13,7 +13,7 @@ use termion::event;
use termion::input::TermRead; use termion::input::TermRead;
use tui::Terminal; use tui::Terminal;
use tui::backend::TermionBackend; use tui::backend::MouseBackend;
use tui::widgets::{Widget, Block, border, Chart, Axis, Marker, Dataset}; use tui::widgets::{Widget, Block, border, Chart, Axis, Marker, Dataset};
use tui::layout::Rect; use tui::layout::Rect;
use tui::style::{Style, Color, Modifier}; use tui::style::{Style, Color, Modifier};
@ -64,7 +64,7 @@ enum Event {
fn main() { fn main() {
// Terminal initialization // Terminal initialization
let backend = TermionBackend::new().unwrap(); let backend = MouseBackend::new().unwrap();
let mut terminal = Terminal::new(backend).unwrap(); let mut terminal = Terminal::new(backend).unwrap();
// Channels // Channels
@ -123,7 +123,7 @@ fn main() {
terminal.show_cursor().unwrap(); terminal.show_cursor().unwrap();
} }
fn draw(t: &mut Terminal<TermionBackend>, app: &App) { fn draw(t: &mut Terminal<MouseBackend>, app: &App) {
Chart::default() Chart::default()
.block(Block::default() .block(Block::default()

View file

@ -1,7 +1,7 @@
extern crate tui; extern crate tui;
use tui::Terminal; use tui::Terminal;
use tui::backend::TermionBackend; use tui::backend::MouseBackend;
use tui::widgets::Widget; use tui::widgets::Widget;
use tui::buffer::Buffer; use tui::buffer::Buffer;
use tui::layout::Rect; use tui::layout::Rect;
@ -31,7 +31,7 @@ impl<'a> Label<'a> {
} }
fn main() { fn main() {
let mut terminal = Terminal::new(TermionBackend::new().unwrap()).unwrap(); let mut terminal = Terminal::new(MouseBackend::new().unwrap()).unwrap();
let size = terminal.size().unwrap(); let size = terminal.size().unwrap();
terminal.clear().unwrap(); terminal.clear().unwrap();
Label::default().text("Test").render(&mut terminal, &size); Label::default().text("Test").render(&mut terminal, &size);

View file

@ -16,7 +16,7 @@ use termion::event;
use termion::input::TermRead; use termion::input::TermRead;
use tui::Terminal; use tui::Terminal;
use tui::backend::TermionBackend; use tui::backend::MouseBackend;
use tui::widgets::{Widget, Block, SelectableList, List, Gauge, Sparkline, Paragraph, border, use tui::widgets::{Widget, Block, SelectableList, List, Gauge, Sparkline, Paragraph, border,
Chart, Axis, Dataset, BarChart, Marker, Tabs, Table}; Chart, Axis, Dataset, BarChart, Marker, Tabs, Table};
use tui::widgets::canvas::{Canvas, Map, MapResolution, Line}; use tui::widgets::canvas::{Canvas, Map, MapResolution, Line};
@ -193,7 +193,7 @@ fn main() {
} }
}); });
let backend = TermionBackend::new().unwrap(); let backend = MouseBackend::new().unwrap();
let mut terminal = Terminal::new(backend).unwrap(); let mut terminal = Terminal::new(backend).unwrap();
terminal.clear().unwrap(); terminal.clear().unwrap();
terminal.hide_cursor().unwrap(); terminal.hide_cursor().unwrap();
@ -266,7 +266,7 @@ fn main() {
terminal.clear().unwrap(); terminal.clear().unwrap();
} }
fn draw(t: &mut Terminal<TermionBackend>, app: &App) -> Result<(), io::Error> { fn draw(t: &mut Terminal<MouseBackend>, app: &App) -> Result<(), io::Error> {
Group::default() Group::default()
.direction(Direction::Vertical) .direction(Direction::Vertical)
@ -293,7 +293,7 @@ fn draw(t: &mut Terminal<TermionBackend>, app: &App) -> Result<(), io::Error> {
Ok(()) Ok(())
} }
fn draw_first_tab(t: &mut Terminal<TermionBackend>, app: &App, area: &Rect) { fn draw_first_tab(t: &mut Terminal<MouseBackend>, app: &App, area: &Rect) {
Group::default() Group::default()
.direction(Direction::Vertical) .direction(Direction::Vertical)
.sizes(&[Size::Fixed(7), Size::Min(7), Size::Fixed(7)]) .sizes(&[Size::Fixed(7), Size::Min(7), Size::Fixed(7)])
@ -304,7 +304,7 @@ fn draw_first_tab(t: &mut Terminal<TermionBackend>, app: &App, area: &Rect) {
}); });
} }
fn draw_gauges(t: &mut Terminal<TermionBackend>, app: &App, area: &Rect) { fn draw_gauges(t: &mut Terminal<MouseBackend>, app: &App, area: &Rect) {
Block::default() Block::default()
.borders(border::ALL) .borders(border::ALL)
@ -332,7 +332,7 @@ fn draw_gauges(t: &mut Terminal<TermionBackend>, app: &App, area: &Rect) {
}); });
} }
fn draw_charts(t: &mut Terminal<TermionBackend>, app: &App, area: &Rect) { fn draw_charts(t: &mut Terminal<MouseBackend>, app: &App, area: &Rect) {
let sizes = if app.show_chart { let sizes = if app.show_chart {
vec![Size::Percent(50), Size::Percent(50)] vec![Size::Percent(50), Size::Percent(50)]
} else { } else {
@ -430,7 +430,7 @@ fn draw_charts(t: &mut Terminal<TermionBackend>, app: &App, area: &Rect) {
}); });
} }
fn draw_text(t: &mut Terminal<TermionBackend>, area: &Rect) { fn draw_text(t: &mut Terminal<MouseBackend>, area: &Rect) {
Paragraph::default() Paragraph::default()
.block(Block::default() .block(Block::default()
.borders(border::ALL) .borders(border::ALL)
@ -449,7 +449,7 @@ fn draw_text(t: &mut Terminal<TermionBackend>, area: &Rect) {
.render(t, area); .render(t, area);
} }
fn draw_second_tab(t: &mut Terminal<TermionBackend>, app: &App, area: &Rect) { fn draw_second_tab(t: &mut Terminal<MouseBackend>, app: &App, area: &Rect) {
Group::default() Group::default()
.direction(Direction::Horizontal) .direction(Direction::Horizontal)
.sizes(&[Size::Percent(30), Size::Percent(70)]) .sizes(&[Size::Percent(30), Size::Percent(70)])

View file

@ -10,7 +10,7 @@ use termion::event;
use termion::input::TermRead; use termion::input::TermRead;
use tui::Terminal; use tui::Terminal;
use tui::backend::TermionBackend; use tui::backend::MouseBackend;
use tui::widgets::{Widget, Block, border, Gauge}; use tui::widgets::{Widget, Block, border, Gauge};
use tui::layout::{Group, Direction, Size, Rect}; use tui::layout::{Group, Direction, Size, Rect};
use tui::style::{Style, Color, Modifier}; use tui::style::{Style, Color, Modifier};
@ -61,7 +61,7 @@ enum Event {
fn main() { fn main() {
// Terminal initialization // Terminal initialization
let backend = TermionBackend::new().unwrap(); let backend = MouseBackend::new().unwrap();
let mut terminal = Terminal::new(backend).unwrap(); let mut terminal = Terminal::new(backend).unwrap();
// Channels // Channels
@ -120,7 +120,7 @@ fn main() {
terminal.show_cursor().unwrap(); terminal.show_cursor().unwrap();
} }
fn draw(t: &mut Terminal<TermionBackend>, app: &App) { fn draw(t: &mut Terminal<MouseBackend>, app: &App) {
Group::default() Group::default()
.direction(Direction::Vertical) .direction(Direction::Vertical)

View file

@ -10,7 +10,7 @@ use termion::event;
use termion::input::TermRead; use termion::input::TermRead;
use tui::Terminal; use tui::Terminal;
use tui::backend::TermionBackend; use tui::backend::MouseBackend;
use tui::widgets::{Widget, Block, border, SelectableList, List}; use tui::widgets::{Widget, Block, border, SelectableList, List};
use tui::layout::{Group, Direction, Size, Rect}; use tui::layout::{Group, Direction, Size, Rect};
use tui::style::{Style, Color, Modifier}; use tui::style::{Style, Color, Modifier};
@ -81,7 +81,7 @@ enum Event {
fn main() { fn main() {
// Terminal initialization // Terminal initialization
let backend = TermionBackend::new().unwrap(); let backend = MouseBackend::new().unwrap();
let mut terminal = Terminal::new(backend).unwrap(); let mut terminal = Terminal::new(backend).unwrap();
// Channels // Channels
@ -156,7 +156,7 @@ fn main() {
terminal.show_cursor().unwrap(); terminal.show_cursor().unwrap();
} }
fn draw(t: &mut Terminal<TermionBackend>, app: &App) { fn draw(t: &mut Terminal<MouseBackend>, app: &App) {
Group::default() Group::default()
.direction(Direction::Horizontal) .direction(Direction::Horizontal)

View file

@ -6,13 +6,13 @@ use termion::event;
use termion::input::TermRead; use termion::input::TermRead;
use tui::Terminal; use tui::Terminal;
use tui::backend::TermionBackend; use tui::backend::MouseBackend;
use tui::widgets::{Widget, Block, Paragraph}; use tui::widgets::{Widget, Block, Paragraph};
use tui::layout::{Group, Direction, Size, Rect}; use tui::layout::{Group, Direction, Size, Rect};
use tui::style::{Style, Color}; use tui::style::{Style, Color};
fn main() { fn main() {
let mut terminal = Terminal::new(TermionBackend::new().unwrap()).unwrap(); let mut terminal = Terminal::new(MouseBackend::new().unwrap()).unwrap();
let stdin = io::stdin(); let stdin = io::stdin();
terminal.clear().unwrap(); terminal.clear().unwrap();
terminal.hide_cursor().unwrap(); terminal.hide_cursor().unwrap();
@ -36,7 +36,7 @@ fn main() {
terminal.show_cursor().unwrap(); terminal.show_cursor().unwrap();
} }
fn draw(t: &mut Terminal<TermionBackend>, size: &Rect) { fn draw(t: &mut Terminal<MouseBackend>, size: &Rect) {
Block::default() Block::default()
.style(Style::default().bg(Color::White)) .style(Style::default().bg(Color::White))

View file

@ -13,7 +13,7 @@ use termion::event;
use termion::input::TermRead; use termion::input::TermRead;
use tui::Terminal; use tui::Terminal;
use tui::backend::TermionBackend; use tui::backend::MouseBackend;
use tui::widgets::{Widget, Block, border, Sparkline}; use tui::widgets::{Widget, Block, border, Sparkline};
use tui::layout::{Group, Direction, Size, Rect}; use tui::layout::{Group, Direction, Size, Rect};
use tui::style::{Style, Color}; use tui::style::{Style, Color};
@ -61,7 +61,7 @@ enum Event {
fn main() { fn main() {
// Terminal initialization // Terminal initialization
let backend = TermionBackend::new().unwrap(); let backend = MouseBackend::new().unwrap();
let mut terminal = Terminal::new(backend).unwrap(); let mut terminal = Terminal::new(backend).unwrap();
// Channels // Channels
@ -120,7 +120,7 @@ fn main() {
terminal.show_cursor().unwrap(); terminal.show_cursor().unwrap();
} }
fn draw(t: &mut Terminal<TermionBackend>, app: &App) { fn draw(t: &mut Terminal<MouseBackend>, app: &App) {
Group::default() Group::default()
.direction(Direction::Vertical) .direction(Direction::Vertical)

View file

@ -7,7 +7,7 @@ use termion::event;
use termion::input::TermRead; use termion::input::TermRead;
use tui::Terminal; use tui::Terminal;
use tui::backend::TermionBackend; use tui::backend::MouseBackend;
use tui::widgets::{Widget, Block, border, Table}; use tui::widgets::{Widget, Block, border, Table};
use tui::layout::{Group, Direction, Size, Rect}; use tui::layout::{Group, Direction, Size, Rect};
use tui::style::{Style, Color, Modifier}; use tui::style::{Style, Color, Modifier};
@ -35,7 +35,7 @@ impl<'a> App<'a> {
fn main() { fn main() {
// Terminal initialization // Terminal initialization
let backend = TermionBackend::new().unwrap(); let backend = MouseBackend::new().unwrap();
let mut terminal = Terminal::new(backend).unwrap(); let mut terminal = Terminal::new(backend).unwrap();
@ -83,7 +83,7 @@ fn main() {
terminal.show_cursor().unwrap(); terminal.show_cursor().unwrap();
} }
fn draw(t: &mut Terminal<TermionBackend>, app: &App) { fn draw(t: &mut Terminal<MouseBackend>, app: &App) {
Group::default() Group::default()
.direction(Direction::Horizontal) .direction(Direction::Horizontal)

View file

@ -9,7 +9,7 @@ use termion::event;
use termion::input::TermRead; use termion::input::TermRead;
use tui::Terminal; use tui::Terminal;
use tui::backend::TermionBackend; use tui::backend::MouseBackend;
use tui::widgets::{Widget, Block, border, Tabs}; use tui::widgets::{Widget, Block, border, Tabs};
use tui::layout::{Group, Direction, Size, Rect}; use tui::layout::{Group, Direction, Size, Rect};
use tui::style::{Style, Color}; use tui::style::{Style, Color};
@ -21,7 +21,7 @@ struct App<'a> {
fn main() { fn main() {
// Terminal initialization // Terminal initialization
let backend = TermionBackend::new().unwrap(); let backend = MouseBackend::new().unwrap();
let mut terminal = Terminal::new(backend).unwrap(); let mut terminal = Terminal::new(backend).unwrap();
// App // App
@ -63,7 +63,7 @@ fn main() {
terminal.show_cursor().unwrap(); terminal.show_cursor().unwrap();
} }
fn draw(t: &mut Terminal<TermionBackend>, app: &mut App) { fn draw(t: &mut Terminal<MouseBackend>, app: &mut App) {
Block::default() Block::default()
.style(Style::default().bg(Color::White)) .style(Style::default().bg(Color::White))