1 |
root |
1.1 |
#! perl |
2 |
|
|
|
3 |
|
|
# same url as used in "selection" |
4 |
|
|
my $url = |
5 |
|
|
qr{( |
6 |
|
|
(?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),]+ |
7 |
|
|
[^.] # do not include a trailing dot, its wrong too often |
8 |
|
|
)}x; |
9 |
|
|
|
10 |
|
|
sub on_add_lines { |
11 |
|
|
my ($term, $str) = @_; |
12 |
|
|
|
13 |
|
|
while ($str =~ $url) { |
14 |
|
|
# found a url, first output preceding text |
15 |
|
|
$term->scr_add_lines (substr $str, 0, $-[1], ""); |
16 |
|
|
# then toggle underline |
17 |
|
|
$term->rstyle ($term->rstyle ^ urxvt::RS_Uline); |
18 |
|
|
# now output the url |
19 |
|
|
$term->scr_add_lines (substr $str, 0, $+[1] - $-[1], ""); |
20 |
|
|
# toggle undelrine again |
21 |
|
|
$term->rstyle ($term->rstyle ^ urxvt::RS_Uline); |
22 |
|
|
} |
23 |
|
|
|
24 |
|
|
# output trailing text |
25 |
|
|
$term->scr_add_lines ($str); |
26 |
|
|
|
27 |
|
|
1 |
28 |
|
|
} |
29 |
|
|
|