Text output may contain hyperlinks. These hyperlinks are encoded through
an escape sequence, specified at
Hyperlinks in terminal emulators. Currently (as of 2024), they are
displayed in many modern terminals, see
OSC8-Adoption. More
terminal emulators will support hyperlinks in the future. Terminal
emulators which don’t support hyperlinks ignore it, except for a few
terminal emulators, for which users may need to disable the hyperlinks
(see The environment variable NO_TERM_HYPERLINKS
) if the heuristic built into
libtextstyle
does not already disable them.
To emit a hyperlink, use code like this:
styled_ostream_t stream = ... ... /* Start a hyperlink. */ styled_ostream_set_hyperlink (stream, url, NULL); ... /* Emit the anchor text. This can be styled text. */ ostream_write_str (stream, "Click here!"); ... /* End the current hyperlink. */ styled_ostream_set_hyperlink (stream, NULL, NULL);
The anchor text can be styled. But the hyperlinks themselves cannot be styled; they behave as implemented by the terminal emulator.