rust-ansi-term icon indicating copy to clipboard operation
rust-ansi-term copied to clipboard

Add hyperlink support

Open joshtriplett opened this issue 4 years ago • 2 comments

Some terminals support hyperlinks to URLs as a text style, defined at https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda .

Add support for these escape sequences to ansi_term, storing the hyperlink target as an Option<Rc>. This avoids copying URLs when modifying styles.

This makes Style no longer Copy, so Style now requires .clone() when duplicating it.

Note that this intentionally omits support for the id attribute, used by screen-oriented applications to group separated links together as "the same link". This arises when splitting links across lines within a windowing or window-splitting mechanism. Applications with such use cases will need other screen-oriented escape sequences that ansi_term doesn't cover, as well.

joshtriplett avatar Apr 23 '20 00:04 joshtriplett

The implementation as written uses Option::as_deref, which was stabilized in Rust 1.40. If that's a problem, I can avoid it.

joshtriplett avatar Apr 23 '20 00:04 joshtriplett

Other than Copy, another breaking change here is that the Rc makes it non-Sync. (And this is kind of a bad situation… e.g. exa needs it to be Sync, but anyone else who's not using threads might not want the overhead of having an Arc in there)

valpackett avatar Sep 13 '21 19:09 valpackett