On Thu, Oct 10, 2019 at 01:06:13PM -0400, David Malcolm wrote: > https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda > describes an emerging standard for embedding URLs in escape sequences > for marking up text output. This is supported e.g. by recent releases > of GNOME Terminal.
Unfortunately, as reported by several people, the OSC 8 ;; URL ST Text OSC 8 ;; ST sequence renders badly on recentish konsole5 terminal emulator, which is something a lot of people use. While the above page suggests the use of ST rather than BEL, in practice that at least currently does better job. Tested with echo -e '\e]8;;http://example.com\aThis is a link\e]8;;\a\n\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n' on various terminals: gnome-terminal-3.30.2 both lines the same, URLs work konsole5-18.12.3 the first line normal text, the second one wrapped in between \s, i.e. \This is a link\ , URLs don't work xterm-334 both lines the same, normal text, URLs don't work rxvt-2.7.10 ditto xterm-314 ditto konsole5-15.12.1 ditto linux kernel 5.0.13 console ditto linux kernel 4.4.14 console ditto gnome-terminal-3.16.2 prints garbage around and both the URL and the text are visible, but the line with ST has more garbage than line with BEL BEL instead of ST is also what ls -l --hyperlink prints. Ok for trunk? 2019-12-07 Jakub Jelinek <ja...@redhat.com> * pretty-print.c (pp_begin_url, pp_end_url, test_urls): Use BEL instead of ST sequence to terminate OSC 8 strings. --- gcc/pretty-print.c.jj 2019-10-11 09:29:15.103953133 +0200 +++ gcc/pretty-print.c 2019-12-07 00:17:00.860500837 +0100 @@ -2043,7 +2043,10 @@ identifier_to_locale (const char *ident) > > OSC 8 ; ; ST > - > OSC (operating system command) is typically ESC ]. */ + > OSC (operating system command) is typically ESC ]. + + Use BEL instead of ST, as that is currently rendered better in some + terminal emulators that don't support OSC 8, like konsole5. */ /* If URL-printing is enabled, write an "open URL" escape sequence to PP for the given URL. */ @@ -2052,7 +2055,7 @@ void pp_begin_url (pretty_printer *pp, const char *url) { if (pp->show_urls) - pp_printf (pp, "\33]8;;%s\33\\", url); + pp_printf (pp, "\33]8;;%s\a", url); } /* If URL-printing is enabled, write a "close URL" escape sequence to PP. */ @@ -2061,7 +2064,7 @@ void pp_end_url (pretty_printer *pp) { if (pp->show_urls) - pp_string (pp, "\33]8;;\33\\"); + pp_string (pp, "\33]8;;\a"); } #if CHECKING_P @@ -2369,7 +2372,7 @@ test_urls () pp_begin_url (&pp, "http://example.com"); pp_string (&pp, "This is a link"); pp_end_url (&pp); - ASSERT_STREQ ("\33]8;;http://example.com\33\\This is a link\33]8;;\33\\", + ASSERT_STREQ ("\33]8;;http://example.com\aThis is a link\33]8;;\a", pp_formatted_text (&pp)); } } Jakub