Image size issues
Still some problems Converting and resizing images to cellsize
Old way worked well in WT but after adding height and refactor to try and support vscode and wezterm it seems slightly off on some images.
src/Sixel/Terminal/SizeHelper.cs src/Sixel/Terminal/OldSize.cs src/Sixel/Terminal/Resizer.cs
Do the different Terminals round differently?
Try and find a better and simpler way to do this
Do the different Terminals round differently?
If this is a question regarding the position of the cursor after an image has been output, then yes, they all behave differently.
Do the different Terminals round differently?
If this is a question regarding the position of the cursor after an image has been output, then yes, they all behave differently.
Thanks for the reply! Was hoping you would know 😀
That sounds like fun..
Yes its for cursor position after image.
When im doing gif "animation" im basically just moving the cursor back the image height and replacing the old image.
This worked fine in WT but was horribly broken in vscode and wezterm (and probably many other Terminals). Either it just walked up the buffer or down messing up the animation
I thought it was just the size being slightly off or the terminal rounding the size differently.
Implementation: https://github.com/trackd/Sixel/blob/main/src/Sixel/Protocols/gif.cs#L102-L177
Note: im starting the render in the powershell format engine, it adds some empty lines after output which i try and remove.
Is there a better way to figure out "rendered" size?
Maybe the best approach would be to snapshot cursor position before and after a frame and use that. But that wouldnt work when it needs to scroll as the position is absolute not relative?
Btw: love your work on WT 👍
Is there a better way to figure out "rendered" size?
I don't think there's a practical way to do that. There are just too many terminals with too many edges cases that behave differently.
Maybe the best approach would be to snapshot cursor position before and after a frame and use that.
Yeah. That is what I would recommend. To deal with the scrolling issue, I would start by outputting a bunch of newline characters to make space for the image, and then move back up again to return to the initial starting point.
For example, if you're expecting the image to occupy 10 rows, you output 10 linefeeds (allowing for one extra row below the image), followed by CUU 10 to return to the starting point. You can then save the position with DECSC, output the image, and restore the position with DECRC. If you want the cursor below the image when you're done, just move it down with CUD 10.
At least that's the theory. I haven't actually tested to see how well that would work, but it at least seems like a viable approach.
Also remember when calculating how many rows the image will occupy, you need to round up to a multiple of 6 first. For example, an image that's 20px high on a terminal with a 20px cell height, will actually occupy 2 rows, because the effective height is 24px. So you need 2 linefeeds to make space for those 2 rows plus an extra row below the image.