use serde::{Deserialize, Serialize};
use super::{PaneAttributes, PaneColor, PaneGlyph};
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PaneCell {
#[serde(default)]
pub glyph: PaneGlyph,
#[serde(default)]
pub attributes: PaneAttributes,
#[serde(default)]
pub foreground: PaneColor,
#[serde(default)]
pub background: PaneColor,
#[serde(default)]
pub underline: PaneColor,
}
impl PaneCell {
#[must_use]
pub fn new(glyph: PaneGlyph) -> Self {
Self {
glyph,
..Self::default()
}
}
#[must_use]
pub fn blank() -> Self {
Self::new(PaneGlyph::blank())
}
#[must_use]
pub fn padding() -> Self {
Self::new(PaneGlyph::padding())
}
#[must_use]
pub const fn is_padding(&self) -> bool {
self.glyph.is_padding()
}
#[must_use]
pub fn text(&self) -> &str {
&self.glyph.text
}
}
impl Default for PaneCell {
fn default() -> Self {
Self {
glyph: PaneGlyph::blank(),
attributes: PaneAttributes::EMPTY,
foreground: PaneColor::Default,
background: PaneColor::Default,
underline: PaneColor::Default,
}
}
}