diff --git a/kitty/screen.c b/kitty/screen.c index f9853240a..cb4791b11 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -879,6 +879,25 @@ cursor_within_margins(Screen *self) { return self->margin_top <= self->cursor->y && self->cursor->y <= self->margin_bottom; } +// Remove all cell images from a portion of the screen and mark lines that +// contain image placeholders as dirty to make sure they are redrawn. This is +// needed when we perform commands that may move some lines without marking them +// as dirty (like screen_insert_lines) and at the same time don't move image +// references (i.e. unlike screen_scroll, which moves everything). +static void +screen_dirty_line_graphics(Screen *self, unsigned int top, unsigned int bottom) { + bool need_to_remove = false; + for (unsigned int y = top; y <= bottom; y++) { + if (self->linebuf->line_attrs[y].has_image_placeholders) { + need_to_remove = true; + linebuf_mark_line_dirty(self->linebuf, y); + self->is_dirty = true; + } + } + if (need_to_remove) + grman_remove_cell_images(self->grman, top, bottom); +} + void screen_handle_graphics_command(Screen *self, const GraphicsCommand *cmd, const uint8_t *payload) { unsigned int x = self->cursor->x, y = self->cursor->y; @@ -890,6 +909,10 @@ screen_handle_graphics_command(Screen *self, const GraphicsCommand *cmd, const u if (self->cursor->y > self->margin_bottom) screen_scroll(self, self->cursor->y - self->margin_bottom); screen_ensure_bounds(self, false, in_margins); } + if (cmd->unicode_placement) { + // Make sure the placeholders are redrawn if we add or change a virtual placement. + screen_dirty_line_graphics(self, 0, self->lines); + } } // }}} @@ -1546,25 +1569,6 @@ screen_fake_move_cursor_to_position(Screen *self, index_type start_x, index_type // Editing {{{ -// Remove all cell images from a portion of the screen and mark lines that -// contain image placeholders as dirty to make sure they are redrawn. This is -// needed when we perform commands that may move some lines without marking them -// as dirty (like screen_insert_lines) and at the same time don't move image -// references (i.e. unlike screen_scroll, which moves everything). -static void -screen_dirty_line_graphics(Screen *self, unsigned int top, unsigned int bottom) { - bool need_to_remove = false; - for (unsigned int y = top; y <= bottom; y++) { - if (self->linebuf->line_attrs[y].has_image_placeholders) { - need_to_remove = true; - linebuf_mark_line_dirty(self->linebuf, y); - self->is_dirty = true; - } - } - if (need_to_remove) - grman_remove_cell_images(self->grman, top, bottom); -} - void screen_erase_in_line(Screen *self, unsigned int how, bool private) { /*Erases a line in a specific way. @@ -2339,8 +2343,8 @@ screen_update_only_line_graphics_data(Screen *self) { for (index_type y = 0; y < MIN(self->lines, self->scrolled_by); y++) { lnum = self->scrolled_by - 1 - y; historybuf_init_line(self->historybuf, lnum, self->historybuf->line); + screen_render_line_graphics(self, self->historybuf->line, y - self->scrolled_by); if (self->historybuf->line->attrs.has_dirty_text) { - screen_render_line_graphics(self, self->historybuf->line, y - self->scrolled_by); historybuf_mark_line_clean(self->historybuf, lnum); } } @@ -2367,9 +2371,9 @@ screen_update_cell_data(Screen *self, void *address, FONTS_DATA_HANDLE fonts_dat for (index_type y = 0; y < MIN(self->lines, self->scrolled_by); y++) { lnum = self->scrolled_by - 1 - y; historybuf_init_line(self->historybuf, lnum, self->historybuf->line); + screen_render_line_graphics(self, self->historybuf->line, y - self->scrolled_by); if (self->historybuf->line->attrs.has_dirty_text) { render_line(fonts_data, self->historybuf->line, lnum, self->cursor, self->disable_ligatures); - screen_render_line_graphics(self, self->historybuf->line, y - self->scrolled_by); if (screen_has_marker(self)) mark_text_in_line(self->marker, self->historybuf->line); historybuf_mark_line_clean(self->historybuf, lnum); }