1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-26 02:46:13 -04:00

[sixel] Allow to scroll sixels horizontally.

It does not work. I don't get it.
This commit is contained in:
Witold Filipczyk 2023-05-22 20:32:57 +02:00
parent 3fee0b4f6a
commit 549034322f
3 changed files with 16 additions and 6 deletions

View File

@ -859,7 +859,7 @@ end:
}
struct image *
copy_frame(struct image *src, int box_width, int box_height, int cell_width, int cell_height, int dy)
copy_frame(struct image *src, int box_width, int box_height, int cell_width, int cell_height, int dx, int dy)
{
sixel_decoder_t *decoder = NULL;
sixel_encoder_t *encoder = NULL;
@ -869,6 +869,7 @@ copy_frame(struct image *src, int box_width, int box_height, int cell_width, int
int ncolors;
int width;
int height;
int x;
int y;
struct image *dest = mem_calloc(1, sizeof(*dest));
SIXELSTATUS status;
@ -924,8 +925,9 @@ copy_frame(struct image *src, int box_width, int box_height, int cell_width, int
if (SIXEL_FAILED(status)) {
goto end;
}
encoder->clipx = 0;
x = src->x - dx;
y = src->y - dy;
encoder->clipx = x >= 0 ? 0 : (-x * cell_width);
encoder->clipy = y >= 0 ? 0 : (-y * cell_height);
encoder->clipwidth = box_width * cell_width;
encoder->clipheight = box_height * cell_height;
@ -940,7 +942,7 @@ copy_frame(struct image *src, int box_width, int box_height, int cell_width, int
if (SIXEL_FAILED(status)) {
goto end;
}
dest->x = src->x;
dest->x = x < 0 ? 0 : x;
dest->y = y < 0 ? 1 : y;
dest->width = src->width;
dest->height = src->height;

View File

@ -30,7 +30,7 @@ void try_to_draw_images(struct terminal *term);
/* return height of image in terminal rows */
int add_image_to_document(struct document *doc, struct string *pixels, int lineno);
struct image *copy_frame(struct image *src, int box_width, int box_height, int cell_width, int cell_height, int dy);
struct image *copy_frame(struct image *src, int box_width, int box_height, int cell_width, int cell_height, int dx, int dy);
#endif

View File

@ -465,7 +465,7 @@ draw_doc(struct session *ses, struct document_view *doc_view, int active)
delete_image((struct image *)term->images.next);
}
if (list_empty(term->images)) {
if (1) {
struct image *im;
foreach (im, doc_view->document->images) {
@ -477,7 +477,15 @@ draw_doc(struct session *ses, struct document_view *doc_view, int active)
continue;
}
struct image *im_copy = copy_frame(im, box->width, box->height, term->cell_width, term->cell_height, vs->y);
if (im->x >= vs->x + box->width) {
continue;
}
if (im->x + ((im->width + term->cell_width - 1) / term->cell_width) < vs->x) {
continue;
}
struct image *im_copy = copy_frame(im, box->width, box->height, term->cell_width, term->cell_height, vs->x, vs->y);
if (im_copy) {
add_to_list(term->images, im_copy);