2018-09-04 17:55:35 +00:00
|
|
|
use tui::backend::CrosstermBackend;
|
|
|
|
use tui::style::{Color, Modifier, Style};
|
|
|
|
use tui::widgets::{Block, Borders, Paragraph, Text, Widget};
|
|
|
|
use tui::Terminal;
|
|
|
|
|
2018-09-23 18:59:51 +00:00
|
|
|
fn main() -> Result<(), failure::Error> {
|
|
|
|
let mut terminal = Terminal::new(CrosstermBackend::new())?;
|
|
|
|
terminal.clear()?;
|
|
|
|
terminal.hide_cursor()?;
|
2018-11-26 02:06:34 +00:00
|
|
|
|
2018-09-23 18:59:51 +00:00
|
|
|
loop {
|
|
|
|
terminal.draw(|mut f| {
|
2018-12-07 14:43:05 +00:00
|
|
|
let size = f.size();
|
2018-09-23 18:59:51 +00:00
|
|
|
let text = [
|
|
|
|
Text::raw("It "),
|
|
|
|
Text::styled("works", Style::default().fg(Color::Yellow)),
|
|
|
|
];
|
|
|
|
Paragraph::new(text.iter())
|
|
|
|
.block(
|
|
|
|
Block::default()
|
|
|
|
.title("Crossterm Backend")
|
|
|
|
.title_style(Style::default().fg(Color::Yellow).modifier(Modifier::Bold))
|
|
|
|
.borders(Borders::ALL)
|
|
|
|
.border_style(Style::default().fg(Color::Magenta)),
|
2018-12-07 15:17:33 +00:00
|
|
|
)
|
|
|
|
.render(&mut f, size);
|
2018-09-23 18:59:51 +00:00
|
|
|
})?;
|
|
|
|
|
2018-11-25 20:49:37 +00:00
|
|
|
let input = crossterm::input();
|
2018-09-23 18:59:51 +00:00
|
|
|
match input.read_char()? {
|
|
|
|
'q' => {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
_ => {}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
Ok(())
|
2018-09-04 17:55:35 +00:00
|
|
|
}
|