public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: David Malcolm <dmalcolm@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 1/2] pretty-print: support URL escape sequences (PR 87488)
Date: Fri, 06 Dec 2019 23:41:00 -0000	[thread overview]
Message-ID: <20191206234113.GJ10088@tucnak> (raw)
In-Reply-To: <20191010170614.2061-1-dmalcolm@redhat.com>

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  <jakub@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

  parent reply	other threads:[~2019-12-06 23:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-10 17:06 David Malcolm
2019-10-10 17:19 ` [PATCH 2/2] Documentation hyperlinks for [-Wname-of-option] " David Malcolm
2019-10-10 17:49   ` Manuel López-Ibáñez
2019-10-11  3:54     ` Eric Gallager
2019-10-14 16:35   ` Michael Matz
2019-12-06 23:41 ` Jakub Jelinek [this message]
2019-12-07  1:31   ` [PATCH 1/2] pretty-print: support URL escape sequences " David Malcolm
2019-12-15 15:09 王昊然
2019-12-15 18:11 ` David Malcolm
2019-12-16  3:42   ` 王昊然

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191206234113.GJ10088@tucnak \
    --to=jakub@redhat.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).