Add helpers to scroll image up and a flag to copy the colours.

This commit is contained in:
Nicholas Marriott
2019-12-05 08:32:25 +00:00
parent 49f2f0a8f1
commit 86c5098a88
3 changed files with 52 additions and 5 deletions

36
image.c
View File

@ -37,13 +37,15 @@ image_free(struct image *im)
free(im);
}
void
int
image_free_all(struct screen *s)
{
struct image *im, *im1;
int redraw = !TAILQ_EMPTY(&s->images);
TAILQ_FOREACH_SAFE(im, &s->images, entry, im1)
image_free(im);
return (redraw);
}
void
@ -97,3 +99,35 @@ image_check_area(struct screen *s, u_int px, u_int py, u_int nx, u_int ny)
}
return (redraw);
}
int
image_scroll_up(struct screen *s, u_int lines)
{
struct image *im, *im1;
int redraw = 0;
u_int sx, sy;
struct sixel_image *new;
TAILQ_FOREACH_SAFE(im, &s->images, entry, im1) {
if (im->py >= lines) {
im->py -= lines;
redraw = 1;
continue;
}
if (im->py + im->sy < lines) {
image_free(im);
redraw = 1;
continue;
}
sx = im->sx;
sy = (im->py + im->sy) - lines;
new = sixel_scale(im->data, 0, 0, 0, im->sy - sy, sx, sy, 1);
sixel_free(im->data);
im->data = new;
im->py = 0;
redraw = 1;
}
return (redraw);
}