aboutsummaryrefslogtreecommitdiff
path: root/src/kitty_graphics.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-06-02 02:27:14 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-06-02 02:31:12 +0300
commitcc527d45fe4821cb11c484372a9f25c51c02e078 (patch)
tree2e3411b39576b0910eba75e2b5b77c5e4e398e74 /src/kitty_graphics.rs
parentf7d315d494b6a3d583574012526d15c1ddc82bfe (diff)
perf: retain terminal render updates
Diffstat (limited to 'src/kitty_graphics.rs')
-rw-r--r--src/kitty_graphics.rs64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/kitty_graphics.rs b/src/kitty_graphics.rs
index 90cf4006..4564bde6 100644
--- a/src/kitty_graphics.rs
+++ b/src/kitty_graphics.rs
@@ -215,6 +215,52 @@ pub(crate) fn encode_local_pane_graphics(
bytes
}
+pub(crate) fn has_visible_pane_graphics(
+ app: &AppState,
+ terminal_runtimes: &TerminalRuntimeRegistry,
+ cell_size: HostCellSize,
+) -> bool {
+ if app.mode != Mode::Terminal || !cell_size.is_known() {
+ return false;
+ }
+
+ let Some(ws_idx) = app.active else {
+ return false;
+ };
+ if app
+ .workspaces
+ .get(ws_idx)
+ .and_then(crate::workspace::Workspace::active_tab)
+ .is_none()
+ {
+ return false;
+ }
+
+ for info in &app.view.pane_infos {
+ let Some(runtime) = app.runtime_for_pane_in_workspace(terminal_runtimes, ws_idx, info.id)
+ else {
+ continue;
+ };
+ let scrollback_offset = runtime
+ .scroll_metrics()
+ .map(|m| m.offset_from_bottom as u32)
+ .unwrap_or(0);
+ for placement in runtime.kitty_image_placements_with_data_filter(|_| false) {
+ let host_placement = HostPlacement {
+ pane_id: info.id,
+ area: info.inner_rect,
+ cell_size,
+ placement,
+ scrollback_offset,
+ };
+ if clipped_placement(&host_placement).is_some() {
+ return true;
+ }
+ }
+ }
+ false
+}
+
fn encode_graphics_update(
bytes: &mut Vec<u8>,
placements: &[HostPlacement],
@@ -328,6 +374,24 @@ pub(crate) fn clear_all_host_graphics() -> io::Result<()> {
}
impl HostGraphicsCache {
+ pub(crate) fn is_empty(&self) -> bool {
+ self.images.is_empty() && self.placements.is_empty()
+ }
+
+ #[cfg(test)]
+ pub(crate) fn test_mark_non_empty(&mut self) {
+ self.images.insert(
+ HOST_IMAGE_ID_BASE,
+ ImageSignature {
+ image_width: 1,
+ image_height: 1,
+ format_code: 32,
+ data_len: 4,
+ data_fingerprint: 1,
+ },
+ );
+ }
+
pub(crate) fn clear_bytes(&mut self) -> Vec<u8> {
let mut bytes = Vec::new();
for id in self.images.keys().copied().collect::<Vec<_>>() {