mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-02 07:15:31 -04:00
sixel: split -> overwrite
This commit is contained in:
parent
ae727e372a
commit
186a07c364
3 changed files with 28 additions and 24 deletions
30
sixel.c
30
sixel.c
|
|
@ -186,8 +186,8 @@ sixel_delete_in_range(struct terminal *term, int _start, int _end)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sixel_split(struct terminal *term, struct sixel *six,
|
sixel_overwrite(struct terminal *term, struct sixel *six,
|
||||||
int row, int col, int height, int width)
|
int row, int col, int height, int width)
|
||||||
{
|
{
|
||||||
assert(row >= 0);
|
assert(row >= 0);
|
||||||
assert(row + height <= term->grid->num_rows);
|
assert(row + height <= term->grid->num_rows);
|
||||||
|
|
@ -290,7 +290,7 @@ sixel_split(struct terminal *term, struct sixel *six,
|
||||||
|
|
||||||
/* Row numbers are absolute */
|
/* Row numbers are absolute */
|
||||||
static void
|
static void
|
||||||
_sixel_split_by_rectangle(
|
_sixel_overwrite_by_rectangle(
|
||||||
struct terminal *term, int row, int col, int height, int width)
|
struct terminal *term, int row, int col, int height, int width)
|
||||||
{
|
{
|
||||||
assert(row + height <= term->grid->num_rows);
|
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_end && col + width - 1 >= col_end) ||
|
||||||
(col >= col_start && 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);
|
sixel_erase(term, six);
|
||||||
tll_remove(term->grid->sixel_images, it);
|
tll_remove(term->grid->sixel_images, it);
|
||||||
}
|
}
|
||||||
|
|
@ -335,7 +335,7 @@ _sixel_split_by_rectangle(
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sixel_split_by_rectangle(
|
sixel_overwrite_by_rectangle(
|
||||||
struct terminal *term, int row, int col, int height, int width)
|
struct terminal *term, int row, int col, int height, int width)
|
||||||
{
|
{
|
||||||
if (likely(tll_length(term->grid->sixel_images) == 0))
|
if (likely(tll_length(term->grid->sixel_images) == 0))
|
||||||
|
|
@ -348,15 +348,15 @@ sixel_split_by_rectangle(
|
||||||
if (wraps) {
|
if (wraps) {
|
||||||
int rows_to_wrap_around = term->grid->num_rows - start;
|
int rows_to_wrap_around = term->grid->num_rows - start;
|
||||||
assert(height - rows_to_wrap_around > 0);
|
assert(height - rows_to_wrap_around > 0);
|
||||||
_sixel_split_by_rectangle(term, start, col, rows_to_wrap_around, width);
|
_sixel_overwrite_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, 0, col, height - rows_to_wrap_around, width);
|
||||||
} else
|
} else
|
||||||
_sixel_split_by_rectangle(term, start, col, height, width);
|
_sixel_overwrite_by_rectangle(term, start, col, height, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Row numbers are absolute */
|
/* Row numbers are absolute */
|
||||||
static void
|
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);
|
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_end && col + width - 1 >= col_end) ||
|
||||||
(col >= col_start && 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);
|
sixel_erase(term, six);
|
||||||
tll_remove(term->grid->sixel_images, it);
|
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
|
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,
|
||||||
(term->grid->offset + row) & (term->grid->num_rows - 1),
|
(term->grid->offset + row) & (term->grid->num_rows - 1),
|
||||||
col, width);
|
col, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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);
|
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},
|
.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);
|
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);
|
LOG_DBG("generating %dx%d pixman image at %d-%d", image.width, image.height, image.pos.row, image.pos.row + image.rows);
|
||||||
|
|
|
||||||
11
sixel.h
11
sixel.h
|
|
@ -12,14 +12,17 @@ void sixel_unhook(struct terminal *term);
|
||||||
|
|
||||||
void sixel_destroy(struct sixel *sixel);
|
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_in_range(struct terminal *term, int row_start, int row_end);
|
||||||
void sixel_delete_at_row(struct terminal *term, int row);
|
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);
|
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_overwrite_by_row(struct terminal *term, int row, int col, int width);
|
||||||
void sixel_split_at_cursor(struct terminal *term);
|
void sixel_overwrite_at_cursor(struct terminal *term);
|
||||||
|
|
||||||
void sixel_colors_report_current(struct terminal *term);
|
void sixel_colors_report_current(struct terminal *term);
|
||||||
void sixel_colors_reset(struct terminal *term);
|
void sixel_colors_reset(struct terminal *term);
|
||||||
|
|
|
||||||
11
terminal.c
11
terminal.c
|
|
@ -1599,7 +1599,7 @@ term_erase(struct terminal *term, const struct coord *start, const struct coord
|
||||||
if (start->row == end->row) {
|
if (start->row == end->row) {
|
||||||
struct row *row = grid_row(term->grid, start->row);
|
struct row *row = grid_row(term->grid, start->row);
|
||||||
erase_cell_range(term, row, start->col, end->col);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1607,14 +1607,15 @@ term_erase(struct terminal *term, const struct coord *start, const struct coord
|
||||||
|
|
||||||
erase_cell_range(
|
erase_cell_range(
|
||||||
term, grid_row(term->grid, start->row), start->col, term->cols - 1);
|
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++)
|
for (int r = start->row + 1; r < end->row; r++)
|
||||||
erase_line(term, grid_row(term->grid, 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);
|
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
|
int
|
||||||
|
|
@ -2383,7 +2384,7 @@ term_print(struct terminal *term, wchar_t wc, int width)
|
||||||
print_linewrap(term);
|
print_linewrap(term);
|
||||||
print_insert(term, width);
|
print_insert(term, width);
|
||||||
|
|
||||||
sixel_split_at_cursor(term);
|
sixel_overwrite_at_cursor(term);
|
||||||
|
|
||||||
/* *Must* get current cell *after* linewrap+insert */
|
/* *Must* get current cell *after* linewrap+insert */
|
||||||
struct row *row = term->grid->cur_row;
|
struct row *row = term->grid->cur_row;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue