From 9edc6ffc15097c777bea622d4b7731fd01509218 Mon Sep 17 00:00:00 2001 From: hcpl Date: Sun, 16 Jul 2017 17:43:46 +0300 Subject: [PATCH] Add example that utilizes terminal default colors --- examples/terminal_default.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 examples/terminal_default.rs diff --git a/examples/terminal_default.rs b/examples/terminal_default.rs new file mode 100644 index 0000000..5082db9 --- /dev/null +++ b/examples/terminal_default.rs @@ -0,0 +1,27 @@ +extern crate cursive; + + +use cursive::Cursive; +use cursive::theme::{Color, Theme}; +use cursive::views::TextView; + + +fn custom_theme_from_cursive(siv: &Cursive) -> Theme { + let mut theme = siv.current_theme().clone(); + theme.colors.background = Color::Default; + theme +} + +fn main() { + let mut siv = Cursive::new(); + let theme = custom_theme_from_cursive(&siv); + + // We can quit by pressing `q` + siv.add_global_callback('q', Cursive::quit); + siv.set_theme(theme); + + siv.add_layer(TextView::new("Hello World with default terminal background color!\n\ + Press q to quit the application.")); + + siv.run(); +}