about summary refs log blame commit diff
path: root/src/entities/entity_char.rs
blob: 70f26bfffdbd97819f9d854a4a30d9a39219be13 (plain) (tree)
1
2
3
4
5
6
7
8
9



                                         
                                            
                       
                     
                 
 




                             
                                                         








                                   
use crate::display::color::Color;
use std::fmt::{self, Display, Formatter};
use termion::color;

#[derive(Debug, Deserialize, PartialEq, Eq)]
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)
        )
    }
}