cursive/examples/markup.rs

32 lines
775 B
Rust
Raw Normal View History

2018-01-10 22:58:29 +00:00
extern crate 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-06-11 06:29:10 +00:00
use cursive::Cursive;
2018-01-10 22:58:29 +00:00
fn main() {
let mut siv = Cursive::default();
2018-01-10 22:58:29 +00:00
let mut styled = StyledString::plain("Isn't ");
2018-03-22 18:04:10 +00:00
styled.append(StyledString::styled(
"that ",
Color::Dark(BaseColor::Red),
));
styled.append(StyledString::styled(
"cool?",
2018-01-22 22:47:56 +00:00
Style::from(Color::Light(BaseColor::Blue)).combine(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();
}