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

Add support for OSC hyperlinks #84

Closed
bitspittle opened this issue Jun 2, 2022 · 4 comments
Closed

Add support for OSC hyperlinks #84

bitspittle opened this issue Jun 2, 2022 · 4 comments
Labels
enhancement New feature / functionality maybe Not sure if we're going to do this issue or not

Comments

@bitspittle
Copy link
Contributor

bitspittle commented Jun 2, 2022

See also: https://en.wikipedia.org/wiki/ANSI_escape_code#OSC_(Operating_System_Command)_sequences
See also: #12 (comment)
See also: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda

I'd really like to do this assuming support for it is standard across all of the main terminals.

@cbcmg FYI

@bitspittle bitspittle added enhancement New feature / functionality maybe Not sure if we're going to do this issue or not labels Jun 2, 2022
@bitspittle
Copy link
Contributor Author

bitspittle commented Jun 5, 2022

I'm having trouble getting this to work.

OSC escape sequences are not as well documented (that I could find) as CSI escape sequences.

A CSI sequence is always a starting character, some optional parameters, and a final terminator code. But as far as I can tell, OSC8 hyperlinks are whatever they want to be? The hyperlink code for example splits up multiple arguments by ;; and also the OSC Esc Sequence character (ESC ]) shows up twice in the string, and then the thing still ultimately has to be terminated by a string terminator or bell character which also shows up in the middle of the sequence????

printf '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\'
         ^ OSC sequence indicator |                |      |
           ^ What is this 8?      |                |      |
                                  ^ String Terminator??   |
                                                   ^ OSC sequence indicator again?
                                                          ^ String Terminator again?

Anyway when I test things out on my own OS, I'm not getting any hyperlink to show up, I'm just getting raw text that doesn't link. This should be the Gnome terminal so it should be supported, but it doesn't seem to work. Same when I try with Konsole. No luck.

It could be I'm doing something wrong OR it could be that my terminal either doesn't support the feature or intentionally disables it?

@cbcmg
Copy link

cbcmg commented Jun 5, 2022

@cbcmg
Copy link

cbcmg commented Jun 5, 2022

2022-06-05 16 16 26

@bitspittle
Copy link
Contributor Author

Yeah, that's exactly what I did in my own terminal with no luck

osc-hyperlink-fail.mp4

BTW, you might be able to do this yourself. I can't promise that it will work, or if it does, that I won't break it in the future, but just for now try putting the following command in a textLine method:

val ESC = Ansi.CtrlChars.ESC
section {
   textLine("${ESC}]8;;http://example.com${ESC}\\This is a link${ESC}]8;;${ESC}\\)
}

The value of Ansi.CtrlChars.ESC is '\u001B'. It's possible the \\ parts above in my code should be changed to a BEL or ST character. BEL would be '\u0007', I'm not sure what ST would be.

cbcmg pushed a commit to cbcmg/kotter that referenced this issue Jun 21, 2022
…simple implementation in VirtualTerminal, and use in 'input' example. Fixes varabyte#84.
bitspittle added a commit that referenced this issue Oct 21, 2022
bitspittle added a commit that referenced this issue Oct 21, 2022
bitspittle added a commit that referenced this issue Oct 21, 2022
bitspittle added a commit that referenced this issue Oct 21, 2022
bitspittle added a commit that referenced this issue Oct 21, 2022
bitspittle added a commit that referenced this issue Oct 21, 2022
bitspittle added a commit that referenced this issue Oct 21, 2022
bitspittle added a commit that referenced this issue Oct 21, 2022
bitspittle added a commit that referenced this issue Oct 21, 2022
bitspittle added a commit that referenced this issue Oct 21, 2022
bitspittle added a commit that referenced this issue Oct 21, 2022
bitspittle added a commit that referenced this issue Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature / functionality maybe Not sure if we're going to do this issue or not
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants