kotter
kotter copied to clipboard
Add support for OSC hyperlinks
See also: https://en.wikipedia.org/wiki/ANSI_escape_code#OSC_(Operating_System_Command)_sequences See also: https://github.com/varabyte/kotter/issues/12#issuecomment-1144444459 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
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?
This might help: https://iterm2.com/documentation-escape-codes.html

Yeah, that's exactly what I did in my own terminal with no luck
https://user-images.githubusercontent.com/43705986/172072885-8efd9f90-72bf-42cc-9c35-0eea0a1de8c9.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.