cursive/examples/markup.rs

30 lines
719 B
Rust
Raw Normal View History

2018-01-10 22:58:29 +00:00
extern crate cursive;
use cursive::Cursive;
2018-01-10 23:03:42 +00:00
#[cfg(feature = "markdown")]
use cursive::utils::markup::markdown;
2018-01-10 22:58:29 +00:00
use cursive::views::{Dialog, TextView};
// Make sure you compile with the `markdown` feature!
//
// cargo run --example markup --features markdown
fn main() {
let mut siv = Cursive::new();
2018-01-16 02:55:27 +00:00
// If markdown is enabled, parse a small text.
2018-01-10 23:03:42 +00:00
#[cfg(feature = "markdown")]
let text = markdown::parse("Isn't *that* **cool**?");
2018-01-10 22:58:29 +00:00
2018-01-10 23:03:42 +00:00
#[cfg(not(feature = "markdown"))]
let text = "Rebuild with --features markdown ;)";
2018-01-16 02:55:27 +00:00
// TextView can natively accept StyledString.
2018-01-10 22:58:29 +00:00
siv.add_layer(
Dialog::around(TextView::new(text)).button("Hell yeah!", |s| s.quit()),
2018-01-10 22:58:29 +00:00
);
siv.run();
}