bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: terminfo capability for hyperlinks


From: G. Branden Robinson
Subject: Re: terminfo capability for hyperlinks
Date: Thu, 2 Jan 2025 23:15:13 -0600

At 2025-01-03T00:54:45+0100, Bruno Haible via Bug reports for ncurses, the GNU 
implementation of curses wrote:
> For about 7 years, this writeup explains how to use hyperlinks in
> terminal emulators:
>   https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
> 
> 6 years ago, I wrote a library (GNU libtextstyle [1]) that makes use
> of this feature on terminal emulators that support it. The problem is
> determining the "support it": I did not find a terminfo capability
> for it, at the time. Nor do I do now. So there still is this ugly code [2]
> that looks at the value of $TERM, instead of using terminfo.
> 
> I also see that some programs introduce extra command-line options in order
> to tell them about the hyperlink capability.
> 
> Would it not make sense to introduce a terminfo capability for this?

It wasn't hard to predict the direction this thread would take; Thomas
has publicly pinched the bridge of his nose at libvte/gnome-terminal's
developers (many of whom are anonymous) many times over the years.  And
I don't blame him for that--when installing a new machine at home or
work I've often been confronted with gnome-terminal as the default and I
always give it a chance.  And every time it frustrates me and I return
to xterm's less fancy but more battle-hardened embrace.

That said, gnome-terminal annoys me _less_ now than it did 20 years ago
or so--the crack pipe seems, if not to have been permanently discarded,
at least placed much farther out of reach.

To those of us gray of beard, Derek Glidden's caricature of the
combatants in the Linux Desktop War was achingly accurate.[2]

As the person who added OSC 8 support to grotty(1) (rationale[3]), I too
would like to see support for it eventuate in terminfo and in terminal
emulator programs.

So to draw some fire onto myself, I'll propose an idea I had for an
xterm implementation.  I'd like to see xterm recognize and interpret OSC
8 sequences--"interpreting" them in the strict sense of an ECMA-48
escape sequence, _not_ as a URL.  (If it's invalid even in the ECMA-48
domain, the sequence should be ignored/discarded.)  But I have some
evidence that Thomas absolutely does not want to get into the business
of sanity checking URLs or launching applications to handle them.

I had been keeping this under my hat until I made some time to try
hacking it in to xterm myself, but that hasn't happened yet.

Here's the idea.

xterm could decorate the character cells associated with an OSC 8
hyperlink.  How it decorates them, I have no opinion.  When
shift+middle-clicking the mouse over such a character cell, a normally
grayed-out entry in the "VT Options" pop-up menu, labeled "Select URL to
Clipboard" or similar, would be enabled.  If that entry were chosen,
that's what would happen.

You get the OSC 8 URL in the clipboard.  Nothing else.  Want to visit it
in a browser?  Go to your browser and paste it.  Want to feed it to a
paranoid URL validator?  Go right ahead.

Never want to use the feature at all?  Don't ever select the "Select URL
to Clipboard" entry in the menu, just like you probably never select
"Show Tek Window" or "Enable Auto Linefeed".

The user accepts all responsibility for doing the things the security
critics of OSC 8 worry about, and must affirmatively, consciously
perform _two_ actions to undertake them, and that's as it should be.
Right now there's not _any_ good way to extract the OSC 8 content from
an xterm window.

In my view, such an implementation reduces the security concerns to just
about what they are with a URL that appears as such in the character
cells of the terminal emulator's main widget, and which have been viewed
with equanimity for as long as there has been a World Wide Web.

It's about as scary as this:

https://example.mss.cn/482d569227ec611ae57db0443b150519

Just like that.  How security-compromised do you feel now?

I expect the hardest part of this is teaching xterm's pop-up menus how
to be sensitive to pointer coordinates when a click event happens.  But
Thomas is of course the expert on this.

If implemented, the upside for me is that I get to show off, and use, a
groff feature in my daily driver.  And maybe terminal emulators will
gradually stop auto-hyperlinking dumb patterns that match, like
"exit(0)", and pretending they're man page cross references.  So I won't
say I have no stake in the outcome.

Okay, y'all can trash me now.

Regards,
Branden

[1] https://invisible-island.net/xterm/xterm.faq.html
[2] http://koplowicz.com/content/kde-vs-gnome-2
[3] https://git.savannah.gnu.org/cgit/groff.git/tree/NEWS?h=1.23.0#n223

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]