| 1 |
root |
1.1 |
#! perl |
| 2 |
|
|
|
| 3 |
|
|
# same url as used in "selection" |
| 4 |
|
|
my $url = |
| 5 |
|
|
qr{( |
| 6 |
root |
1.2 |
(?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+ |
| 7 |
|
|
[ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27(),~] # do not include a trailing dot, its wrong too often |
| 8 |
root |
1.1 |
)}x; |
| 9 |
|
|
|
| 10 |
root |
1.3 |
sub on_line_update { |
| 11 |
|
|
my ($term, $row) = @_; |
| 12 |
root |
1.1 |
|
| 13 |
root |
1.3 |
# fetch the line that has changed |
| 14 |
|
|
my $line = $term->line ($row); |
| 15 |
|
|
my $text = $line->t; |
| 16 |
|
|
|
| 17 |
|
|
# find all urls (if any) |
| 18 |
|
|
while ($text =~ /$url/g) { |
| 19 |
|
|
my $rend = $line->r; |
| 20 |
|
|
|
| 21 |
|
|
# mark all characters as underlined. we _must_ not toggle underline, |
| 22 |
|
|
# as we might get called on an already-marked url. |
| 23 |
|
|
$_ |= urxvt::RS_Uline |
| 24 |
|
|
for @{$rend}[ $-[1] .. $+[1] - 1]; |
| 25 |
|
|
|
| 26 |
|
|
$line->r ($rend); |
| 27 |
root |
1.1 |
} |
| 28 |
|
|
|
| 29 |
root |
1.3 |
() |
| 30 |
root |
1.1 |
} |
| 31 |
|
|
|