This patch adds a new configuration option,
‘osc8-underline=url-mode|always’.
When set to ‘url-mode’, OSC-8 URLs are only
highlighted (i.e. underlined) in url-mode, just like auto-detected
URLs.
When set to ‘always’, they are always underlined, regardless of mode,
and regardless of their other attributes.
This is implemented by tagging collected URLs with a boolean,
instructing urls_render() and urls_reset() whether they should update
the cells’ ‘url’ attribute or not.
The OSC-8 collecter sets this based on the value of ‘osc8-underline’.
Finally, when closing an OSC-8 URL, the cells are immediately tagged
with the ‘url’ attribute if ‘osc8-underline’ is set to ‘always’.
URI ranges are per row. Translate by detecting URI range start/end
coordinates, and opening and closing a corresponding URI range on the
new grid.
We need to take care when line-wrapping the new grid; here we need to
manually close the still-open URI ranges (on the new grid), and
re-opening them on the next row.
If the client application emitted e.g:
\E]8;;http://foo\E\\\E]8;;\E\\
i.e. an anchor without content, then we ended up with an ‘end’
coordinate that lied *before* the ‘start’ coordinate, since we
subtract one (column) from the end point to make it inclusive.
By default, the URL isn’t shown on the jump-label. For auto-detect
URLs, doing so is virtually always useless, as the URL is already
visible in the grid.
For OSC-8 URLs however, the URL is often _not_ visible in the
grid. Many times, seeing the URL is still not needed (if you’re doing
‘ls --hyperlink’, you already know what the URIs are).
But it is still useful to have a way to show the URLs.
This patch adds a new key binding action that can be used in url-mode
to toggle the URL on and off in the jump label.
It is bound to ctrl+t by default.
Remove URLs with the same start and end coordinates. Such duplicate
URLs can be created by emitting an OSC-8 URL with matching grid
content:
\E]8;;http://foo\E\\http://foo\E]8;;\E\\
Doing so means the next OSC-8 URL emitted by the client application,
with the same ID, will get a *new* id internally.
Instead, hash the string and use that as ID.
In case an URL is split up into multiple parts, those parts are now
treated as a single URL when it comes to key assignment.
Only the *first* URL part is actually assigned a key combo. The other
parts are ignored.
We still highlight them, but for all other purposes they are ignored.