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;
|
extern crate cursive;
|
||||||
|
|
||||||
use cursive::views::{Dialog, TextView};
|
use cursive::views::{Dialog, TextView};
|
||||||
use cursive::Cursive;
|
use cursive::{thene, Cursive};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut siv = Cursive::default();
|
let mut siv = Cursive::default();
|
||||||
@ -9,7 +9,7 @@ fn main() {
|
|||||||
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_theme(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(
|
||||||
|
@ -313,16 +313,14 @@ impl Cursive {
|
|||||||
pub fn load_theme_file<P: AsRef<Path>>(
|
pub fn load_theme_file<P: AsRef<Path>>(
|
||||||
&mut self, filename: P,
|
&mut self, filename: P,
|
||||||
) -> Result<(), theme::Error> {
|
) -> Result<(), theme::Error> {
|
||||||
self.set_theme(try!(theme::load_theme_file(filename)));
|
theme::load_theme_file(filename).map(|theme| self.set_theme(theme))
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads a theme from the given string content.
|
/// Loads a theme from the given string content.
|
||||||
///
|
///
|
||||||
/// Content must be valid toml.
|
/// Content must be valid toml.
|
||||||
pub fn load_toml(&mut self, content: &str) -> Result<(), theme::Error> {
|
pub fn load_toml(&mut self, content: &str) -> Result<(), theme::Error> {
|
||||||
self.set_theme(try!(theme::load_toml(content)));
|
theme::load_toml(content).map(|theme| self.set_theme(theme))
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the refresh rate, in frames per second.
|
/// Sets the refresh rate, in frames per second.
|
||||||
|
Loading…
Reference in New Issue
Block a user