use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PaneGlyph {
#[serde(default = "default_glyph_text")]
pub text: String,
#[serde(default = "default_glyph_width")]
pub width: u8,
#[serde(default)]
pub padding: bool,
}
impl PaneGlyph {
#[must_use]
pub fn new(text: impl Into<String>, width: u8) -> Self {
Self {
text: text.into(),
width,
padding: false,
}
}
#[must_use]
pub fn blank() -> Self {
Self {
text: " ".to_owned(),
width: 1,
padding: false,
}
}
#[must_use]
pub fn padding() -> Self {
Self {
text: " ".to_owned(),
width: 0,
padding: true,
}
}
#[must_use]
pub const fn is_padding(&self) -> bool {
self.padding
}
}
impl Default for PaneGlyph {
fn default() -> Self {
Self::blank()
}
}
fn default_glyph_text() -> String {
" ".to_owned()
}
const fn default_glyph_width() -> u8 {
1
}