--- rxvt-unicode/src/perl/mark-urls 2006/01/06 01:16:58 1.3 +++ rxvt-unicode/src/perl/mark-urls 2006/01/11 02:13:56 1.5 @@ -4,14 +4,20 @@ my $url = qr{( (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+ - [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27(),~] # do not include a trailing dot, its wrong too often + [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27()~] # exclude some trailing characters (heuristic) )}x; +sub on_start { + my ($self) = @_; + + $self->{browser} = urxvt::untaint $self->x_resource ("urlLauncher") || "x-www-browser"; +} + sub on_line_update { - my ($term, $row) = @_; + my ($self, $row) = @_; # fetch the line that has changed - my $line = $term->line ($row); + my $line = $self->line ($row); my $text = $line->t; # find all urls (if any) @@ -29,3 +35,20 @@ () } +sub on_button_press { + my ($self, $event) = @_; + my $row = $event->{row}; + my $col = $event->{col}; + + my $line = $self->line ($row); + my $text = $line->t; + + while($text =~ /$url/g) { + if ($-[0] <= $col && $+[0] >= $col) { + system "$self->{browser} \Q$1\E &"; + return 1; + } + } + () +} +