From 186a07c364536dd482938ba9a0ce0a4d7e6d74c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 27 Jun 2020 15:29:47 +0200 Subject: [PATCH] sixel: split -> overwrite --- sixel.c | 30 +++++++++++++++--------------- sixel.h | 11 +++++++---- terminal.c | 11 ++++++----- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/sixel.c b/sixel.c index 62a165f9..a4b27416 100644 --- a/sixel.c +++ b/sixel.c @@ -186,8 +186,8 @@ sixel_delete_in_range(struct terminal *term, int _start, int _end) } static void -sixel_split(struct terminal *term, struct sixel *six, - int row, int col, int height, int width) +sixel_overwrite(struct terminal *term, struct sixel *six, + int row, int col, int height, int width) { assert(row >= 0); assert(row + height <= term->grid->num_rows); @@ -290,7 +290,7 @@ sixel_split(struct terminal *term, struct sixel *six, /* Row numbers are absolute */ static void -_sixel_split_by_rectangle( +_sixel_overwrite_by_rectangle( struct terminal *term, int row, int col, int height, int width) { assert(row + height <= term->grid->num_rows); @@ -326,7 +326,7 @@ _sixel_split_by_rectangle( (col <= col_end && col + width - 1 >= col_end) || (col >= col_start && col + width - 1 <= col_end)) { - sixel_split(term, six, start, col, height, width); + sixel_overwrite(term, six, start, col, height, width); sixel_erase(term, six); tll_remove(term->grid->sixel_images, it); } @@ -335,7 +335,7 @@ _sixel_split_by_rectangle( } void -sixel_split_by_rectangle( +sixel_overwrite_by_rectangle( struct terminal *term, int row, int col, int height, int width) { if (likely(tll_length(term->grid->sixel_images) == 0)) @@ -348,15 +348,15 @@ sixel_split_by_rectangle( if (wraps) { int rows_to_wrap_around = term->grid->num_rows - start; assert(height - rows_to_wrap_around > 0); - _sixel_split_by_rectangle(term, start, col, rows_to_wrap_around, width); - _sixel_split_by_rectangle(term, 0, col, height - rows_to_wrap_around, width); + _sixel_overwrite_by_rectangle(term, start, col, rows_to_wrap_around, width); + _sixel_overwrite_by_rectangle(term, 0, col, height - rows_to_wrap_around, width); } else - _sixel_split_by_rectangle(term, start, col, height, width); + _sixel_overwrite_by_rectangle(term, start, col, height, width); } /* Row numbers are absolute */ static void -_sixel_split_by_row(struct terminal *term, int row, int col, int width) +_sixel_overwrite_by_row(struct terminal *term, int row, int col, int width) { assert(col >= 0); @@ -384,7 +384,7 @@ _sixel_split_by_row(struct terminal *term, int row, int col, int width) (col <= col_end && col + width - 1 >= col_end) || (col >= col_start && col + width - 1 <= col_end)) { - sixel_split(term, six, row, col, 1, width); + sixel_overwrite(term, six, row, col, 1, width); sixel_erase(term, six); tll_remove(term->grid->sixel_images, it); } @@ -393,18 +393,18 @@ _sixel_split_by_row(struct terminal *term, int row, int col, int width) } void -sixel_split_by_row(struct terminal *term, int row, int col, int width) +sixel_overwrite_by_row(struct terminal *term, int row, int col, int width) { - _sixel_split_by_row( + _sixel_overwrite_by_row( term, (term->grid->offset + row) & (term->grid->num_rows - 1), col, width); } void -sixel_split_at_cursor(struct terminal *term) +sixel_overwrite_at_cursor(struct terminal *term) { - sixel_split_by_row( + sixel_overwrite_by_row( term, term->grid->cursor.point.row, term->grid->cursor.point.col, 1); } @@ -448,7 +448,7 @@ sixel_unhook(struct terminal *term) .pos = (struct coord){cursor->col, cur_row}, }; - sixel_split_by_rectangle( + sixel_overwrite_by_rectangle( term, cursor->row, image.pos.col, image.rows, image.cols); LOG_DBG("generating %dx%d pixman image at %d-%d", image.width, image.height, image.pos.row, image.pos.row + image.rows); diff --git a/sixel.h b/sixel.h index 9db720a2..6b272e94 100644 --- a/sixel.h +++ b/sixel.h @@ -12,14 +12,17 @@ void sixel_unhook(struct terminal *term); void sixel_destroy(struct sixel *sixel); -/* Row numbers are relative to current grid offset */ +/* Deletes all sixels that are touched by the specified row(s). Row + * numbers are relative to the current grid aoffset */ void sixel_delete_in_range(struct terminal *term, int row_start, int row_end); void sixel_delete_at_row(struct terminal *term, int row); -void sixel_split_by_rectangle( +/* Remove sixel data from the specified location. Row numbers are + * relative to the current grid offset */ +void sixel_overwrite_by_rectangle( struct terminal *term, int row, int col, int height, int width); -void sixel_split_by_row(struct terminal *term, int row, int col, int width); -void sixel_split_at_cursor(struct terminal *term); +void sixel_overwrite_by_row(struct terminal *term, int row, int col, int width); +void sixel_overwrite_at_cursor(struct terminal *term); void sixel_colors_report_current(struct terminal *term); void sixel_colors_reset(struct terminal *term); diff --git a/terminal.c b/terminal.c index c41173a3..504dec57 100644 --- a/terminal.c +++ b/terminal.c @@ -1599,7 +1599,7 @@ term_erase(struct terminal *term, const struct coord *start, const struct coord if (start->row == end->row) { struct row *row = grid_row(term->grid, start->row); erase_cell_range(term, row, start->col, end->col); - sixel_split_by_row(term, start->row, start->col, end->col - start->col + 1); + sixel_overwrite_by_row(term, start->row, start->col, end->col - start->col + 1); return; } @@ -1607,14 +1607,15 @@ term_erase(struct terminal *term, const struct coord *start, const struct coord erase_cell_range( term, grid_row(term->grid, start->row), start->col, term->cols - 1); - sixel_split_by_row(term, start->row, start->col, term->cols - start->col); + sixel_overwrite_by_row(term, start->row, start->col, term->cols - start->col); for (int r = start->row + 1; r < end->row; r++) erase_line(term, grid_row(term->grid, r)); - sixel_split_by_rectangle(term, start->row + 1, 0, end->row - start->row, term->cols); + sixel_overwrite_by_rectangle( + term, start->row + 1, 0, end->row - start->row, term->cols); erase_cell_range(term, grid_row(term->grid, end->row), 0, end->col); - sixel_split_by_row(term, end->row, 0, end->col + 1); + sixel_overwrite_by_row(term, end->row, 0, end->col + 1); } int @@ -2383,7 +2384,7 @@ term_print(struct terminal *term, wchar_t wc, int width) print_linewrap(term); print_insert(term, width); - sixel_split_at_cursor(term); + sixel_overwrite_at_cursor(term); /* *Must* get current cell *after* linewrap+insert */ struct row *row = term->grid->cur_row;