use crate::cell_renderer::{Cell, PaneViewport};
use par_term_config::SeparatorMark;
pub fn compute_visible_separator_marks(
marks: &[par_term_config::ScrollbackMark],
scrollback_len: usize,
scroll_offset: usize,
visible_lines: usize,
) -> Vec<SeparatorMark> {
let mut out = Vec::new();
fill_visible_separator_marks(
&mut out,
marks,
scrollback_len,
scroll_offset,
visible_lines,
);
out
}
pub(crate) fn fill_visible_separator_marks(
out: &mut Vec<SeparatorMark>,
marks: &[par_term_config::ScrollbackMark],
scrollback_len: usize,
scroll_offset: usize,
visible_lines: usize,
) {
out.clear();
let viewport_start = scrollback_len.saturating_sub(scroll_offset);
let viewport_end = viewport_start + visible_lines;
for mark in marks {
if mark.line >= viewport_start && mark.line < viewport_end {
let screen_row = mark.line - viewport_start;
out.push((screen_row, mark.exit_code, mark.color));
}
}
}
pub struct PaneRenderInfo<'a> {
pub viewport: PaneViewport,
pub cells: &'a [Cell],
pub grid_size: (usize, usize),
pub cursor_pos: Option<(usize, usize)>,
pub cursor_opacity: f32,
pub show_scrollbar: bool,
pub marks: Vec<par_term_config::ScrollbackMark>,
pub scrollback_len: usize,
pub scroll_offset: usize,
pub background: Option<par_term_config::PaneBackground>,
pub graphics: Vec<par_term_emu_core_rust::graphics::TerminalGraphic>,
pub virtual_placements: Vec<par_term_emu_core_rust::graphics::TerminalGraphic>,
}
#[derive(Clone, Copy, Debug)]
pub struct DividerRenderInfo {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
pub hovered: bool,
}
impl DividerRenderInfo {
pub fn from_rect(rect: &par_term_config::DividerRect, hovered: bool) -> Self {
Self {
x: rect.x,
y: rect.y,
width: rect.width,
height: rect.height,
hovered,
}
}
}
#[derive(Clone, Debug)]
pub struct PaneTitleInfo {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
pub title: String,
pub focused: bool,
pub text_color: [f32; 3],
pub bg_color: [f32; 3],
}
#[derive(Clone, Copy, Debug)]
pub struct PaneDividerSettings {
pub divider_color: [f32; 3],
pub hover_color: [f32; 3],
pub show_focus_indicator: bool,
pub focus_color: [f32; 3],
pub focus_width: f32,
pub divider_style: par_term_config::DividerStyle,
}
impl Default for PaneDividerSettings {
fn default() -> Self {
Self {
divider_color: [0.3, 0.3, 0.3],
hover_color: [0.5, 0.6, 0.8],
show_focus_indicator: true,
focus_color: [0.4, 0.6, 1.0],
focus_width: 1.0,
divider_style: par_term_config::DividerStyle::default(),
}
}
}