mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-04 07:15:29 -04:00
sixel: place cursor on the last character row touched by the sixel
After emitting a sixel, place the cursor on the character row touched by the last sixel. The last sixel _may_ not be a multiple of 6 pixels, *if* the sixel had an explicit width/height set via raster attributes. This is an intended deviation from the DEC cursor placement algorithm, where the cursor is placed on the character row touched by the last sixel's *upper* pixel. The adjusted algorithm implemented here makes it much easier for applications to handle text-after-sixels, since they can now simply assume a single text newline is required to move the cursor to a character row not touched by the sixel.
This commit is contained in:
parent
5f41eb798b
commit
282c55aa4a
2 changed files with 8 additions and 12 deletions
|
|
@ -109,6 +109,9 @@
|
||||||
determining whether a key combination produces text or not.
|
determining whether a key combination produces text or not.
|
||||||
* CSI-t queries now report pixel values **unscaled**, instead of
|
* CSI-t queries now report pixel values **unscaled**, instead of
|
||||||
**scaled** ([#1643][1643]).
|
**scaled** ([#1643][1643]).
|
||||||
|
* Sixel: text cursor is now placed on the last text row touched by the
|
||||||
|
sixel, instead of the text row touched by the _upper_ pixel of the
|
||||||
|
last sixel ([#chafa-192][chafa-192]).
|
||||||
|
|
||||||
[1526]: https://codeberg.org/dnkl/foot/issues/1526
|
[1526]: https://codeberg.org/dnkl/foot/issues/1526
|
||||||
[1528]: https://codeberg.org/dnkl/foot/issues/1528
|
[1528]: https://codeberg.org/dnkl/foot/issues/1528
|
||||||
|
|
@ -116,6 +119,7 @@
|
||||||
[kitty-6913]: https://github.com/kovidgoyal/kitty/issues/6913
|
[kitty-6913]: https://github.com/kovidgoyal/kitty/issues/6913
|
||||||
[1584]: https://codeberg.org/dnkl/foot/issues/1584
|
[1584]: https://codeberg.org/dnkl/foot/issues/1584
|
||||||
[1643]: https://codeberg.org/dnkl/foot/issues/1643
|
[1643]: https://codeberg.org/dnkl/foot/issues/1643
|
||||||
|
[chafa-192]: https://github.com/hpjansson/chafa/issues/192
|
||||||
|
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
|
||||||
16
sixel.c
16
sixel.c
|
|
@ -1230,19 +1230,11 @@ sixel_unhook(struct terminal *term)
|
||||||
int row = term->grid->cursor.point.row;
|
int row = term->grid->cursor.point.row;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Position the text cursor based on the **upper**
|
* Position the text cursor based on the text row
|
||||||
* pixel, of the last sixel.
|
* touched by 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 term_rows =
|
||||||
const int sixel_rows = (image.original.height + sixel_row_height - 1) / sixel_row_height;
|
(image.original.height + term->cell_height - 1) / term->cell_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;
|
|
||||||
|
|
||||||
xassert(term_rows <= image.rows);
|
xassert(term_rows <= image.rows);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue