chafa icon indicating copy to clipboard operation
chafa copied to clipboard

xterm sixel support not detected automatically

Open ploum opened this issue 1 year ago • 5 comments

using xterm 384 with xterm -ti vt340

happening: chafa picture.jpg return pictures in symbols. chafa -f sixels picture.jpg returns pictures in sixels (perfect quality)

expected: with "-f sixels", chafa should recognize sixels support and use sixels by default

ploum avatar Feb 08 '24 14:02 ploum

Oops, realized afterward that this was with chafa 1.12. Will test with 1.14 later.

ploum avatar Feb 08 '24 14:02 ploum

I think the situation is the same in 1.14. XTerm used to default to having sixel support turned off - you had to enable VT340 support in order to get it, and I couldn't find a way to passively detect when this was the case. It looks like newer XTerm has it turned on. Do you know in which version this was changed, and how old it is?

hpjansson avatar Feb 08 '24 19:02 hpjansson

On 24/02/08 11:17, Hans Petter Jansson wrote:

I think the situation is the same in 1.14. XTerm used to default to having sixel support turned off - you had to enable VT340 support in order to get it, and I couldn't find a way to passively detect when this was the case. It looks like newer XTerm has it turned on. Do you know in which version this was changed, and how old it is?

I had no idea it was turned on by default.

But there’s a very interesting detection mechanism in the lsix project, which seems to check for a reply code of "4" to the vt220 escape sequence (no, I don’t understand how it works)

# IS TERMINAL SIXEL CAPABLE?		# Send Device Attributes
IFS=";?c" read -a REPLY -s -t 1 -d "c" -p $'\e[c' >&2
for code in "${REPLY[@]}"; do
if [[ $code == "4" ]]; then
     hassixel=yup
     break
fi
done

# YAFT is vt102 compatible, cannot respond to vt220 escape sequence.
if [[ "$TERM" == yaft* ]]; then hassixel=yeah; fi

Please note that this only works with bash, not in zsh (which may use the POSIX read version without all those options).

ploum avatar Feb 08 '24 21:02 ploum

Looks like I was wrong about XTerm enabling support by default. xterm -ti vt340 seems to be required still on xterm-389. lsix is actively probing the terminal, which we're not yet doing (and which when implemented may still not work in all situations, like when we can't access the controlling terminal).

So the action item here is to implement active probing. I put some of the scaffolding in place in Chafa 1.14, so it may not be that far away.

hpjansson avatar Feb 08 '24 22:02 hpjansson

@hpjansson FYI, you can enable the graphics protocols in XTerm without "downgrading" to VT340 by setting the decGraphicsID resource. That's been an option since patch 357 if the logs are accurate.

j4james avatar Mar 09 '24 20:03 j4james