mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-10 07:04:17 +00:00
Fix examples
This commit is contained in:
parent
a9aa23aead
commit
bb61028e0c
12 changed files with 40 additions and 40 deletions
|
@ -10,7 +10,7 @@ use termion::event;
|
|||
use termion::input::TermRead;
|
||||
|
||||
use tui::Terminal;
|
||||
use tui::backend::TermionBackend;
|
||||
use tui::backend::MouseBackend;
|
||||
use tui::widgets::{Widget, Block, border, BarChart};
|
||||
use tui::layout::{Group, Direction, Size, Rect};
|
||||
use tui::style::{Style, Color, Modifier};
|
||||
|
@ -64,7 +64,7 @@ enum Event {
|
|||
|
||||
fn main() {
|
||||
// Terminal initialization
|
||||
let backend = TermionBackend::new().unwrap();
|
||||
let backend = MouseBackend::new().unwrap();
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
|
||||
// Channels
|
||||
|
@ -123,7 +123,7 @@ fn main() {
|
|||
terminal.show_cursor().unwrap();
|
||||
}
|
||||
|
||||
fn draw(t: &mut Terminal<TermionBackend>, app: &App) {
|
||||
fn draw(t: &mut Terminal<MouseBackend>, app: &App) {
|
||||
|
||||
Group::default()
|
||||
.direction(Direction::Vertical)
|
||||
|
|
|
@ -6,13 +6,13 @@ use termion::event;
|
|||
use termion::input::TermRead;
|
||||
|
||||
use tui::Terminal;
|
||||
use tui::backend::TermionBackend;
|
||||
use tui::backend::MouseBackend;
|
||||
use tui::widgets::{Widget, Block, border};
|
||||
use tui::layout::{Group, Direction, Size, Rect};
|
||||
use tui::style::{Style, Color, Modifier};
|
||||
|
||||
fn main() {
|
||||
let mut terminal = Terminal::new(TermionBackend::new().unwrap()).unwrap();
|
||||
let mut terminal = Terminal::new(MouseBackend::new().unwrap()).unwrap();
|
||||
let stdin = io::stdin();
|
||||
terminal.clear().unwrap();
|
||||
terminal.hide_cursor().unwrap();
|
||||
|
@ -34,7 +34,7 @@ fn main() {
|
|||
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
|
||||
// Just draw the block and the group on the same area and build the group
|
||||
|
|
|
@ -10,7 +10,7 @@ use termion::event;
|
|||
use termion::input::TermRead;
|
||||
|
||||
use tui::Terminal;
|
||||
use tui::backend::TermionBackend;
|
||||
use tui::backend::MouseBackend;
|
||||
use tui::widgets::{Widget, Block, border};
|
||||
use tui::widgets::canvas::{Canvas, Map, MapResolution, Line};
|
||||
use tui::layout::{Group, Rect, Direction, Size};
|
||||
|
@ -75,7 +75,7 @@ enum Event {
|
|||
|
||||
fn main() {
|
||||
// Terminal initialization
|
||||
let backend = TermionBackend::new().unwrap();
|
||||
let backend = MouseBackend::new().unwrap();
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
|
||||
// Channels
|
||||
|
@ -150,7 +150,7 @@ fn main() {
|
|||
terminal.show_cursor().unwrap();
|
||||
}
|
||||
|
||||
fn draw(t: &mut Terminal<TermionBackend>, app: &App) {
|
||||
fn draw(t: &mut Terminal<MouseBackend>, app: &App) {
|
||||
|
||||
|
||||
Group::default()
|
||||
|
|
|
@ -13,7 +13,7 @@ use termion::event;
|
|||
use termion::input::TermRead;
|
||||
|
||||
use tui::Terminal;
|
||||
use tui::backend::TermionBackend;
|
||||
use tui::backend::MouseBackend;
|
||||
use tui::widgets::{Widget, Block, border, Chart, Axis, Marker, Dataset};
|
||||
use tui::layout::Rect;
|
||||
use tui::style::{Style, Color, Modifier};
|
||||
|
@ -64,7 +64,7 @@ enum Event {
|
|||
|
||||
fn main() {
|
||||
// Terminal initialization
|
||||
let backend = TermionBackend::new().unwrap();
|
||||
let backend = MouseBackend::new().unwrap();
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
|
||||
// Channels
|
||||
|
@ -123,7 +123,7 @@ fn main() {
|
|||
terminal.show_cursor().unwrap();
|
||||
}
|
||||
|
||||
fn draw(t: &mut Terminal<TermionBackend>, app: &App) {
|
||||
fn draw(t: &mut Terminal<MouseBackend>, app: &App) {
|
||||
|
||||
Chart::default()
|
||||
.block(Block::default()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
extern crate tui;
|
||||
|
||||
use tui::Terminal;
|
||||
use tui::backend::TermionBackend;
|
||||
use tui::backend::MouseBackend;
|
||||
use tui::widgets::Widget;
|
||||
use tui::buffer::Buffer;
|
||||
use tui::layout::Rect;
|
||||
|
@ -31,7 +31,7 @@ impl<'a> Label<'a> {
|
|||
}
|
||||
|
||||
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();
|
||||
terminal.clear().unwrap();
|
||||
Label::default().text("Test").render(&mut terminal, &size);
|
||||
|
|
|
@ -16,7 +16,7 @@ use termion::event;
|
|||
use termion::input::TermRead;
|
||||
|
||||
use tui::Terminal;
|
||||
use tui::backend::TermionBackend;
|
||||
use tui::backend::MouseBackend;
|
||||
use tui::widgets::{Widget, Block, SelectableList, List, Gauge, Sparkline, Paragraph, border,
|
||||
Chart, Axis, Dataset, BarChart, Marker, Tabs, Table};
|
||||
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();
|
||||
terminal.clear().unwrap();
|
||||
terminal.hide_cursor().unwrap();
|
||||
|
@ -266,7 +266,7 @@ fn main() {
|
|||
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()
|
||||
.direction(Direction::Vertical)
|
||||
|
@ -293,7 +293,7 @@ fn draw(t: &mut Terminal<TermionBackend>, app: &App) -> Result<(), io::Error> {
|
|||
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()
|
||||
.direction(Direction::Vertical)
|
||||
.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()
|
||||
.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 {
|
||||
vec![Size::Percent(50), Size::Percent(50)]
|
||||
} 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()
|
||||
.block(Block::default()
|
||||
.borders(border::ALL)
|
||||
|
@ -449,7 +449,7 @@ fn draw_text(t: &mut Terminal<TermionBackend>, area: &Rect) {
|
|||
.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()
|
||||
.direction(Direction::Horizontal)
|
||||
.sizes(&[Size::Percent(30), Size::Percent(70)])
|
||||
|
|
|
@ -10,7 +10,7 @@ use termion::event;
|
|||
use termion::input::TermRead;
|
||||
|
||||
use tui::Terminal;
|
||||
use tui::backend::TermionBackend;
|
||||
use tui::backend::MouseBackend;
|
||||
use tui::widgets::{Widget, Block, border, Gauge};
|
||||
use tui::layout::{Group, Direction, Size, Rect};
|
||||
use tui::style::{Style, Color, Modifier};
|
||||
|
@ -61,7 +61,7 @@ enum Event {
|
|||
|
||||
fn main() {
|
||||
// Terminal initialization
|
||||
let backend = TermionBackend::new().unwrap();
|
||||
let backend = MouseBackend::new().unwrap();
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
|
||||
// Channels
|
||||
|
@ -120,7 +120,7 @@ fn main() {
|
|||
terminal.show_cursor().unwrap();
|
||||
}
|
||||
|
||||
fn draw(t: &mut Terminal<TermionBackend>, app: &App) {
|
||||
fn draw(t: &mut Terminal<MouseBackend>, app: &App) {
|
||||
|
||||
Group::default()
|
||||
.direction(Direction::Vertical)
|
||||
|
|
|
@ -10,7 +10,7 @@ use termion::event;
|
|||
use termion::input::TermRead;
|
||||
|
||||
use tui::Terminal;
|
||||
use tui::backend::TermionBackend;
|
||||
use tui::backend::MouseBackend;
|
||||
use tui::widgets::{Widget, Block, border, SelectableList, List};
|
||||
use tui::layout::{Group, Direction, Size, Rect};
|
||||
use tui::style::{Style, Color, Modifier};
|
||||
|
@ -81,7 +81,7 @@ enum Event {
|
|||
|
||||
fn main() {
|
||||
// Terminal initialization
|
||||
let backend = TermionBackend::new().unwrap();
|
||||
let backend = MouseBackend::new().unwrap();
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
|
||||
// Channels
|
||||
|
@ -156,7 +156,7 @@ fn main() {
|
|||
terminal.show_cursor().unwrap();
|
||||
}
|
||||
|
||||
fn draw(t: &mut Terminal<TermionBackend>, app: &App) {
|
||||
fn draw(t: &mut Terminal<MouseBackend>, app: &App) {
|
||||
|
||||
Group::default()
|
||||
.direction(Direction::Horizontal)
|
||||
|
|
|
@ -6,13 +6,13 @@ use termion::event;
|
|||
use termion::input::TermRead;
|
||||
|
||||
use tui::Terminal;
|
||||
use tui::backend::TermionBackend;
|
||||
use tui::backend::MouseBackend;
|
||||
use tui::widgets::{Widget, Block, Paragraph};
|
||||
use tui::layout::{Group, Direction, Size, Rect};
|
||||
use tui::style::{Style, Color};
|
||||
|
||||
fn main() {
|
||||
let mut terminal = Terminal::new(TermionBackend::new().unwrap()).unwrap();
|
||||
let mut terminal = Terminal::new(MouseBackend::new().unwrap()).unwrap();
|
||||
let stdin = io::stdin();
|
||||
terminal.clear().unwrap();
|
||||
terminal.hide_cursor().unwrap();
|
||||
|
@ -36,7 +36,7 @@ fn main() {
|
|||
terminal.show_cursor().unwrap();
|
||||
}
|
||||
|
||||
fn draw(t: &mut Terminal<TermionBackend>, size: &Rect) {
|
||||
fn draw(t: &mut Terminal<MouseBackend>, size: &Rect) {
|
||||
|
||||
Block::default()
|
||||
.style(Style::default().bg(Color::White))
|
||||
|
|
|
@ -13,7 +13,7 @@ use termion::event;
|
|||
use termion::input::TermRead;
|
||||
|
||||
use tui::Terminal;
|
||||
use tui::backend::TermionBackend;
|
||||
use tui::backend::MouseBackend;
|
||||
use tui::widgets::{Widget, Block, border, Sparkline};
|
||||
use tui::layout::{Group, Direction, Size, Rect};
|
||||
use tui::style::{Style, Color};
|
||||
|
@ -61,7 +61,7 @@ enum Event {
|
|||
|
||||
fn main() {
|
||||
// Terminal initialization
|
||||
let backend = TermionBackend::new().unwrap();
|
||||
let backend = MouseBackend::new().unwrap();
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
|
||||
// Channels
|
||||
|
@ -120,7 +120,7 @@ fn main() {
|
|||
terminal.show_cursor().unwrap();
|
||||
}
|
||||
|
||||
fn draw(t: &mut Terminal<TermionBackend>, app: &App) {
|
||||
fn draw(t: &mut Terminal<MouseBackend>, app: &App) {
|
||||
|
||||
Group::default()
|
||||
.direction(Direction::Vertical)
|
||||
|
|
|
@ -7,7 +7,7 @@ use termion::event;
|
|||
use termion::input::TermRead;
|
||||
|
||||
use tui::Terminal;
|
||||
use tui::backend::TermionBackend;
|
||||
use tui::backend::MouseBackend;
|
||||
use tui::widgets::{Widget, Block, border, Table};
|
||||
use tui::layout::{Group, Direction, Size, Rect};
|
||||
use tui::style::{Style, Color, Modifier};
|
||||
|
@ -35,7 +35,7 @@ impl<'a> App<'a> {
|
|||
|
||||
fn main() {
|
||||
// Terminal initialization
|
||||
let backend = TermionBackend::new().unwrap();
|
||||
let backend = MouseBackend::new().unwrap();
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
|
||||
|
||||
|
@ -83,7 +83,7 @@ fn main() {
|
|||
terminal.show_cursor().unwrap();
|
||||
}
|
||||
|
||||
fn draw(t: &mut Terminal<TermionBackend>, app: &App) {
|
||||
fn draw(t: &mut Terminal<MouseBackend>, app: &App) {
|
||||
|
||||
Group::default()
|
||||
.direction(Direction::Horizontal)
|
||||
|
|
|
@ -9,7 +9,7 @@ use termion::event;
|
|||
use termion::input::TermRead;
|
||||
|
||||
use tui::Terminal;
|
||||
use tui::backend::TermionBackend;
|
||||
use tui::backend::MouseBackend;
|
||||
use tui::widgets::{Widget, Block, border, Tabs};
|
||||
use tui::layout::{Group, Direction, Size, Rect};
|
||||
use tui::style::{Style, Color};
|
||||
|
@ -21,7 +21,7 @@ struct App<'a> {
|
|||
|
||||
fn main() {
|
||||
// Terminal initialization
|
||||
let backend = TermionBackend::new().unwrap();
|
||||
let backend = MouseBackend::new().unwrap();
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
|
||||
// App
|
||||
|
@ -63,7 +63,7 @@ fn main() {
|
|||
terminal.show_cursor().unwrap();
|
||||
}
|
||||
|
||||
fn draw(t: &mut Terminal<TermionBackend>, app: &mut App) {
|
||||
fn draw(t: &mut Terminal<MouseBackend>, app: &mut App) {
|
||||
|
||||
Block::default()
|
||||
.style(Style::default().bg(Color::White))
|
||||
|
|
Loading…
Reference in a new issue