use crate::console::{Console, ConsoleOptions};
use crate::measure::Measurement;
use crate::segment::Segment;
use crate::text::Text;
pub trait Renderable {
fn rich_render(&self, console: &Console, options: &ConsoleOptions) -> Vec<Segment>;
fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement {
Measurement::new(options.max_width, options.max_width)
}
}
pub trait LineRenderable: Renderable {
fn try_for_each_line<E>(
&self,
console: &Console,
options: &ConsoleOptions,
emit: impl FnMut(Vec<Segment>) -> Result<(), E>,
) -> Result<(), E>;
}
pub trait OwnedTableRows {
fn extend_owned_rows(&mut self, rows: Vec<Vec<String>>) -> &mut Self;
}
pub trait Highlighter {
fn highlight(&self, text: &mut Text);
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Support {
Unsupported,
Inferred,
Confirmed,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct TargetCapabilities {
pub width: usize,
pub height: usize,
pub color_system: Option<crate::color::ColorSystem>,
pub interactive: bool,
pub unicode: bool,
pub hyperlinks: bool,
pub sixel: Support,
}
pub trait RenderEnvironment: Send + Sync {
fn capabilities(&self) -> TargetCapabilities;
}
pub trait ConsoleEnvironment {
fn set_render_environment(&mut self, value: Option<std::sync::Arc<dyn RenderEnvironment>>);
fn render_environment(&self) -> Option<&dyn RenderEnvironment>;
}