Skip to main content

load_theme_str

Function load_theme_str 

Source
pub fn load_theme_str(text: &str, base: Theme) -> Result<Theme, ThemeError>
Expand description

Load a theme from TOML text, filling anything absent from base.

Inheritance is what makes a theme file worth hand-writing: a user who wants a different accent color writes three lines, not twenty-one. base is typically glass_default.

ยงErrors

ThemeError::Syntax if the text is not TOML, ThemeError::WrongType if a field holds the wrong kind of value, and ThemeError::BadColor if a color is not #RRGGBB or #RRGGBBAA โ€” each naming the field, since a theme file has twenty-one of them and a caller cannot bisect a hand-written one.

A section โ€” title_bar, colors, buttons or one button within it โ€” that is not a table is ignored rather than refused, as upstream ignores it: its fields are simply absent and inherit from base.