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

Fix sixel issues and add a clearing sequence #99

Closed veltza closed 1 year ago

veltza commented 1 year ago

This patch fixes the following sixel issues:

The patch also adds a control sequence for removing sixels:

Because the sixels are implemented as overlay images, they cannot be removed by clearing the underlaying cells. Therefore, we need a control sequence to remove them. I opted to choose ESC[6J as the control sequence because it is not used and the number refers to sixels. So when the lf file manager supports sixels [1], you can use the following minimal scripts to preview images in lf:

previewer:

#!/bin/sh
case "$(readlink -f "$1")" in
    *.bmp|*.gif|*.jpg|*.jpeg|*.png|*.webp|*.six|*.svg|*.xpm)
        chafa -s "$(($2-3))x$3" -f sixels "$1"
        exit 1 ;;
    *)
        bat "$1" ;;
esac

cleaner:

#!/bin/sh
printf "\033[6J" >/dev/tty

[1] https://github.com/gokcehan/lf/pull/1211

bakkeby commented 1 year ago

This looks very good, thank you.