mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Fix the theme example (#452)
- Remove the inline feature detection, it doesn't work for features of dependencies. Instead use `required-features` in `Cargo.toml` for the specific binary. - The asset moved one level up relatively to `../../assets/style.toml`
This commit is contained in:
parent
fc59ee6f17
commit
fc5060a8e0
@ -20,3 +20,6 @@ cursive = { path = "../cursive", default-features=false }
|
|||||||
[features]
|
[features]
|
||||||
default = ["cursive/default"]
|
default = ["cursive/default"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "theme"
|
||||||
|
required-features = ["cursive/toml"]
|
||||||
|
@ -3,13 +3,11 @@ use cursive::views::{Dialog, TextView};
|
|||||||
fn main() {
|
fn main() {
|
||||||
let mut siv = cursive::default();
|
let mut siv = cursive::default();
|
||||||
|
|
||||||
#[cfg(feature = "toml")]
|
|
||||||
{
|
|
||||||
// You can load a theme from a file at runtime for fast development.
|
// You can load a theme from a file at runtime for fast development.
|
||||||
siv.load_theme_file("assets/style.toml").unwrap();
|
siv.load_theme_file("assets/style.toml").unwrap();
|
||||||
|
|
||||||
// Or you can directly load it from a string for easy deployment.
|
// Or you can directly load it from a string for easy deployment.
|
||||||
siv.load_toml(include_str!("../assets/style.toml")).unwrap();
|
siv.load_toml(include_str!("../../assets/style.toml")).unwrap();
|
||||||
|
|
||||||
siv.add_layer(
|
siv.add_layer(
|
||||||
Dialog::around(TextView::new(
|
Dialog::around(TextView::new(
|
||||||
@ -19,19 +17,6 @@ fn main() {
|
|||||||
.title("Themed dialog")
|
.title("Themed dialog")
|
||||||
.button("Quit", |s| s.quit()),
|
.button("Quit", |s| s.quit()),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "toml"))]
|
|
||||||
{
|
|
||||||
siv.add_layer(
|
|
||||||
Dialog::around(TextView::new(
|
|
||||||
"Run this example again with the `toml` feature!\n\n\
|
|
||||||
cargo run --example theme --features toml",
|
|
||||||
))
|
|
||||||
.title("Themed dialog - missing `toml` feature")
|
|
||||||
.button("Quit", |s| s.quit()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
siv.run();
|
siv.run();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user