mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Update theme example to use Cursive::load_toml
This commit is contained in:
parent
4ccc07c6d3
commit
f5535f2db7
@ -1,7 +1,7 @@
|
||||
extern crate cursive;
|
||||
|
||||
use cursive::views::{Dialog, TextView};
|
||||
use cursive::Cursive;
|
||||
use cursive::{thene, Cursive};
|
||||
|
||||
fn main() {
|
||||
let mut siv = Cursive::default();
|
||||
@ -9,7 +9,7 @@ fn main() {
|
||||
siv.load_theme_file("assets/style.toml").unwrap();
|
||||
|
||||
// Or you can directly load it from a string for easy deployment.
|
||||
// siv.load_theme(include_str!("../assets/style.toml")).unwrap();
|
||||
siv.load_toml(include_str!("../assets/style.toml").unwrap());
|
||||
|
||||
siv.add_layer(
|
||||
Dialog::around(TextView::new(
|
||||
|
@ -313,16 +313,14 @@ impl Cursive {
|
||||
pub fn load_theme_file<P: AsRef<Path>>(
|
||||
&mut self, filename: P,
|
||||
) -> Result<(), theme::Error> {
|
||||
self.set_theme(try!(theme::load_theme_file(filename)));
|
||||
Ok(())
|
||||
theme::load_theme_file(filename).map(|theme| self.set_theme(theme))
|
||||
}
|
||||
|
||||
/// Loads a theme from the given string content.
|
||||
///
|
||||
/// Content must be valid toml.
|
||||
pub fn load_toml(&mut self, content: &str) -> Result<(), theme::Error> {
|
||||
self.set_theme(try!(theme::load_toml(content)));
|
||||
Ok(())
|
||||
theme::load_toml(content).map(|theme| self.set_theme(theme))
|
||||
}
|
||||
|
||||
/// Sets the refresh rate, in frames per second.
|
||||
|
Loading…
Reference in New Issue
Block a user