ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/mark-urls
Revision: 1.3
Committed: Fri Jan 6 01:16:58 2006 UTC (18 years, 5 months ago) by root
Branch: MAIN
Changes since 1.2: +17 -15 lines
Log Message:
*** empty log message ***

File Contents

# Content
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 [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27(),~] # do not include a trailing dot, its wrong too often
8 )}x;
9
10 sub on_line_update {
11 my ($term, $row) = @_;
12
13 # 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 }
28
29 ()
30 }
31