diff --git a/gen-apc-parsers.py b/gen-apc-parsers.py index f5b74ad07..6e5d6bccb 100755 --- a/gen-apc-parsers.py +++ b/gen-apc-parsers.py @@ -250,7 +250,7 @@ def write_header(text: str, path: str) -> None: def graphics_parser() -> None: flag = frozenset keymap: KeymapType = { - 'a': ('action', flag('tTqpdf')), + 'a': ('action', flag('tTqpdfa')), 'd': ('delete_action', flag('aAiIcCfFnNpPqQxXyYzZ')), 't': ('transmission_type', flag('dfts')), 'o': ('compressed', flag('z')), diff --git a/kitty/graphics.c b/kitty/graphics.c index c619018f4..61ef9f609 100644 --- a/kitty/graphics.c +++ b/kitty/graphics.c @@ -774,13 +774,16 @@ grman_update_layers(GraphicsManager *self, unsigned int scrolled_by, float scree // Animation {{{ #define DEFAULT_GAP 40 +#define _frame_number num_lines +#define _other_frame_number num_cells +#define _gap z_index static Image* handle_animation_frame_load_command(GraphicsManager *self, GraphicsCommand *g, Image *img, const uint8_t *payload) { - uint32_t frame_number = g->num_lines, fmt = g->format ? g->format : RGBA; + uint32_t frame_number = g->_frame_number, fmt = g->format ? g->format : RGBA; if (!frame_number || frame_number > img->extra_framecnt + 2) frame_number = img->extra_framecnt + 2; bool is_new_frame = frame_number == img->extra_framecnt + 2; - g->num_lines = frame_number; + g->_frame_number = frame_number; unsigned char tt = g->transmission_type ? g->transmission_type : 'd'; size_t w = img->width, h = img->height; if (tt == 'd' && self->currently_loading_data_for.image_id == img->internal_id) { @@ -821,17 +824,17 @@ handle_animation_frame_load_command(GraphicsManager *self, GraphicsCommand *g, I if (is_new_frame) { key.frame_id = ++img->frame_id_counter; if (!key.frame_id) key.frame_id = ++img->frame_id_counter; - if (g->num_cells) { + if (g->_other_frame_number) { ImageAndFrame other = { .image_id = img->internal_id }; - if (g->num_cells > 1) { - other.frame_id = g->num_cells - 2; + if (g->_other_frame_number > 1) { + other.frame_id = g->_other_frame_number - 2; if (other.frame_id >= img->extra_framecnt) { - FAIL("ENODATA", "No data for frame with number: %u found in image: %u", g->num_cells, img->client_id); + FAIL("ENODATA", "No data for frame with number: %u found in image: %u", g->_other_frame_number, img->client_id); } other.frame_id = img->extra_frames[other.frame_id].id; } if (!read_from_cache(self, other, &base_data, &data_sz)) { - FAIL("ENODATA", "No data for frame with number: %u found in image: %u", g->num_cells, img->client_id); + FAIL("ENODATA", "No data for frame with number: %u found in image: %u", g->_other_frame_number, img->client_id); } } else { base_data = calloc(1, expected_data_sz); @@ -879,7 +882,7 @@ handle_animation_frame_load_command(GraphicsManager *self, GraphicsCommand *g, I img->extra_frames[frame_number - 2].gap = DEFAULT_GAP; img->extra_frames[frame_number - 2].id = key.frame_id; } - if (g->z_index > 0) img->extra_frames[frame_number - 2].gap = g->z_index; + if (g->_gap > 0) img->extra_frames[frame_number - 2].gap = g->_gap; } return img; } @@ -897,7 +900,7 @@ handle_delete_frame_command(GraphicsManager *self, const GraphicsCommand *g, boo REPORT_ERROR("Animation command refers to non-existent image with id: %u and number: %u", g->id, g->image_number); return NULL; } - uint32_t frame_number = MIN(img->extra_framecnt + 1, g->num_lines); + uint32_t frame_number = MIN(img->extra_framecnt + 1, g->_frame_number); if (!frame_number) frame_number = 1; if (!img->extra_framecnt) return g->delete_action == 'F' ? img : NULL; ImageAndFrame key = {.image_id=img->internal_id}; diff --git a/kitty/parse-graphics-command.h b/kitty/parse-graphics-command.h index 81d53db92..484bb9231 100644 --- a/kitty/parse-graphics-command.h +++ b/kitty/parse-graphics-command.h @@ -144,8 +144,9 @@ static inline void parse_graphics_code(Screen *screen, case action: { g.action = screen->parser_buf[pos++] & 0xff; - if (g.action != 'p' && g.action != 't' && g.action != 'q' && - g.action != 'f' && g.action != 'T' && g.action != 'd') { + if (g.action != 'q' && g.action != 'd' && g.action != 'p' && + g.action != 't' && g.action != 'T' && g.action != 'f' && + g.action != 'a') { REPORT_ERROR("Malformed GraphicsCommand control block, unknown flag " "value for action: 0x%x", g.action); @@ -155,16 +156,16 @@ static inline void parse_graphics_code(Screen *screen, case delete_action: { g.delete_action = screen->parser_buf[pos++] & 0xff; - if (g.delete_action != 'x' && g.delete_action != 'z' && - g.delete_action != 'X' && g.delete_action != 'i' && - g.delete_action != 'n' && g.delete_action != 'a' && - g.delete_action != 'F' && g.delete_action != 'I' && - g.delete_action != 'f' && g.delete_action != 'Q' && - g.delete_action != 'y' && g.delete_action != 'C' && - g.delete_action != 'q' && g.delete_action != 'Y' && - g.delete_action != 'p' && g.delete_action != 'Z' && - g.delete_action != 'A' && g.delete_action != 'P' && - g.delete_action != 'N' && g.delete_action != 'c') { + if (g.delete_action != 'F' && g.delete_action != 'n' && + g.delete_action != 'x' && g.delete_action != 'I' && + g.delete_action != 'p' && g.delete_action != 'i' && + g.delete_action != 'C' && g.delete_action != 'Q' && + g.delete_action != 'A' && g.delete_action != 'z' && + g.delete_action != 'y' && g.delete_action != 'c' && + g.delete_action != 'Z' && g.delete_action != 'N' && + g.delete_action != 'X' && g.delete_action != 'q' && + g.delete_action != 'P' && g.delete_action != 'f' && + g.delete_action != 'Y' && g.delete_action != 'a') { REPORT_ERROR("Malformed GraphicsCommand control block, unknown flag " "value for delete_action: 0x%x", g.delete_action);