ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/mark-urls
(Generate patch)

Comparing rxvt-unicode/src/perl/mark-urls (file contents):
Revision 1.3 by root, Fri Jan 6 01:16:58 2006 UTC vs.
Revision 1.6 by root, Thu Jan 12 01:30:53 2006 UTC

2 2
3# same url as used in "selection" 3# same url as used in "selection"
4my $url = 4my $url =
5 qr{( 5 qr{(
6 (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+ 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 7 [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27()~] # exclude some trailing characters (heuristic)
8 )}x; 8 )}x;
9 9
10sub on_start {
11 my ($self) = @_;
12
13 $self->{browser} = urxvt::untaint $self->x_resource ("urlLauncher") || "x-www-browser";
14}
15
10sub on_line_update { 16sub on_line_update {
11 my ($term, $row) = @_; 17 my ($self, $row) = @_;
12 18
13 # fetch the line that has changed 19 # fetch the line that has changed
14 my $line = $term->line ($row); 20 my $line = $self->line ($row);
15 my $text = $line->t; 21 my $text = $line->t;
16 22
17 # find all urls (if any) 23 # find all urls (if any)
18 while ($text =~ /$url/g) { 24 while ($text =~ /$url/g) {
19 my $rend = $line->r; 25 my $rend = $line->r;
27 } 33 }
28 34
29 () 35 ()
30} 36}
31 37
38sub on_button_release {
39 my ($self, $event) = @_;
40 my $row = $event->{row};
41 my $col = $event->{col};
42
43 my $line = $self->line ($row);
44 my $text = $line->t;
45
46 if ($event->{button} == 2) {
47 while ($text =~ /$url/g) {
48 if ($-[0] <= $col && $+[0] >= $col) {
49 system "$self->{browser} \Q$1\E &";
50 return 1;
51 }
52 }
53 }
54
55 ()
56}
57

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines