Fix bug with cursor colors and old config

There was no default supplied for Colors.cursor. This caused config
not specifying that property to break. Adding a default should fix that.
This commit is contained in:
Joe Wilm 2017-01-30 09:45:09 -08:00
parent 9f064001e2
commit b27d1266d6
1 changed files with 9 additions and 4 deletions

View File

@ -706,11 +706,19 @@ pub enum Error {
#[derive(Debug, Deserialize)]
pub struct Colors {
primary: PrimaryColors,
#[serde(default="default_cursor_colors")]
cursor: PrimaryColors,
normal: AnsiColors,
bright: AnsiColors,
}
fn default_cursor_colors() -> PrimaryColors {
PrimaryColors {
foreground: Rgb { r: 0, g: 0, b: 0 },
background: Rgb { r: 0xff, g: 0xff, b: 0xff },
}
}
#[derive(Debug, Deserialize)]
pub struct PrimaryColors {
#[serde(deserialize_with = "rgb_from_hex")]
@ -726,10 +734,7 @@ impl Default for Colors {
background: Rgb { r: 0, g: 0, b: 0 },
foreground: Rgb { r: 0xea, g: 0xea, b: 0xea },
},
cursor: PrimaryColors {
foreground: Rgb { r: 0, g: 0, b: 0 },
background: Rgb { r: 0xff, g: 0xff, b: 0xff },
},
cursor: default_cursor_colors(),
normal: AnsiColors {
black: Rgb {r: 0x00, g: 0x00, b: 0x00},
red: Rgb {r: 0xd5, g: 0x4e, b: 0x53},