par_term_terminal/terminal/
graphics.rs1use super::TerminalManager;
2use par_term_emu_core_rust::graphics::TerminalGraphic;
3
4impl TerminalManager {
5 #[allow(dead_code)]
8 pub fn get_graphics(&self) -> Vec<TerminalGraphic> {
9 let pty = self.pty_session.lock();
10 let terminal = pty.terminal();
11 let term = terminal.lock();
12 let graphics: Vec<_> = term.all_graphics().to_vec();
13 if !graphics.is_empty() {
14 log::debug!("Returning {} graphics from core library", graphics.len());
15 for (i, g) in graphics.iter().enumerate() {
16 log::trace!(
17 " [{}] protocol={:?}, pos=({},{}), size={}x{}",
18 i,
19 g.protocol,
20 g.position.0,
21 g.position.1,
22 g.width,
23 g.height
24 );
25 }
26 }
27 graphics
28 }
29
30 #[allow(dead_code)]
32 pub fn get_graphics_at_row(&self, row: usize) -> Vec<TerminalGraphic> {
33 let pty = self.pty_session.lock();
34 let terminal = pty.terminal();
35 let term = terminal.lock();
36 term.graphics_at_row(row)
37 .iter()
38 .map(|g| (*g).clone())
39 .collect()
40 }
41
42 #[allow(dead_code)]
44 pub fn graphics_count(&self) -> usize {
45 let pty = self.pty_session.lock();
46 let terminal = pty.terminal();
47 let term = terminal.lock();
48 term.graphics_count()
49 }
50
51 pub fn get_scrollback_graphics(&self) -> Vec<TerminalGraphic> {
53 let pty = self.pty_session.lock();
54 let terminal = pty.terminal();
55 let term = terminal.lock();
56 term.all_scrollback_graphics().to_vec()
57 }
58
59 pub fn update_animations(&self) -> bool {
61 let pty = self.pty_session.lock();
62 let terminal = pty.terminal();
63 let mut term = terminal.lock();
64 let changed_images = term.graphics_store_mut().update_animations();
65 !changed_images.is_empty()
66 }
67
68 pub fn get_graphics_with_animations(&self) -> Vec<TerminalGraphic> {
70 let pty = self.pty_session.lock();
71 let terminal = pty.terminal();
72 let term = terminal.lock();
73
74 let mut graphics = Vec::new();
75
76 let base_graphics: Vec<_> = term.all_graphics().to_vec();
77
78 log::debug!(
79 "get_graphics_with_animations() - base_graphics count: {}",
80 base_graphics.len()
81 );
82
83 for (idx, graphic) in base_graphics.iter().enumerate() {
84 log::trace!(
85 "Processing graphic {} - pos=({},{}), size={}x{}, kitty_id={:?}",
86 idx,
87 graphic.position.0,
88 graphic.position.1,
89 graphic.width,
90 graphic.height,
91 graphic.kitty_image_id
92 );
93
94 if let Some(image_id) = graphic.kitty_image_id
95 && let Some(anim) = term.graphics_store().get_animation(image_id)
96 && let Some(current_frame) = anim.current_frame()
97 {
98 let mut animated_graphic = graphic.clone();
99 animated_graphic.pixels = current_frame.pixels.clone();
100 animated_graphic.width = current_frame.width;
101 animated_graphic.height = current_frame.height;
102
103 log::debug!(
104 "Using animated frame {} for image {}",
105 anim.current_frame,
106 image_id
107 );
108
109 graphics.push(animated_graphic);
110 continue;
111 }
112 log::trace!("Using static graphic {}", idx);
113 graphics.push(graphic.clone());
114 }
115
116 log::debug!("Returning {} graphics total", graphics.len());
117 graphics
118 }
119}