benjajaja / ratatui-image

Ratatui widget for rendering image graphics in terminals that support it
https://crates.io/crates/ratatui-image
MIT License
115 stars 16 forks source link

guess_protocol() falls back to Halfblocks on Windows Terminal (Preview) #37

Closed matthias-buttgereit closed 2 weeks ago

matthias-buttgereit commented 2 months ago

Windows Terminal (Preview) supports Sixel as of 1.22 (https://github.com/microsoft/terminal/releases).

When running code inside WSL it does actually display images using Sixel but outside of WSL it falls back to Halfblocks.

Windows Terminal (Preview) without WSL Windows Terminal (Preview) with WSL
Screenshot 2024-08-29 191116 Screenshot 2024-08-29 191146

My guess is that the guess_protocol() function is not testing for Sixel support under Windows. Not sure if there is a way to do it yet but would be great if it could be added.

j4james commented 2 months ago

FYI, there is a bug in the latest Windows Terminal preview that affects VT reports in applications that don't enable VT input mode (see https://github.com/microsoft/terminal/issues/17813). It's possible that might be why it's not working outside WSL. VT input mode is set automatically in WSL, but that isn't the case for regular Windows console applications, unless they set the mode themselves, and I don't think the crossterm library does that.

matthias-buttgereit commented 2 months ago

Seems like Sixel is working in Windows Terminal (Preview) even without WSL when you manually cycle through the protocols (like in the demo example).

Screenshot 2024-09-10 175542

Just showing some weird behaviour when resizing (not fully clearing the area) but that might be a problem on the Windows Terminal part.

benjajaja commented 2 weeks ago

@matthias-buttgereit the weird behaviour is most likely an incorrect font-size, which should now be guessed correctly on WSL on master.

benjajaja commented 2 weeks ago

@matthias-buttgereit this should work on master now.