Skip to content
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

Does not detect hyperlink support in other terminals #1

Open
nogweii opened this issue Jan 18, 2024 · 3 comments
Open

Does not detect hyperlink support in other terminals #1

nogweii opened this issue Jan 18, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@nogweii
Copy link

nogweii commented Jan 18, 2024

Describe the problem

Alacritty, Kitty, and KDE's Konsole all support the hyperlink escape code. It's not just iTerm & VTE based terminals.

Steps to reproduce the problem

puts TTY::Link("foo", "https://google.com")

Actual behaviour

To print out the hyperlink.

Expected behaviour

Fallback output was printed instead.

Describe your environment

  • OS version: Arch Linux
  • Ruby version: 3.2.2
  • TTY::Link version: 0.1.1
@nogweii nogweii added the bug Something isn't working label Jan 18, 2024
@piotrmurach
Copy link
Owner

Thanks for submitting this issue. 🙏

It's not just iTerm & VTE based terminals.

At the time this gem was created this was the case. These were the first terminals to support hyperlinks. The world has changed since. Alacritty has added support only recently(around 2022).

Therefore, I disagree that this is a 'bug'. More of a feature request. I'm sure you can appreciate that there are more terminals adding hyperlinks support and more terminals appearing all the time. This is in a way an 'impossible' task to create detection that works for every terminal including the ones that don't even exist yet. However, we can certainly try to support the most common ones.

I'd welcome help here. It can be in many forms. Either a PR that implements support for a given terminal. Alternatively, information on how to detect the terminal type from ENV and whether there is a version requirement. For example, use this name from the TERM variable and apply it to any version higher than 3.0 using X_VERSION variable. Ideally, this would be tested by installing a given terminal and verifying that detection works.

Further, we could add a configuration option to the link_to to allow overriding automatic detection. For example, it could take one of always|auto|never:

TTY::Link.link_to("ttytoolkit.org", "https://ttytoolkit.org", hyperlink: :always)

Similarly, provide an environment variable to allow configuration for a tool that uses tty-link:

TTY_LINK_HYPERLINK=never

@piotrmurach piotrmurach added enhancement New feature or request and removed bug Something isn't working labels Jan 20, 2024
@nogweii
Copy link
Author

nogweii commented Jan 21, 2024

The official mechanism would be to query the terminfo database for the capability, using something like this library. I'm not certain what the hyperlink capability is called.

In the mean time, adding an parameter would be a good stop-gap.

@piotrmurach
Copy link
Owner

The official mechanism would be to query the terminfo database for the capability

This sentiment is not universally appreciated. See the comments from the kitty terminal issue in regards to hyperlinks.

termcap/terminfo is an awful solution because it means you have to have the terminfo files on remote servers as well when using SSH. Not to mention that the maintainers of terminfo have gone permanently to sleep.

Further, there are more direct downsides to using terminfo:

  • The ruby-terminfo uses C extensions that no longer compile on modern Ruby. I tried to install it on 3.2. There are no modern alternatives and I won't be investing time in writing my own.
  • The info added to terminfo doesn't seem to contain anything related to hyperlinks support capability as far as I can tell.
  • No every terminal emulator adds entries to terminfo database. For example, very popular hyper terminal doesn't do it.

It feels rather heavy-handed solution for such a small library to employ. I'd rather rely on environment variables and do the best-approximated feature detection possible. I don't want perfect accuracy, if I can detect let's say alacritty terminal and cannot get its version, I'm fine assuming it supports hyperlinks for all versions.

Would you have time to provide help with identifying terminals with hyperlinks support and their env variables?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants