2018-01-17 17:35:57 +00:00
|
|
|
use cursive::theme::BaseColor;
|
2018-01-22 22:37:27 +00:00
|
|
|
use cursive::theme::Color;
|
2018-01-17 17:35:57 +00:00
|
|
|
use cursive::theme::Effect;
|
2018-01-22 22:37:27 +00:00
|
|
|
use cursive::theme::Style;
|
2018-01-17 17:35:57 +00:00
|
|
|
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() {
|
2020-04-15 19:20:50 +00:00
|
|
|
let mut siv = cursive::default();
|
2018-01-10 22:58:29 +00:00
|
|
|
|
2018-01-17 17:35:57 +00:00
|
|
|
let mut styled = StyledString::plain("Isn't ");
|
2018-06-16 20:23:09 +00:00
|
|
|
styled.append(StyledString::styled("that ", Color::Dark(BaseColor::Red)));
|
2018-01-17 17:35:57 +00:00
|
|
|
styled.append(StyledString::styled(
|
|
|
|
"cool?",
|
2018-01-22 22:47:56 +00:00
|
|
|
Style::from(Color::Light(BaseColor::Blue)).combine(Effect::Bold),
|
2018-01-17 17:35:57 +00:00
|
|
|
));
|
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(
|
2018-01-17 17:35:57 +00:00
|
|
|
Dialog::around(TextView::new(styled))
|
|
|
|
.button("Hell yeah!", |s| s.quit()),
|
2018-01-10 22:58:29 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
siv.run();
|
|
|
|
}
|