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

Support OSC 8 hyperlinks in messages #1368

Open
theViz343 opened this issue Mar 31, 2023 · 5 comments
Open

Support OSC 8 hyperlinks in messages #1368

theViz343 opened this issue Mar 31, 2023 · 5 comments

Comments

@theViz343
Copy link
Member

theViz343 commented Mar 31, 2023

With the introduction of the OSC 8 escape sequence, hyperlinks with custom text become possible to display on terminals. It would be useful to implement this in Zulip terminal but urwid does not support it out of the box currently (there is an issue filed regarding it).

An immediate usecase would be in message information popups. Implementing hyperlinks in message information popups will help display clickable long links which span over multiple lines - these links are currently not clickable. Since there is no official urwid support for OSC 8 yet, a possible solution would be to surround the entire text link with the escape sequence.

Whenever urwid does support OSC 8, it might be worthwhile to investigate the use of hyperlinks in the normal message body.

CZO discussion

@AnonymouX47
Copy link

AnonymouX47 commented May 17, 2023

Hello!

I recently developed some urwid widgets that might be useful here. See this Hyperlink widget.

Feature suggestions and bug reports are gladly welcome.

Thanks.

@AnonymouX47
Copy link

AnonymouX47 commented May 17, 2023

From the CZO discussion:

One of the challenges is that terminals (emulators) have their own set of supported features, and knowing which set a given one supports can be difficult to detect, like those lists indicate - and that can depend on their internal configuration too.

. . .

Yeah, detecting if the user's terminal is supported is a challenge and currently I'm not aware if there is any particularly good way to do so. An alternative solution may be to allow the user to add OSC 8 hyperlink feature as a launch option (command line/zuliprc).


One good thing about the OSC 8 sequence is that it's non harmful to terminal emulators that lack the feature, provided they recognize and parse OSC sequences which almost any terminal emulator worthy of being used today does (which includes every terminal emulator and multiplexer I can think of right now).
A terminal emulator that doesn't implement the feature should simply eat up the escape sequences without doing anything (since the DEC Private Mode should be unrecognized) and write out the plain text in-between like nothing ever happened.

Detecting support actually isn't difficult (though involves querying the terminal 1), though in most use cases it's unnecessary because of the reason mentioned above. So, I don't think making it optional is necessary. You may simply keep the current numbered list alongside for the sake of non-supporting terminal emulators.

Footnotes

  1. Introduces it's own caveats which aren't a problem as long as the query is performed before starting the urwid screen or expecting any user input

@neiljp
Copy link
Collaborator

neiljp commented May 19, 2023

@AnonymouX47 Thanks for the details - your library looks interesting 👍

The other component to your library looks like it could handle rendering into urwid format from various others - it's a little off-topic on this issue, but I'd be interested to discuss further if you dropped into our stream on chat.zulip.org :)

@AnonymouX47
Copy link

Thanks for the compliments.

The other component to your library looks like it could handle rendering into urwid format from various others

If you mean parse_text(), yes.

  • it's a little off-topic on this issue, but I'd be interested to discuss further if you dropped into our stream on chat.zulip.org :)

I don't mind... but I don't know what's next after signing up 🥲

@neiljp
Copy link
Collaborator

neiljp commented May 21, 2023

@AnonymouX47 If you've already signed up:

  • If you use the web, the 'CZO discussion' link will take you to the previous conversation
  • If you use zulip-terminal, one route is to move the cursor to the #zulip-terminal stream (left panel0, switch the left panel to topics using t and use q to search for the topic Hyperlink support using OSC-8 escape sequences, using enter to switch to that topic.
  • mobile also works :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants