mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
term: erasing characters now splits sixels instead of deleting them
This commit is contained in:
parent
0953ffd2d3
commit
ae727e372a
3 changed files with 30 additions and 18 deletions
34
sixel.c
34
sixel.c
|
|
@ -334,14 +334,14 @@ _sixel_split_by_rectangle(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
sixel_split_by_rectangle(
|
sixel_split_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))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int start = (term->grid->offset + _row) & (term->grid->num_rows - 1);
|
const int start = (term->grid->offset + row) & (term->grid->num_rows - 1);
|
||||||
const int end = (start + height - 1) & (term->grid->num_rows - 1);
|
const int end = (start + height - 1) & (term->grid->num_rows - 1);
|
||||||
const bool wraps = end < start;
|
const bool wraps = end < start;
|
||||||
|
|
||||||
|
|
@ -356,14 +356,14 @@ sixel_split_by_rectangle(
|
||||||
|
|
||||||
/* Row numbers are absolute */
|
/* Row numbers are absolute */
|
||||||
static void
|
static void
|
||||||
sixel_split_at_point(struct terminal *term, int row, int col)
|
_sixel_split_by_row(struct terminal *term, int row, int col, int width)
|
||||||
{
|
{
|
||||||
assert(col >= 0);
|
assert(col >= 0);
|
||||||
|
|
||||||
assert(row >= 0);
|
assert(row >= 0);
|
||||||
assert(row < term->grid->num_rows);
|
assert(row < term->grid->num_rows);
|
||||||
assert(col >= 0);
|
assert(col >= 0);
|
||||||
assert(col < term->grid->num_cols);
|
assert(col + width <= term->grid->num_cols);
|
||||||
|
|
||||||
if (likely(tll_length(term->grid->sixel_images) == 0))
|
if (likely(tll_length(term->grid->sixel_images) == 0))
|
||||||
return;
|
return;
|
||||||
|
|
@ -378,10 +378,13 @@ sixel_split_at_point(struct terminal *term, int row, int col)
|
||||||
|
|
||||||
if (row >= six_start && row <= six_end) {
|
if (row >= six_start && row <= six_end) {
|
||||||
const int col_start = six->pos.col;
|
const int col_start = six->pos.col;
|
||||||
const int col_end = six->pos.col + six->cols;
|
const int col_end = six->pos.col + six->cols - 1;
|
||||||
|
|
||||||
if (col >= col_start && col < col_end) {
|
if ((col <= col_start && col + width - 1 >= col_start) ||
|
||||||
sixel_split(term, six, row, col, 1, 1);
|
(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_erase(term, six);
|
sixel_erase(term, six);
|
||||||
tll_remove(term->grid->sixel_images, it);
|
tll_remove(term->grid->sixel_images, it);
|
||||||
}
|
}
|
||||||
|
|
@ -389,13 +392,20 @@ sixel_split_at_point(struct terminal *term, int row, int col)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sixel_split_by_row(struct terminal *term, int row, int col, int width)
|
||||||
|
{
|
||||||
|
_sixel_split_by_row(
|
||||||
|
term,
|
||||||
|
(term->grid->offset + row) & (term->grid->num_rows - 1),
|
||||||
|
col, width);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sixel_split_at_cursor(struct terminal *term)
|
sixel_split_at_cursor(struct terminal *term)
|
||||||
{
|
{
|
||||||
sixel_split_at_point(
|
sixel_split_by_row(
|
||||||
term,
|
term, term->grid->cursor.point.row, term->grid->cursor.point.col, 1);
|
||||||
(term->grid->offset + term->grid->cursor.point.row) & (term->grid->num_rows - 1),
|
|
||||||
term->grid->cursor.point.col);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
4
sixel.h
4
sixel.h
|
|
@ -15,6 +15,10 @@ void sixel_destroy(struct sixel *sixel);
|
||||||
/* Row numbers are relative to current grid offset */
|
/* Row numbers are relative to current grid offset */
|
||||||
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(
|
||||||
|
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_split_at_cursor(struct terminal *term);
|
||||||
|
|
||||||
void sixel_colors_report_current(struct terminal *term);
|
void sixel_colors_report_current(struct terminal *term);
|
||||||
|
|
|
||||||
10
terminal.c
10
terminal.c
|
|
@ -1599,9 +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);
|
||||||
/* TODO: split instead */
|
|
||||||
sixel_delete_at_row(term, start->row);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1609,14 +1607,14 @@ 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);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
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);
|
||||||
/* TODO: split instead */
|
|
||||||
sixel_delete_in_range(term, start->row, end->row);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue