-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Issue description
On tmux built today 2023-11-28 from master (bdf8e61) with sh autogen.sh && ./configure --enable-sixel --enable-systemd
, sixels are correctly displayed. That's wonderful!
However, when using tmux integrated scrollback, empty (blank) placeholders of the sixels are shown: this creates a confusing user experience for the scrollback, where images can vanish and then reappear when going back to the bottom of the scrollback.
Suggested fix
Use derasterize to convert the sixels into an appropriate ANSI+Unicode text equivalent as done in sixel-tmux: it's illustrated at the "Let's scroll back" step of the first example, after using gnuplot.
Drawback: an ANSI+Unicode text equivalent stored inside the placeholders of the scrollback history would not be "pixel perfect", so it might be offered as a ./configure flag like --sixel-scrollback-derasterize.
Discussion of the alternatives
Keeping all the sixels image in memory or in a file may be a worse solution, especially for long-running sessions. Still, it could be another configure option like --sixel-scrollback-keep for uses who don't care about keeping a low memory usage, or simply prefer a pixel-perfect solutions.
Even if imperfect, a simple textual representation using little storage would be sufficient to provide a reminder of what the images looked like in the context they were displayed, and where they were: when scrolling back in the example above, the derasterized version are sufficient to remember the snake and vimperator happened before the gnuplot.
Advantages of the proposed approach
The derasterize could also offer compatibility with terminals that don't support sixel yet: instead of showing empty/blank placeholders, tmux could be used as 'magic goggles allowing to see sixels': not perfectly, but at least enough to experience some of the dense information they can carry.
This is something very helpful when doing gnuplot over ssh to quickly diagnose issues on remote systems and fix them live: in this case, the remove system would only need to have tmux with this feature enabled, and could be ssh'ed with any terminal while still allowing the exact same gnuplot command to show the information.
Choice of defaults
I am extremely surprised and happy to see mainline tmux now support sixels, and that it will be in the next 3.4 main version. It's a wonderful step forward!
Yet it would be even better if 3.4 could support this "downgraded sixel experience" mode when sixels are not available or during the scrollback.
Therefore, I would even suggest to have "--sixel-scrollback-derasterize" as a default option: if for any reason the linux distributions packaging tmux do no use "--enable-sixel" by default, tmux would then at least show something were sixels should be, instead of blank placeholders.
Suggested implementation
The code to implement the suggested feature works in sixel-tmux. Please take a look at it, change it however you want it, and feel free to copy anything from the derasterize scrollback feature of sixel-tmux into mainline tmux, with or without attribution to me. I don't care, I only care about sixels and the users.
If you prefer to implement directly from derasterize, its license is as free/open/compatible as can be. basicidea.c is even in the public domain.
Still, should the licenses terms cause any issues, please let me know and I'll be happy to change them to anything you want (and I'd ask @jart if it includes her code).
Required information
Please provide the following information:
- tmux version (
tmux -V
): tmux next-3.4 - Platform (
uname -sp
): Linux unknown (kernel 6.2.2, with arch freshly updated) - $TERM inside and outside of tmux (
echo $TERM
): xterm-256color - Logs from tmux (
tmux kill-server; tmux -vv new
) (available upon request, but not needed)