about summary refs log tree commit diff
path: root/src/entities/entity_char.rs
blob: 88ca8a55a823c3ea44d93b10140acb213525f3ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use crate::display::color::Color;
use std::fmt::{self, Display, Formatter};
use termion::color;

#[derive(Debug, Deserialize)]
pub struct EntityChar {
    #[serde(default)]
    color: Color,

    #[serde(rename = "char")]
    chr: char,
}

impl Display for EntityChar {
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        write!(
            f,
            "{}{}{}",
            color::Fg(&self.color),
            self.chr,
            color::Fg(color::Reset)
        )
    }
}