mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-24 01:46:31 +00:00
35 lines
995 B
Rust
35 lines
995 B
Rust
extern crate cursive;
|
|
|
|
use cursive::Cursive;
|
|
use cursive::align::HAlign;
|
|
use cursive::view::Boxable;
|
|
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::default();
|
|
|
|
// 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.
|
|
siv.add_fullscreen_layer(
|
|
Dialog::around(Panel::new(TextView::new(content)))
|
|
// This is the alignment for the button
|
|
.h_align(HAlign::Center)
|
|
.button("Quit", |s| s.quit())
|
|
.title("Unicode and wide-character support")
|
|
.full_screen(),
|
|
);
|
|
// Show a popup on top of the view.
|
|
siv.add_layer(Dialog::info(
|
|
"Try resizing the terminal!\n(Press 'q' to \
|
|
quit when you're done.)",
|
|
));
|
|
|
|
siv.run();
|
|
}
|