mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-06 01:40:22 -05:00
sixel: delete/split: early(ier) exit when there aren't in sixel images
Avoid unnecessary wrap checks if the sixel image list is empty.
This commit is contained in:
parent
a25ff1ed84
commit
0953ffd2d3
2 changed files with 20 additions and 10 deletions
25
sixel.c
25
sixel.c
|
|
@ -118,9 +118,13 @@ sixel_delete_at_point(struct terminal *term, int row, int col)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: remove */
|
||||||
void
|
void
|
||||||
sixel_delete_at_row(struct terminal *term, int row)
|
sixel_delete_at_row(struct terminal *term, int row)
|
||||||
{
|
{
|
||||||
|
if (likely(tll_length(term->grid->sixel_images) == 0))
|
||||||
|
return;
|
||||||
|
|
||||||
sixel_delete_at_point(
|
sixel_delete_at_point(
|
||||||
term, (term->grid->offset + row) & (term->grid->num_rows - 1), -1);
|
term, (term->grid->offset + row) & (term->grid->num_rows - 1), -1);
|
||||||
}
|
}
|
||||||
|
|
@ -135,12 +139,6 @@ _sixel_delete_in_range(struct terminal *term, int start, int end)
|
||||||
assert(end >= 0);
|
assert(end >= 0);
|
||||||
assert(end < term->grid->num_rows);
|
assert(end < term->grid->num_rows);
|
||||||
|
|
||||||
if (likely(tll_length(term->grid->sixel_images) == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (start == end)
|
|
||||||
return sixel_delete_at_point(term, start, -1);
|
|
||||||
|
|
||||||
tll_foreach(term->grid->sixel_images, it) {
|
tll_foreach(term->grid->sixel_images, it) {
|
||||||
struct sixel *six = &it->item;
|
struct sixel *six = &it->item;
|
||||||
|
|
||||||
|
|
@ -163,6 +161,15 @@ _sixel_delete_in_range(struct terminal *term, int start, int end)
|
||||||
void
|
void
|
||||||
sixel_delete_in_range(struct terminal *term, int _start, int _end)
|
sixel_delete_in_range(struct terminal *term, int _start, int _end)
|
||||||
{
|
{
|
||||||
|
if (likely(tll_length(term->grid->sixel_images) == 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_start == _end) {
|
||||||
|
/* Avoid expensive wrap calculation */
|
||||||
|
return sixel_delete_at_point(
|
||||||
|
term, (term->grid->offset + _start) & (term->grid->num_rows - 1), -1);
|
||||||
|
}
|
||||||
|
|
||||||
assert(_end >= _start);
|
assert(_end >= _start);
|
||||||
const int lines = _end - _start + 1;
|
const int lines = _end - _start + 1;
|
||||||
const int start = (term->grid->offset + _start) & (term->grid->num_rows - 1);
|
const int start = (term->grid->offset + _start) & (term->grid->num_rows - 1);
|
||||||
|
|
@ -293,9 +300,6 @@ _sixel_split_by_rectangle(
|
||||||
assert(col >= 0);
|
assert(col >= 0);
|
||||||
assert(col + width <= term->grid->num_cols);
|
assert(col + width <= term->grid->num_cols);
|
||||||
|
|
||||||
if (likely(tll_length(term->grid->sixel_images) == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* We don't handle rectangle wrapping around */
|
/* We don't handle rectangle wrapping around */
|
||||||
assert(row + height <= term->grid->num_rows);
|
assert(row + height <= term->grid->num_rows);
|
||||||
|
|
||||||
|
|
@ -334,6 +338,9 @@ static 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))
|
||||||
|
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;
|
||||||
|
|
|
||||||
|
|
@ -1599,6 +1599,8 @@ 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);
|
||||||
|
|
||||||
|
/* TODO: split instead */
|
||||||
sixel_delete_at_row(term, start->row);
|
sixel_delete_at_row(term, start->row);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1612,6 +1614,8 @@ term_erase(struct terminal *term, const struct coord *start, const struct coord
|
||||||
erase_line(term, grid_row(term->grid, r));
|
erase_line(term, grid_row(term->grid, r));
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
/* TODO: split instead */
|
||||||
sixel_delete_in_range(term, start->row, end->row);
|
sixel_delete_in_range(term, start->row, end->row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2381,7 +2385,6 @@ 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_delete_at_cursor(term);
|
|
||||||
sixel_split_at_cursor(term);
|
sixel_split_at_cursor(term);
|
||||||
|
|
||||||
/* *Must* get current cell *after* linewrap+insert */
|
/* *Must* get current cell *after* linewrap+insert */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue