use crate::renderer::cell::{Cell, Pen};
#[derive(Debug, Clone, Copy)]
pub struct ScreenCell<'a>(&'a Cell);
impl<'a> ScreenCell<'a> {
pub(super) const fn new(cell: &'a Cell) -> Self {
Self(cell)
}
#[must_use]
pub fn text(&self) -> String {
let mut text = String::new();
self.0.push_text(&mut text);
text
}
#[must_use]
pub const fn width(&self) -> u8 {
self.0.width
}
#[must_use]
pub fn is_continuation(&self) -> bool {
self.0.is_continuation()
}
#[must_use]
pub fn style(&self) -> String {
Pen::DEFAULT.transition(&self.0.pen)
}
#[must_use]
pub fn link(&self) -> Option<&'a str> {
let link: &'a str = self.0.link.as_deref()?;
link.split_once(';').map(|(_, url)| url)
}
}