hackerb9 / lsix

Like "ls", but for images. Shows thumbnails in terminal using sixel graphics.
GNU General Public License v3.0
4.03k stars 127 forks source link

Support OSC 8 (hyperlinks) to make previews clickable #37

Open christianparpart opened 4 years ago

christianparpart commented 4 years ago

Hi,

I really like your little tool, and I'm surprised that a shell script is sufficient for that (with help of ImageMagick).

I'd like you to consider adding hyperlink (OSC 8) support so the generated previews are clickable. This would be a great addition, what do you think?

hackerb9 commented 4 years ago

Thank you for the kind words.

That sounds like a potentially useful addition iff it can be done in a way that preserves the simplicity of lsix.

One problem is that the thumbnails are generated in blocks and they are not necessarily aligned with character cells. We would need a simple and efficient way to mark the character cells for each image. You wouldn't happen to have written code to do that yet, would you?

Also, I've read the official DEC documentation and Xterm's ctlseqs, but never run across OSC 8 before. Do you have a reference to where it is defined?

christianparpart commented 4 years ago

Have a look here: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda

Mind, the list on that document is not complete anymore, but it contains a very good specification.

Also, I just implemented sixel graphics basic support in my own terminal emulator and have been looking for client apps using that so I can test on it. So I found you, too. And cake up with the above idea.

hackerb9 commented 4 years ago

It's a good idea. But it looks like it will add too much complexity to lsix. I'm hoping to keep that program minimalist so others can easily modify it.

I have another sixel project I'm working on, an image viewer, that is not released yet. Fitting the URLs into it would not be as hard as I aligned the images with the character cells. If you send me e-mail (hackerb9@member.fsf.org), then I can share with you the preliminary code so you can test your terminal emulator.

hackerb9 commented 4 years ago

Have a look here: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda

Mind, the list on that document is not complete anymore, but it contains a very good specification.

Also, I just implemented sixel graphics basic support in my own terminal emulator and have been looking for client apps using that so I can test on it. So I found you, too. And cake up with the above idea.

By the way, can you please send a link to your terminal emulator? I added the OSC 8 URL escape to the thumbnails in the sixel image viewer I mentioned, but I have no idea if it worked or not. The sixel terminal emulators I have tried (xterm & mlterm) don't support OSC 8 and the OSC 8 emulators (all VTE based) don't support sixel. Sounds like your program will fill a niche!

christianparpart commented 4 years ago

By the way, can you please send a link to your terminal emulator? I added the OSC 8 URL escape to the thumbnails in the sixel image viewer I mentioned, but I have no idea if it worked or not. The sixel terminal emulators I have tried (xterm & mlterm) don't support OSC 8 and the OSC 8 emulators (all VTE based) don't support sixel. Sounds like your program will fill a niche!

Hey.

You can find it here: https://github.com/christianparpart/contour/

The sixel support is in the development branch named, wip. Please don't just git pull in the wip branch but git fetch && git reset --hard origin/wip when updating

I tested OSC-8 together with image support and it works in Contour. I will email you, too

WSLUser commented 3 years ago

Here's the implementation from Windows Terminal: https://github.com/microsoft/terminal/pull/7251 (there are follow-up PRs that improve the story of hyperlinks including adding File URIs as a acknowledged scheme (though with some limitations still in place).

hackerb9 commented 3 years ago

Have a look here: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda

Mind, the list on that document is not complete anymore, but it contains a very good specification.

Also, I just implemented sixel graphics basic support in my own terminal emulator and have been looking for client apps using that so I can test on it. So I found you, too. And cake up with the above idea.

And an excellent idea it is! 🥮

I'm sorry I lost track of this for nearly a year. I had meant to clean up my sixel image viewer code so it was presentable before publishing it, but I realized that I should just get it out there.

Here is vv, a very basic sixel image viewer that uses OSC 8.

The hand symbol shows up in Contour when I hover but nothing happens when I left or right click. Does Contour show the URL when hovering over a link? I'm not seeing anything. I'll have to reread the OSC 8 spec.

christianparpart commented 3 years ago

The hand symbol shows up in Contour when I hover but nothing happens when I left or right click.

Use Ctrl modifier with left click. That is also configurable in the input mappings.

Does Contour show the URL when hovering over a link? I'm not seeing anything.

No. But really good idea. Will add that.

hackerb9 commented 3 years ago

Nice. It works now. Is it a known problem that Contour sometimes coredumps on sixels?

christianparpart commented 3 years ago

Nice. It works now. Is it a known problem that Contour sometimes coredumps on sixels?

On sixels? That is new! But resize in alt screen and then leaving alt screen causing a SEGV is known. I am working on that. Maybe you can get me a stack trace of such thing as a new ticket ? :-)

hackerb9 commented 3 years ago

@christianparpart Ticket sent.