bakkeby / st-flexipatch

An st build with preprocessor directives to decide which patches to include during build time
MIT License
347 stars 107 forks source link

add sixel tmux terminfo entry #112

Closed step- closed 6 months ago

veltza commented 6 months ago

This works, but st-sx uses the following VT identification in config.def.h/config.h for tmux:

/* identification sequence returned in DA and DECID */
char *vtiden = "\033[?62;4c"; /* VT200 family (62) with sixel (4) */

I think this is a better solution for st-flexipatch as well because st-flexipatch uses a different vtiden when sixels are not used whereas the terminfo entry is a static solution. But I'll let Bakkeby decide if he wants to merge this anyway.

bakkeby commented 6 months ago

Checked this and yes it looks to work both ways. If it works with the config change alone then perhaps we should just use that.

step- commented 6 months ago

If it works with the config change alone then perhaps we should just use that.

Sorry, I can't confirm that it works without terminfo entry. With "Sxl" added to terminfo my tmux shows the image. Without it tmux shows a text placeholder labelled "SIXEL IMAGE (49x15)" but no graphics.

To run my test: apply this PR, then

# confirm that sixel works with tmux terminfo entry
tic -sx st.info
cp /usr/share/terminfo/s/st-256color ~/.terminfo/s/st-256color #if you have a user's terminfo
infocmp -a st-256color | grep -B 3 Sxl  # should print matched Sxl
grep terminal-features ~/.tmux.conf # should not print lines adding sixel feature
cat /tmp/image.sixel # should display graphics

Edit st.info and remove this PR, then

# confirm that sixel doesn't work without tmux terminfo entry
tic -sx st.info
cp /usr/share/terminfo/s/st-256color ~/.terminfo/s/st-256color #if you have a user's terminfo
infocmp -a st-256color | grep -B 3 Sxl  # should not output anything
killall tmux # important: reset tmux otherwise prior terminfo will still apply
grep terminal-features ~/.tmux.conf # should not print lines adding sixel feature
st -e env TERM=st-256color tmux & # start first tmux session
# in tmux session
cat /tmp/image.sixel # prints text placeholder and no graphics for me
bakkeby commented 6 months ago

The way you would confirm this is to remove the Sxl from the terminfo, then use the configuration that velza referred to and see if sixel images show.

I tried this yesterday and it worked both ways for me.

Tbh it confused me a bit at first how the image does not display in tmux if it is too large and how the image disappears on resize. They say of course that sixel support is very limited.

veltza commented 6 months ago

Sixels do not work properly inside tmux in the current development branch. That's a different problem than this. It prevents images from appearing on the screen. I'm on it and will send a PR soon.

step- commented 6 months ago

The way you would confirm this is to remove the Sxl from the terminfo, then use the configuration that velza referred to and see if sixel images show.

Ah, right. Just tried again with the vtiden from https://github.com/bakkeby/st-flexipatch/pull/112#issuecomment-1973140906 and this time it worked. So this PR is not needed, and I'm going to close it. Feel free to reopen.

Tbh it confused me a bit at first how the image does not display in tmux if it is too large and how the image disappears on resize. They say of course that sixel support is very limited.

Yes, it's still rough but moving in the right direction. I read in tmux closed issues that the intention is to improve the current level of support for sixel before adding more terminal image features. As far as image size, I think the current limit is set to 1 MB, and for larger values one needs to recompile tmux.

Closing PR