cursive/examples/markup.rs

29 lines
744 B
Rust
Raw Normal View History

2018-01-10 22:58:29 +00:00
extern crate cursive;
use cursive::Cursive;
use cursive::theme::BaseColor;
2018-01-22 22:37:27 +00:00
use cursive::theme::Color;
use cursive::theme::Effect;
2018-01-22 22:37:27 +00:00
use cursive::theme::Style;
use cursive::utils::markup::StyledString;
2018-01-22 22:37:27 +00:00
use cursive::views::{Dialog, TextView};
2018-01-10 22:58:29 +00:00
fn main() {
let mut siv = Cursive::new();
let mut styled = StyledString::plain("Isn't ");
styled.append(StyledString::styled("that ", Color::Dark(BaseColor::Red)));
styled.append(StyledString::styled(
"cool?",
Style::from(Color::Light(BaseColor::Blue)).add(Effect::Bold),
));
2018-01-10 23:03:42 +00:00
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(styled))
.button("Hell yeah!", |s| s.quit()),
2018-01-10 22:58:29 +00:00
);
siv.run();
}