par_term/app/
render_cache.rs

1use crate::cell_renderer::Cell;
2use crate::selection::Selection;
3
4/// State related to render caching and dirty tracking
5pub struct RenderCache {
6    pub cells: Option<Vec<Cell>>, // Cached cells from last render (dirty tracking)
7    pub generation: u64,          // Last terminal generation number (for dirty tracking)
8    pub scroll_offset: usize,     // Last scroll offset (for cache invalidation)
9    pub cursor_pos: Option<(usize, usize)>, // Last cursor position (for cache invalidation)
10    pub selection: Option<Selection>, // Last selection state (for cache invalidation)
11    pub applied_opacity: f32,     // Last opacity value sent to renderer
12    pub terminal_title: String,   // Last known terminal title (for change detection)
13    pub scrollback_len: usize,    // Last known scrollback length
14}
15
16impl RenderCache {
17    pub fn new(initial_opacity: f32) -> Self {
18        Self {
19            cells: None,
20            generation: 0,
21            scroll_offset: 0,
22            cursor_pos: None,
23            selection: None,
24            applied_opacity: initial_opacity,
25            terminal_title: String::new(),
26            scrollback_len: 0,
27        }
28    }
29}