mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-01 01:40:13 -05:00
sixel: remove ‘max_col’
The image width *is* the maximum number of columns we’ve seen.
This commit is contained in:
parent
1c9c1aafc8
commit
4b0e9a6bee
2 changed files with 3 additions and 13 deletions
15
sixel.c
15
sixel.c
|
|
@ -39,7 +39,6 @@ sixel_init(struct terminal *term)
|
||||||
term->sixel.pos = (struct coord){0, 0};
|
term->sixel.pos = (struct coord){0, 0};
|
||||||
term->sixel.row_byte_ofs = 0;
|
term->sixel.row_byte_ofs = 0;
|
||||||
term->sixel.color_idx = 0;
|
term->sixel.color_idx = 0;
|
||||||
term->sixel.max_col = 0;
|
|
||||||
term->sixel.param = 0;
|
term->sixel.param = 0;
|
||||||
term->sixel.param_idx = 0;
|
term->sixel.param_idx = 0;
|
||||||
memset(term->sixel.params, 0, sizeof(term->sixel.params));
|
memset(term->sixel.params, 0, sizeof(term->sixel.params));
|
||||||
|
|
@ -830,7 +829,6 @@ sixel_unhook(struct terminal *term)
|
||||||
term->sixel.image.data = NULL;
|
term->sixel.image.data = NULL;
|
||||||
term->sixel.image.width = 0;
|
term->sixel.image.width = 0;
|
||||||
term->sixel.image.height = 0;
|
term->sixel.image.height = 0;
|
||||||
term->sixel.max_col = 0;
|
|
||||||
term->sixel.pos = (struct coord){0, 0};
|
term->sixel.pos = (struct coord){0, 0};
|
||||||
|
|
||||||
free(term->sixel.private_palette);
|
free(term->sixel.private_palette);
|
||||||
|
|
@ -923,12 +921,9 @@ sixel_add(struct terminal *term, uint32_t color, uint8_t sixel)
|
||||||
|
|
||||||
int width = term->sixel.image.width;
|
int width = term->sixel.image.width;
|
||||||
|
|
||||||
if (term->sixel.pos.col >= width) {
|
if (unlikely(term->sixel.pos.col >= width)) {
|
||||||
width = max(
|
width = term->sixel.pos.col + 1;
|
||||||
term->sixel.image.width,
|
if (unlikely(!resize(term, width, term->sixel.image.height)))
|
||||||
max(term->sixel.max_col, term->sixel.pos.col + 1));
|
|
||||||
|
|
||||||
if (!resize(term, width, term->sixel.image.height))
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -971,14 +966,10 @@ decsixel(struct terminal *term, uint8_t c)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '$':
|
case '$':
|
||||||
if (term->sixel.pos.col > term->sixel.max_col)
|
|
||||||
term->sixel.max_col = term->sixel.pos.col;
|
|
||||||
term->sixel.pos.col = 0;
|
term->sixel.pos.col = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '-':
|
case '-':
|
||||||
if (term->sixel.pos.col > term->sixel.max_col)
|
|
||||||
term->sixel.max_col = term->sixel.pos.col;
|
|
||||||
term->sixel.pos.row += 6;
|
term->sixel.pos.row += 6;
|
||||||
term->sixel.pos.col = 0;
|
term->sixel.pos.col = 0;
|
||||||
term->sixel.row_byte_ofs += term->sixel.image.width * 6;
|
term->sixel.row_byte_ofs += term->sixel.image.width * 6;
|
||||||
|
|
|
||||||
|
|
@ -523,7 +523,6 @@ struct terminal {
|
||||||
struct coord pos; /* Current sixel coordinate */
|
struct coord pos; /* Current sixel coordinate */
|
||||||
size_t row_byte_ofs; /* Byte position into image, for current row */
|
size_t row_byte_ofs; /* Byte position into image, for current row */
|
||||||
int color_idx; /* Current palette index */
|
int color_idx; /* Current palette index */
|
||||||
int max_col; /* Largest column index we've seen (aka the image width) */
|
|
||||||
uint32_t *private_palette; /* Private palette, used when private mode 1070 is enabled */
|
uint32_t *private_palette; /* Private palette, used when private mode 1070 is enabled */
|
||||||
uint32_t *shared_palette; /* Shared palette, used when private mode 1070 is disabled */
|
uint32_t *shared_palette; /* Shared palette, used when private mode 1070 is disabled */
|
||||||
uint32_t *palette; /* Points to either private_palette or shared_palette */
|
uint32_t *palette; /* Points to either private_palette or shared_palette */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue