2015-05-18 18:36:15 +00:00
|
|
|
extern crate cursive;
|
|
|
|
|
2017-10-12 23:38:55 +00:00
|
|
|
use cursive::align::HAlign;
|
2017-10-15 04:18:50 +00:00
|
|
|
use cursive::views::{Dialog, Panel, TextView};
|
2018-05-08 06:17:07 +00:00
|
|
|
use cursive::Cursive;
|
2015-05-18 18:36:15 +00:00
|
|
|
|
|
|
|
fn main() {
|
2015-05-22 07:01:23 +00:00
|
|
|
// Read some long text from a file.
|
2016-07-18 01:41:36 +00:00
|
|
|
let content = include_str!("../assets/lorem.txt");
|
2015-05-18 18:36:15 +00:00
|
|
|
|
2018-04-01 23:39:03 +00:00
|
|
|
let mut siv = Cursive::default();
|
2015-05-25 18:37:28 +00:00
|
|
|
|
2015-05-18 18:36:15 +00:00
|
|
|
// We can quit by pressing q
|
2015-05-28 01:04:33 +00:00
|
|
|
siv.add_global_callback('q', |s| s.quit());
|
2015-05-18 18:36:15 +00:00
|
|
|
|
2015-05-22 07:01:23 +00:00
|
|
|
// 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(
|
2017-10-14 00:53:39 +00:00
|
|
|
Dialog::around(Panel::new(TextView::new(content)))
|
2018-05-08 06:17:07 +00:00
|
|
|
.title("Unicode and wide-character support")
|
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)
|
2018-05-08 06:17:07 +00:00
|
|
|
.button("Quit", |s| s.quit()),
|
2017-10-12 23:38:55 +00:00
|
|
|
);
|
2015-05-22 07:01:23 +00:00
|
|
|
// 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.)",
|
|
|
|
));
|
2015-05-18 18:36:15 +00:00
|
|
|
|
|
|
|
siv.run();
|
|
|
|
}
|