From 28ee19cd8c77f3b49b10e72c32afa42cd5578139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 2 Mar 2024 11:30:52 +0100 Subject: [PATCH] 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. --- sixel.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/sixel.c b/sixel.c index c046145f..38a4a09f 100644 --- a/sixel.c +++ b/sixel.c @@ -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);