2018-01-17 17:35:57 +00:00
|
|
|
use cursive::theme::{Color, PaletteColor, Theme};
|
2019-11-15 19:41:05 +00:00
|
|
|
use cursive::views::Text;
|
2018-06-11 06:29:10 +00:00
|
|
|
use cursive::Cursive;
|
2017-07-16 14:43:46 +00:00
|
|
|
|
2018-01-16 02:55:27 +00:00
|
|
|
// This example sets the background color to the terminal default.
|
|
|
|
//
|
|
|
|
// This way, it looks more natural.
|
2017-07-16 14:43:46 +00:00
|
|
|
|
|
|
|
fn main() {
|
2018-04-01 23:39:03 +00:00
|
|
|
let mut siv = Cursive::default();
|
2018-01-16 02:55:27 +00:00
|
|
|
|
2017-07-16 14:43:46 +00:00
|
|
|
let theme = custom_theme_from_cursive(&siv);
|
2018-01-16 02:55:27 +00:00
|
|
|
siv.set_theme(theme);
|
2017-07-16 14:43:46 +00:00
|
|
|
|
|
|
|
// We can quit by pressing `q`
|
|
|
|
siv.add_global_callback('q', Cursive::quit);
|
2018-01-16 02:55:27 +00:00
|
|
|
|
2019-11-15 19:41:05 +00:00
|
|
|
siv.add_layer(Text::new(
|
2017-10-12 23:38:55 +00:00
|
|
|
"Hello World with default terminal background color!\n\
|
|
|
|
Press q to quit the application.",
|
|
|
|
));
|
2017-07-16 14:43:46 +00:00
|
|
|
|
|
|
|
siv.run();
|
|
|
|
}
|
2018-01-16 02:55:27 +00:00
|
|
|
|
|
|
|
fn custom_theme_from_cursive(siv: &Cursive) -> Theme {
|
|
|
|
// We'll return the current theme with a small modification.
|
|
|
|
let mut theme = siv.current_theme().clone();
|
|
|
|
|
2018-01-21 19:06:33 +00:00
|
|
|
theme.palette[PaletteColor::Background] = Color::TerminalDefault;
|
2018-01-16 02:55:27 +00:00
|
|
|
|
|
|
|
theme
|
|
|
|
}
|