-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sixel preview are not interpreted, but displayed as plain text, #675
Comments
@adrienbarlier Short answer, sixel images are not working in lf. Long answer, we interpret escape codes ourselves for the previews instead of pushing them directly to the terminal. Currently we only have standard color escape codes and other things are ignored. At some point, I thought about pushing unknown escape codes directly to the terminal so things like sixels might work. However, sixel images were not working properly with tcell when I tried it on xterm. Things might be different on foot terminal. There's also some complication for such escape codes as previews are stored as arrays of lines and escape codes may not obey that model. I have also seen some unmerged sixel patches on tcell side which may be of interest. |
Thank you for this quite clear answer @gokcehan , "we interpret escape codes ourselves for the previews instead of pushing them directly to the terminal" I am curious to understand this behavior more deeply, in which section of your work can i see the code responsible of that please ? |
@adrienbarlier You can take a look at |
+1 on this, still very interested. |
Can i haz some sixels? Please! ç.ç |
The sixel library for tcell seems to be abandoned, so I think the only we can do sixel rendering is directly writing to stdout/stderr, for reference, photon by ghost08 (the only tcell based project I can find that uses sixel) writes directly to stdout. So I wrote some code to test if it would work on lf, and it did. From what I can tell, it doesn't interfere with the rest of the application. Screenshot and previewer script on the right, tested on foot and konsole in wayland. Here's a snippet that I added to if r == gEscapeCode && i+1 < len(s) && s[i+1] == 'P' {
// idk how to match the closing pattern `ESC \` so I'm not using j below
j := strings.IndexAny(s[i+1:len(s)], "\x1b")
if j == -1 {
continue
}
j ++
// ANSI sequence that moves cursor to where we want
moveCursor := fmt.Sprintf("\033[%d;%dH", win.y+y, win.x+x)
os.Stdout.WriteString(moveCursor)
os.Stdout.WriteString(s)
i += j
continue
} Now we just need to somehow clean up the sixel image afterwards, which should be doable. For this we need to calculate the area being drawn on (the photon project I mentioned might leave some clue), or we could expose some kind of command to let the user clean up sections of the pane manually. or worst case scenario redraw the whole pane. I'll take a look and hopefully it'll work out Possibly helpful: |
I tried with sptv and lfimg to get this to work using I think that showing images with sixel protocol and some kind of persistent cache for the converted image without the need to convert things everytime would make this veeery fast... My pc is too slow plz help and thanks for the contribution btw |
To clarify, I made some changes to lf itself for it to work, I'll upload the code later, it's getting late...
lf already caches the output of your preview panel and I can confirm that it works as intended with sixel. Also, we would probably need to increase the bandwidth on the previewer-reader, I keep getting this error when I use a larger size of sixel image or a more colorful image. Not sure if it's possible though.
|
"I'll upload the code later, it's getting late..." take your time xD |
I use this config |
Got it, same here. I am so anxious to see this implemented xD |
Same here, god I love lf ! |
Hi there, is there any chance of implementing sixel in near future? Maybe merging @horriblename 's fork? I love |
for reasons mentioned in the PR, the fork won't be merged |
I feared that would be the case, kinda hoped it changed since then. |
@horriblename If you like, you can add your fork or patch to https://github.com/gokcehan/lf/wiki/Patches-and-community-forks. |
I know this is probably not the right place, but @horriblename the fork is also rather out-of-date, do you still maintain it and do you plan to update it? |
yeah I still intend to maintain it, but I just update occasionally and forgot to do it lately, thanks for reminding me lol @ilyagr thanks for mentioning the fork section, I'll add it soon |
Regarding @horriblename fork, I see it was declined because of the maintaining could be difficult. Since I see most of the code are new functions and not much changes, would it be possible to have it as a plugging/optional package or conditionally compiled? That would make it easy to switch off/remove it is makes any problems. |
@DusanLesan I have taken another look at the PR and unfortunately I still think this is a non-trivial patch. Specifically, it seems to integrate heavily into |
@gokcehan Ok. I do not feel strongly about sixel graphics format support as I do not actually need it myself. It just looks like important feature to users wanting to switch to wayland. It looked trivial to me since changes in nav.go looked like mostly additions that might be circumvented by few if statements or compilation options. But I do not know go and whatever you guys decide, it is ok by me |
I'll try to smooth out the code a bit and make a PR soon |
No longer an issue, Sixel previews are now officially supported as of dd82949 |
Running e0abb29, previews don't work. |
can you elaborate? I'm guessing you didn't add |
That was it 🤦♂️ thanks |
Hi,
Is there anything in particular to do in order to let lf display sixel preview ?
WM: Sway
Terminal: Foot
displaying preview with chafa, options in pictures
The text was updated successfully, but these errors were encountered: