sericom_core/screen_buffer/cell.rs
1use crossterm::style::Color;
2
3use crate::configs::get_config;
4
5/// `Cell` represents a cell within the terminal's window/frame.
6///
7/// Used to hold rendering state for all the cells within the [`ScreenBuffer`][`super::ScreenBuffer`].
8/// Each line within [`ScreenBuffer`][`super::ScreenBuffer`] is represented by a `Vec<Cell>`.
9#[derive(Clone, Debug)]
10pub struct Cell {
11 pub(super) character: char,
12 pub(super) fg_color: Color,
13 pub(super) bg_color: Color,
14 pub(super) is_selected: bool,
15}
16
17impl Default for Cell {
18 /// The default for [`Cell`] is the fg color from [`Appearance.fg`][`crate::configs::Appearance`],
19 /// the bg color from [`Appearance.bg`][`crate::configs::Appearance`], `' '` for the character, and is not selected.
20 fn default() -> Self {
21 let config = get_config();
22 Self {
23 character: ' ',
24 fg_color: Color::from(&config.appearance.fg),
25 bg_color: Color::from(&config.appearance.bg),
26 is_selected: false,
27 }
28 }
29}