| Did you know ... | Search Documentation: |
| Automatic links |
Besides the hyperlinks a client marks using OSC 8, terminal_image->auto_link
makes the terminal find links in plain text. Found links behave exactly
like OSC 8 links: they are drawn in terminal_image<-link_style,
highlighted in
terminal_image<-link_armed_style
while hovered, reported by terminal_image<-link
and activated through terminal_image<-link_message.
.g., vim
or less).
The example below makes http(s) URLs links to themselves
and links
#1234 to the corresponding issue on GitHub. The URL pattern
does not include punctuation that ends a sentence. Note the double
backslash: the target is a quoted Prolog atom.
auto_link_demo :-
new(T, terminal_image(600, 300)),
send(T, auto_link,
regex('https?://[^[:space:]]*[^[:space:].,;:!?)]')),
send(T, auto_link, regex('#([0-9]+)'),
'https://github.com/SWI-Prolog/swipl-devel/issues/\\1'),
send(T, link_message, message(@prolog, www_open_url, @arg1)),
send(new(W, window('Links', size(600, 300))), display, T),
send(W, open),
send(T, insert, 'See https://www.swi-prolog.org or issue #1234.\r\n').
Epilog (library(epilog)) uses this to link URLs and File:Line
or
File:Line:Column locations such as those in compiler
messages. More patterns can be added through the multifile hook epilog:auto_link/2.