fix: image appearing over alternate screen

This commit is contained in:
2026-07-04 21:18:12 +02:00
parent 96b85f0159
commit 04b6776ebf
7 changed files with 344 additions and 162 deletions
+35 -3
View File
@@ -137,10 +137,18 @@ pub struct GraphicsCommand {
pub delete_target: DeleteTarget,
/// Unicode placeholder (virtual placement).
pub unicode_placeholder: bool,
/// Parent image ID (for relative placement).
pub parent_image_id: Option<u32>,
/// Parent placement ID (for relative placement).
pub parent_placement_id: Option<u32>,
/// Horizontal cell displacement from parent.
pub h_offset: i32,
/// Vertical cell displacement from parent.
pub v_offset: i32,
/// Parent image ID (for animation frames).
pub parent_id: Option<u32>,
/// Parent placement ID (for animation frames).
pub parent_placement_id: Option<u32>,
pub parent_placement_id_anim: Option<u32>,
/// Frame number (for animation).
pub frame_number: Option<u32>,
/// Frame gap in milliseconds (z key for animation frames).
@@ -256,6 +264,17 @@ impl GraphicsCommand {
cmd.height = value.parse().ok();
}
}
"P" => {
if is_animation {
// P = parent_frame_index for animation
cmd.base_frame = value.parse().ok();
} else {
cmd.parent_image_id = value.parse().ok();
}
}
"Q" => cmd.parent_placement_id = value.parse().ok(),
"H" => cmd.h_offset = value.parse().unwrap_or(0),
"V" => cmd.v_offset = value.parse().unwrap_or(0),
"x" => cmd.src_x = value.parse().unwrap_or(0),
"y" => cmd.src_y = value.parse().unwrap_or(0),
"w" => cmd.src_width = value.parse().unwrap_or(0),
@@ -1611,6 +1630,19 @@ impl ImageStorage {
cmd.rows as usize
};
// Handle relative positioning
let (final_col, final_row) = if let (Some(p_id), Some(q_id)) = (cmd.parent_image_id, cmd.parent_placement_id) {
if let Some(parent) = self.placements.iter().find(|p| p.image_id == p_id && p.placement_id == q_id) {
let col = parent.col as i32 + cmd.h_offset;
let row = parent.row as i32 + cmd.v_offset;
(col.max(0) as usize, row.max(0) as usize)
} else {
(cursor_col, cursor_row)
}
} else {
(cursor_col, cursor_row)
};
// Don't create actual placement for virtual placements (U=1)
// Virtual placements are referenced by Unicode placeholders
if cmd.unicode_placeholder {
@@ -1626,8 +1658,8 @@ impl ImageStorage {
let placement = ImagePlacement {
image_id: id,
placement_id: cmd.placement_id.unwrap_or(0),
col: cursor_col,
row: cursor_row,
col: final_col,
row: final_row,
cols,
rows,
z_index: cmd.z_index,