2018-01-10 22:58:29 +00:00
|
|
|
extern crate cursive;
|
|
|
|
|
|
|
|
use cursive::Cursive;
|
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() {
|
|
|
|
let mut siv = Cursive::new();
|
|
|
|
|
2018-01-17 17:35:57 +00:00
|
|
|
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(
|
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();
|
|
|
|
}
|