use ctl_text::{Overflow, Text};
use crate::align::Align;
#[derive(Clone, Debug)]
pub struct Column {
pub(crate) header: Option<Text>,
pub(crate) overflow: Overflow,
pub(crate) align: Align,
}
impl Column {
#[must_use]
pub fn new(header: impl Into<Text>) -> Self {
Self::headed(Some(header.into()))
}
#[must_use]
pub fn untitled() -> Self {
Self::headed(None)
}
fn headed(header: Option<Text>) -> Self {
Self {
header,
overflow: Overflow::default(),
align: Align::default(),
}
}
#[must_use]
pub fn overflow(mut self, overflow: Overflow) -> Self {
self.overflow = overflow;
self
}
#[must_use]
pub fn numeric(self) -> Self {
self.align(Align::Right)
}
#[must_use]
pub fn align(mut self, align: Align) -> Self {
self.align = align;
self
}
}