cursive/examples/lorem.rs

35 lines
991 B
Rust
Raw Normal View History

extern crate cursive;
use cursive::Cursive;
2017-10-12 23:38:55 +00:00
use cursive::align::HAlign;
2017-08-15 00:01:49 +00:00
use cursive::view::Boxable;
2017-10-15 04:18:50 +00:00
use cursive::views::{Dialog, Panel, TextView};
fn main() {
// Read some long text from a file.
let content = include_str!("../assets/lorem.txt");
let mut siv = Cursive::new();
// We can quit by pressing q
siv.add_global_callback('q', |s| s.quit());
// The text is too long to fit on a line, so the view will wrap lines,
// and will adapt to the terminal size.
2017-10-12 23:38:55 +00:00
siv.add_fullscreen_layer(
Dialog::around(Panel::new(TextView::new(content)))
2018-01-16 02:55:27 +00:00
// This is the alignment for the button
2017-10-12 23:38:55 +00:00
.h_align(HAlign::Center)
.button("Quit", |s| s.quit())
2018-02-20 19:09:45 +00:00
.title("Unicode and wide-character support")
2017-10-12 23:38:55 +00:00
.full_screen(),
);
// Show a popup on top of the view.
2017-10-12 23:38:55 +00:00
siv.add_layer(Dialog::info(
"Try resizing the terminal!\n(Press 'q' to \
quit when you're done.)",
));
siv.run();
}