hpjansson / chafa

📺🗿 Terminal graphics for the 21st century.
https://hpjansson.org/chafa/
GNU Lesser General Public License v3.0
2.86k stars 60 forks source link

Add support for Framebuffer graphics #200

Open xplshn opened 5 months ago

xplshn commented 5 months ago

It'd be great if Chafa supported Framebuffer graphics, one can use fbsplash to display images in the framebuffer of the Linux console if the image is in the PPM format, if you need more details about how it works, see https://github.com/kraxel/fbida

Thanks! This would be specially great for all the programs based on Chafa! Like the Kew music player for example!

hpjansson commented 5 months ago

Interesting proposal, but direct rendering is a bit outside our wheelhouse. Currently we just generate terminal escape sequences and leave the rendering to the terminal. You can make this work in the framebuffer using fbterm, which is fully supported - but AFAICT fbterm doesn't support any graphics protocol, only ANSI art.

However, I have long term plans kicking around for an API that leaves all the rendering details to Chafa. This could take the form of a ChafaDisplay and an asynchronous loop to update it. It would require Chafa to own the display and act a lot like ncurses. ChafaDisplay could in theory be anything - a terminal, framebuffer, conpty, SDL surface or what have you. It'll take us some time to get there, though, since more scaffolding would be needed (e.g. move to GObject so we can have a clean API with signals, API for image placement, update deltas, etc).

It'll probably take at least a year before I've gotten that out of the way (this is a part-time project, so I have to prioritize) and have a chance to look at a framebuffer backend. I'll keep this issue open as a reminder.

In the meantime, the simplest way to improve on this situation would be to implement a graphics protocol (e.g. sixels) in fbterm or some other framebuffer terminal. I could add support for that to Chafa quickly.

j4james commented 5 months ago

If you're looking for a framebuffer terminal that can do graphics, I know yaft has some level of sixel support. However, it doesn't appear to be maintained anymore, so if there are bugs, you'll just have to learn to live with them.

hpjansson commented 5 months ago

Thanks, James - I completely forgot about yaft! We do support sixels there. Must've been working ok when I tested it - it will be enabled if TERM=yaft or TERM=yaft-256color.

xplshn commented 5 months ago

@hpjansson I think this library/program being small is its biggest feature, simply using fbsplash if it is available is the best solution to support framebuffer sessions as well as terminal sessions. Anyways, thanks for this awesome piece of software!