sixel: place cursor on the last row touched by the sixel

Before this patch, we implemented the DEC algorithm strictly, which
places the cursor on the text row touched by the *upper* pixel of the
last sixel.

Now, we place the cursor on the text row touched by the **bottom**
pixel of the last sixel.
This commit is contained in:
Daniel Eklöf 2024-03-02 11:30:52 +01:00
parent d3b348a5b1
commit 28ee19cd8c
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

12
sixel.c
View file

@ -1197,19 +1197,13 @@ sixel_unhook(struct terminal *term)
int row = term->grid->cursor.point.row;
/*
* Position the text cursor based on the **upper**
* Position the text cursor based on the **bottom**
* pixel, of the last sixel.
*
* In most cases, that'll end up being the very last
* row of the sixel (which we're already at, thanks to
* the linefeeds). But for some combinations of font
* and image sizes, the final cursor position is
* higher up.
*/
const int sixel_row_height = 6 * term->sixel.pan;
const int sixel_rows = (image.original.height + sixel_row_height - 1) / sixel_row_height;
const int upper_pixel_last_sixel = (sixel_rows - 1) * sixel_row_height;
const int term_rows = (upper_pixel_last_sixel + term->cell_height - 1) / term->cell_height;
const int bottom_pixel_last_sixel = sixel_rows * sixel_row_height - 1;
const int term_rows = (bottom_pixel_last_sixel + term->cell_height - 1) / term->cell_height;
xassert(term_rows <= image.rows);