Skip to main content

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 terminal_title: String,   // Last known terminal title (for change detection)
12    pub scrollback_len: usize,    // Last known scrollback length
13}
14
15impl RenderCache {
16    pub fn new() -> Self {
17        Self {
18            cells: None,
19            generation: 0,
20            scroll_offset: 0,
21            cursor_pos: None,
22            selection: None,
23            terminal_title: String::new(),
24            scrollback_len: 0,
25        }
26    }
27}
28
29impl Default for RenderCache {
30    fn default() -> Self {
31        Self::new()
32    }
33}