From 96405c2ca97aed6bb126a5a39d81b97100743b78 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 2 Oct 2020 20:55:10 +0200 Subject: sixel: overwrite-by-rectangle expects ‘width’ to not exceed screen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a crash when the emitted sixel extends beyond the right margin. The crash only happens when there are other sixel images already emitted. Fixes part of #151 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index f919972d..87e6440f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,8 @@ * Crash when `foot.ini` contains an invalid section name (https://codeberg.org/dnkl/foot/issues/159). * Background opacity when in _reverse video_ mode. +* Crash when writing a sixel image that extends outside the terminal's + right margin (https://codeberg.org/dnkl/foot/issues/151). ### Security -- cgit v1.3 From bc75f4744c02b60d896f445f6c2278416aa33ed2 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 2 Oct 2020 20:56:44 +0200 Subject: sixel: fix sheared image when image crosses scrollback wrap-around MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a sixel image crosses the scrollback wrap-around, it is split up into (at least) two pieces. We use cursor->point.col for all pieces’ x-coordinate. This caused the final image to appear sheared, since we do a carriage-return (after a number of linefeeds) after each piece - this causes the cursor’s position to be reset to the left margin. The solution is simple; remember the cursor’s initial x-coordinate, and use that to position all image pieces. Closes #151. --- CHANGELOG.md | 3 +++ sixel.c | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 87e6440f..668b2c01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,9 @@ * Background opacity when in _reverse video_ mode. * Crash when writing a sixel image that extends outside the terminal's right margin (https://codeberg.org/dnkl/foot/issues/151). +* Sixel image at non-zero column positions getting sheared at + seemingly random occasions + (https://codeberg.org/dnkl/foot/issues/151). ### Security diff --git a/sixel.c b/sixel.c index 0600a434..747e3d00 100644 --- a/sixel.c +++ b/sixel.c @@ -448,6 +448,16 @@ sixel_unhook(struct terminal *term) int pixel_rows_left = term->sixel.image.height; const int stride = term->sixel.image.width * sizeof(uint32_t); + /* + * Need to 'remember' current cursor column. + * + * If we split up the sixel (to avoid scrollback wrap-around), we + * will emit a carriage-return (after several linefeeds), which + * will reset the cursor column to 0. If we use _that_ column for + * the subsequent image parts, the image will look sheared. + */ + const int start_col = term->grid->cursor.point.col; + /* We do not allow sixels to cross the scrollback wrap-around, as * this makes intersection calculations much more complicated */ while (pixel_rows_left > 0) { @@ -478,7 +488,7 @@ sixel_unhook(struct terminal *term) .height = height, .rows = (height + term->cell_height - 1) / term->cell_height, .cols = (width + term->cell_width - 1) / term->cell_width, - .pos = (struct coord){cursor->col, cur_row}, + .pos = (struct coord){start_col, cur_row}, }; sixel_overwrite_by_rectangle( -- cgit v1.3 From 606e901ceab75f3624f3fc1dde8307a647947607 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 7 Oct 2020 18:46:11 +0200 Subject: changelog: we’ve fixed several sixel+reflow related bugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 668b2c01..1df82ec3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,8 @@ * Sixel image at non-zero column positions getting sheared at seemingly random occasions (https://codeberg.org/dnkl/foot/issues/151). +* Crash after either resizing a window or changing the font size if + there were sixels present in the scrollback while doing so. ### Security -- cgit v1.3