mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Update toml to 0.3
This commit is contained in:
parent
4f82e87d0d
commit
cbe237624f
@ -22,7 +22,7 @@ version = "0.6"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
num = "0.1"
|
num = "0.1"
|
||||||
odds = "0.2"
|
odds = "0.2"
|
||||||
toml = "0.2"
|
toml = "0.3"
|
||||||
unicode-segmentation = "1.0"
|
unicode-segmentation = "1.0"
|
||||||
unicode-width = "0.1"
|
unicode-width = "0.1"
|
||||||
|
|
||||||
|
15
src/theme.rs
15
src/theme.rs
@ -210,7 +210,7 @@ impl Default for Theme {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Theme {
|
impl Theme {
|
||||||
fn load(&mut self, table: &toml::Table) {
|
fn load(&mut self, table: &toml::value::Table) {
|
||||||
if let Some(&toml::Value::Boolean(shadow)) = table.get("shadow") {
|
if let Some(&toml::Value::Boolean(shadow)) = table.get("shadow") {
|
||||||
self.shadow = shadow;
|
self.shadow = shadow;
|
||||||
}
|
}
|
||||||
@ -314,7 +314,7 @@ pub struct Palette {
|
|||||||
|
|
||||||
impl Palette {
|
impl Palette {
|
||||||
/// Fills `self` with the colors from the given `table`.
|
/// Fills `self` with the colors from the given `table`.
|
||||||
fn load(&mut self, table: &toml::Table) {
|
fn load(&mut self, table: &toml::value::Table) {
|
||||||
load_color(&mut self.background, table.get("background"));
|
load_color(&mut self.background, table.get("background"));
|
||||||
load_color(&mut self.shadow, table.get("shadow"));
|
load_color(&mut self.shadow, table.get("shadow"));
|
||||||
load_color(&mut self.view, table.get("view"));
|
load_color(&mut self.view, table.get("view"));
|
||||||
@ -413,7 +413,7 @@ pub enum Error {
|
|||||||
/// An error occured when reading the file.
|
/// An error occured when reading the file.
|
||||||
Io(io::Error),
|
Io(io::Error),
|
||||||
/// An error occured when parsing the toml content.
|
/// An error occured when parsing the toml content.
|
||||||
Parse,
|
Parse(toml::de::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<io::Error> for Error {
|
impl From<io::Error> for Error {
|
||||||
@ -422,6 +422,12 @@ impl From<io::Error> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<toml::de::Error> for Error {
|
||||||
|
fn from(err: toml::de::Error) -> Self {
|
||||||
|
Error::Parse(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Color {
|
impl Color {
|
||||||
fn parse(value: &str) -> Option<Self> {
|
fn parse(value: &str) -> Option<Self> {
|
||||||
Some(match value {
|
Some(match value {
|
||||||
@ -490,8 +496,7 @@ pub fn load_theme_file<P: AsRef<Path>>(filename: P) -> Result<Theme, Error> {
|
|||||||
|
|
||||||
/// Loads a theme string and sets it as active.
|
/// Loads a theme string and sets it as active.
|
||||||
pub fn load_theme(content: &str) -> Result<Theme, Error> {
|
pub fn load_theme(content: &str) -> Result<Theme, Error> {
|
||||||
let mut parser = toml::Parser::new(content);
|
let table = toml::de::from_str(content)?;
|
||||||
let table = try!(parser.parse().ok_or(Error::Parse));
|
|
||||||
|
|
||||||
let mut theme = Theme::default();
|
let mut theme = Theme::default();
|
||||||
theme.load(&table);
|
theme.load(&table);
|
||||||
|
Loading…
Reference in New Issue
Block a user