Updated style file format

This commit is contained in:
Alexandre Bury 2015-05-25 01:12:51 -07:00
parent bfccae1b8e
commit 89221fae55
2 changed files with 31 additions and 16 deletions

View File

@ -1,14 +1,29 @@
background = "#3465a4"
shadow = "#000000"
# Everything in a theme file is optional.
shadow = false
borders = "simple", # Alternatives are "none" and "outset"
# Base colors are red, green, blue,
# cyan, magenta, yellow, white and black.
[colors]
background = "black"
# If the value is an array, the first valid color will be used.
# If the terminal doesn't support custom color,
# non-base colors will be skipped.
shadow = ["#000000", "black"]
view = "#d3d7cf"
primary = "#111111"
# Array and simple values have the same effect.
primary = ["#111111"]
secondary = "#EEEEEE"
tertiary = "#444444"
# Hex values can use lower or uppercase.
# (base color MUST be lowercase)
title_primary = "#ff5555"
title_secondary = "#ffff55"
highlight = "#FF0000"
# Lower precision values can use only 3 digits.
highlight = "#F00"
highlight_inactive = "#5555FF"

View File

@ -133,15 +133,15 @@ impl Color {
if s.starts_with("#") {
let s = &s[1..];
// HTML-style
let l = match s.len() {
6 => 2,
3 => 1,
let (l,max) = match s.len() {
6 => (2,255),
3 => (1,15),
_ => panic!("Cannot parse color: {}", s),
};
self.r = (load_hex(&s[0*l..1*l]) as i32 * 1000 / 255) as i16;
self.g = (load_hex(&s[1*l..2*l]) as i32 * 1000 / 255) as i16;
self.b = (load_hex(&s[2*l..3*l]) as i32 * 1000 / 255) as i16;
self.r = (load_hex(&s[0*l..1*l]) as i32 * 1000 / max) as i16;
self.g = (load_hex(&s[1*l..2*l]) as i32 * 1000 / max) as i16;
self.b = (load_hex(&s[2*l..3*l]) as i32 * 1000 / max) as i16;
} else {
// Unknown color. Panic.
panic!("Cannot parse color: {}", s);